22 #include <hblabel.h> |
22 #include <hblabel.h> |
23 #include <qsignalmapper.h> |
23 #include <qsignalmapper.h> |
24 #include <hbtooltip.h> |
24 #include <hbtooltip.h> |
25 #include <qsettings.h> |
25 #include <qsettings.h> |
26 #include <hbinputdialog.h> |
26 #include <hbinputdialog.h> |
27 #include<hbscrollarea.h> |
27 #include <hbscrollarea.h> |
28 #include <qgraphicswidget.h> |
28 #include <qgraphicswidget.h> |
29 #include <hbglobal.h> |
29 #include <hbglobal.h> |
|
30 #include <hbdataform.h> |
|
31 #include <hbdataformmodel.h> |
|
32 #include <hbdocumentloader.h> |
|
33 #include <hbcombobox.h> |
|
34 #include <hbdataformviewitem.h> |
|
35 #include <hbradiobuttonlist.h> |
|
36 #include <qdir.h> |
|
37 #include <qsql.h> |
|
38 #include <qsqldatabase.h> |
|
39 #include <qsqlquery.h> |
|
40 #include <cpixcontentinfocommon.h> |
|
41 const char *DELIMETER_DOCML = ":/xml/delimeterscreen.docml"; |
|
42 const char *DIALOG = "dialog"; |
|
43 const char *DATAFORM = "dataForm"; |
30 |
44 |
31 //---------------------------------------------------------------------------------------------------------------------------- |
45 //---------------------------------------------------------------------------------------------------------------------------- |
32 //SettingsWidget::SettingsWidget() |
46 //SettingsWidget::SettingsWidget() |
33 // |
47 // |
34 //---------------------------------------------------------------------------------------------------------------------------- |
48 //---------------------------------------------------------------------------------------------------------------------------- |
35 SettingsWidget::SettingsWidget() : |
49 SettingsWidget::SettingsWidget() : |
36 HbWidget() |
50 signalMapper(NULL), popup(NULL), mDocumentLoader(NULL), dataform(NULL), |
37 { |
51 mModel(NULL),mSelectedScope(0),mSelectedProvider(0) |
38 deviceCategoryList = (QStringList() << hbTrId("txt_search_list_device") |
52 { |
39 << hbTrId("txt_search_list_contatcs") << hbTrId( |
53 for (int i = 0; i < 8; i++) |
40 "txt_search_list_media") << hbTrId("txt_search_list_messagemail") |
54 { |
41 << hbTrId("txt_search_list_calendarnotes") << hbTrId( |
55 mDeviceMapping.append(false); |
42 "txt_search_list_applications") << hbTrId( |
56 } |
43 "txt_search_list_all_other_files")); |
57 |
44 internetCategoryList = (QStringList() << hbTrId( |
58 mDeviceCategoryRefList = (QStringList() << "first" << "second" << "third" |
45 "txt_search_list_internet") << "Google" << "Bing"); |
59 << "fourth" << "fifth" << "sixth" << "seventh" << "eigth"); |
46 |
60 |
47 QGraphicsLinearLayout *linearLayout = new QGraphicsLinearLayout( |
61 mchangestate = true; |
48 Qt::Vertical); |
62 mInstialize = true; |
49 |
63 isInternetSelected = false; |
50 setLayout(linearLayout); |
64 storeDefaultSettings(); |
51 |
65 } |
52 popup = new HbDialog(); |
66 //---------------------------------------------------------------------------------------------------------------------------- |
|
67 //SettingsWidget::intialize() |
|
68 // |
|
69 //---------------------------------------------------------------------------------------------------------------------------- |
|
70 void SettingsWidget::initialize() |
|
71 { |
|
72 bool ok = false; |
|
73 if (!mDocumentLoader) |
|
74 { |
|
75 mDocumentLoader = new HbDocumentLoader(); |
|
76 mDocumentLoader->load(DELIMETER_DOCML, &ok); |
|
77 } |
|
78 QGraphicsWidget *widget = NULL; |
|
79 if (!popup) |
|
80 { |
|
81 widget = mDocumentLoader->findWidget(DIALOG); |
|
82 Q_ASSERT_X(ok && (widget != 0), "DIALOG", "invalid view"); |
|
83 |
|
84 popup = qobject_cast<HbDialog*> (widget); |
|
85 } |
|
86 if (!dataform) |
|
87 { |
|
88 widget = mDocumentLoader->findWidget(DATAFORM); |
|
89 Q_ASSERT_X(ok && (widget != 0), "DATAFORM", "invalid view"); |
|
90 dataform = qobject_cast<HbDataForm*> (widget); |
|
91 } |
|
92 if (!mModel) |
|
93 { |
|
94 mModel = new HbDataFormModel(); |
|
95 } |
|
96 if (!signalMapper) |
|
97 { |
|
98 signalMapper = new QSignalMapper(this); |
|
99 } |
|
100 |
|
101 createGui(); |
|
102 } |
|
103 //---------------------------------------------------------------------------------------------------------------------------- |
|
104 //SettingsWidget::createGui() |
|
105 // |
|
106 //---------------------------------------------------------------------------------------------------------------------------- |
|
107 void SettingsWidget::createGui() |
|
108 { |
53 popup->setDismissPolicy(HbDialog::NoDismiss); |
109 popup->setDismissPolicy(HbDialog::NoDismiss); |
54 |
|
55 popup->setTimeout(HbDialog::NoTimeout); |
110 popup->setTimeout(HbDialog::NoTimeout); |
56 |
111 |
57 HbAction * action = new HbAction(hbTrId("txt_common_button_ok"), popup); |
112 HbAction * action = new HbAction(hbTrId("txt_common_button_ok"), popup); |
58 connect(action, SIGNAL(triggered()), this, SLOT(checkBoxOkEvent())); |
113 connect(action, SIGNAL(triggered()), this, SLOT(checkBoxOkEvent())); |
59 popup->setPrimaryAction(action); |
114 mActions.append(action); |
60 |
115 |
61 action = new HbAction(hbTrId("txt_common_button_cancel"), popup); |
116 action = new HbAction(hbTrId("txt_common_button_cancel"), popup); |
62 connect(action, SIGNAL(triggered()), this, SLOT(checkBoxCancelEvent())); |
117 connect(action, SIGNAL(triggered()), this, SLOT(checkBoxCancelEvent())); |
63 popup->setSecondaryAction(action); |
118 mActions.append(action); |
64 |
119 |
65 //device category creation |
120 popup->addActions(mActions); |
66 |
121 |
67 HbCheckBox *checkboxitem = NULL; |
122 dataform->setModel(mModel); |
68 |
123 |
69 signalMapper = new QSignalMapper(this); |
124 HbLabel *label = new HbLabel(hbTrId("txt_search_title_search_scope")); |
70 |
125 popup->setHeadingWidget(label); |
71 for (int i = 0; i < deviceCategoryList.count(); i++) |
126 |
72 { |
127 preparecategories(); |
73 checkboxitem = new HbCheckBox(deviceCategoryList.at(i)); |
128 |
74 |
129 loadBaseSettings(); |
75 mDeviceCheckBoxList.append(checkboxitem); |
130 |
76 |
131 HbDataFormModelItem* themeComboGeneral = mModel->appendDataFormItem( |
77 signalMapper->setMapping(mDeviceCheckBoxList.at(i), i); |
132 HbDataFormModelItem::ComboBoxItem, hbTrId( |
78 |
133 "txt_search_qtl_dialog_pri_heading_delimiter")); |
79 connect(mDeviceCheckBoxList.at(i), SIGNAL(stateChanged(int)), |
134 |
80 signalMapper, SLOT(map())); |
135 themeComboGeneral->setContentWidgetData(QString("items"), mCategoryList); |
81 |
136 |
82 if (i == 0) |
137 themeComboGeneral->setContentWidgetData(QString("currentIndex"), |
83 { |
138 mSelectedScope); |
84 //arrange device search &internet search |
139 |
85 linearLayout->addItem(mDeviceCheckBoxList.at(i)); |
140 QModelIndex index = mModel->indexFromItem(themeComboGeneral); |
|
141 |
|
142 HbDataFormViewItem *formItem = dataform->dataFormViewItem(index); |
|
143 |
|
144 HbComboBox *comboBox = |
|
145 static_cast<HbComboBox*> (formItem->dataItemContentWidget()); |
|
146 |
|
147 q_currentIndexChanged(mSelectedScope); |
|
148 |
|
149 connect(comboBox, SIGNAL(currentIndexChanged(int)), this, |
|
150 SLOT(q_currentIndexChanged(int))); |
|
151 |
|
152 } |
|
153 //---------------------------------------------------------------------------------------------------------------------------- |
|
154 //SettingsWidget::q_currentIndexChanged() |
|
155 // |
|
156 //---------------------------------------------------------------------------------------------------------------------------- |
|
157 void SettingsWidget::q_currentIndexChanged(int avalue) |
|
158 { |
|
159 for (int i = 0; i < mModelItemList.count(); i++) |
|
160 { |
|
161 mModel->removeItem(mModelItemList.at(i)); |
|
162 } |
|
163 mModelItemList.clear(); |
|
164 // int ret = mModel->rowCount(); |
|
165 if (!avalue) //device category creation |
|
166 { |
|
167 isInternetSelected = false; |
|
168 HbCheckBox *checkboxitem = NULL; |
|
169 mDeviceCheckBoxList.clear(); |
|
170 for (int i = 0; i < mDeviceListDisplay.count(); i++) |
|
171 { |
|
172 |
|
173 HbDataFormModelItem* mModelItem = mModel->appendDataFormItem( |
|
174 HbDataFormModelItem::CheckBoxItem); |
|
175 mModelItemList.append(mModelItem); |
|
176 QModelIndex index = mModel->indexFromItem(mModelItem); |
|
177 |
|
178 HbDataFormViewItem *formItem = dataform->dataFormViewItem(index); |
|
179 |
|
180 checkboxitem |
|
181 = static_cast<HbCheckBox*> (formItem->dataItemContentWidget()); |
|
182 |
|
183 checkboxitem->setText(mDeviceListDisplay.at(i)); |
|
184 |
|
185 mDeviceCheckBoxList.append(checkboxitem); |
|
186 |
|
187 signalMapper->setMapping(mDeviceCheckBoxList.at(i), i); |
|
188 |
|
189 connect(mDeviceCheckBoxList.at(i), SIGNAL(stateChanged(int)), |
|
190 signalMapper, SLOT(map())); |
|
191 |
|
192 connect(signalMapper, SIGNAL(mapped(int)), this, |
|
193 SLOT(itemChecked(int))); |
|
194 } |
|
195 loadDeviceSettings(); |
|
196 } |
|
197 else |
|
198 { |
|
199 isInternetSelected = true; |
|
200 mDeviceCheckBoxList.clear(); |
|
201 HbDataFormModelItem* mModelItem = mModel->appendDataFormItem( |
|
202 HbDataFormModelItem::RadioButtonListItem); |
|
203 mModelItemList.append(mModelItem); |
|
204 mModelItem->setContentWidgetData("items", internetCategoryList); |
|
205 |
|
206 QModelIndex index = mModel->indexFromItem(mModelItem); |
|
207 |
|
208 HbDataFormViewItem *formItem = dataform->dataFormViewItem(index); |
|
209 |
|
210 mradiolist |
|
211 = static_cast<HbRadioButtonList*> (formItem->dataItemContentWidget()); |
|
212 |
|
213 mradiolist->setPreviewMode(HbRadioButtonList::NoPreview); |
|
214 |
|
215 mradiolist->setSelected(mSelectedProvider); |
|
216 connect(mradiolist, SIGNAL(itemSelected(int)), this, |
|
217 SLOT(q_itemSelected(int))); |
|
218 |
|
219 for (int i = 0; i < mActions.count(); i++) |
|
220 popup->removeAction(mActions.at(i)); |
|
221 popup->addActions(mActions); |
|
222 popup->removeAction(mActions.at(0)); |
|
223 } |
|
224 } |
|
225 //---------------------------------------------------------------------------------------------------------------------------- |
|
226 //SettingsWidget::preparecategories() |
|
227 // |
|
228 //---------------------------------------------------------------------------------------------------------------------------- |
|
229 void SettingsWidget::preparecategories() |
|
230 { |
|
231 // read form database |
|
232 |
|
233 |
|
234 QString mConnectionName("cpixcontentinfo.sq"); |
|
235 QString mDatabaseName("c:\\Private\\2001f6fb\\cpixcontentinfo.sq"); |
|
236 |
|
237 QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE", mConnectionName); |
|
238 db.setDatabaseName(mDatabaseName); |
|
239 |
|
240 QSqlQuery query(QSqlDatabase::database(mConnectionName)); |
|
241 QString statement = "SELECT NAME FROM table1"; |
|
242 |
|
243 query.prepare(statement); |
|
244 query.exec(); |
|
245 while (query.next()) |
|
246 { |
|
247 QString category_name = query.value(0).toString(); |
|
248 int value = query.value(2).toInt(); |
|
249 if (value) |
|
250 { |
|
251 mCategoryDbMapping.insert(category_name, false); |
86 } |
252 } |
87 else |
253 else |
88 { |
254 { |
89 //arrange other subcategoriess |
255 mCategoryDbMapping.insert(category_name, true); |
90 mDeviceCheckBoxList.at(i)->setContentsMargins(20, 0, 0, 0); |
256 } |
91 linearLayout->addItem(mDeviceCheckBoxList.at(i)); |
257 qDebug() <<"string db= "<<category_name; |
92 } |
258 } |
93 } |
259 db.close(); |
94 int j = 0; |
260 |
95 for (int i = deviceCategoryList.count(); i < internetCategoryList.count() |
261 /* mCategoryDbMapping.insert("Contacts", true); |
96 + deviceCategoryList.count(); i++) |
262 mCategoryDbMapping.insert("Audios", true); |
97 { |
263 mCategoryDbMapping.insert("Images", true); |
98 |
264 mCategoryDbMapping.insert("Videos", true); |
99 checkboxitem = new HbCheckBox(internetCategoryList.at(j)); |
265 mCategoryDbMapping.insert("Messages", true); |
100 |
266 mCategoryDbMapping.insert("email", true); |
101 mInternetCheckBoxList.append(checkboxitem); |
267 mCategoryDbMapping.insert("Calendar", true); |
102 |
268 mCategoryDbMapping.insert("Notes", true); |
103 signalMapper->setMapping(mInternetCheckBoxList.at(j), i); |
269 mCategoryDbMapping.insert("Applications", true); |
104 |
270 mCategoryDbMapping.insert("Bookmarks", true); |
105 connect(mInternetCheckBoxList.at(j), SIGNAL(stateChanged(int)), |
271 mCategoryDbMapping.insert("Files", true); */ |
106 signalMapper, SLOT(map())); |
272 |
107 |
273 // mCategoryDbMapping.insert("email", true); // to remove once email starts working |
108 if (i == deviceCategoryList.count()) |
274 |
109 { |
275 mDeviceListDisplay.append("Select all"); |
110 //arrange device search &internet search |
276 mDeviceMapping.insert(0, true); |
111 linearLayout->addItem(mInternetCheckBoxList.at(j)); |
277 |
112 } |
278 if (mCategoryDbMapping.value("Contacts")) |
113 else |
279 { |
114 { |
280 mDeviceMapping.insert(1, true); |
115 //arrange other subcategoriess |
281 mDeviceListDisplay.append(hbTrId("txt_search_list_contatcs")); |
116 mInternetCheckBoxList.at(j)->setContentsMargins(20, 0, 0, 0); |
282 } |
117 linearLayout->addItem(mInternetCheckBoxList.at(j)); |
283 |
118 |
284 if (mCategoryDbMapping.value("Audios") |
119 } |
285 || mCategoryDbMapping.value("Images") || mCategoryDbMapping.value( |
120 j++; |
286 "Videos")) |
121 } |
287 { |
122 |
288 mDeviceListDisplay.append(hbTrId("txt_search_list_media")); |
123 connect(signalMapper, SIGNAL(mapped(int)), this, SLOT(itemChecked(int))); |
289 mDeviceMapping.insert(2, true); |
124 |
290 } |
125 //Heading label |
291 |
126 |
292 if (mCategoryDbMapping.value("Messages") || mCategoryDbMapping.value( |
127 HbLabel *label = new HbLabel(hbTrId( |
293 "email")) |
128 "txt_search_qtl_dialog_pri_heading_delimiter")); |
294 { |
129 popup->setHeadingWidget(label); |
295 mDeviceListDisplay.append(hbTrId("txt_search_list_messagemail")); |
130 |
296 mDeviceMapping.insert(3, true); |
131 HbScrollArea* scrollArea = new HbScrollArea(popup); |
297 } |
132 scrollArea->setScrollDirections(Qt::Vertical); |
298 |
133 scrollArea->setFlag(QGraphicsItem::ItemClipsChildrenToShape, true); |
299 if (mCategoryDbMapping.value("Calendar") || mCategoryDbMapping.value( |
134 scrollArea->setContentWidget(this); |
300 "Notes")) |
135 popup->setContentWidget(scrollArea); |
301 { |
136 |
302 mDeviceListDisplay.append(hbTrId("txt_search_list_calendarnotes")); |
137 // loadSettingsFrominiFile(); |
303 mDeviceMapping.insert(4, true); |
138 } |
304 } |
|
305 |
|
306 if (mCategoryDbMapping.value("Applications")) |
|
307 { |
|
308 mDeviceListDisplay.append(hbTrId("txt_search_list_applications")); |
|
309 mDeviceMapping.insert(5, true); |
|
310 } |
|
311 |
|
312 if (mCategoryDbMapping.value("Bookmarks")) |
|
313 { |
|
314 mDeviceListDisplay.append(hbTrId("txt_search_list_bookmarks")); |
|
315 mDeviceMapping.insert(6, true); |
|
316 } |
|
317 |
|
318 if (mCategoryDbMapping.value("Files")) |
|
319 { |
|
320 mDeviceListDisplay.append(hbTrId("txt_search_list_all_other_files")); |
|
321 mDeviceMapping.insert(7, true); |
|
322 } |
|
323 internetCategoryList = (QStringList() << "Google" << "Bing"); |
|
324 |
|
325 mCategoryList = (QStringList() << hbTrId("txt_search_list_device") |
|
326 << hbTrId("txt_search_list_internet")); |
|
327 } |
|
328 |
139 //---------------------------------------------------------------------------------------------------------------------------- |
329 //---------------------------------------------------------------------------------------------------------------------------- |
140 //SettingsWidget::~SettingsWidget() |
330 //SettingsWidget::~SettingsWidget() |
141 // |
331 // |
142 //---------------------------------------------------------------------------------------------------------------------------- |
332 //---------------------------------------------------------------------------------------------------------------------------- |
143 SettingsWidget::~SettingsWidget() |
333 SettingsWidget::~SettingsWidget() |
144 { |
334 { |
145 delete signalMapper; |
335 delete signalMapper; |
146 //delete popup; |
336 //delete popup; |
|
337 //delete dataform; |
|
338 delete mModel; |
|
339 //delete mradiolist; |
|
340 mDeviceCheckBoxList.clear(); |
|
341 mInternetCheckBoxList.clear(); |
|
342 mModelItemList.clear(); |
|
343 mActions.clear(); |
|
344 delete mDocumentLoader; |
|
345 //delete popup; |
147 } |
346 } |
148 //---------------------------------------------------------------------------------------------------------------------------- |
347 //---------------------------------------------------------------------------------------------------------------------------- |
149 //SettingsWidget::launchSettingWidget() |
348 //SettingsWidget::launchSettingWidget() |
150 // |
349 // |
151 //---------------------------------------------------------------------------------------------------------------------------- |
350 //---------------------------------------------------------------------------------------------------------------------------- |
152 void SettingsWidget::launchSettingWidget() |
351 void SettingsWidget::launchSettingWidget() |
153 { |
352 { |
154 loadSettingsFrominiFile(); |
353 if (mInstialize) |
|
354 { |
|
355 initialize(); |
|
356 mInstialize = false; |
|
357 } |
|
358 q_currentIndexChanged(mSelectedScope); |
155 setActionVisibility(); |
359 setActionVisibility(); |
156 popup->show(); |
360 popup->show(); |
157 } |
361 } |
158 //---------------------------------------------------------------------------------------------------------------------------- |
362 //---------------------------------------------------------------------------------------------------------------------------- |
159 //SettingsWidget::setActionVisibility() |
363 //SettingsWidget::setActionVisibility() |
167 if (mDeviceCheckBoxList.at(i)->checkState() == Qt::Checked) |
371 if (mDeviceCheckBoxList.at(i)->checkState() == Qt::Checked) |
168 { |
372 { |
169 noItemSelected = false; |
373 noItemSelected = false; |
170 } |
374 } |
171 } |
375 } |
172 for (int i = 0; i < mInternetCheckBoxList.count(); i++) |
376 for (int i = 0; i < mActions.count(); i++) |
173 { |
377 popup->removeAction(mActions.at(i)); |
174 if (mInternetCheckBoxList.at(i)->checkState() == Qt::Checked) |
378 popup->addActions(mActions); |
175 { |
379 if (noItemSelected) |
176 noItemSelected = false; |
380 { |
177 } |
381 popup->removeAction(mActions.at(0)); |
178 } |
|
179 if (!noItemSelected) |
|
180 { |
|
181 popup->primaryAction()->setVisible(true); |
|
182 } |
|
183 else |
|
184 { |
|
185 popup->primaryAction()->setVisible(false); |
|
186 } |
382 } |
187 } |
383 } |
188 //---------------------------------------------------------------------------------------------------------------------------- |
384 //---------------------------------------------------------------------------------------------------------------------------- |
189 //SettingsWidget::itemChecked( int selectedIndex) |
385 //SettingsWidget::itemChecked( int selectedIndex) |
190 // |
386 // |
191 //---------------------------------------------------------------------------------------------------------------------------- |
387 //---------------------------------------------------------------------------------------------------------------------------- |
192 void SettingsWidget::itemChecked(int selectedIndex) |
388 void SettingsWidget::itemChecked(int selectedIndex) |
193 { |
389 { |
194 int totalcount = deviceCategoryList.count() |
390 if (mDeviceCheckBoxList.count() != 0) |
195 + internetCategoryList.count(); |
391 { |
196 |
392 if (selectedIndex == 0 && mchangestate) // validating the select all |
197 if (selectedIndex == 0) // validating the parent category "devices" |
393 { |
198 { |
394 if ((mDeviceCheckBoxList.at(selectedIndex)->checkState() |
199 if ((mDeviceCheckBoxList.at(selectedIndex)->checkState() |
395 == Qt::Checked)) |
200 == Qt::Checked)) |
396 { |
201 { |
397 checkSubCategories(); |
202 isInternetSelected = false; |
398 } |
203 checkSubCategories(0); |
399 else |
204 unCheckSubCategories(0); |
400 { |
|
401 unCheckSubCategories(); |
|
402 } |
205 } |
403 } |
206 else |
404 else |
207 { |
405 { |
208 unCheckSubCategories(1); |
406 if ((mDeviceCheckBoxList.at(selectedIndex)->checkState() |
209 } |
407 == Qt::Unchecked)) |
210 setActionVisibility(); |
408 { |
211 return; |
409 mchangestate = false; |
212 } |
410 mDeviceCheckBoxList.at(0)->setCheckState(Qt::Unchecked); |
213 else if (selectedIndex == deviceCategoryList.count())// validating the parent category "internet" |
411 setActionVisibility(); |
214 { |
412 return; |
215 if (mInternetCheckBoxList.at(selectedIndex |
413 } |
216 - deviceCategoryList.count())->checkState() == Qt::Checked) |
414 } |
217 { |
415 } |
218 isInternetSelected = true; |
416 mchangestate = true; |
219 checkSubCategories(1); |
|
220 unCheckSubCategories(1); |
|
221 } |
|
222 else |
|
223 { |
|
224 unCheckSubCategories(0); |
|
225 } |
|
226 setActionVisibility(); |
|
227 return; |
|
228 } |
|
229 if (selectedIndex < deviceCategoryList.count())// validating the sub categories under "devices" |
|
230 { |
|
231 if (mDeviceCheckBoxList.at(selectedIndex)->checkState() |
|
232 == Qt::Checked) |
|
233 { |
|
234 isInternetSelected = false; |
|
235 unCheckSubCategories(0); |
|
236 |
|
237 } |
|
238 } |
|
239 else // validating the sub categories under "internet" |
|
240 { |
|
241 int curentindex = (selectedIndex + internetCategoryList.count()) |
|
242 - (deviceCategoryList.count() + internetCategoryList.count()); |
|
243 |
|
244 if (mInternetCheckBoxList.at(curentindex)->checkState() |
|
245 == Qt::Checked) |
|
246 { |
|
247 isInternetSelected = true; |
|
248 unCheckSubCategories(1); |
|
249 //return; |
|
250 } |
|
251 } |
|
252 setActionVisibility(); |
417 setActionVisibility(); |
253 } |
418 } |
254 //---------------------------------------------------------------------------------------------------------------------------- |
419 //---------------------------------------------------------------------------------------------------------------------------- |
255 //SettingsWidget::check(int checkSubCategory) |
420 //SettingsWidget::checkSubCategories |
256 // |
421 // |
257 //---------------------------------------------------------------------------------------------------------------------------- |
422 //---------------------------------------------------------------------------------------------------------------------------- |
258 void SettingsWidget::checkSubCategories(int checkSubCategory) |
423 void SettingsWidget::checkSubCategories() |
259 { |
424 { |
260 if (checkSubCategory == 0) |
425 for (int i = 0; i < mDeviceCheckBoxList.count(); i++) |
261 { |
426 { |
262 for (int i = 0; i < mDeviceCheckBoxList.count(); i++) |
427 mDeviceCheckBoxList.at(i)->setCheckState(Qt::Checked); |
263 { |
428 } |
264 mDeviceCheckBoxList.at(i)->setCheckState(Qt::Checked); |
429 } |
265 } |
430 //---------------------------------------------------------------------------------------------------------------------------- |
266 } |
431 //SettingsWidget::unCheckSubCategories |
267 else |
432 // |
268 { |
433 //---------------------------------------------------------------------------------------------------------------------------- |
269 for (int i = 0; i < mInternetCheckBoxList.count(); i++) |
434 void SettingsWidget::unCheckSubCategories() |
270 { |
435 { |
271 mInternetCheckBoxList.at(i)->setCheckState(Qt::Checked); |
436 for (int i = 0; i < mDeviceCheckBoxList.count(); i++) |
272 } |
437 { |
273 } |
438 mDeviceCheckBoxList.at(i)->setCheckState(Qt::Unchecked); |
274 } |
|
275 //---------------------------------------------------------------------------------------------------------------------------- |
|
276 //SettingsWidget::unCheckSubCategories(int unCheckSubCategory) |
|
277 // |
|
278 //---------------------------------------------------------------------------------------------------------------------------- |
|
279 void SettingsWidget::unCheckSubCategories(int unCheckSubCategory) |
|
280 { |
|
281 if (unCheckSubCategory == 0) |
|
282 { |
|
283 for (int i = 0; i < mInternetCheckBoxList.count(); i++) |
|
284 { |
|
285 mInternetCheckBoxList.at(i)->setCheckState(Qt::Unchecked); |
|
286 } |
|
287 } |
|
288 else |
|
289 { |
|
290 for (int i = 0; i < mDeviceCheckBoxList.count(); i++) |
|
291 { |
|
292 mDeviceCheckBoxList.at(i)->setCheckState(Qt::Unchecked); |
|
293 } |
|
294 } |
439 } |
295 } |
440 } |
296 //---------------------------------------------------------------------------------------------------------------------------- |
441 //---------------------------------------------------------------------------------------------------------------------------- |
297 //SettingsWidget::checkBoxCancelEvent() |
442 //SettingsWidget::checkBoxCancelEvent() |
298 // |
443 // |
299 //---------------------------------------------------------------------------------------------------------------------------- |
444 //---------------------------------------------------------------------------------------------------------------------------- |
300 void SettingsWidget::checkBoxCancelEvent() |
445 void SettingsWidget::checkBoxCancelEvent() |
301 { |
446 { |
302 loadSettingsFrominiFile();//bug fix for cancel event selection should not reflect "go" button |
447 // loadDeviceSettings();//bug fix for cancel event selection should not reflect "go" button |
303 emit settingsEvent(false); |
448 emit settingsEvent(false); |
304 } |
449 } |
305 //---------------------------------------------------------------------------------------------------------------------------- |
450 //---------------------------------------------------------------------------------------------------------------------------- |
306 //void SettingsWidget::checkBoxOkEvent() |
451 //void SettingsWidget::checkBoxOkEvent() |
307 // |
452 // |
317 // |
462 // |
318 //---------------------------------------------------------------------------------------------------------------------------- |
463 //---------------------------------------------------------------------------------------------------------------------------- |
319 |
464 |
320 void SettingsWidget::storeSettingsToiniFile() |
465 void SettingsWidget::storeSettingsToiniFile() |
321 { |
466 { |
322 QSettings appSettings("Search.ini", QSettings::IniFormat); |
467 QSettings appSettings("search.ini", QSettings::IniFormat); |
323 |
468 appSettings.setValue("selectedcategory", mSelectedScope); |
324 appSettings.setValue("DeviceCount", mDeviceCheckBoxList.count()); |
469 appSettings.setValue("devicecount", mDeviceCategoryRefList.count()); |
325 for (int i = 0; i < mDeviceCheckBoxList.count(); i++) |
470 if (!isInternetSelected) |
326 { |
471 { |
327 if (mDeviceCheckBoxList.at(i)->checkState() == Qt::Checked) |
472 int j = 0; |
328 { |
473 for (int i = 0; i < mDeviceCategoryRefList.count(); i++) |
329 appSettings.setValue(mDeviceCheckBoxList.at(i)->text(), 1); |
474 { |
330 emit selectedItemCategory(i, true); |
475 if (mDeviceMapping.at(i)) |
331 } |
476 { |
332 else |
477 if (mDeviceCheckBoxList.at(j)->checkState() == Qt::Checked) |
333 { |
478 { |
334 appSettings.setValue(mDeviceCheckBoxList.at(i)->text(), 0); |
479 appSettings.setValue(mDeviceCategoryRefList.at(i), 1); |
335 emit selectedItemCategory(i, false); |
480 emit selectedItemCategory(i, true); |
336 } |
481 } |
337 } |
482 else |
338 // int totalcount = i; |
483 { |
339 appSettings.setValue("InternetCount", mInternetCheckBoxList.count()); |
484 appSettings.setValue(mDeviceCategoryRefList.at(i), 0); |
340 for (int i = 0; i < mInternetCheckBoxList.count(); i++) |
485 emit selectedItemCategory(i, false); |
341 { |
486 } |
342 if (mInternetCheckBoxList.at(i)->checkState() == Qt::Checked) |
487 j++; |
343 { |
488 } |
344 appSettings.setValue(mInternetCheckBoxList.at(i)->text(), 1); |
489 else |
345 // emit selectedcategory(totalcount,true); |
490 { |
346 } |
491 appSettings.setValue(mDeviceCategoryRefList.at(i), 0); |
347 else |
492 emit selectedItemCategory(i, false); |
348 { |
493 } |
349 appSettings.setValue(mInternetCheckBoxList.at(i)->text(), 0); |
494 |
350 //emit selectedcategory(totalcount,false); |
495 } |
351 } |
496 } |
352 // totalcount++; |
497 appSettings.setValue("internetcount", internetCategoryList.count()); |
353 } |
498 appSettings.setValue("selectedprovider", mSelectedProvider); |
354 } |
499 } |
355 |
500 //---------------------------------------------------------------------------------------------------------------------------- |
356 //---------------------------------------------------------------------------------------------------------------------------- |
501 //void SettingsWidget::loadBaseSettings() |
357 //void SettingsWidget::loadSettingsFrominiFile() |
502 // |
358 // |
503 //---------------------------------------------------------------------------------------------------------------------------- |
359 //---------------------------------------------------------------------------------------------------------------------------- |
504 void SettingsWidget::loadBaseSettings() |
360 |
505 { |
361 void SettingsWidget::loadSettingsFrominiFile() |
506 QSettings appSettings("search.ini", QSettings::IniFormat); |
362 { |
507 int value; |
363 enableDefaultSettings(); |
508 if (!(appSettings.contains("selectedcategory"))) |
364 isInternetSelected = false; |
509 { |
365 QSettings appSettings("Search.ini", QSettings::IniFormat); |
510 value = 0; |
366 int ret = 0; |
511 } |
367 for (int i = 0; i < mDeviceCheckBoxList.count(); i++) |
512 else |
368 { |
513 { |
369 ret = appSettings.value(mDeviceCheckBoxList.at(i)->text()).toInt(); |
514 value = appSettings.value("selectedcategory").toInt(); |
370 if (ret) |
515 } |
371 { |
516 mSelectedScope = value; |
372 mDeviceCheckBoxList.at(i)->setCheckState(Qt::Checked); |
517 if (mSelectedScope) |
373 emit selectedItemCategory(i, true); |
518 { |
374 } |
519 isInternetSelected = true; |
375 else |
520 } |
376 { |
521 else |
377 mDeviceCheckBoxList.at(i)->setCheckState(Qt::Unchecked); |
522 { |
378 emit selectedItemCategory(i, false); |
523 isInternetSelected = false; |
379 } |
524 } |
380 } |
525 mSelectedProvider = appSettings.value("selectedprovider").toInt(); |
381 for (int i = 0; i < mInternetCheckBoxList.count(); i++) |
526 } |
382 { |
527 |
383 |
528 //---------------------------------------------------------------------------------------------------------------------------- |
384 ret = appSettings.value(mInternetCheckBoxList.at(i)->text()).toInt(); |
529 //void SettingsWidget::loadDeviceSettings() |
385 if (ret) |
530 // |
386 { |
531 //---------------------------------------------------------------------------------------------------------------------------- |
387 isInternetSelected = true; |
532 void SettingsWidget::loadDeviceSettings() |
388 mInternetCheckBoxList.at(i)->setCheckState(Qt::Checked); |
533 { |
389 // emit selectedcategory(mInternetCheckBoxList.at(i)->text(),true); |
534 QSettings appSettings("search.ini", QSettings::IniFormat); |
390 } |
535 int value; |
391 else |
536 if (!isInternetSelected) |
392 { |
537 { |
393 mInternetCheckBoxList.at(i)->setCheckState(Qt::Unchecked); |
538 int j = 0; |
394 // emit selectedcategory(mInternetCheckBoxList.at(i)->text(),false); |
539 for (int i = 0; i < mDeviceCategoryRefList.count(); i++) |
395 } |
540 { |
396 } |
541 if (!(appSettings.contains(mDeviceCategoryRefList.at(i)))) |
397 |
542 { |
|
543 value = 1; |
|
544 } |
|
545 else |
|
546 { |
|
547 value |
|
548 = appSettings.value(mDeviceCategoryRefList.at(i)).toInt(); |
|
549 } |
|
550 if (mDeviceMapping.count() && mDeviceCheckBoxList.count() |
|
551 && mDeviceMapping.at(i)) |
|
552 { |
|
553 if (value) |
|
554 { |
|
555 mDeviceCheckBoxList.at(j)->setCheckState(Qt::Checked); |
|
556 } |
|
557 else |
|
558 { |
|
559 mDeviceCheckBoxList.at(j)->setCheckState(Qt::Unchecked); |
|
560 } |
|
561 j++; |
|
562 } |
|
563 if (value) // get the setting before ui preparation |
|
564 { |
|
565 emit selectedItemCategory(i, true); |
|
566 } |
|
567 else |
|
568 { |
|
569 emit selectedItemCategory(i, false); |
|
570 } |
|
571 } |
|
572 } |
398 } |
573 } |
399 //---------------------------------------------------------------------------------------------------------------------------- |
574 //---------------------------------------------------------------------------------------------------------------------------- |
400 //SettingsWidget::isInternetSearchOptionSelected() |
575 //SettingsWidget::isInternetSearchOptionSelected() |
401 // |
576 // |
402 //---------------------------------------------------------------------------------------------------------------------------- |
577 //---------------------------------------------------------------------------------------------------------------------------- |
403 bool SettingsWidget::isInternetSearchOptionSelected() |
578 bool SettingsWidget::isInternetSearchOptionSelected() |
404 { |
579 { |
|
580 loadBaseSettings(); |
405 return isInternetSelected; |
581 return isInternetSelected; |
406 } |
582 } |
407 //---------------------------------------------------------------------------------------------------------------------------- |
583 |
408 //void SettingsWidget::changeDeviceInternetCheck() |
584 //---------------------------------------------------------------------------------------------------------------------------- |
409 // |
585 //void SettingsWidget::storeDefaultSettings() |
410 //---------------------------------------------------------------------------------------------------------------------------- |
586 // |
411 void SettingsWidget::changeDeviceInternetCheck() |
587 //---------------------------------------------------------------------------------------------------------------------------- |
412 { |
588 void SettingsWidget::storeDefaultSettings() |
413 if (isInternetSearchOptionSelected() == true) |
589 { |
414 { |
590 QSettings appSettings("search.ini", QSettings::IniFormat); |
415 mDeviceCheckBoxList.at(0)->setCheckState(Qt::Checked); |
591 if (!appSettings.contains("selectedcategory")) // change the settings for the first time only |
416 |
592 { |
417 } |
593 mSelectedScope = 0; |
418 else |
594 mSelectedProvider = 0; |
419 |
595 appSettings.setValue("selectedcategory", mSelectedScope); |
420 { |
596 appSettings.setValue("devicecount", mDeviceCategoryRefList.count()); |
421 |
597 for (int i = 0; i < mDeviceCategoryRefList.count(); i++) |
422 mInternetCheckBoxList.at(0)->setCheckState(Qt::Checked); |
598 appSettings.setValue(mDeviceCategoryRefList.at(i), 1); |
423 |
599 appSettings.setValue("internetcount", internetCategoryList.count()); |
424 } |
600 appSettings.setValue("selectedprovider", mSelectedProvider); |
425 |
601 } |
426 emit settingsChanged(); |
602 } |
427 } |
|
428 //---------------------------------------------------------------------------------------------------------------------------- |
|
429 //void SettingsWidget::enableDefaultSettings() |
|
430 // |
|
431 //---------------------------------------------------------------------------------------------------------------------------- |
|
432 void SettingsWidget::enableDefaultSettings() |
|
433 { |
|
434 QSettings appSettings("Search.ini", QSettings::IniFormat); |
|
435 if (!appSettings.contains("DeviceCount")) // change the settings for the first time only |
|
436 { |
|
437 appSettings.setValue("DeviceCount", mDeviceCheckBoxList.count()); |
|
438 for (int i = 0; i < mDeviceCheckBoxList.count(); i++) |
|
439 { |
|
440 // mDeviceCheckBoxList.at(i)->setCheckState(Qt::Checked); |
|
441 appSettings.setValue(mDeviceCheckBoxList.at(i)->text(), 1); |
|
442 } |
|
443 for (int i = 0; i < mInternetCheckBoxList.count(); i++) |
|
444 { |
|
445 //mInternetCheckBoxList.at(i)->setCheckState(Qt::Unchecked); |
|
446 appSettings.setValue(mInternetCheckBoxList.at(i)->text(), 0); |
|
447 } |
|
448 // storeSettingsToiniFile(); |
|
449 } |
|
450 |
|
451 } |
|