107 void SettingsWidget::createGui() |
99 void SettingsWidget::createGui() |
108 { |
100 { |
109 popup->setDismissPolicy(HbDialog::NoDismiss); |
101 popup->setDismissPolicy(HbDialog::NoDismiss); |
110 popup->setTimeout(HbDialog::NoTimeout); |
102 popup->setTimeout(HbDialog::NoTimeout); |
111 |
103 |
112 HbAction * action = new HbAction(hbTrId("txt_common_button_ok"), popup); |
104 primaryAction = new HbAction(hbTrId("txt_common_button_ok"), popup); |
113 connect(action, SIGNAL(triggered()), this, SLOT(checkBoxOkEvent())); |
105 |
114 mActions.append(action); |
106 connect(primaryAction, SIGNAL(triggered()), this, SLOT(slotOkEvent())); |
115 |
107 |
116 action = new HbAction(hbTrId("txt_common_button_cancel"), popup); |
108 secondaryAction = new HbAction(hbTrId("txt_common_button_cancel"), popup); |
117 connect(action, SIGNAL(triggered()), this, SLOT(checkBoxCancelEvent())); |
109 connect(secondaryAction, SIGNAL(triggered()), this, SLOT(slotCancelEvent())); |
118 mActions.append(action); |
110 |
119 |
111 popup->addAction(primaryAction); |
120 popup->addActions(mActions); |
112 popup->addAction(secondaryAction); |
121 |
113 |
122 dataform->setModel(mModel); |
114 dataform->setModel(mModel); |
123 |
115 |
124 HbLabel *label = new HbLabel(hbTrId("txt_search_title_search_scope")); |
116 HbLabel *label = new HbLabel(hbTrId("txt_search_title_search_scope")); |
125 popup->setHeadingWidget(label); |
117 popup->setHeadingWidget(label); |
126 |
118 |
127 preparecategories(); |
119 preparecategories(); |
128 |
120 |
129 loadBaseSettings(); |
121 loadBaseSettings(); |
130 |
122 |
131 HbDataFormModelItem* themeComboGeneral = mModel->appendDataFormItem( |
123 HbDataFormModelItem* themeComboGeneral = mModel->appendDataFormItem(HbDataFormModelItem::ComboBoxItem, hbTrId("txt_search_info_select_search_scope")); |
132 HbDataFormModelItem::ComboBoxItem, hbTrId( |
|
133 "txt_search_info_select_search_scope")); |
|
134 |
124 |
135 themeComboGeneral->setContentWidgetData("items", mCategoryList); |
125 themeComboGeneral->setContentWidgetData("items", mCategoryList); |
136 |
126 |
137 themeComboGeneral->setContentWidgetData("currentIndex", mSelectedScope); |
127 themeComboGeneral->setContentWidgetData("currentIndex", mSelectedScope); |
138 |
128 |
139 QModelIndex index = mModel->indexFromItem(themeComboGeneral); |
129 QModelIndex index = mModel->indexFromItem(themeComboGeneral); |
140 |
130 |
141 HbDataFormViewItem *formItem = |
131 HbDataFormViewItem *formItem = static_cast<HbDataFormViewItem *> (dataform->itemByIndex(index)); |
142 static_cast<HbDataFormViewItem *> (dataform->itemByIndex(index)); |
|
143 |
132 |
144 comboBox = static_cast<HbComboBox*> (formItem->dataItemContentWidget()); |
133 comboBox = static_cast<HbComboBox*> (formItem->dataItemContentWidget()); |
145 |
134 |
146 q_currentIndexChanged(mSelectedScope); |
135 slotcurrentIndexChanged(mSelectedScope); |
147 |
136 |
148 connect(comboBox, SIGNAL(currentIndexChanged(int)), this, |
137 connect(comboBox, SIGNAL(currentIndexChanged(int)), this,SLOT(slotcurrentIndexChanged(int))); |
149 SLOT(q_currentIndexChanged(int))); |
138 } |
150 |
139 //---------------------------------------------------------------------------------------------------------------------------- |
151 } |
140 //SettingsWidget::slotcurrentIndexChanged() |
152 //---------------------------------------------------------------------------------------------------------------------------- |
141 // |
153 //SettingsWidget::q_currentIndexChanged() |
142 //---------------------------------------------------------------------------------------------------------------------------- |
154 // |
143 void SettingsWidget::slotcurrentIndexChanged(int avalue) |
155 //---------------------------------------------------------------------------------------------------------------------------- |
|
156 void SettingsWidget::q_currentIndexChanged(int avalue) |
|
157 { |
144 { |
158 for (int i = 0; i < mModelItemList.count(); i++) |
145 for (int i = 0; i < mModelItemList.count(); i++) |
159 { |
146 { |
160 mModel->removeItem(mModelItemList.at(i)); |
147 mModel->removeItem(mModelItemList.at(i)); |
161 } |
148 } |
162 mModelItemList.clear(); |
149 mModelItemList.clear(); |
163 // int ret = mModel->rowCount(); |
|
164 if (!avalue) //device category creation |
150 if (!avalue) //device category creation |
165 { |
151 { |
166 isInternetSelected = false; |
152 isInternetSelected = false; |
|
153 |
167 HbCheckBox *checkboxitem = NULL; |
154 HbCheckBox *checkboxitem = NULL; |
|
155 |
|
156 qDeleteAll(mDeviceCheckBoxList.begin(), mDeviceCheckBoxList.end()); |
|
157 |
168 mDeviceCheckBoxList.clear(); |
158 mDeviceCheckBoxList.clear(); |
|
159 |
169 for (int i = 0; i < mDeviceListDisplay.count(); i++) |
160 for (int i = 0; i < mDeviceListDisplay.count(); i++) |
170 { |
161 { |
171 |
162 HbDataFormModelItem* mModelItem = mModel->appendDataFormItem( HbDataFormModelItem::CheckBoxItem); |
172 HbDataFormModelItem* mModelItem = mModel->appendDataFormItem( |
163 |
173 HbDataFormModelItem::CheckBoxItem); |
|
174 mModelItemList.append(mModelItem); |
164 mModelItemList.append(mModelItem); |
|
165 |
175 QModelIndex index = mModel->indexFromItem(mModelItem); |
166 QModelIndex index = mModel->indexFromItem(mModelItem); |
176 |
167 |
177 HbDataFormViewItem *formItem = |
168 HbDataFormViewItem *formItem = static_cast<HbDataFormViewItem *> (dataform->itemByIndex(index)); |
178 static_cast<HbDataFormViewItem *> (dataform->itemByIndex( |
169 |
179 index)); |
170 checkboxitem = static_cast<HbCheckBox*> (formItem->dataItemContentWidget()); |
180 |
|
181 checkboxitem |
|
182 = static_cast<HbCheckBox*> (formItem->dataItemContentWidget()); |
|
183 |
171 |
184 checkboxitem->setText(mDeviceListDisplay.at(i)); |
172 checkboxitem->setText(mDeviceListDisplay.at(i)); |
185 |
173 |
186 mDeviceCheckBoxList.append(checkboxitem); |
174 mDeviceCheckBoxList.append(checkboxitem); |
187 |
175 |
188 signalMapper->setMapping(mDeviceCheckBoxList.at(i), i); |
176 signalMapper->setMapping(mDeviceCheckBoxList.at(i), i); |
189 |
177 |
190 connect(mDeviceCheckBoxList.at(i), SIGNAL(stateChanged(int)), |
178 connect(mDeviceCheckBoxList.at(i), SIGNAL(stateChanged(int)),signalMapper, SLOT(map())); |
191 signalMapper, SLOT(map())); |
179 |
192 |
180 connect(signalMapper, SIGNAL(mapped(int)), this,SLOT(slotstateChanged(int))); |
193 connect(signalMapper, SIGNAL(mapped(int)), this, |
|
194 SLOT(itemChecked(int))); |
|
195 } |
181 } |
196 loadDeviceSettings(); |
182 loadDeviceSettings(); |
197 } |
183 } |
198 else |
184 else |
199 { |
185 { |
200 isInternetSelected = true; |
186 isInternetSelected = true; |
|
187 |
|
188 qDeleteAll(mDeviceCheckBoxList.begin(), mDeviceCheckBoxList.end()); |
|
189 |
201 mDeviceCheckBoxList.clear(); |
190 mDeviceCheckBoxList.clear(); |
202 HbDataFormModelItem* mModelItem = mModel->appendDataFormItem( |
191 |
203 HbDataFormModelItem::RadioButtonListItem); |
192 HbDataFormModelItem* mModelItem = mModel->appendDataFormItem(HbDataFormModelItem::RadioButtonListItem); |
|
193 |
204 mModelItemList.append(mModelItem); |
194 mModelItemList.append(mModelItem); |
|
195 |
205 QStringList internetCategoryList; |
196 QStringList internetCategoryList; |
|
197 |
206 QMapIterator<int, QString> i(mServiceProviders); |
198 QMapIterator<int, QString> i(mServiceProviders); |
207 int selectedindex = 0; |
199 |
208 int Iterator = 0; |
200 int selectedindex = 0,Iterator = 0; |
|
201 |
209 while (i.hasNext()) |
202 while (i.hasNext()) |
210 { |
203 { |
211 i.next(); |
204 i.next(); |
212 if (i.key() == mSelectedProvider) |
205 if (i.key() == mSelectedProvider) |
213 selectedindex = Iterator; |
206 selectedindex = Iterator; |
214 Iterator++; |
207 Iterator++; |
215 internetCategoryList.append(i.value()); |
208 internetCategoryList.append(i.value()); |
216 } |
209 } |
217 mModelItem->setContentWidgetData("items", internetCategoryList); |
210 mModelItem->setContentWidgetData("items", internetCategoryList); |
218 |
211 |
219 mModelItem->setContentWidgetData("previewMode", |
212 mModelItem->setContentWidgetData("previewMode",HbRadioButtonList::NoPreview); |
220 HbRadioButtonList::NoPreview); |
|
221 |
213 |
222 mModelItem->setContentWidgetData("selected", selectedindex); |
214 mModelItem->setContentWidgetData("selected", selectedindex); |
223 |
215 |
224 QModelIndex index = mModel->indexFromItem(mModelItem); |
216 QModelIndex index = mModel->indexFromItem(mModelItem); |
225 |
217 |
226 HbDataFormViewItem *formItem = |
218 HbDataFormViewItem *formItem = static_cast<HbDataFormViewItem *> (dataform->itemByIndex(index)); |
227 static_cast<HbDataFormViewItem *> (dataform->itemByIndex( |
219 |
228 index)); |
220 mradiolist = static_cast<HbRadioButtonList*> (formItem->dataItemContentWidget()); |
229 mradiolist |
221 |
230 = static_cast<HbRadioButtonList*> (formItem->dataItemContentWidget()); |
222 connect(mradiolist, SIGNAL(itemSelected(int)), this,SLOT(slotitemSelected(int))); |
231 |
223 } |
232 connect(mradiolist, SIGNAL(itemSelected(int)), this, |
224 |
233 SLOT(slotitemSelected(int))); |
|
234 } |
|
235 setActionVisibility(); |
225 setActionVisibility(); |
236 } |
226 } |
237 //---------------------------------------------------------------------------------------------------------------------------- |
227 //---------------------------------------------------------------------------------------------------------------------------- |
238 //SettingsWidget::preparecategories() |
228 //SettingsWidget::preparecategories() |
239 // |
229 // |
240 //---------------------------------------------------------------------------------------------------------------------------- |
230 //---------------------------------------------------------------------------------------------------------------------------- |
241 void SettingsWidget::preparecategories() |
231 void SettingsWidget::preparecategories() |
242 { |
232 { |
243 // read form database |
233 // read form database |
244 |
|
245 mDeviceListDisplay.clear(); |
234 mDeviceListDisplay.clear(); |
|
235 mDeviceStoragelist.clear(); |
246 mCategoryList.clear(); |
236 mCategoryList.clear(); |
247 mDeviceMapping.clear(); |
237 |
248 for (int i = 0; i < 8; i++) |
238 QString tempstr; |
249 { |
239 for (int i = 0; i < mUiLoader->ContentInfoList().count(); i++) |
250 mDeviceMapping.append(false); |
240 { |
251 } |
241 if (tempstr != hbTrId(mUiLoader->ContentInfoList().at(i)->getDisplayName().toAscii())) |
252 mCategoryDbMapping.clear(); |
242 { |
253 |
243 tempstr = hbTrId(mUiLoader->ContentInfoList().at(i)->getDisplayName().toAscii()); |
254 QString mConnectionName(QString::fromUtf16(KContentInfoFileName().Ptr(), |
244 |
255 KContentInfoFileName().Length())); |
245 mDeviceListDisplay.insert(mUiLoader->ContentInfoList().at(i)->getDisplayOrder(), |
256 QString mDatabaseName(QString::fromUtf16(KCIDBPath().Ptr(), |
246 hbTrId(mUiLoader->ContentInfoList().at(i)->getDisplayName().toAscii())); |
257 KCIDBPath().Length()) + "\\" + mConnectionName); |
247 |
258 |
248 mDeviceStoragelist.insert(mUiLoader->ContentInfoList().at(i)->getDisplayOrder(), |
259 QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE", mConnectionName); |
249 mUiLoader->ContentInfoList().at(i)->getDisplayName()); |
260 db.setDatabaseName(mDatabaseName); |
250 } |
261 |
251 } |
262 QSqlQuery query(QSqlDatabase::database(mConnectionName)); |
|
263 QString statement = QString("SELECT * FROM ") + QString::fromUtf16( |
|
264 KContentInfoTableName().Ptr(), KContentInfoTableName().Length()); |
|
265 query.prepare(statement); |
|
266 query.exec(); |
|
267 while (query.next()) |
|
268 { |
|
269 QString category_name = query.value(0).toString(); |
|
270 int value = query.value(2).toInt(); |
|
271 if (value) |
|
272 { |
|
273 mCategoryDbMapping.insert(category_name, false); |
|
274 } |
|
275 else |
|
276 { |
|
277 mCategoryDbMapping.insert(category_name, true); |
|
278 } |
|
279 } |
|
280 db.close(); |
|
281 |
|
282 /* mCategoryDbMapping.insert("Contacts", true); |
|
283 mCategoryDbMapping.insert("Audios", true); |
|
284 mCategoryDbMapping.insert("Images", true); |
|
285 mCategoryDbMapping.insert("Videos", true); |
|
286 mCategoryDbMapping.insert("Messages", true); |
|
287 mCategoryDbMapping.insert("email", true); |
|
288 mCategoryDbMapping.insert("Calendar", true); |
|
289 mCategoryDbMapping.insert("Notes", true); |
|
290 mCategoryDbMapping.insert("Applications", true); |
|
291 mCategoryDbMapping.insert("Bookmarks", true); |
|
292 mCategoryDbMapping.insert("Files", true); */ |
|
293 |
|
294 mDeviceListDisplay.append(hbTrId("txt_search_list_select_all")); |
|
295 mDeviceMapping.insert(0, true); |
|
296 |
|
297 if (mCategoryDbMapping.value("Contacts")) |
|
298 { |
|
299 mDeviceMapping.insert(1, true); |
|
300 mDeviceListDisplay.append(hbTrId("txt_search_list_contatcs")); |
|
301 } |
|
302 if (mCategoryDbMapping.value("Audios") || mCategoryDbMapping.value( |
|
303 "Images") || mCategoryDbMapping.value("Videos")) |
|
304 { |
|
305 mDeviceListDisplay.append(hbTrId("txt_search_list_media")); |
|
306 mDeviceMapping.insert(2, true); |
|
307 } |
|
308 if (mCategoryDbMapping.value("Messages") || mCategoryDbMapping.value( |
|
309 "email")) |
|
310 { |
|
311 mDeviceListDisplay.append(hbTrId("txt_search_list_messagemail")); |
|
312 mDeviceMapping.insert(3, true); |
|
313 } |
|
314 if (mCategoryDbMapping.value("Calendar") || mCategoryDbMapping.value( |
|
315 "Notes")) |
|
316 { |
|
317 mDeviceListDisplay.append(hbTrId("txt_search_list_calendarnotes")); |
|
318 mDeviceMapping.insert(4, true); |
|
319 } |
|
320 if (mCategoryDbMapping.value("Applications")) |
|
321 { |
|
322 mDeviceListDisplay.append(hbTrId("txt_search_list_applications")); |
|
323 mDeviceMapping.insert(5, true); |
|
324 } |
|
325 if (mCategoryDbMapping.value("Bookmarks")) |
|
326 { |
|
327 mDeviceListDisplay.append(hbTrId("txt_search_list_bookmarks")); |
|
328 mDeviceMapping.insert(6, true); |
|
329 } |
|
330 if (mCategoryDbMapping.value("Files")) |
|
331 { |
|
332 mDeviceListDisplay.append(hbTrId("txt_search_list_all_other_files")); |
|
333 mDeviceMapping.insert(7, true); |
|
334 } |
|
335 |
|
336 if (mServiceProviders.count()) |
252 if (mServiceProviders.count()) |
337 { |
253 { |
338 mCategoryList = (QStringList() << hbTrId("txt_search_list_device") |
254 mCategoryList = (QStringList() << hbTrId("txt_search_list_device")<< hbTrId("txt_search_list_internet")); |
339 << hbTrId("txt_search_list_internet")); |
|
340 } |
255 } |
341 else |
256 else |
342 { |
257 { |
343 mCategoryList = (QStringList() << hbTrId("txt_search_list_device")); |
258 mCategoryList = (QStringList() << hbTrId("txt_search_list_device")); |
344 } |
259 } |
|
260 storeDefaultSettings(); |
345 } |
261 } |
346 //---------------------------------------------------------------------------------------------------------------------------- |
262 //---------------------------------------------------------------------------------------------------------------------------- |
347 //SettingsWidget::~SettingsWidget() |
263 //SettingsWidget::~SettingsWidget() |
348 // |
264 // |
349 //---------------------------------------------------------------------------------------------------------------------------- |
265 //---------------------------------------------------------------------------------------------------------------------------- |
350 SettingsWidget::~SettingsWidget() |
266 SettingsWidget::~SettingsWidget() |
351 { |
267 { |
|
268 SearchUiLoader::deleteinstance(); |
352 delete signalMapper; |
269 delete signalMapper; |
353 delete mModel; |
270 delete mModel; |
354 mDeviceCheckBoxList.clear(); |
271 mDeviceCheckBoxList.clear(); |
355 mInternetCheckBoxList.clear(); |
272 mInternetCheckBoxList.clear(); |
356 mModelItemList.clear(); |
273 mModelItemList.clear(); |
357 mActions.clear(); |
|
358 delete mDocumentLoader; |
274 delete mDocumentLoader; |
359 delete mInternetHandler; |
275 delete mInternetHandler; |
360 } |
276 } |
361 //---------------------------------------------------------------------------------------------------------------------------- |
277 //---------------------------------------------------------------------------------------------------------------------------- |
362 //SettingsWidget::launchSettingWidget() |
278 //SettingsWidget::launchSettingWidget() |
472 } |
378 } |
473 //---------------------------------------------------------------------------------------------------------------------------- |
379 //---------------------------------------------------------------------------------------------------------------------------- |
474 //SettingsWidget::checkBoxCancelEvent() |
380 //SettingsWidget::checkBoxCancelEvent() |
475 // |
381 // |
476 //---------------------------------------------------------------------------------------------------------------------------- |
382 //---------------------------------------------------------------------------------------------------------------------------- |
477 void SettingsWidget::checkBoxCancelEvent() |
383 void SettingsWidget::slotCancelEvent() |
478 { |
384 { |
479 // loadDeviceSettings();//bug fix for cancel event selection should not reflect "go" button |
|
480 emit settingsEvent(false); |
385 emit settingsEvent(false); |
481 } |
386 } |
482 //---------------------------------------------------------------------------------------------------------------------------- |
387 //---------------------------------------------------------------------------------------------------------------------------- |
483 //void SettingsWidget::checkBoxOkEvent() |
388 //void SettingsWidget::checkBoxOkEvent() |
484 // |
389 // |
485 //---------------------------------------------------------------------------------------------------------------------------- |
390 //---------------------------------------------------------------------------------------------------------------------------- |
486 |
391 |
487 void SettingsWidget::checkBoxOkEvent() |
392 void SettingsWidget::slotOkEvent() |
488 { |
393 { |
489 storeSettingsToiniFile(); |
394 storeSettingsToiniFile(); |
490 emit settingsEvent(true); |
395 emit settingsEvent(true); |
491 } |
396 } |
492 //---------------------------------------------------------------------------------------------------------------------------- |
397 //---------------------------------------------------------------------------------------------------------------------------- |
493 //void SettingsWidget::storeSettingsToiniFile() |
398 //void SettingsWidget::storeSettingsToiniFile() |
494 // |
399 // |
495 //---------------------------------------------------------------------------------------------------------------------------- |
400 //---------------------------------------------------------------------------------------------------------------------------- |
496 |
|
497 void SettingsWidget::storeSettingsToiniFile() |
401 void SettingsWidget::storeSettingsToiniFile() |
498 { |
402 { |
499 QSettings appSettings(SETTINGS_INI_PATH, QSettings::IniFormat); |
403 QSettings appSettings(SETTINGS_INI_PATH, QSettings::IniFormat); |
500 isInternetSelected ? (mSelectedScope = 1) : (mSelectedScope = 0); |
404 isInternetSelected ? (mSelectedScope = 1) : (mSelectedScope = 0); |
501 appSettings.setValue("selectedcategory", mSelectedScope); |
405 appSettings.setValue("selectedcategory", mSelectedScope); |
502 appSettings.setValue("devicecount", mDeviceCategoryRefList.count()); |
|
503 if (!isInternetSelected) |
406 if (!isInternetSelected) |
504 { |
407 { |
505 int j = 0; |
408 for (int i = 0; i < mDeviceCheckBoxList.count(); i++) |
506 for (int i = 0; i < mDeviceCategoryRefList.count(); i++) |
409 { |
507 { |
410 int value; |
508 if (mDeviceMapping.at(i)) |
411 (mDeviceCheckBoxList.at(i)->checkState() == Qt::Checked) ? (value = 1) : (value = 0); |
509 { |
412 |
510 if (mDeviceCheckBoxList.at(j)->checkState() == Qt::Checked) |
413 appSettings.setValue(mDeviceStoragelist.at(i), value); |
511 { |
414 |
512 appSettings.setValue(mDeviceCategoryRefList.at(i), 1); |
415 for (int j = 0; j < mUiLoader->ContentInfoList().count(); j++) |
513 emit selectedItemCategory(i, true); |
416 { |
514 } |
417 if (mUiLoader->ContentInfoList().at(j)->getDisplayName() == mDeviceStoragelist.at(i)) |
515 else |
418 value ? (mUiLoader->ContentInfoList().at(j)->setSelected(true)) : (mUiLoader->ContentInfoList().at(j)->setSelected(false)); |
516 { |
|
517 appSettings.setValue(mDeviceCategoryRefList.at(i), 0); |
|
518 emit selectedItemCategory(i, false); |
|
519 } |
|
520 j++; |
|
521 } |
|
522 else |
|
523 { |
|
524 appSettings.setValue(mDeviceCategoryRefList.at(i), 0); |
|
525 emit selectedItemCategory(i, false); |
|
526 } |
419 } |
527 } |
420 } |
528 } |
421 } |
529 } |
422 } |
530 //---------------------------------------------------------------------------------------------------------------------------- |
423 //---------------------------------------------------------------------------------------------------------------------------- |