1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0"" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: An extension to HbDataFormModel, can be filled with model items comes from controlpanel plugins. |
|
15 * |
|
16 */ |
|
17 |
|
18 #include "cpcategorysettingformmodel.h" |
|
19 #include <QString> |
|
20 #include "cpcategorymodelutility.h" |
|
21 #include <cpitemdatahelper.h> |
|
22 |
|
23 /* |
|
24 * Private implementation |
|
25 */ |
|
26 class CpCategorySettingFormModelPrivate |
|
27 { |
|
28 public: |
|
29 CpCategorySettingFormModelPrivate(const QString &configFile) : |
|
30 mInitialized(false), |
|
31 mConfigFile(configFile) |
|
32 { |
|
33 } |
|
34 |
|
35 ~CpCategorySettingFormModelPrivate() |
|
36 { |
|
37 } |
|
38 |
|
39 public: |
|
40 bool mInitialized; |
|
41 QString mConfigFile; |
|
42 }; |
|
43 |
|
44 /* |
|
45 * Constructor |
|
46 */ |
|
47 CpCategorySettingFormModel::CpCategorySettingFormModel(const QString &configFile) : |
|
48 d (new CpCategorySettingFormModelPrivate(configFile)) |
|
49 { |
|
50 } |
|
51 |
|
52 /* |
|
53 * Destructor |
|
54 */ |
|
55 CpCategorySettingFormModel::~CpCategorySettingFormModel() |
|
56 { |
|
57 delete d; |
|
58 } |
|
59 |
|
60 /* |
|
61 * Initialize |
|
62 */ |
|
63 void CpCategorySettingFormModel::initialize(CpItemDataHelper &itemDataHelper) |
|
64 { |
|
65 //avoid to be called twice |
|
66 if (!d->mInitialized) { |
|
67 //give derived class a change do their special things before loading config plugins |
|
68 beforeLoadingConfigPlugins(itemDataHelper); |
|
69 |
|
70 int pluginItemStartPosition = invisibleRootItem()->childCount(); |
|
71 //give derived class a change do their special things after loading config plugins |
|
72 afterLoadingConfigPlugins(itemDataHelper); |
|
73 |
|
74 //load plugins which are configured |
|
75 CpCategoryModelUtility::buildConfigPluginItems(invisibleRootItem(), |
|
76 d->mConfigFile, |
|
77 itemDataHelper, |
|
78 pluginItemStartPosition); |
|
79 |
|
80 d->mInitialized = true; |
|
81 } |
|
82 } |
|
83 |
|
84 /* |
|
85 * Derived class can override this function to do some specific work before loading config plugins |
|
86 */ |
|
87 void CpCategorySettingFormModel::beforeLoadingConfigPlugins(CpItemDataHelper&/*itemDataHelper*/) |
|
88 { |
|
89 } |
|
90 |
|
91 /* |
|
92 * Derived class can override this function to do some specific work after loading config plugins |
|
93 */ |
|
94 void CpCategorySettingFormModel::afterLoadingConfigPlugins(CpItemDataHelper &/*itemDataHelper*/) |
|
95 { |
|
96 } |
|
97 |
|
98 //End of File |
|