searchui/stateproviders/searchstateprovider/src/settingswidget.cpp
changeset 26 367228f82b66
parent 21 708468d5143e
child 27 7a8855317cbd
equal deleted inserted replaced
24:1abfa342db42 26:367228f82b66
    14  * Description:  Implementation of the settings widget
    14  * Description:  Implementation of the settings widget
    15  *
    15  *
    16  */
    16  */
    17 #include "settingswidget.h"
    17 #include "settingswidget.h"
    18 #include "onlinehandler.h"
    18 #include "onlinehandler.h"
       
    19 #include "searchuiloader.h"
    19 #include <hbdialog.h>
    20 #include <hbdialog.h>
    20 #include <hbcheckbox.h>
    21 #include <hbcheckbox.h>
    21 #include <qgraphicslinearlayout.h>
    22 #include <qgraphicslinearlayout.h>
    22 #include <hbaction.h>
    23 #include <hbaction.h>
    23 #include <hblabel.h>
    24 #include <hblabel.h>
    24 #include <qsignalmapper.h>
    25 #include <qsignalmapper.h>
    25 #include <hbtooltip.h>
       
    26 #include <qsettings.h>
    26 #include <qsettings.h>
    27 #include <hbinputdialog.h>
    27 #include <hbinputdialog.h>
    28 #include <hbscrollarea.h>
    28 #include <hbscrollarea.h>
    29 #include <qgraphicswidget.h>
    29 #include <qgraphicswidget.h>
    30 #include <hbglobal.h>
    30 #include <hbglobal.h>
    33 #include <hbdocumentloader.h>
    33 #include <hbdocumentloader.h>
    34 #include <hbcombobox.h>
    34 #include <hbcombobox.h>
    35 #include <hbdataformviewitem.h>
    35 #include <hbdataformviewitem.h>
    36 #include <hbradiobuttonlist.h>
    36 #include <hbradiobuttonlist.h>
    37 #include <qdir.h>
    37 #include <qdir.h>
    38 #include <qsql.h>
       
    39 #include <qsqldatabase.h>
       
    40 #include <qsqlquery.h>
       
    41 #include <cpixcontentinfocommon.h>
       
    42 
    38 
    43 const char *DELIMETER_DOCML = ":/xml/delimeterscreen.docml";
    39 const char *DELIMETER_DOCML = ":/xml/delimeterscreen.docml";
    44 const char *DIALOG = "dialog";
    40 const char *DIALOG = "dialog";
    45 const char *DATAFORM = "dataForm";
    41 const char *DATAFORM = "dataForm";
    46 
    42 
    49 //
    45 //
    50 //----------------------------------------------------------------------------------------------------------------------------
    46 //----------------------------------------------------------------------------------------------------------------------------
    51 SettingsWidget::SettingsWidget() :
    47 SettingsWidget::SettingsWidget() :
    52     signalMapper(NULL), popup(NULL), mDocumentLoader(NULL), dataform(NULL),
    48     signalMapper(NULL), popup(NULL), mDocumentLoader(NULL), dataform(NULL),
    53             mModel(NULL), mSelectedScope(0), mSelectedProvider(0), comboBox(
    49             mModel(NULL), mSelectedScope(0), mSelectedProvider(0), comboBox(
    54                     NULL), mInternetHandler(NULL)
    50                     NULL), mInternetHandler(NULL),mUiLoader(NULL)
    55     {
    51     {
    56     for (int i = 0; i < 8; i++)
    52     mUiLoader = SearchUiLoader::instance();
    57         {
    53   
    58         mDeviceMapping.append(false);
    54     connect(mUiLoader, SIGNAL(dbChanged), this, SLOT(slotdbChanged()));
    59         }
       
    60     mDeviceCategoryRefList = (QStringList() << "first" << "second" << "third"
       
    61             << "fourth" << "fifth" << "sixth" << "seventh" << "eigth");
       
    62 
    55 
    63     mchangestate = true;
    56     mchangestate = true;
    64     mInstialize = true;
    57     mInstialize = true;
    65     isInternetSelected = false;
    58     isInternetSelected = false;
    66     storeDefaultSettings();
       
    67     }
    59     }
    68 //----------------------------------------------------------------------------------------------------------------------------
    60 //----------------------------------------------------------------------------------------------------------------------------
    69 //SettingsWidget::intialize()
    61 //SettingsWidget::intialize()
    70 //
    62 //
    71 //----------------------------------------------------------------------------------------------------------------------------
    63 //----------------------------------------------------------------------------------------------------------------------------
   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()
   366     {
   282     {
   367     if (mInstialize)
   283     if (mInstialize)
   368         {
   284         {
   369         initialize();
   285         initialize();
   370         mInstialize = false;
   286         mInstialize = false;
   371         }
       
   372     if (mDeviceListDisplay.count() != 7)
       
   373         {
       
   374         preparecategories();
       
   375         q_currentIndexChanged(mSelectedScope);
       
   376         QDir dir;
       
   377         dir.remove(SETTINGS_INI_PATH);
       
   378         storeDefaultSettings();
       
   379         }
   287         }
   380     // refresh the screen to top     
   288     // refresh the screen to top     
   381     QModelIndex index = mModel->index(0, 0);
   289     QModelIndex index = mModel->index(0, 0);
   382     dataform->scrollTo(index);
   290     dataform->scrollTo(index);
   383     comboBox->setCurrentIndex(mSelectedScope);
   291     comboBox->setCurrentIndex(mSelectedScope);
   400             break;
   308             break;
   401             }
   309             }
   402         }
   310         }
   403     if (!isInternetSelected)
   311     if (!isInternetSelected)
   404         {
   312         {
   405         mActions.at(0)->setVisible(true);
   313         primaryAction->setVisible(true);
   406         if (noItemSelected)
   314         if (noItemSelected)
   407             {
   315             {
   408             mActions.at(0)->setVisible(false);
   316             primaryAction->setVisible(false);
   409             }
   317             }
   410         }
   318         }
   411     else
   319     else
   412         {
   320         {
   413         mActions.at(0)->setVisible(true);
   321         primaryAction->setVisible(true);
   414         }
   322         }
   415     }
   323     }
   416 //----------------------------------------------------------------------------------------------------------------------------
   324 //----------------------------------------------------------------------------------------------------------------------------
   417 //SettingsWidget::itemChecked( int selectedIndex)
   325 //SettingsWidget::slotstateChanged( int selectedIndex)
   418 //
   326 //
   419 //----------------------------------------------------------------------------------------------------------------------------
   327 //----------------------------------------------------------------------------------------------------------------------------
   420 void SettingsWidget::itemChecked(int selectedIndex)
   328 void SettingsWidget::slotstateChanged(int selectedIndex)
   421     {
   329     {
   422     if (mDeviceCheckBoxList.count() != 0)
   330     if (mDeviceCheckBoxList.count() != 0)
   423         {
   331         {
   424         if (selectedIndex == 0 && mchangestate) // validating the select all
   332         if (selectedIndex == 0 && mchangestate) // validating the select all
   425             {
   333             {
   426             if ((mDeviceCheckBoxList.at(selectedIndex)->checkState()
   334             if ((mDeviceCheckBoxList.at(selectedIndex)->checkState() == Qt::Checked))
   427                     == Qt::Checked))
       
   428                 {
   335                 {
   429                 checkSubCategories();
   336                 checkSubCategories();
   430                 }
   337                 }
   431             else
   338             else
   432                 {
   339                 {
   433                 unCheckSubCategories();
   340                 unCheckSubCategories();
   434                 }
   341                 }
   435             }
   342             }
   436         else
   343         else
   437             {
   344             {
   438             if ((mDeviceCheckBoxList.at(selectedIndex)->checkState()
   345             if ((mDeviceCheckBoxList.at(selectedIndex)->checkState() == Qt::Unchecked))
   439                     == Qt::Unchecked))
       
   440                 {
   346                 {
   441                 mchangestate = false;
   347                 mchangestate = false;
   442                 mDeviceCheckBoxList.at(0)->setCheckState(Qt::Unchecked);
   348                 mDeviceCheckBoxList.at(0)->setCheckState(Qt::Unchecked);
   443                 setActionVisibility();
   349                 setActionVisibility();
   444                 return;
   350                 return;
   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 //----------------------------------------------------------------------------------------------------------------------------
   533 //----------------------------------------------------------------------------------------------------------------------------
   426 //----------------------------------------------------------------------------------------------------------------------------
   534 void SettingsWidget::loadBaseSettings()
   427 void SettingsWidget::loadBaseSettings()
   535     {
   428     {
   536     QSettings appSettings(SETTINGS_INI_PATH, QSettings::IniFormat);
   429     QSettings appSettings(SETTINGS_INI_PATH, QSettings::IniFormat);
   537     mSelectedScope = appSettings.value("selectedcategory", 0).toInt();
   430     mSelectedScope = appSettings.value("selectedcategory", 0).toInt();
   538     mSelectedScope ? (isInternetSelected = true) : (isInternetSelected
   431     mSelectedScope ? (isInternetSelected = true) : (isInternetSelected = false);
   539             = false);
       
   540     }
   432     }
   541 
   433 
   542 //----------------------------------------------------------------------------------------------------------------------------
   434 //----------------------------------------------------------------------------------------------------------------------------
   543 //void SettingsWidget::loadDeviceSettings()
   435 //void SettingsWidget::loadDeviceSettings()
   544 //
   436 //
   546 void SettingsWidget::loadDeviceSettings()
   438 void SettingsWidget::loadDeviceSettings()
   547     {
   439     {
   548     QSettings appSettings(SETTINGS_INI_PATH, QSettings::IniFormat);
   440     QSettings appSettings(SETTINGS_INI_PATH, QSettings::IniFormat);
   549     int value;
   441     int value;
   550     if (!isInternetSelected)
   442     if (!isInternetSelected)
   551         {
   443         {        
   552         int j = 0;
   444         for (int i = 0; i < mDeviceStoragelist.count(); i++)
   553         for (int i = 0; i < mDeviceCategoryRefList.count(); i++)
   445             {
   554             {
   446             value = appSettings.value(mDeviceStoragelist.at(i), 1).toInt();
   555             value
   447             if (value && mDeviceCheckBoxList.at(i))
   556                     = appSettings.value(mDeviceCategoryRefList.at(i), 1).toInt();
   448                 {
   557             if (mDeviceMapping.count() && mDeviceCheckBoxList.count()
   449                 mDeviceCheckBoxList.at(i)->setCheckState(Qt::Checked);
   558                     && mDeviceMapping.at(i))
   450                 }
   559                 {
   451             else
   560                 if (value)
   452                 {
       
   453                 mDeviceCheckBoxList.at(i)->setCheckState(Qt::Unchecked);
       
   454                 }
       
   455             }
       
   456         QStringList allKeys = appSettings.allKeys();
       
   457         for (int k = 0; k < allKeys.count(); k++)
       
   458             {
       
   459             value = appSettings.value(allKeys.at(k), 1).toInt();
       
   460             for (int j = 0; j < mUiLoader->ContentInfoList().count(); j++)
       
   461                 {
       
   462                 if (mUiLoader->ContentInfoList().at(j)->getDisplayName() == allKeys.at(k))
   561                     {
   463                     {
   562                     mDeviceCheckBoxList.at(j)->setCheckState(Qt::Checked);
   464                     value ? (mUiLoader->ContentInfoList().at(j)->setSelected(true)) : (mUiLoader->ContentInfoList().at(j)->setSelected(false));                
   563                     }
   465                     }
   564                 else
   466                 }
   565                     {
       
   566                     mDeviceCheckBoxList.at(j)->setCheckState(Qt::Unchecked);
       
   567                     }
       
   568                 j++;
       
   569                 }
       
   570             value
       
   571                   ? (emit selectedItemCategory(i, true))
       
   572                      : (emit selectedItemCategory(i, false));
       
   573             }
   467             }
   574         }
   468         }
   575     }
   469     }
   576 //----------------------------------------------------------------------------------------------------------------------------
   470 //----------------------------------------------------------------------------------------------------------------------------
   577 //SettingsWidget::isInternetSearchOptionSelected()
   471 //SettingsWidget::isInternetSearchOptionSelected()
   587 //
   481 //
   588 //----------------------------------------------------------------------------------------------------------------------------
   482 //----------------------------------------------------------------------------------------------------------------------------
   589 void SettingsWidget::storeDefaultSettings()
   483 void SettingsWidget::storeDefaultSettings()
   590     {
   484     {
   591     QSettings appSettings(SETTINGS_INI_PATH, QSettings::IniFormat);
   485     QSettings appSettings(SETTINGS_INI_PATH, QSettings::IniFormat);
   592     if (!appSettings.contains("selectedcategory")) // change the settings for the first time only
   486     if (!appSettings.contains("selectedcategory"))
   593         {
   487         {
   594         mSelectedScope = 0;
   488         mSelectedScope = 0;
   595         appSettings.setValue("selectedcategory", mSelectedScope);
   489         appSettings.setValue("selectedcategory", mSelectedScope);
   596         appSettings.setValue("devicecount", mDeviceCategoryRefList.count());
   490         }
   597         for (int i = 0; i < mDeviceCategoryRefList.count(); i++)
   491     for (int i = 0; i < mDeviceStoragelist.count(); i++)
   598             appSettings.setValue(mDeviceCategoryRefList.at(i), 1);
   492         {
       
   493         if (!appSettings.contains(mDeviceStoragelist.at(i)))
       
   494             appSettings.setValue(mDeviceStoragelist.at(i), 1);
   599         }
   495         }
   600     }
   496     }
   601 //----------------------------------------------------------------------------------------------------------------------------
   497 //----------------------------------------------------------------------------------------------------------------------------
   602 //void SettingsWidget::slotproviderDetails()
   498 //void SettingsWidget::slotproviderDetails()
   603 //
   499 //
   641 void SettingsWidget::loadIS()
   537 void SettingsWidget::loadIS()
   642     {
   538     {
   643     if (!mInternetHandler)
   539     if (!mInternetHandler)
   644         {
   540         {
   645         mInternetHandler = new OnlineHandler();
   541         mInternetHandler = new OnlineHandler();
   646         connect(mInternetHandler,
   542         
   647                 SIGNAL(providerDetails(QString, HbIcon, int)), this,
   543         connect(mInternetHandler,SIGNAL(providerDetails(QString, HbIcon, int)), this,SLOT(slotproviderDetails(QString, HbIcon, int)));
   648                 SLOT(slotproviderDetails(QString, HbIcon, int)));
   544 
   649 
   545         connect(mInternetHandler, SIGNAL(defaultProvider(const int)), this,SLOT(slotdefaultProvider(const int)));
   650         connect(mInternetHandler, SIGNAL(defaultProvider(const int)), this,
   546         
   651                 SLOT(slotdefaultProvider(const int)));
       
   652         mInternetHandler->readSettings();
   547         mInternetHandler->readSettings();
   653         }
   548         }
   654     }
   549     }
       
   550 //----------------------------------------------------------------------------------------------------------------------------
       
   551 //void SettingsWidget::slotdbChanged()
       
   552 //
       
   553 //----------------------------------------------------------------------------------------------------------------------------
       
   554 void SettingsWidget::slotdbChanged()
       
   555     {
       
   556     preparecategories();
       
   557     
       
   558     slotcurrentIndexChanged(mSelectedScope);
       
   559     }