searchui/stateproviders/searchstateprovider/src/searchuiloader.cpp
changeset 26 367228f82b66
parent 21 708468d5143e
equal deleted inserted replaced
24:1abfa342db42 26:367228f82b66
    27 #include <hbaction.h>
    27 #include <hbaction.h>
    28 #include <hbinstance.h>
    28 #include <hbinstance.h>
    29 #include <tstasksettings.h>
    29 #include <tstasksettings.h>
    30 #include <hbshrinkingvkbhost.h>
    30 #include <hbshrinkingvkbhost.h>
    31 #include <qinputcontext.h>
    31 #include <qinputcontext.h>
       
    32 #include <cpixcontentinfodbread.h>
       
    33 #include <cpixcontentinfodbdef.h>
    32 
    34 
    33 const char *SEARCHSTATEPROVIDER_DOCML = ":/xml/searchstateprovider.docml";
    35 const char *SEARCHSTATEPROVIDER_DOCML = ":/xml/searchstateprovider.docml";
    34 const char *TOC_VIEW = "tocView";
    36 const char *TOC_VIEW = "tocView";
    35 const char *TUT_SEARCHPANEL_WIDGET = "searchPanel";
    37 const char *TUT_SEARCHPANEL_WIDGET = "searchPanel";
    36 const char *TUT_LIST_VIEW = "listView";
    38 const char *TUT_LIST_VIEW = "listView";
    41 // ---------------------------------------------------------------------------
    43 // ---------------------------------------------------------------------------
    42 // SearchUiLoader::SearchUiLoader
    44 // SearchUiLoader::SearchUiLoader
    43 // ---------------------------------------------------------------------------
    45 // ---------------------------------------------------------------------------
    44 SearchUiLoader::SearchUiLoader() :
    46 SearchUiLoader::SearchUiLoader() :
    45     mDocumentLoader(NULL), mView(NULL), mListWidget(NULL),
    47     mDocumentLoader(NULL), mView(NULL), mListWidget(NULL),
    46             mSearchPanel(NULL), mClient(NULL), mMainWindow(NULL)
    48             mSearchPanel(NULL), mClient(NULL), mMainWindow(NULL), mDb(NULL)
    47     {
    49     {
    48     bool ok = false;
    50     bool ok = false;
    49 
    51 
    50     mDocumentLoader = new HbDocumentLoader();
    52     mDocumentLoader = new HbDocumentLoader();
    51 
    53 
   108 
   110 
   109     mVirtualKeyboard = new HbShrinkingVkbHost(mView);
   111     mVirtualKeyboard = new HbShrinkingVkbHost(mView);
   110 
   112 
   111     mBringtoForground = true;
   113     mBringtoForground = true;
   112 
   114 
       
   115     readDB();
   113     }
   116     }
   114 // ---------------------------------------------------------------------------
   117 // ---------------------------------------------------------------------------
   115 // SearchUiLoader::~SearchUiLoader
   118 // SearchUiLoader::~SearchUiLoader
   116 // ---------------------------------------------------------------------------
   119 // ---------------------------------------------------------------------------
   117 SearchUiLoader::~SearchUiLoader()
   120 SearchUiLoader::~SearchUiLoader()
   118     {
   121     {
   119     delete mMainWindow;
       
   120     delete mDocumentLoader;
   122     delete mDocumentLoader;
       
   123     qDeleteAll(mContentInfoList.begin(), mContentInfoList.end());
       
   124     mContentInfoList.clear();
       
   125     delete mDb;
       
   126     delete mMainWindow;    
   121     delete mClient;
   127     delete mClient;
   122     }
   128     }
   123 // ---------------------------------------------------------------------------
   129 // ---------------------------------------------------------------------------
   124 // SearchUiLoader::slotsendtobackground
   130 // SearchUiLoader::slotsendtobackground
   125 // ---------------------------------------------------------------------------
   131 // ---------------------------------------------------------------------------
   152             ic->filterEvent(event);
   158             ic->filterEvent(event);
   153             delete event;
   159             delete event;
   154             }
   160             }
   155         }
   161         }
   156     }
   162     }
   157 
   163 void SearchUiLoader::readDB()
       
   164     {
       
   165     if (!mDb)
       
   166         {
       
   167         mDb = new ContentInfoDbRead();
       
   168         
       
   169         connect(mDb,SIGNAL(dataChanged()),this,SLOT(slotdataChanged));
       
   170         }
       
   171     
       
   172     qDeleteAll(mContentInfoList.begin(), mContentInfoList.end());
       
   173     
       
   174     mContentInfoList.clear();
       
   175     
       
   176     QStringList primarykeys = mDb->getPrimaryKeys();
       
   177     
       
   178     if(primarykeys.count())
       
   179         {
       
   180         SearchContentInfoDbData* ptr = new SearchContentInfoDbData();
       
   181         
       
   182         ptr->setBaseApp("root");                
       
   183 
       
   184         ptr->setDisplayIcon(QString());
       
   185 
       
   186         ptr->setDisplayName("txt_search_list_select_all");
       
   187 
       
   188         ptr->setExceptionString(QString());
       
   189 
       
   190         ptr->setDisplayOrder(0);
       
   191 
       
   192         ptr->setTranslationPath(QString());
       
   193 
       
   194         ptr->setActivityUri(QString());
       
   195 
       
   196         mContentInfoList.append(ptr);
       
   197         }
       
   198     for (int i = 0; i < primarykeys.count(); i++)
       
   199         {
       
   200         if (!(mDb->getValues(primarykeys.at(i), BLACKLISTSTATUS).toInt()))
       
   201             {
       
   202             SearchContentInfoDbData* ptr = new SearchContentInfoDbData();
       
   203 
       
   204             ptr->setCategoryName(primarykeys.at(i));
       
   205 
       
   206             ptr->setBaseApp(mDb->getValues(primarykeys.at(i), BASEAPP));
       
   207 
       
   208             ptr->setDisplayIcon(
       
   209                     mDb->getValues(primarykeys.at(i), DISPLAYICON));
       
   210 
       
   211             ptr->setDisplayName(
       
   212                     mDb->getValues(primarykeys.at(i), DISPLAYNAME));
       
   213 
       
   214             ptr->setExceptionString(mDb->getValues(primarykeys.at(i),
       
   215                     EXPECTIONID));
       
   216 
       
   217             ptr->setDisplayOrder(mDb->getValues(primarykeys.at(i),
       
   218                     DISPLAYORDER).toInt());
       
   219 
       
   220             ptr->setTranslationPath(mDb->getValues(primarykeys.at(i),
       
   221                     TRANSLATION));
       
   222 
       
   223             ptr->setActivityUri(mDb->getValues(primarykeys.at(i), ACTIONURI));
       
   224 
       
   225             mContentInfoList.append(ptr);
       
   226             }
       
   227         }
       
   228     emit dbChanged();
       
   229     }
       
   230 void SearchUiLoader::slotdataChanged()
       
   231     {
       
   232     //refresh the data base info
       
   233     readDB();
       
   234     }
   158 // ---------------------------------------------------------------------------
   235 // ---------------------------------------------------------------------------
   159 // SearchMainWindow::slotViewReady
   236 // SearchMainWindow::slotViewReady
   160 // ---------------------------------------------------------------------------
   237 // ---------------------------------------------------------------------------
   161 void SearchMainWindow::slotViewReady()
   238 void SearchMainWindow::slotViewReady()
   162     {
   239     {