95 // mValidatorRealm, mValidatorUsername |
101 // mValidatorRealm, mValidatorUsername |
96 // mConfigIf: scoped pointer deleted automatically |
102 // mConfigIf: scoped pointer deleted automatically |
97 } |
103 } |
98 |
104 |
99 /*! |
105 /*! |
100 * Initializes the sim-aka ui and initializes objects based on configuration |
106 * Creates EAP-SIM/AKA UI and initilizes settings read via |
101 * read from the database. |
107 * EapQtConfigInterface |
102 */ |
108 */ |
103 void CpEapSimAkaUi::initializeSimAkaUi() |
109 void CpEapSimAkaUi::createUi() |
104 { |
110 { |
105 qDebug("CpEapSimAkaUi::initializeSimAkaUi"); |
111 qDebug("CpEapSimAkaUi::createUi"); |
106 |
112 |
107 CpItemDataHelper itemDataHelper; |
113 // Read EAP Configurations |
108 |
|
109 // Read Configurations |
|
110 EapQtConfig eapConfig; |
|
111 bool configurationRead = mConfigIf->readConfiguration(mOuterHandle, mPluginInfo.pluginHandle(), |
114 bool configurationRead = mConfigIf->readConfiguration(mOuterHandle, mPluginInfo.pluginHandle(), |
112 eapConfig); |
115 mEapConfig); |
113 if (!configurationRead) { |
116 if (!configurationRead) { |
114 qDebug("CpEapSimAkaUi::initializeSimAkaUi - read configuration failed."); |
117 qDebug("CpEapSimAkaUi::initializeSimAkaUi - read configuration failed."); |
115 } |
118 } |
116 |
119 |
117 // Create UI objects and group |
120 // Construct EAP-SIM/AKA settings UI |
118 mForm = new HbDataForm(); |
121 mForm = new HbDataForm(); |
119 this->setWidget(mForm); |
122 this->setWidget(mForm); |
|
123 mModel = new HbDataFormModel(mForm); |
|
124 |
|
125 mGroupItem = new HbDataFormModelItem(HbDataFormModelItem::GroupItem, |
|
126 HbParameterLengthLimiter( |
|
127 hbTrId("txt_occ_subhead_eap_module_settings")).arg( |
|
128 mPluginInfo.localizationId())); |
|
129 mModel->appendDataFormItem(mGroupItem); |
|
130 |
|
131 // The parameter given as 0 is a HbDataForm pointer, not parent |
|
132 mItemDataHelper = new CpItemDataHelper(0); |
|
133 mItemDataHelper->setParent(this); |
|
134 |
|
135 // Create UI components |
|
136 createUsername(); |
|
137 createRealm(); |
120 |
138 |
121 mModel = new HbDataFormModel(mForm); |
139 mItemDataHelper->bindToForm(mForm); |
122 HbDataFormModelItem *groupItem = new HbDataFormModelItem(HbDataFormModelItem::GroupItem, |
140 mForm->setModel(mModel); |
123 hbTrId("txt_occ_subhead_eap_module_settings").arg(mPluginInfo.localizationId())); |
141 |
124 mModel->appendDataFormItem(groupItem); |
|
125 |
|
126 // Connect signal to add validators when items get activated (visualization created). |
142 // Connect signal to add validators when items get activated (visualization created). |
127 bool connected = connect(mForm, SIGNAL( itemShown(const QModelIndex&) ), this, |
143 bool connected = connect(mForm, SIGNAL( itemShown(const QModelIndex&) ), this, |
128 SLOT( setValidator(const QModelIndex) )); |
144 SLOT( setValidator(const QModelIndex) )); |
129 Q_ASSERT(connected); |
145 Q_ASSERT(connected); |
130 |
146 |
|
147 // Expand EAP-SIM/AKA settings group |
|
148 mForm->setExpanded(mModel->indexFromItem(mGroupItem), true); |
|
149 } |
|
150 |
|
151 /*! |
|
152 * Creates Username group: |
|
153 * Generate automatically checkBox and username lineEdit |
|
154 */ |
|
155 void CpEapSimAkaUi::createUsername() |
|
156 { |
|
157 qDebug("CpEapSimAkaUi::createUsername()"); |
131 // UsernameAutomatic |
158 // UsernameAutomatic |
132 mUsernameAutomatic = new CpSettingFormItemData(HbDataFormModelItem::CheckBoxItem, hbTrId( |
159 mUsernameAutomatic = new CpSettingFormItemData(HbDataFormModelItem::CheckBoxItem, hbTrId( |
133 "txt_occ_setlabel_user_name")); |
160 "txt_occ_setlabel_user_name")); |
134 mUsernameAutomatic->setContentWidgetData("text", hbTrId( |
161 mUsernameAutomatic->setContentWidgetData("text", hbTrId( |
135 "txt_occ_setlabel_user_name_val_generate_automatica")); |
162 "txt_occ_setlabel_user_name_val_generate_automatica")); |
136 // Initialize the value from EapQtConfig |
163 // Initialize the value from EapQtConfig |
137 // Generate username automatically is selected by default |
164 // Generate username automatically is selected by default |
138 mUsernameAutomatic->setContentWidgetData("checkState", boolToCheckState(eapConfig.value( |
165 mUsernameAutomatic->setContentWidgetData("checkState", boolToCheckState(mEapConfig.value( |
139 EapQtConfig::UsernameAutomatic).toBool())); |
166 EapQtConfig::UsernameAutomatic).toBool())); |
140 // Connect signal to disable/enable username when usernameAutomatic changed |
167 // Connect signal to disable/enable username when usernameAutomatic changed |
141 mForm->addConnection(mUsernameAutomatic, SIGNAL(stateChanged(int)), this, |
168 mForm->addConnection(mUsernameAutomatic, SIGNAL(stateChanged(int)), this, |
142 SLOT(usernameAutomaticChanged(int))); |
169 SLOT(usernameAutomaticChanged(int))); |
143 groupItem->appendChild(mUsernameAutomatic); |
170 mGroupItem->appendChild(mUsernameAutomatic); |
144 |
171 |
145 //Username |
172 //Username |
146 mUsername = new CpSettingFormItemData(HbDataFormModelItem::TextItem, hbTrId( |
173 mUsername = new CpSettingFormItemData(HbDataFormModelItem::TextItem, hbTrId( |
147 "txt_occ_setlabel_user_name")); |
174 "txt_occ_setlabel_user_name")); |
148 mUsername->setContentWidgetData("text", eapConfig.value(EapQtConfig::Username)); |
175 mUsername->setContentWidgetData("text", mEapConfig.value(EapQtConfig::Username)); |
149 // Dimmed username if usernameAutomatic selected |
176 // Dim username if usernameAutomatic selected |
150 usernameAutomaticChanged(mUsernameAutomatic->contentWidgetData("checkState") == Qt::Checked); |
177 usernameAutomaticChanged(mUsernameAutomatic->contentWidgetData("checkState") == Qt::Checked); |
151 groupItem->appendChild(mUsername); |
178 mGroupItem->appendChild(mUsername); |
152 |
179 } |
|
180 |
|
181 /*! |
|
182 * Creates Realm group: |
|
183 * Generate automatically checkBox and realm lineEdit |
|
184 */ |
|
185 void CpEapSimAkaUi::createRealm() |
|
186 { |
|
187 qDebug("CpEapSimAkaUi::createRealm()"); |
153 // RealmAutomatic |
188 // RealmAutomatic |
154 mRealmAutomatic = new CpSettingFormItemData(HbDataFormModelItem::CheckBoxItem, hbTrId( |
189 mRealmAutomatic = new CpSettingFormItemData(HbDataFormModelItem::CheckBoxItem, hbTrId( |
155 "txt_occ_setlabel_realm")); |
190 "txt_occ_setlabel_realm")); |
156 mRealmAutomatic->setContentWidgetData("text", hbTrId( |
191 mRealmAutomatic->setContentWidgetData("text", hbTrId( |
157 "txt_occ_setlabel_realm_val_generate_automatically")); |
192 "txt_occ_setlabel_realm_val_generate_automatically")); |
158 // Initialize the value from EapQtConfig |
193 // Initialize the value from EapQtConfig |
159 // Generate realm automatically is selected by default |
194 // Generate realm automatically is selected by default |
160 mRealmAutomatic->setContentWidgetData("checkState", boolToCheckState(eapConfig.value( |
195 mRealmAutomatic->setContentWidgetData("checkState", boolToCheckState(mEapConfig.value( |
161 EapQtConfig::RealmAutomatic).toBool())); |
196 EapQtConfig::RealmAutomatic).toBool())); |
162 // connect signal to disable/enable realm when realmAutomatic changed |
197 // connect signal to disable/enable realm when realmAutomatic changed |
163 mForm->addConnection(mRealmAutomatic, SIGNAL(stateChanged(int)), this, |
198 mForm->addConnection(mRealmAutomatic, SIGNAL(stateChanged(int)), this, |
164 SLOT(realmAutomaticChanged(int))); |
199 SLOT(realmAutomaticChanged(int))); |
165 groupItem->appendChild(mRealmAutomatic); |
200 mGroupItem->appendChild(mRealmAutomatic); |
166 |
201 |
167 //Realm |
202 //Realm |
168 mRealm = new CpSettingFormItemData(HbDataFormModelItem::TextItem, hbTrId( |
203 mRealm = new CpSettingFormItemData(HbDataFormModelItem::TextItem, hbTrId( |
169 "txt_occ_setlabel_realm")); |
204 "txt_occ_setlabel_realm")); |
170 mRealm->setContentWidgetData("text", eapConfig.value(EapQtConfig::Realm)); |
205 mRealm->setContentWidgetData("text", mEapConfig.value(EapQtConfig::Realm)); |
171 // Dimmed realm if realmAutomatic selected |
206 // Dim realm if realmAutomatic selected |
172 realmAutomaticChanged(mRealmAutomatic->contentWidgetData("checkState") == Qt::Checked); |
207 realmAutomaticChanged(mRealmAutomatic->contentWidgetData("checkState") == Qt::Checked); |
173 groupItem->appendChild(mRealm); |
208 mGroupItem->appendChild(mRealm); |
174 |
|
175 // Set the model |
|
176 itemDataHelper.bindToForm(mForm); |
|
177 mForm->setModel(mModel); |
|
178 |
|
179 // Expand simakaui settings group |
|
180 mForm->setExpanded(mModel->indexFromItem(groupItem), TRUE); |
|
181 } |
209 } |
182 |
210 |
183 /*! |
211 /*! |
184 * Adds validators. |
212 * Adds validators. |
185 * |
213 * |
217 * |
245 * |
218 */ |
246 */ |
219 void CpEapSimAkaUi::close() |
247 void CpEapSimAkaUi::close() |
220 { |
248 { |
221 qDebug("CpEapSimAkaUi::close"); |
249 qDebug("CpEapSimAkaUi::close"); |
|
250 |
|
251 // Validate configuration |
222 if (validate()) { |
252 if (validate()) { |
223 qDebug("CpEapSimAkaUi::close - Store settings and exit"); |
253 qDebug("CpEapSimAkaUi::close - Validation OK"); |
224 storeSettings(); |
254 |
225 CpBaseSettingView::close(); |
255 // Store settings |
|
256 if (storeSettings()){ |
|
257 qDebug("CpEapSimAkaUi::close - Settings stored, close view"); |
|
258 // Close view |
|
259 CpBaseSettingView::close(); |
|
260 } |
|
261 else { |
|
262 qDebug("CpEapSimAkaUi::close - Store settings failed, prompt warning"); |
|
263 // Store failed. Show error note to user |
|
264 QScopedPointer<HbMessageBox> infoBox; |
|
265 infoBox.reset(new HbMessageBox( |
|
266 HbMessageBox::MessageTypeWarning)); |
|
267 infoBox->setAttribute(Qt::WA_DeleteOnClose); |
|
268 infoBox->setText(hbTrId("txt_occ_info_unable_to_save_setting")); |
|
269 infoBox->clearActions(); |
|
270 // Connect 'OK'-button to CpBaseSettingView 'aboutToClose'-signal |
|
271 HbAction *okAction = new HbAction(hbTrId("txt_common_button_ok")); |
|
272 infoBox->addAction(okAction); |
|
273 bool connected = connect( |
|
274 okAction, |
|
275 SIGNAL(triggered()), |
|
276 this, |
|
277 SIGNAL(aboutToClose())); |
|
278 Q_ASSERT(connected); |
|
279 infoBox->open(); |
|
280 infoBox.take(); |
|
281 } |
226 } |
282 } |
227 else { |
283 else { |
228 qDebug("CpEapSimAkaUi::close - validation failed. Prompt question."); |
284 qDebug("CpEapSimAkaUi::close - validation failed. Prompt question."); |
229 HbMessageBox *note = new HbMessageBox(HbMessageBox::MessageTypeQuestion); |
285 QScopedPointer<HbMessageBox> messageBox; |
230 note->setAttribute(Qt::WA_DeleteOnClose); |
286 messageBox.reset(new HbMessageBox( |
231 note->setText(hbTrId("txt_occ_info_incomplete_details_return_without_sa")); |
287 HbMessageBox::MessageTypeQuestion)); |
232 note->clearActions(); |
288 messageBox->setAttribute(Qt::WA_DeleteOnClose); |
|
289 messageBox->setText(hbTrId("txt_occ_info_incomplete_details_return_without_sa")); |
|
290 messageBox->clearActions(); |
233 // Connect 'YES'-button to CpBaseSettingView 'aboutToClose'-signal |
291 // Connect 'YES'-button to CpBaseSettingView 'aboutToClose'-signal |
234 HbAction *okAction = new HbAction(hbTrId("txt_common_button_yes")); |
292 HbAction *okAction = new HbAction(hbTrId("txt_common_button_yes")); |
235 note->addAction(okAction); |
293 messageBox->addAction(okAction); |
236 bool connected = connect( |
294 bool connected = connect( |
237 okAction, |
295 okAction, |
238 SIGNAL(triggered()), |
296 SIGNAL(triggered()), |
239 this, |
297 this, |
240 SIGNAL(aboutToClose())); |
298 SIGNAL(aboutToClose())); |
241 Q_ASSERT(connected); |
299 Q_ASSERT(connected); |
242 // Clicking 'NO'-button does nothing |
300 // Clicking 'NO'-button does nothing |
243 HbAction *cancelAction = new HbAction(hbTrId("txt_common_button_no")); |
301 HbAction *cancelAction = new HbAction(hbTrId("txt_common_button_no")); |
244 note->addAction(cancelAction); |
302 messageBox->addAction(cancelAction); |
245 note->setTimeout(HbPopup::NoTimeout); |
303 messageBox->setTimeout(HbPopup::NoTimeout); |
246 note->open(); |
304 messageBox->open(); |
|
305 messageBox.take(); |
247 } |
306 } |
248 } |
307 } |
249 |
308 |
250 /*! |
309 /*! |
251 * Dims the realm if generate realm automatically has been selected. |
310 * Dims the realm if generate realm automatically has been selected. |