|
1 /* |
|
2 * Copyright (c) 2009 - 2010 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: |
|
15 * |
|
16 */ |
|
17 |
|
18 // System includes |
|
19 #include <QApplication> |
|
20 #include <QLocale> |
|
21 #include <QTranslator> |
|
22 #include <QStringList> |
|
23 #include <cpitemdatahelper.h> |
|
24 #include <hblineedit.h> |
|
25 #include <hbdataformmodel.h> |
|
26 #include "actioncustomitem.h" |
|
27 |
|
28 // User includes |
|
29 #include "vmbxuiengine.h" |
|
30 #include "vmbxcpgroup.h" |
|
31 #include "loggerutil.h" |
|
32 |
|
33 /*! |
|
34 Constructor |
|
35 */ |
|
36 VmbxCpGroup::VmbxCpGroup( |
|
37 CpItemDataHelper &itemDataHelper) : |
|
38 CpSettingFormItemData(HbDataFormModelItem::GroupItem, |
|
39 hbTrId("txt_phone_subhead_call_mbx"), NULL), |
|
40 mUiEngine(NULL), |
|
41 mDefaultMailboxEditor(NULL), |
|
42 mCsVoice1Editor(NULL), |
|
43 mCsVideo1Editor(NULL), |
|
44 mItemHelper(itemDataHelper) |
|
45 { |
|
46 _DBGLOG("VmbxCpGroup::VmbxCpGroup >") |
|
47 // Localization file loading |
|
48 QTranslator translator; |
|
49 QString lang = QLocale::system().name(); |
|
50 QString path = "z:/resource/qt/translations/"; |
|
51 |
|
52 bool translatorLoaded = translator.load(path + "telephone_cp_" + lang); |
|
53 _DBGLOG("VmbxCpGroup::VmbxCpGroup translator loaded") |
|
54 if (translatorLoaded && qApp) { |
|
55 qApp->installTranslator(&translator); |
|
56 _DBGLOG("VmbxCpGroup::VmbxCpGroup translator installed") |
|
57 } |
|
58 |
|
59 mUiEngine = new VmbxUiEngine(); |
|
60 |
|
61 loadingPreparation(); |
|
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(updateVmbxNumber(const TVmbxType))); |
|
68 _DBGLOG2("VmbxCpGroup::VmbxCpGroup connect ret=", ret) |
|
69 _DBGLOG("VmbxCpGroup::VmbxCpGroup <") |
|
70 } |
|
71 |
|
72 /*! |
|
73 Destructor |
|
74 */ |
|
75 VmbxCpGroup::~VmbxCpGroup() |
|
76 { |
|
77 _DBGLOG("VmbxCpGroup::~VmbxCpGroup") |
|
78 if (mUiEngine) { |
|
79 delete mUiEngine; |
|
80 mUiEngine = NULL; |
|
81 } |
|
82 } |
|
83 |
|
84 /*! |
|
85 Preparation before loading |
|
86 */ |
|
87 void VmbxCpGroup::loadingPreparation() |
|
88 { |
|
89 _DBGLOG("VmbxCpGroup::loadingPreparation >") |
|
90 |
|
91 ActionCustomItem *viewItem = new ActionCustomItem(); |
|
92 mItemHelper.addItemPrototype(viewItem); |
|
93 mItemHelper.connectToForm( |
|
94 SIGNAL(itemShown(QModelIndex)), this, SLOT(itemShown(QModelIndex))); |
|
95 |
|
96 // Create cs voice primary editor |
|
97 mCsVoice1Editor= createDataFormModelItem(EVmbxVoice); |
|
98 if (mUiEngine->isVideoSupport()){ |
|
99 _DBGLOG("VmbxCpGroup::loadingPreparation create video1 mailbox") |
|
100 mCsVideo1Editor= createDataFormModelItem(EVmbxVideo); |
|
101 } |
|
102 _DBGLOG("VmbxCpGroup::loadingPreparation <") |
|
103 } |
|
104 |
|
105 HbDataFormModelItem* VmbxCpGroup::createDataFormModelItem( |
|
106 const TVmbxType vmbxType) |
|
107 { |
|
108 _DBGLOG("VmbxCpGroup::createDataFormModelItem >") |
|
109 QString number(""); |
|
110 HbDataFormModelItem *item = 0; |
|
111 QString name(""); |
|
112 bool create(false); |
|
113 if (EVmbxVoice == vmbxType) { |
|
114 _DBGLOG("VmbxCpGroup::createDataFormModelItem voice") |
|
115 name = hbTrId("txt_phone_setlabel_default_mbx_val_voice"); |
|
116 create = true; |
|
117 } else if (EVmbxVideo == vmbxType) { |
|
118 _DBGLOG("VmbxCpGroup::createDataFormModelItem video") |
|
119 name = hbTrId("txt_phone_setlabel_default_mbx_val_video"); |
|
120 create = true; |
|
121 } |
|
122 if (create) { |
|
123 item = new HbDataFormModelItem( |
|
124 static_cast<HbDataFormModelItem::DataItemType>( |
|
125 ActionCustomItem::VmbxEditItem),name); |
|
126 |
|
127 appendChild(item); |
|
128 |
|
129 if (EVmbxVoice == vmbxType) { |
|
130 if (mUiEngine->isVoiceWritable()) { |
|
131 _DBGLOG("VmbxCpGroup::createDataFormModelItem add voice") |
|
132 mItemHelper.addConnection(item, SIGNAL(editItemClicked()), |
|
133 this, SLOT(queryCsVoiceNumber())); |
|
134 }else { |
|
135 _DBGLOG("VmbxCpGroup::createDataFormModelItem voice no read") |
|
136 item->setEnabled(false); |
|
137 } |
|
138 } else if (EVmbxVideo == vmbxType) { |
|
139 if (mUiEngine->isVideoWritable()) { |
|
140 _DBGLOG("VmbxCpGroup::createDataFormModelItem add video") |
|
141 mItemHelper.addConnection(item, SIGNAL(editItemClicked()), |
|
142 this, SLOT(queryCsVideoNumber())); |
|
143 }else { |
|
144 _DBGLOG("VmbxCpGroup::createDataFormModelItem video no read") |
|
145 item->setEnabled(false); |
|
146 } |
|
147 } |
|
148 } |
|
149 _DBGLOG("VmbxCpGroup::createDataFormModelItem <") |
|
150 return item; |
|
151 } |
|
152 |
|
153 /*! |
|
154 Query voice number |
|
155 */ |
|
156 void VmbxCpGroup::queryCsVoiceNumber() |
|
157 { |
|
158 _DBGLOG("VmbxCpGroup::queryCsVoiceNumber >") |
|
159 mCsVoice1Editor->setEnabled(false); |
|
160 QString number; |
|
161 int result = mUiEngine->queryVoiceNumber(number); |
|
162 _DBGLOG2("VmbxCpGroup::queryCsVoiceNumber result=", result) |
|
163 if (KErrNone == result) { |
|
164 _DBGLOG2("VmbxCpGroup::queryCsVoiceNumber >, number=", number) |
|
165 mUiEngine->setCsVoiceNumber(number); |
|
166 UpdateWidgetContent(mCsVoice1Index, number); |
|
167 } |
|
168 mCsVoice1Editor->setEnabled(true); |
|
169 _DBGLOG("VmbxCpGroup::queryCsVoiceNumber <") |
|
170 } |
|
171 |
|
172 /*! |
|
173 Query video number |
|
174 */ |
|
175 void VmbxCpGroup::queryCsVideoNumber() |
|
176 { |
|
177 _DBGLOG("VmbxCpGroup::queryCsVideoNumber >") |
|
178 mCsVideo1Editor->setEnabled(false); |
|
179 QString number; |
|
180 int result = mUiEngine->queryVideoNumber(number); |
|
181 _DBGLOG2("VmbxCpGroup::queryCsVideoNumber result=", result) |
|
182 if (KErrNone == result) { |
|
183 _DBGLOG2("VmbxCpGroup::queryCsVideoNumber >, number=", number) |
|
184 mUiEngine->setCsVideoNumber(number); |
|
185 UpdateWidgetContent(mCsVideo1Index, number); |
|
186 } |
|
187 mCsVideo1Editor->setEnabled(true); |
|
188 _DBGLOG("VmbxCpGroup::queryCsVideoNumber <") |
|
189 } |
|
190 |
|
191 /*! |
|
192 Update number when vmbx number changed by OTA,OMA etc. |
|
193 */ |
|
194 void VmbxCpGroup::updateVmbxNumber(const TVmbxType vmbxType) |
|
195 { |
|
196 _DBGLOG("VmbxCpGroup::updateVmbxNumber >") |
|
197 |
|
198 QString number(""); |
|
199 if (EVmbxVoice == vmbxType) { |
|
200 if (mCsVoice1Editor && mUiEngine){ |
|
201 mUiEngine->getCsVoiceNumber(number); |
|
202 _DBGLOG2("VmbxCpGroup::updateVmbxNumber\ |
|
203 number=", number) |
|
204 UpdateWidgetContent(mCsVoice1Index, number); |
|
205 } |
|
206 } else if (EVmbxVideo == vmbxType) { |
|
207 if (mCsVideo1Editor && mUiEngine){ |
|
208 mUiEngine->getCsVideoNumber(number); |
|
209 _DBGLOG2("VmbxCpGroup::updateVmbxNumber\ |
|
210 newUiValue=", number) |
|
211 UpdateWidgetContent(mCsVideo1Index, number); |
|
212 } |
|
213 } |
|
214 _DBGLOG("VmbxCpGroup::updateVmbxNumber <") |
|
215 } |
|
216 |
|
217 /*! |
|
218 slot for item has been shown on the UI |
|
219 */ |
|
220 void VmbxCpGroup::itemShown(const QModelIndex &item) |
|
221 { |
|
222 _DBGLOG("VmbxCpGroup::itemShown >") |
|
223 |
|
224 HbDataFormModelItem* modelItem = mItemHelper.modelItemFromModelIndex(item); |
|
225 |
|
226 if (modelItem == mCsVoice1Editor ) { |
|
227 _DBGLOG("VmbxCpGroup::itemShown voice") |
|
228 mCsVoice1Index = item; |
|
229 updateVmbxNumber(EVmbxVoice); |
|
230 }else if (modelItem == mCsVideo1Editor ) { |
|
231 _DBGLOG("VmbxCpGroup::itemShown video") |
|
232 mCsVideo1Index = item; |
|
233 updateVmbxNumber(EVmbxVideo); |
|
234 } |
|
235 _DBGLOG("VmbxCpGroup::itemShown <") |
|
236 } |
|
237 |
|
238 /*! |
|
239 Update the vmbx number to the UI |
|
240 */ |
|
241 void VmbxCpGroup::UpdateWidgetContent(const QModelIndex &item, |
|
242 const QString &string) |
|
243 { |
|
244 _DBGLOG("VmbxCpGroup::UpdateWidgetContent >") |
|
245 HbLineEdit* widget = static_cast<HbLineEdit *>( |
|
246 mItemHelper.widgetFromModelIndex(item)); |
|
247 if (widget) { |
|
248 _DBGLOG("VmbxCpGroup::UpdateWidgetContent widegt found") |
|
249 widget->setText(string); |
|
250 } |
|
251 if (item == mCsVoice1Index) { |
|
252 mCsVoice1Editor->setContentWidgetData("setText", string); |
|
253 } else if (item == mCsVideo1Index) { |
|
254 mCsVideo1Editor->setContentWidgetData("setText", string); |
|
255 } |
|
256 _DBGLOG("VmbxCpGroup::UpdateWidgetContent <") |
|
257 |
|
258 } |
|
259 |
|
260 //End of file |