14 * Description: |
14 * Description: |
15 * |
15 * |
16 */ |
16 */ |
17 |
17 |
18 #include "cptelephonypluginview.h" |
18 #include "cptelephonypluginview.h" |
19 #include "cpplugincommon.h" |
|
20 #include "cppluginlogging.h" |
19 #include "cppluginlogging.h" |
21 #include <QPluginLoader> |
20 #include <QPluginLoader> |
22 #include <QApplication> |
21 #include <QApplication> |
23 #include <QLocale> |
22 #include <QLocale> |
24 #include <QTranslator> |
23 #include <QTranslator> |
25 #include <hbdataformmodel.h> |
24 #include <hbdataformmodel.h> |
26 #include <cppluginplatinterface.h> |
25 #include <cpplugininterface.h> |
27 #include <cpsettingformitemdata.h> |
26 #include <cpsettingformitemdata.h> |
28 #include <cpitemdatahelper.h> |
27 #include <cpitemdatahelper.h> |
|
28 #include <cppluginutility.h> |
|
29 #include <cppluginloader.h> |
29 |
30 |
30 CpTelephonyPluginView::CpTelephonyPluginView() : |
31 CpTelephonyPluginView::CpTelephonyPluginView() : |
31 CpBaseSettingView(), |
32 CpBaseSettingView(0,0), |
32 m_helper(NULL) |
33 m_helper(NULL) |
33 { |
34 { |
34 DPRINT << ": IN"; |
35 DPRINT << ": IN"; |
35 |
36 |
36 // Localization file loading |
37 // Localization file loading |
43 if (translatorLoaded) { |
44 if (translatorLoaded) { |
44 qApp->installTranslator(&translator); |
45 qApp->installTranslator(&translator); |
45 DPRINT << ": translator installed"; |
46 DPRINT << ": translator installed"; |
46 } |
47 } |
47 |
48 |
48 HbDataForm *form = settingForm(); |
49 HbDataForm *form = qobject_cast<HbDataForm*>(widget()); |
49 if (form) { |
50 if (form) { |
50 HbDataFormModel *model = new HbDataFormModel; |
51 HbDataFormModel *model = new HbDataFormModel; |
51 form->setHeading(hbTrId("Telephone settings")); |
52 form->setHeading(hbTrId("Telephone settings")); |
52 // Create and initialize plugin's item data helper |
53 // Create and initialize plugin's item data helper |
53 m_helper = initializeItemDataHelper(); |
54 m_helper = initializeItemDataHelper(); |
54 HbDataFormModelItem *item(NULL); |
55 QList<CpSettingFormItemData*> items; |
55 |
56 |
|
57 // Load calls plugin |
56 DPRINT << ": Loading cpcallsplugin"; |
58 DPRINT << ": Loading cpcallsplugin"; |
57 // Load calls plugin |
59 items.append(groupItemFromPlugin("cpcallsplugin")); |
58 item = groupItemFromPlugin("cpcallsplugin"); |
|
59 if (item) { |
|
60 model->appendDataFormItem(item); |
|
61 } |
|
62 |
60 |
63 // Load diverts plugin |
61 // Load diverts plugin |
64 DPRINT << ": Loading cpdivertsplugin"; |
62 DPRINT << ": Loading cpdivertsplugin"; |
65 item = groupItemFromPlugin("cpdivertplugin"); |
63 items.append(groupItemFromPlugin("cpdivertplugin")); |
66 if (item) { |
64 |
67 model->appendDataFormItem(item); |
|
68 } |
|
69 |
65 |
70 // Load call mailboxes plugin |
66 // Load call mailboxes plugin |
71 DPRINT << ": Loading vmbxcpplugin"; |
67 DPRINT << ": Loading vmbxcpplugin"; |
72 item = groupItemFromPlugin("vmbxcpplugin"); |
68 items.append(groupItemFromPlugin("vmbxcpplugin")); |
73 if (item) { |
69 |
74 model->appendDataFormItem(item); |
70 // Insert items to form model |
|
71 foreach (CpSettingFormItemData* i, items) { |
|
72 model->appendDataFormItem(i); |
75 } |
73 } |
76 |
74 |
77 form->setModel(model); |
75 form->setModel(model); |
78 } |
76 } |
79 |
77 |
80 DPRINT << ": OUT"; |
78 DPRINT << ": OUT"; |
81 } |
79 } |
87 delete m_helper; |
85 delete m_helper; |
88 |
86 |
89 DPRINT << ": OUT"; |
87 DPRINT << ": OUT"; |
90 } |
88 } |
91 |
89 |
92 HbDataFormModelItem* CpTelephonyPluginView::groupItemFromPlugin( const QString& plugin ) |
90 QList<CpSettingFormItemData*> CpTelephonyPluginView::groupItemFromPlugin( const QString& plugin ) |
93 { |
91 { |
94 DPRINT << ": IN"; |
92 DPRINT << ": IN"; |
95 |
93 |
96 CpSettingFormItemData *item(NULL); |
94 QList<CpSettingFormItemData*> items; |
97 CpPluginPlatInterface *p(NULL); |
95 CpPluginInterface *p(NULL); |
98 try { |
96 try { |
99 p = Tools::loadCpPlugin(plugin); |
97 p = CpPluginLoader::loadCpPlugin(plugin); |
100 if (p && m_helper){ |
98 if (p && m_helper){ |
101 item = p->createSettingFormItemData(*m_helper); |
99 items = p->createSettingFormItemData(*m_helper); |
102 if (item){ |
|
103 item->setType(HbDataFormModelItem::GroupItem); |
|
104 QObject::connect( |
|
105 settingForm(), SIGNAL(itemShown(QModelIndex)), |
|
106 item, SLOT(itemShown(QModelIndex))); |
|
107 DPRINT << "plugin:" << plugin; |
|
108 } |
|
109 } |
100 } |
110 } catch(...) { |
101 } catch(...) { |
111 DPRINT << "CATCH ERROR"; |
102 DPRINT << "CATCH ERROR"; |
112 delete p; |
103 delete p; |
113 } |
104 } |
114 |
105 |
115 DPRINT << ": OUT"; |
106 DPRINT << ": OUT"; |
116 return item; |
107 return items; |
117 } |
|
118 |
|
119 void CpTelephonyPluginView::onConnectionAdded(HbDataFormModelItem *item, |
|
120 const QString &signal, |
|
121 QObject *receiver, |
|
122 const QString &method) |
|
123 { |
|
124 DPRINT << ": IN"; |
|
125 |
|
126 if (HbDataForm *form = settingForm()) { |
|
127 form->addConnection(item, signal.toAscii(), receiver, method.toAscii()); |
|
128 } |
|
129 |
|
130 DPRINT << ": OUT"; |
|
131 } |
|
132 |
|
133 void CpTelephonyPluginView::onConnectionRemoved(HbDataFormModelItem *item, |
|
134 const QString &signal, |
|
135 QObject *receiver, |
|
136 const QString &method) |
|
137 { |
|
138 DPRINT << ": IN"; |
|
139 |
|
140 if (HbDataForm *form = settingForm()) { |
|
141 form->removeConnection(item, signal.toAscii(), receiver, method.toAscii()); |
|
142 } |
|
143 |
|
144 DPRINT << ": OUT"; |
|
145 } |
|
146 |
|
147 void CpTelephonyPluginView::onPrototypeAdded(HbAbstractViewItem *prototype) |
|
148 { |
|
149 DPRINT << ": IN"; |
|
150 |
|
151 if (HbDataForm *form = settingForm()) { |
|
152 QList<HbAbstractViewItem *> prototypes = form->itemPrototypes(); |
|
153 prototypes.append(prototype); |
|
154 form->setItemPrototypes(prototypes); |
|
155 } |
|
156 |
|
157 DPRINT << ": OUT"; |
|
158 } |
108 } |
159 |
109 |
160 CpItemDataHelper* CpTelephonyPluginView::initializeItemDataHelper() |
110 CpItemDataHelper* CpTelephonyPluginView::initializeItemDataHelper() |
161 { |
111 { |
162 DPRINT << ": IN"; |
112 DPRINT; |
163 |
113 return new CpItemDataHelper(qobject_cast<HbDataForm*>(widget())); |
164 CpItemDataHelper *itemDataHelper = new CpItemDataHelper; |
|
165 DPRINT << "itemDataHelper:" << reinterpret_cast<int>(itemDataHelper); |
|
166 itemDataHelper->bindToForm(settingForm()); |
|
167 connect(itemDataHelper, |
|
168 SIGNAL(connectionAdded(HbDataFormModelItem*, QString, QObject *, QString)), |
|
169 this, |
|
170 SLOT(onConnectionAdded(HbDataFormModelItem*, QString, QObject *, QString))); |
|
171 connect(itemDataHelper, |
|
172 SIGNAL(connectionRemoved(HbDataFormModelItem*, QString, QObject *, QString)), |
|
173 this, |
|
174 SLOT(onConnectionRemoved(HbDataFormModelItem*, QString, QObject *, QString))); |
|
175 connect(itemDataHelper, |
|
176 SIGNAL(prototypeAdded(HbAbstractViewItem *)), |
|
177 this, |
|
178 SLOT(onPrototypeAdded(HbAbstractViewItem *))); |
|
179 |
|
180 DPRINT << ": OUT : helper signals connected"; |
|
181 return itemDataHelper; |
|
182 } |
114 } |
183 |
115 |
184 // End of File. |
116 // End of File. |