14 * Description: |
14 * Description: |
15 * |
15 * |
16 */ |
16 */ |
17 |
17 |
18 // System includes |
18 // System includes |
|
19 #include <QApplication> |
|
20 #include <QLocale> |
|
21 #include <QTranslator> |
|
22 #include <QStringList> |
19 #include <cpitemdatahelper.h> |
23 #include <cpitemdatahelper.h> |
|
24 #include <hblineedit.h> |
20 |
25 |
21 // User includes |
26 // User includes |
22 #include "vmbxuiengine.h" |
27 #include "vmbxuiengine.h" |
23 #include "vmbxcpgroup.h" |
28 #include "vmbxcpgroup.h" |
24 #include "loggerutil.h" |
29 #include "loggerutil.h" |
25 |
30 |
|
31 // custom dataform type |
|
32 #define CustomDataFormType \ |
|
33 static_cast<HbDataFormModelItem::DataItemType>(HbDataFormModelItem::CustomItemBase) |
|
34 |
26 /*! |
35 /*! |
27 Constructor |
36 Constructor |
28 */ |
37 */ |
29 VmbxCpGroup::VmbxCpGroup( |
38 VmbxCpGroup::VmbxCpGroup( |
30 const QString &configFile, |
|
31 const HbDataFormModelItem *parent) : |
|
32 CpSettingFormItemData(parent), |
|
33 mUiEngine(0), |
|
34 mEditorCsVoice1(0), |
|
35 mEditorCsVoice2(0), |
|
36 mEditorCsVideo1(0) |
|
37 { |
|
38 Q_UNUSED(configFile); |
|
39 } |
|
40 |
|
41 /*! |
|
42 Constructor |
|
43 */ |
|
44 VmbxCpGroup::VmbxCpGroup( |
|
45 HbDataFormModelItem::DataItemType type, |
|
46 const QString &label, |
|
47 const QString &configFile, |
|
48 const HbDataFormModelItem *parent, |
|
49 CpItemDataHelper &itemDataHelper) : |
39 CpItemDataHelper &itemDataHelper) : |
50 CpSettingFormItemData(type, label, parent), |
40 CpSettingFormItemData(HbDataFormModelItem::GroupItem, |
51 mUiEngine(0), |
41 hbTrId("txt_phone_subhead_call_mbx"), NULL), |
52 mEditorCsVoice1(0), |
42 mUiEngine(NULL), |
53 mEditorCsVoice2(0), |
43 mDefaultMailboxEditor(NULL), |
54 mEditorCsVideo1(0) |
44 mCsVoice1Editor(NULL), |
|
45 mCsVideo1Editor(NULL) |
55 { |
46 { |
56 _DBGLOG2("VmbxCpGroup::VmbxCpGroup label=",label) |
47 _DBGLOG2("VmbxCpGroup::VmbxCpGroup label=",label) |
57 Q_UNUSED(configFile); |
48 // Localization file loading |
|
49 QTranslator translator; |
|
50 QString lang = QLocale::system().name(); |
|
51 QString path = "z:/resource/qt/translations/"; |
|
52 |
|
53 bool translatorLoaded = translator.load(path + "telephone_cp_" + lang); |
|
54 _DBGLOG("VmbxCpGroup::VmbxCpGroup translator loaded") |
|
55 if (translatorLoaded && qApp) { |
|
56 qApp->installTranslator(&translator); |
|
57 _DBGLOG("VmbxCpGroup::VmbxCpGroup translator installed") |
|
58 } |
|
59 |
58 mUiEngine = new VmbxUiEngine(); |
60 mUiEngine = new VmbxUiEngine(); |
59 loadingPreparation(itemDataHelper); |
61 loadingPreparation(itemDataHelper); |
|
62 |
|
63 // Request notify when VMBX number changed |
|
64 mUiEngine->notifyVmbxNumberChange(true); |
|
65 bool ret = connect(mUiEngine, |
|
66 SIGNAL(voiceMailboxEngineEntriesUpdated(const TVmbxType)), |
|
67 this, SLOT(vmbxNumberChanged(const TVmbxType))); |
|
68 _DBGLOG2("VmbxCpGroup::VmbxCpGroup connect ret=", ret) |
60 _DBGLOG("VmbxCpGroup::VmbxCpGroup <") |
69 _DBGLOG("VmbxCpGroup::VmbxCpGroup <") |
61 } |
70 } |
62 |
71 |
63 /*! |
72 /*! |
64 Destructor |
73 Destructor |
71 mUiEngine = NULL; |
80 mUiEngine = NULL; |
72 } |
81 } |
73 } |
82 } |
74 |
83 |
75 /*! |
84 /*! |
|
85 Notification slot for engine signal about |
|
86 Voice Mailbox entries' changes |
|
87 */ |
|
88 void VmbxCpGroup::voiceMailboxEngineEntriesUpdated() |
|
89 { |
|
90 _DBGLOG("VmbxCpGroup::voiceMailboxEngineEntriesUpdated") |
|
91 // Consider is there need to pass the actual modified data |
|
92 // and mailbox type enum to slot (here) so only needed |
|
93 // data can be updated. |
|
94 updateAllMailboxesToUi(); |
|
95 } |
|
96 |
|
97 /*! |
|
98 Save default mailbox when user selection finished |
|
99 */ |
|
100 void VmbxCpGroup::saveDefaultMailbox(int aIndex) |
|
101 { |
|
102 if (0 == aIndex){ |
|
103 _DBGLOG("VmbxCpGroup::saveDefaultMailbox voice") |
|
104 }else if(1 == aIndex){ |
|
105 _DBGLOG("VmbxCpGroup::saveDefaultMailbox video") |
|
106 }else{ |
|
107 _DBGLOG("VmbxCpGroup::saveDefaultMailbox other") |
|
108 } |
|
109 } |
|
110 |
|
111 /*! |
76 Preparation before loading |
112 Preparation before loading |
77 */ |
113 */ |
78 void VmbxCpGroup::loadingPreparation(CpItemDataHelper &itemDataHelper) |
114 void VmbxCpGroup::loadingPreparation(CpItemDataHelper &itemDataHelper) |
79 { |
115 { |
80 _DBGLOG("VmbxCpGroup::loadingPreparation >") |
116 _DBGLOG("VmbxCpGroup::loadingPreparation >") |
81 |
117 |
82 QString newUiValue(""); |
118 // #Following code is reserved for TB10.2 |
83 |
119 // Create default mailbox selection |
84 mEditorCsVoice1 = new CpSettingFormItemData( |
|
85 HbDataFormModelItem::TextItem, tr("Call mailbox") ); |
|
86 _DBGLOG("VmbxCpGroup::loadingPreparation appendChild") |
|
87 itemDataHelper.addConnection( |
|
88 mEditorCsVoice1, |
|
89 SIGNAL(textChanged(QString)), |
|
90 mUiEngine, SLOT(uiCsVoice1Changed(QString)) |
|
91 ); |
|
92 // appendChild takes ownership |
120 // appendChild takes ownership |
93 appendChild(mEditorCsVoice1); |
121 //if (mUiEngine->isVideoSupport()){ |
94 |
122 // mDefaultMailboxEditor = new CpSettingFormItemData( |
95 // Todo: add csVoice2 if ALS supported |
123 // HbDataFormModelItem::ComboBoxItem, |
96 |
124 // hbTrId("Default mailbox"), |
97 // Todo: add video only if supported |
125 // this); |
98 //mEditorCsVideo1 = new CpSettingFormItemData( |
126 //itemDataHelper.addConnection( |
99 // HbDataFormModelItem::TextItem, tr("Video mailbox") ); |
127 // mDefaultMailboxEditor, SIGNAL(currentIndexChanged(int)), |
100 //_DBGLOG("VmbxCpGroup::loadingPreparation appendChild") |
128 // mUiEngine, SLOT(saveCsVoice1Number())); |
101 //appendChild( mEditorCsVideo1 ); |
129 //QStringList list; |
102 |
130 //list.append(hbTrId("Voice")); |
103 // TODO: get all ps addresses AND THEIR NAMES from engine and add ui controls |
131 //list.append(hbTrId("Video")); |
104 //for them |
132 //mDefaultMailboxEditor->setContentWidgetData("items", QVariant(list)); |
105 // Set UI control pointers to mPsServiceEditors |
133 //appendChild(mDefaultMailboxEditor); |
|
134 //} |
|
135 |
|
136 // Create cs voice primary editor |
|
137 mCsVoice1Editor= new HbDataFormModelItem( |
|
138 CustomDataFormType, |
|
139 hbTrId("txt_phone_setlabel_default_mbx_val_voice")); |
|
140 _DBGLOG("VmbxCpGroup::loadingPreparation appendChild voice1 mailbox") |
|
141 |
|
142 QString voice1Number; |
|
143 mUiEngine->getCsVoice1Number(voice1Number); |
|
144 // Show voice line1 number on lineedit |
|
145 mCsVoice1Editor->setContentWidgetData(QString("text"), voice1Number); |
|
146 // Connect ui editing signals and allow ui control |
|
147 // eidting if vmbx allows editing |
|
148 if (mUiEngine->isVoiceWritable()) { |
|
149 // When click the lineedit, the query dialog would pop up. |
|
150 itemDataHelper.addConnection(mCsVoice1Editor, SIGNAL(clicked()), |
|
151 this, SLOT(queryCsVoiceNumber())); |
|
152 } else { |
|
153 // If not writable, Dim the voice editor |
|
154 mCsVoice1Editor->setEnabled(false); |
|
155 } |
|
156 // Add child |
|
157 appendChild(mCsVoice1Editor); |
|
158 |
|
159 // Create cs video primary editor |
|
160 if (mUiEngine->isVideoSupport()){ |
|
161 mCsVideo1Editor= new HbDataFormModelItem( |
|
162 CustomDataFormType, |
|
163 hbTrId("txt_phone_setlabel_default_mbx_val_video")); |
|
164 _DBGLOG("VmbxCpGroup::loadingPreparation appendChild video1 mailbox") |
|
165 QString video1Number; |
|
166 mUiEngine->getCsVideo1Number(video1Number); |
|
167 // Show video line1 number on lineedit |
|
168 mCsVideo1Editor->setContentWidgetData(QString("text"), video1Number); |
|
169 // Check video editing permission and connect signal |
|
170 if (mUiEngine->isVideoWritable()) { |
|
171 itemDataHelper.addConnection(mCsVideo1Editor, SIGNAL(clicked()), |
|
172 this, SLOT(queryCsVideoNumber())); |
|
173 } else { |
|
174 // If not writable, Dim the Video editor |
|
175 mCsVideo1Editor->setEnabled(false); |
|
176 } |
|
177 appendChild( mCsVideo1Editor ); |
|
178 } |
|
179 // TODO: Create cs voice als editor |
|
180 // TODO: Create cs video als editor |
|
181 // TODO: Create all ps service editors |
106 |
182 |
107 updateAllMailboxesToUi(); |
183 updateAllMailboxesToUi(); |
108 |
|
109 // TODO: below connect ui editing signals and allow ui control |
|
110 // eidting if vmbx allows editing |
|
111 |
184 |
112 // TODO: here check CS ALS editing permission and connnect signal |
185 // TODO: here check CS ALS editing permission and connnect signal |
113 // and enable editing |
186 // and enable editing |
114 |
187 |
115 // TODO: here check video editing permission and connect signal |
|
116 // if ok |
|
117 |
|
118 // No need for Video ALS on UI, implement later if necessary. |
188 // No need for Video ALS on UI, implement later if necessary. |
119 |
|
120 |
|
121 // Editing of PS Services is not allowed by default, disable ui editing |
189 // Editing of PS Services is not allowed by default, disable ui editing |
122 // for them. |
190 // for them. |
123 |
191 |
124 _DBGLOG("VmbxCpGroup::loadingPreparation <") |
192 _DBGLOG("VmbxCpGroup::loadingPreparation <") |
125 } |
|
126 |
|
127 /*! |
|
128 Update Cs voice primary |
|
129 */ |
|
130 void VmbxCpGroup::updateCsVoicePrimaryToUi() |
|
131 { |
|
132 _DBGLOG("VmbxCpGroup::updateCsVoicePrimaryToUi") |
|
133 if (mEditorCsVoice1 && mUiEngine) { |
|
134 QString newUiValue(""); |
|
135 mUiEngine->getCsVoice1Number(newUiValue); |
|
136 mEditorCsVoice1->setContentWidgetData("text", newUiValue); |
|
137 } |
|
138 } |
|
139 |
|
140 /*! |
|
141 Update Cs voice Als |
|
142 */ |
|
143 void VmbxCpGroup::updateCsVoiceAlsToUi() |
|
144 { |
|
145 _DBGLOG("VmbxCpGroup::updateCsVoiceAlsToUi") |
|
146 if (mEditorCsVoice2 && mUiEngine){ |
|
147 QString newUiValue(""); |
|
148 mUiEngine->getCsVoice1Number(newUiValue ); |
|
149 _DBGLOG2("VmbxCpGroup::updateCsVoiceAlsToUi newUiValue=", newUiValue) |
|
150 mEditorCsVoice2->setContentWidgetData("text", newUiValue ); |
|
151 } |
|
152 } |
|
153 |
|
154 /*! |
|
155 update Cs video primary |
|
156 */ |
|
157 void VmbxCpGroup::updateCsVideoPrimaryToUi() |
|
158 { |
|
159 _DBGLOG("VmbxCpGroup::updateCsVideoPrimaryToUi >") |
|
160 if (mEditorCsVideo1 && mUiEngine){ |
|
161 QString newUiValue(""); |
|
162 mUiEngine->getCsVideo1Number(newUiValue); |
|
163 _DBGLOG2("VmbxCpGroup::updateCsVideoPrimaryToUi newUiValue=", \ |
|
164 newUiValue) |
|
165 mEditorCsVideo1->setContentWidgetData("text", newUiValue); |
|
166 } |
|
167 _DBGLOG("VmbxCpGroup::updateCsVideoPrimaryToUi <") |
|
168 } |
|
169 |
|
170 /*! |
|
171 update Ps services |
|
172 */ |
|
173 void VmbxCpGroup::updatePsServicesToUi() |
|
174 { |
|
175 _DBGLOG("VmbxCpGroup::updatePsServicesToUi >") |
|
176 // Set values from engine to ui |
|
177 // NOTICE: IT IS POSSIBLE THAT PS SERVICES WILL NOT BE DISPLAYED BY VMBX |
|
178 // CONTROL PANEL WHEN WE GET THE NEW UI CONCEPT!!!!!! |
|
179 _DBGLOG("VmbxCpGroup::updatePsServicesToUi <") |
|
180 } |
193 } |
181 |
194 |
182 /*! |
195 /*! |
183 Update default mailbox |
196 Update default mailbox |
184 */ |
197 */ |
187 _DBGLOG("VmbxCpGroup::updateDefaultMailboxToUi >") |
200 _DBGLOG("VmbxCpGroup::updateDefaultMailboxToUi >") |
188 // Consider should you check here if the number |
201 // Consider should you check here if the number |
189 // length of the default mailbox |
202 // length of the default mailbox |
190 // and reset the default mailbox type selection to "none" if it is. |
203 // and reset the default mailbox type selection to "none" if it is. |
191 // If you do so, remember to save the new value to engine. |
204 // If you do so, remember to save the new value to engine. |
|
205 if (mDefaultMailboxEditor && mUiEngine) { |
|
206 // TODO: Need a new API to save default mailbox |
|
207 } |
192 _DBGLOG("VmbxCpGroup::updateDefaultMailboxToUi <") |
208 _DBGLOG("VmbxCpGroup::updateDefaultMailboxToUi <") |
193 } |
209 } |
194 |
210 |
195 /*! |
211 /*! |
|
212 Update Cs voice primary |
|
213 */ |
|
214 void VmbxCpGroup::updateCsVoice1ToUi() |
|
215 { |
|
216 _DBGLOG("VmbxCpGroup::updateCsVoice1ToUi") |
|
217 if (mCsVoice1Editor && mUiEngine) { |
|
218 QString newUiValue(""); |
|
219 mUiEngine->getCsVoice1Number(newUiValue); |
|
220 _DBGLOG2("VmbxCpGroup::updateCsVoice1ToUi\ |
|
221 newUiValue=", newUiValue) |
|
222 mCsVoice1Editor->setContentWidgetData("text", newUiValue); |
|
223 } |
|
224 } |
|
225 |
|
226 /*! |
|
227 update Cs video primary |
|
228 */ |
|
229 void VmbxCpGroup::updateCsVideo1ToUi() |
|
230 { |
|
231 _DBGLOG("VmbxCpGroup::updateCsVideo1ToUi >") |
|
232 if (mCsVideo1Editor && mUiEngine){ |
|
233 QString newUiValue(""); |
|
234 mUiEngine->getCsVideo1Number(newUiValue); |
|
235 _DBGLOG2("VmbxCpGroup::updateCsVideo1ToUi\ |
|
236 newUiValue=", newUiValue) |
|
237 mCsVideo1Editor->setContentWidgetData("text", newUiValue); |
|
238 } |
|
239 _DBGLOG("VmbxCpGroup::updateCsVideo1ToUi <") |
|
240 } |
|
241 |
|
242 /*! |
196 Update all mailboxes |
243 Update all mailboxes |
197 */ |
244 */ |
198 void VmbxCpGroup::updateAllMailboxesToUi() |
245 void VmbxCpGroup::updateAllMailboxesToUi() |
199 { |
246 { |
200 _DBGLOG("VmbxCpGroup::updateAllMailboxesToUi >") |
247 _DBGLOG("VmbxCpGroup::updateAllMailboxesToUi >") |
201 updateCsVoicePrimaryToUi(); |
248 updateCsVoice1ToUi(); |
202 //updateCsVoiceAlsToUi(); |
249 if (mUiEngine->isVideoSupport()) { |
203 //updateCsVideoPrimaryToUi(); |
250 updateDefaultMailboxToUi(); |
204 //updatePsServicesToUi(); |
251 updateCsVideo1ToUi(); |
205 //updateDefaultMailboxToUi(); |
252 } |
206 _DBGLOG("VmbxCpGroup::updateAllMailboxesToUi <") |
253 _DBGLOG("VmbxCpGroup::updateAllMailboxesToUi <") |
207 } |
254 } |
208 |
255 |
209 /*! |
256 /*! |
210 Notification slot for engine signal about |
257 Query voice number |
211 Voice Mailbox entries' changes |
258 */ |
212 */ |
259 void VmbxCpGroup::queryCsVoiceNumber() |
213 void VmbxCpGroup::voiceMailboxEngineEntriesUpdated() |
260 { |
214 { |
261 _DBGLOG("VmbxCpGroup::queryCsVoiceNumber >") |
215 _DBGLOG("VmbxCpGroup::voiceMailboxEngineEntriesUpdated") |
262 mCsVoice1Editor->setEnabled(false); |
216 // Consider is there need to pass the actual modified data |
263 QString number; |
217 // and mailbox type enum to slot (here) so only needed |
264 int result = mUiEngine->queryVoiceNumber(number); |
218 // data can be updated. |
265 _DBGLOG2("VmbxCpGroup::queryCsVoiceNumber result=", result) |
219 updateAllMailboxesToUi(); |
266 if (KErrNone == result) { |
|
267 mCsVoice1Editor->setContentWidgetData(QString("text"), number); |
|
268 _DBGLOG2("VmbxCpGroup::queryCsVoiceNumber >, number=", number) |
|
269 mUiEngine->setCsVoice1Number(number); |
|
270 } |
|
271 mCsVoice1Editor->setEnabled(true); |
|
272 _DBGLOG("VmbxCpGroup::queryCsVoiceNumber <") |
|
273 } |
|
274 |
|
275 /*! |
|
276 Query video number |
|
277 */ |
|
278 void VmbxCpGroup::queryCsVideoNumber() |
|
279 { |
|
280 _DBGLOG("VmbxCpGroup::queryCsVideoNumber >") |
|
281 mCsVideo1Editor->setEnabled(false); |
|
282 QString number; |
|
283 int result = mUiEngine->queryVideoNumber(number); |
|
284 _DBGLOG2("VmbxCpGroup::queryCsVideoNumber result=", result) |
|
285 if (KErrNone == result) { |
|
286 mCsVideo1Editor->setContentWidgetData(QString("text"), number); |
|
287 _DBGLOG2("VmbxCpGroup::queryCsVideoNumber >, number=", number) |
|
288 mUiEngine->setCsVideo1Number(number); |
|
289 } |
|
290 mCsVideo1Editor->setEnabled(true); |
|
291 _DBGLOG("VmbxCpGroup::queryCsVideoNumber <") |
|
292 } |
|
293 |
|
294 /*! |
|
295 Update number when vmbx number changed by OTA,OMA etc. |
|
296 */ |
|
297 void VmbxCpGroup::vmbxNumberChanged(const TVmbxType vmbxType) |
|
298 { |
|
299 _DBGLOG("VmbxCpGroup::vmbxNumberChanged >") |
|
300 // Update cs voice number |
|
301 if (EVmbxVoice == vmbxType) { |
|
302 updateCsVoice1ToUi(); |
|
303 // Update cs video number |
|
304 } else if (EVmbxVideo == vmbxType) { |
|
305 updateCsVideo1ToUi(); |
|
306 } |
|
307 _DBGLOG("VmbxCpGroup::vmbxNumberChanged <") |
220 } |
308 } |
221 |
309 |
222 //End of file |
310 //End of file |