changeset 2 | 208a4ba3894c |
parent 0 | ccd0fd43f247 |
child 3 | 6832643895f7 |
0:ccd0fd43f247 | 2:208a4ba3894c |
---|---|
15 * |
15 * |
16 */ |
16 */ |
17 |
17 |
18 #include "searchprogressivestate.h" |
18 #include "searchprogressivestate.h" |
19 #include "indevicehandler.h" |
19 #include "indevicehandler.h" |
20 #include "qcpixdocument.h" |
20 #include <qcpixdocument.h> |
21 #include "qcpixdocumentfield.h" |
21 #include <qcpixdocumentfield.h> |
22 #include <hbmainwindow.h> |
22 #include <hbmainwindow.h> |
23 #include <hbview.h> |
23 #include <hbview.h> |
24 #include <hblabel.h> |
24 #include <hblabel.h> |
25 #include <hbicon.h> |
25 #include <hbicon.h> |
26 #include <hbmenu.h> |
26 #include <hbmenu.h> |
28 #include <hblistview.h> |
28 #include <hblistview.h> |
29 #include <hbdocumentloader.h> |
29 #include <hbdocumentloader.h> |
30 #include <hbsearchpanel.h> |
30 #include <hbsearchpanel.h> |
31 #include <hbaction.h> |
31 #include <hbaction.h> |
32 #include <qstandarditemmodel.h> |
32 #include <qstandarditemmodel.h> |
33 #include <xqservicerequest.h> |
|
34 #include <hbframebackground.h> |
33 #include <hbframebackground.h> |
35 #include <hbabstractviewitem.h> |
34 #include <hbabstractviewitem.h> |
36 #include <hbframebackground.h> |
35 #include <hbframebackground.h> |
37 #include <hblistviewitem.h> |
36 #include <hblistviewitem.h> |
38 #include <hbapplication.h> |
37 #include <hbapplication.h> |
49 const char *SEARCHSTATEPROVIDER_DOCML = ":/xml/searchstateprovider.docml"; |
48 const char *SEARCHSTATEPROVIDER_DOCML = ":/xml/searchstateprovider.docml"; |
50 const char *TOC_VIEW = "tocView"; |
49 const char *TOC_VIEW = "tocView"; |
51 const char *TUT_SEARCHPANEL_WIDGET = "searchPanel"; |
50 const char *TUT_SEARCHPANEL_WIDGET = "searchPanel"; |
52 const char *TUT_LIST_VIEW = "listView"; |
51 const char *TUT_LIST_VIEW = "listView"; |
53 const QSize defaultIconSize(30, 30); |
52 const QSize defaultIconSize(30, 30); |
54 |
53 const int totalcategories = 10; |
55 // --------------------------------------------------------------------------- |
54 // --------------------------------------------------------------------------- |
56 // SearchProgressiveState::SearchProgressiveState |
55 // SearchProgressiveState::SearchProgressiveState |
57 // --------------------------------------------------------------------------- |
56 // --------------------------------------------------------------------------- |
58 // |
57 // |
59 SearchProgressiveState::SearchProgressiveState(QState *parent) : |
58 SearchProgressiveState::SearchProgressiveState(QState *parent) : |
60 QState(parent), mMainWindow(NULL), mView(NULL), mListView(NULL), |
59 QState(parent), mMainWindow(NULL), mView(NULL), mListView(NULL), |
61 mDocumentLoader(NULL), mModel(NULL), mSearchHandler(NULL) |
60 mDocumentLoader(NULL), mModel(NULL), mSearchHandler(NULL), |
61 mAiwMgr(0), mRequest(0) |
|
62 { |
62 { |
63 |
63 |
64 mMainWindow = hbInstance->allMainWindows().at(0); |
64 mMainWindow = hbInstance->allMainWindows().at(0); |
65 mModel = new QStandardItemModel(this); |
65 mModel = new QStandardItemModel(this); |
66 |
66 |
67 proxyModel = new QSortFilterProxyModel(this); |
67 |
68 proxyModel->setSourceModel(mModel); |
68 mAiwMgr = new XQApplicationManager; |
69 |
69 |
70 mDocumentLoader = new HbDocumentLoader(); |
70 mDocumentLoader = new HbDocumentLoader(); |
71 bool ok = false; |
71 bool ok = false; |
72 mDocumentLoader->load(SEARCHSTATEPROVIDER_DOCML, &ok); |
72 mDocumentLoader->load(SEARCHSTATEPROVIDER_DOCML, &ok); |
73 |
73 |
98 { |
98 { |
99 prototypeListView->setTextFormat(Qt::RichText); |
99 prototypeListView->setTextFormat(Qt::RichText); |
100 |
100 |
101 } |
101 } |
102 mListView->setModel(mModel, prototype); |
102 mListView->setModel(mModel, prototype); |
103 } |
103 |
104 //bool bl = mListView->itemRecycling(); |
104 HbAbstractItemView::ItemAnimations noCreationAndRemovalAnimations = |
105 // mListView->setItemRecycling(false); |
105 HbAbstractItemView::All; |
106 //mListView->setModel(proxyModel); |
106 noCreationAndRemovalAnimations ^= HbAbstractItemView::Appear; |
107 noCreationAndRemovalAnimations ^= HbAbstractItemView::Disappear; |
|
108 |
|
109 mListView->setEnabledAnimations(noCreationAndRemovalAnimations); |
|
110 } |
|
111 |
|
107 |
112 |
108 mSearchPanel = qobject_cast<HbSearchPanel *> ( |
113 mSearchPanel = qobject_cast<HbSearchPanel *> ( |
109 mDocumentLoader->findWidget(TUT_SEARCHPANEL_WIDGET)); |
114 mDocumentLoader->findWidget(TUT_SEARCHPANEL_WIDGET)); |
110 if (mSearchPanel) |
115 if (mSearchPanel) |
111 { |
116 { |
112 mSearchPanel->setSearchOptionsEnabled(true); |
117 mSearchPanel->setSearchOptionsEnabled(true); |
113 } |
118 } |
114 |
119 |
115 mSearchHandler = new InDeviceHandler(); |
120 constructHandlers(); |
116 if (mView) |
121 |
122 if (mView && mMainWindow) |
|
117 { |
123 { |
118 mMainWindow->addView(mView); |
124 mMainWindow->addView(mView); |
119 mMainWindow->setCurrentView(mView); |
125 mMainWindow->setCurrentView(mView); |
120 } |
126 } |
121 mDatabasecount = 0; |
127 mDatabasecount = 0; |
141 for (int i = 0; i < appUid.Count(); i++) |
147 for (int i = 0; i < appUid.Count(); i++) |
142 { |
148 { |
143 mIconArray.append(getAppIconFromAppId(appUid[i])); |
149 mIconArray.append(getAppIconFromAppId(appUid[i])); |
144 } |
150 } |
145 |
151 |
152 #ifdef OST_TRACE_COMPILER_IN_USE |
|
153 //start() the timers to avoid worrying abt having to start()/restart() later |
|
154 m_categorySearchApiTime.start(); |
|
155 m_categorySearchUiTime.start(); |
|
156 m_totalSearchUiTime.start(); |
|
157 m_categoryGetDocumentApiTime.start(); |
|
158 m_getDocumentCatergoryTimeAccumulator = 0; |
|
159 #endif |
|
146 } |
160 } |
147 // --------------------------------------------------------------------------- |
161 // --------------------------------------------------------------------------- |
148 // SearchProgressiveState::~SearchProgressiveState |
162 // SearchProgressiveState::~SearchProgressiveState |
149 // --------------------------------------------------------------------------- |
163 // --------------------------------------------------------------------------- |
150 // |
164 // |
151 SearchProgressiveState::~SearchProgressiveState() |
165 SearchProgressiveState::~SearchProgressiveState() |
152 { |
166 { |
153 if (proxyModel) |
167 if (mAiwMgr) |
154 { |
168 { |
155 delete proxyModel; |
169 delete mAiwMgr; |
156 } |
170 } |
157 |
171 |
158 if (mModel) |
172 if (mModel) |
159 { |
173 { |
160 delete mModel; |
174 delete mModel; |
161 } |
175 } |
162 if (mDocumentLoader) |
176 if (mDocumentLoader) |
163 { |
177 { |
164 delete mDocumentLoader; |
178 delete mDocumentLoader; |
165 } |
179 } |
166 if (mSearchHandler) |
180 |
167 { |
181 for (int i = 0; i < mSearchHandlerList.count(); i++) |
168 delete mSearchHandler; |
182 { |
169 } |
183 delete mSearchHandlerList.at(i); |
170 |
184 } |
185 |
|
186 } |
|
187 |
|
188 // --------------------------------------------------------------------------- |
|
189 // SearchProgressiveState::constructHandlers |
|
190 // --------------------------------------------------------------------------- |
|
191 // |
|
192 void SearchProgressiveState::constructHandlers() |
|
193 { |
|
194 InDeviceHandler* handler = NULL; |
|
195 for (int i = 0; i < totalcategories; i++) |
|
196 { |
|
197 handler = new InDeviceHandler(); |
|
198 switch (i) |
|
199 { |
|
200 case 0: |
|
201 { |
|
202 handler->setCategory(""); |
|
203 break; |
|
204 } |
|
205 case 1: |
|
206 { |
|
207 handler->setCategory("contact"); |
|
208 break; |
|
209 } |
|
210 case 2: |
|
211 { |
|
212 handler->setCategory("media"); |
|
213 break; |
|
214 } |
|
215 case 3: |
|
216 { |
|
217 handler->setCategory("msg"); |
|
218 break; |
|
219 } |
|
220 case 4: |
|
221 { |
|
222 handler->setCategory("email"); |
|
223 break; |
|
224 } |
|
225 case 5: |
|
226 { |
|
227 handler->setCategory("calendar"); |
|
228 break; |
|
229 } |
|
230 case 6: |
|
231 { |
|
232 handler->setCategory("notes"); |
|
233 break; |
|
234 } |
|
235 case 7: |
|
236 { |
|
237 handler->setCategory("applications"); |
|
238 break; |
|
239 } |
|
240 case 8: |
|
241 { |
|
242 handler->setCategory("file"); |
|
243 break; |
|
244 } |
|
245 case 9: |
|
246 { |
|
247 handler->setCategory("bookmark"); |
|
248 break; |
|
249 } |
|
250 } |
|
251 mSearchHandlerList.append(handler); |
|
252 } |
|
171 } |
253 } |
172 |
254 |
173 // --------------------------------------------------------------------------- |
255 // --------------------------------------------------------------------------- |
174 // SearchProgressiveState::onEntry |
256 // SearchProgressiveState::onEntry |
175 // --------------------------------------------------------------------------- |
257 // --------------------------------------------------------------------------- |
180 QState::onEntry(event); |
262 QState::onEntry(event); |
181 |
263 |
182 activateSignals(); |
264 activateSignals(); |
183 |
265 |
184 // If this is not the current view, we're getting back from plugin view |
266 // If this is not the current view, we're getting back from plugin view |
185 |
267 if (mMainWindow) |
186 if (mMainWindow->currentView() != mView) |
268 { |
187 { |
269 if (mMainWindow->currentView() != mView) |
188 mMainWindow->setCurrentView(mView, true); |
270 { |
189 } |
271 mMainWindow->setCurrentView(mView, true); |
190 mMainWindow->show(); |
272 } |
191 |
273 mMainWindow->show(); |
274 } |
|
192 if (loadSettings) |
275 if (loadSettings) |
193 { |
276 { |
194 emit settingsState(); |
277 emit settingsState(); |
195 loadSettings = false; |
278 loadSettings = false; |
196 } |
279 } |
197 |
280 setSelectedCategories(); |
198 } |
281 } |
199 // --------------------------------------------------------------------------- |
282 // --------------------------------------------------------------------------- |
200 // SearchProgressiveState::onExit |
283 // SearchProgressiveState::onExit |
201 // --------------------------------------------------------------------------- |
284 // --------------------------------------------------------------------------- |
202 // |
285 // |
210 // SearchProgressiveState::activateSignals |
293 // SearchProgressiveState::activateSignals |
211 // --------------------------------------------------------------------------- |
294 // --------------------------------------------------------------------------- |
212 // |
295 // |
213 void SearchProgressiveState::activateSignals() |
296 void SearchProgressiveState::activateSignals() |
214 { |
297 { |
215 if (mSearchHandler) |
298 for (int i = 0; i < mSearchHandlerList.count(); i++) |
216 { |
299 { |
217 connect(mSearchHandler, SIGNAL(handleSearchResult(int,int)), this, |
300 connect(mSearchHandlerList.at(i), |
218 SLOT(onSearchComplete(int,int))); |
301 SIGNAL(handleAsyncSearchResult(int,int)), this, |
219 connect(mSearchHandler, SIGNAL(handleAsyncSearchResult(int,int)), |
302 SLOT(onAsyncSearchComplete(int,int))); |
220 this, SLOT(onAsyncSearchComplete(int,int))); |
303 connect(mSearchHandlerList.at(i), |
221 connect(mSearchHandler, SIGNAL(handleDocument(int,QCPixDocument*)), |
304 SIGNAL(handleDocument(int,QCPixDocument*)), this, |
222 this, SLOT(onGetDocumentComplete(int,QCPixDocument*))); |
305 SLOT(onGetDocumentComplete(int,QCPixDocument*))); |
223 } |
306 } |
224 if (mListView) |
307 if (mListView) |
225 { |
308 { |
226 connect(mListView, SIGNAL(activated(const QModelIndex)), this, |
309 connect(mListView, SIGNAL(activated(const QModelIndex)), this, |
227 SLOT(openResultitem(const QModelIndex))); |
310 SLOT(openResultitem(const QModelIndex))); |
231 connect(mSearchPanel, SIGNAL(criteriaChanged(QString)), this, |
314 connect(mSearchPanel, SIGNAL(criteriaChanged(QString)), this, |
232 SLOT(startNewSearch(QString))); |
315 SLOT(startNewSearch(QString))); |
233 |
316 |
234 connect(mSearchPanel, SIGNAL(searchOptionsClicked()), this, |
317 connect(mSearchPanel, SIGNAL(searchOptionsClicked()), this, |
235 SLOT(setSettings())); |
318 SLOT(setSettings())); |
236 |
319 |
237 connect(mSearchPanel, SIGNAL(exitClicked()), this, |
320 connect(mSearchPanel, SIGNAL(exitClicked()), this, |
238 SLOT(cancelSearch())); |
321 SLOT(cancelSearch())); |
322 } |
|
323 if (mModel) |
|
324 { |
|
325 connect(mModel, SIGNAL(rowsInserted(QModelIndex,int,int)), this, |
|
326 SLOT(getrowsInserted())); |
|
327 |
|
328 connect(mModel, SIGNAL(rowsRemoved(QModelIndex,int,int)), this, |
|
329 SLOT(getrowsRemoved())); |
|
239 } |
330 } |
240 } |
331 } |
241 // --------------------------------------------------------------------------- |
332 // --------------------------------------------------------------------------- |
242 // SearchProgressiveState::deActivateSignals |
333 // SearchProgressiveState::deActivateSignals |
243 // --------------------------------------------------------------------------- |
334 // --------------------------------------------------------------------------- |
244 // |
335 // |
245 void SearchProgressiveState::deActivateSignals() |
336 void SearchProgressiveState::deActivateSignals() |
246 { |
337 { |
247 if (mSearchHandler) |
338 for (int i = 0; i < mSearchHandlerList.count(); i++) |
248 { |
339 { |
249 disconnect(mSearchHandler, SIGNAL(handleSearchResult(int,int)), this, |
340 disconnect(mSearchHandlerList.at(i), |
250 SLOT(onSearchComplete(int,int))); |
341 SIGNAL(handleAsyncSearchResult(int,int)), this, |
251 disconnect(mSearchHandler, SIGNAL(handleAsyncSearchResult(int,int)), |
342 SLOT(onAsyncSearchComplete(int,int))); |
252 this, SLOT(onAsyncSearchComplete(int,int))); |
343 disconnect(mSearchHandlerList.at(i), |
253 disconnect(mSearchHandler, |
|
254 SIGNAL(handleDocument(int,QCPixDocument*)), this, |
344 SIGNAL(handleDocument(int,QCPixDocument*)), this, |
255 SLOT(onGetDocumentComplete(int,QCPixDocument*))); |
345 SLOT(onGetDocumentComplete(int,QCPixDocument*))); |
256 } |
346 } |
257 if (mListView) |
347 if (mListView) |
258 { |
348 { |
264 disconnect(mSearchPanel, SIGNAL(criteriaChanged(QString)), this, |
354 disconnect(mSearchPanel, SIGNAL(criteriaChanged(QString)), this, |
265 SLOT(startNewSearch(QString))); |
355 SLOT(startNewSearch(QString))); |
266 |
356 |
267 disconnect(mSearchPanel, SIGNAL(searchOptionsClicked()), this, |
357 disconnect(mSearchPanel, SIGNAL(searchOptionsClicked()), this, |
268 SLOT(setSettings())); |
358 SLOT(setSettings())); |
269 } |
359 |
270 } |
360 disconnect(mSearchPanel, SIGNAL(exitClicked()), this, |
271 |
361 SLOT(cancelSearch())); |
272 // --------------------------------------------------------------------------- |
362 } |
273 // SearchProgressiveState::onSearchComplete |
363 if (mModel) |
274 // --------------------------------------------------------------------------- |
364 { |
275 // |
365 disconnect(mModel, SIGNAL(rowsInserted(QModelIndex,int,int)), this, |
276 void SearchProgressiveState::onSearchComplete(int aError, int aResultCount) |
366 SLOT(getrowsInserted())); |
277 { |
367 |
278 if (aError != 0) |
368 disconnect(mModel, SIGNAL(rowsRemoved(QModelIndex,int,int)), this, |
279 { |
369 SLOT(getrowsRemoved())); |
280 //Error found |
|
281 return; |
|
282 } |
|
283 if (aResultCount > 0) |
|
284 { |
|
285 mResultcount = aResultCount; |
|
286 mResultparser = 0; |
|
287 mSearchHandler->getDocumentAsyncAtIndex(mResultparser); |
|
288 } |
370 } |
289 } |
371 } |
290 // --------------------------------------------------------------------------- |
372 // --------------------------------------------------------------------------- |
291 // SearchProgressiveState::onAsyncSearchComplete |
373 // SearchProgressiveState::onAsyncSearchComplete |
292 // --------------------------------------------------------------------------- |
374 // --------------------------------------------------------------------------- |
293 // |
375 // |
294 void SearchProgressiveState::onAsyncSearchComplete(int aError, |
376 void SearchProgressiveState::onAsyncSearchComplete(int aError, |
295 int aResultCount) |
377 int aResultCount) |
296 { |
378 { |
379 PERF_CAT_API_ENDLOG |
|
380 PERF_CAT_HITS_ENDLOG |
|
297 |
381 |
298 if (aError != 0) |
382 if (aError != 0) |
299 { |
383 { |
300 //some error print logs |
384 //some error print logs |
301 searchOnCategory(mSearchString); |
385 searchOnCategory(mSearchString); |
307 } |
391 } |
308 else if (aResultCount > 0) |
392 else if (aResultCount > 0) |
309 { |
393 { |
310 mResultcount = aResultCount; |
394 mResultcount = aResultCount; |
311 mResultparser = 0; |
395 mResultparser = 0; |
312 |
396 PERF_CAT_GETDOC_TIME_RESTART |
397 PERF_CAT_GETDOC_ACCUMULATOR_RESET |
|
313 mSearchHandler->getDocumentAsyncAtIndex(mResultparser); |
398 mSearchHandler->getDocumentAsyncAtIndex(mResultparser); |
314 } |
399 } |
315 } |
400 } |
316 // --------------------------------------------------------------------------- |
401 // --------------------------------------------------------------------------- |
317 // SearchProgressiveState::onGetDocumentComplete |
402 // SearchProgressiveState::onGetDocumentComplete |
318 // --------------------------------------------------------------------------- |
403 // --------------------------------------------------------------------------- |
319 // |
404 // |
320 void SearchProgressiveState::onGetDocumentComplete(int aError, |
405 void SearchProgressiveState::onGetDocumentComplete(int aError, |
321 QCPixDocument* aDoc) |
406 QCPixDocument* aDoc) |
322 { |
407 { |
408 PERF_CAT_GETDOC_TIME_ACCUMULATE |
|
323 if (aDoc == NULL || aError != 0) |
409 if (aDoc == NULL || aError != 0) |
324 return; |
410 return; |
325 QStringList liststr; |
411 QStringList liststr; |
326 QString secondrow = aDoc->excerpt(); |
412 QString secondrow = aDoc->excerpt(); |
327 QString baseclass = aDoc->baseAppClass(); |
|
328 QString Uid = aDoc->docId(); |
|
329 QString firstrow; |
413 QString firstrow; |
330 |
414 |
331 //-------------- html tag creation------------------- |
415 //-------------- html tag creation------------------- |
332 QString htmlTagPre = QString("<u>"); |
416 QString htmlTagPre = QString("<u>"); |
333 QString htmlTagPost = QString("</u>"); |
417 QString htmlTagPost = QString("</u>"); |
334 int insertpt = secondrow.indexOf(mOriginalString, 0, Qt::CaseInsensitive); |
418 int insertpt = secondrow.indexOf(mOriginalString, 0, Qt::CaseInsensitive); |
335 if (insertpt >= 0) |
419 if (insertpt >= 0) |
336 { |
420 { |
337 int preTagLen = htmlTagPre.length(); |
|
338 |
|
339 secondrow.insert(insertpt, htmlTagPre); |
421 secondrow.insert(insertpt, htmlTagPre); |
340 |
422 |
341 secondrow.insert(insertpt + mOriginalString.length() + preTagLen, |
423 secondrow.insert(insertpt + mOriginalString.length() |
342 htmlTagPost); |
424 + htmlTagPre.length(), htmlTagPost); |
343 //--------------------Html Tag Creation completed------------ |
425 } |
344 } |
426 //--------------------Html Tag Creation completed------------ |
345 |
|
346 QStandardItem* listitem = new QStandardItem(); |
427 QStandardItem* listitem = new QStandardItem(); |
347 |
428 |
348 if (aDoc->baseAppClass().contains("contact")) |
429 if (aDoc->baseAppClass().contains("contact")) |
349 { |
430 { |
350 int index = aDoc->fieldCount(); |
431 QString givename; |
351 for (int i = 0; i < index; i++) |
432 QString familyname; |
352 { |
433 bool bgivenname = false; |
353 if (aDoc->field(i).name().contains("GivenName")) |
434 bool bfamilyname = false; |
354 { |
435 for (int i = 0; i < aDoc->fieldCount(); i++) |
355 firstrow = aDoc->field(i).value(); |
436 { |
356 break; |
437 if (!bgivenname && aDoc->field(i).name().contains("GivenName")) |
357 } |
438 { |
439 givename.append(aDoc->field(i).value()); |
|
440 bgivenname = true; |
|
441 } |
|
442 if (!bfamilyname && aDoc->field(i).name().contains("FamilyName")) |
|
443 { |
|
444 familyname.append(aDoc->field(i).value()); |
|
445 bfamilyname = true; |
|
446 } |
|
447 if (bgivenname && bfamilyname) |
|
448 break; |
|
449 } |
|
450 if (givename.length()) |
|
451 { |
|
452 firstrow.append(givename); |
|
453 } |
|
454 if (familyname.length()) |
|
455 { |
|
456 if (firstrow.length()) |
|
457 firstrow.append(" "); |
|
458 firstrow.append(familyname); |
|
358 } |
459 } |
359 if (firstrow.length() == 0) |
460 if (firstrow.length() == 0) |
360 firstrow = baseclass; |
461 { |
462 firstrow = hbTrId("txt_phob_list_unknown"); |
|
463 } |
|
361 liststr << firstrow << secondrow; |
464 liststr << firstrow << secondrow; |
362 listitem->setData(mIconArray.at(0), Qt::DecorationRole); |
465 listitem->setData(mIconArray.at(0), Qt::DecorationRole); |
363 |
|
364 } |
466 } |
365 else if (aDoc->baseAppClass().contains("audio")) |
467 else if (aDoc->baseAppClass().contains("audio")) |
366 { |
468 { |
367 int index = aDoc->fieldCount(); |
469 firstrow.append(filterDoc(aDoc, "Title")); |
368 for (int i = 0; i < index; i++) |
|
369 { |
|
370 if (aDoc->field(i).name().contains("Name")) |
|
371 { |
|
372 firstrow = aDoc->field(i).value(); |
|
373 break; |
|
374 } |
|
375 } |
|
376 if (firstrow.length() == 0) |
470 if (firstrow.length() == 0) |
377 firstrow = baseclass; |
471 { |
472 firstrow = hbTrId("txt_mus_dblist_val_unknown4"); |
|
473 } |
|
378 liststr << firstrow << secondrow; |
474 liststr << firstrow << secondrow; |
379 listitem->setData(mIconArray.at(1), Qt::DecorationRole); |
475 listitem->setData(mIconArray.at(1), Qt::DecorationRole); |
380 } |
476 } |
381 else if (aDoc->baseAppClass().contains("video")) |
477 else if (aDoc->baseAppClass().contains("video")) |
382 { |
478 { |
383 int index = aDoc->fieldCount(); |
479 firstrow.append(filterDoc(aDoc, "Title")); |
384 for (int i = 0; i < index; i++) |
|
385 { |
|
386 if (aDoc->field(i).name().contains("Name")) |
|
387 { |
|
388 firstrow = aDoc->field(i).value(); |
|
389 break; |
|
390 } |
|
391 } |
|
392 if (firstrow.length() == 0) |
480 if (firstrow.length() == 0) |
393 firstrow = baseclass; |
481 { |
482 firstrow.append(filterDoc(aDoc, "Name")); |
|
483 } |
|
394 liststr << firstrow << secondrow; |
484 liststr << firstrow << secondrow; |
395 listitem->setData(mIconArray.at(2), Qt::DecorationRole); |
485 listitem->setData(mIconArray.at(2), Qt::DecorationRole); |
396 |
|
397 } |
486 } |
398 else if (aDoc->baseAppClass().contains("image")) |
487 else if (aDoc->baseAppClass().contains("image")) |
399 { |
488 { |
400 int index = aDoc->fieldCount(); |
489 firstrow.append(filterDoc(aDoc, "Name")); |
401 for (int i = 0; i < index; i++) |
|
402 { |
|
403 if (aDoc->field(i).name().contains("Name")) |
|
404 { |
|
405 firstrow = aDoc->field(i).value(); |
|
406 break; |
|
407 } |
|
408 } |
|
409 if (firstrow.length() == 0) |
|
410 firstrow = baseclass; |
|
411 liststr << firstrow << secondrow; |
490 liststr << firstrow << secondrow; |
412 listitem->setData(mIconArray.at(3), Qt::DecorationRole); |
491 listitem->setData(mIconArray.at(3), Qt::DecorationRole); |
413 } |
492 } |
414 else if (aDoc->baseAppClass().contains("msg")) |
493 else if (aDoc->baseAppClass().contains("msg")) |
415 { |
494 { |
416 int index = aDoc->fieldCount(); |
495 QString subject; |
417 for (int i = 0; i < index; i++) |
496 QString body; |
418 { |
497 bool bsubject = false; |
419 if (aDoc->field(i).name().contains("Subject")) |
498 bool bbody = false; |
420 { |
499 for (int i = 0; i < aDoc->fieldCount(); i++) |
421 firstrow = aDoc->field(i).value(); |
500 { |
422 break; |
501 if (!bsubject && aDoc->field(i).name().contains("Subject")) |
423 } |
502 { |
503 subject.append(aDoc->field(i).value()); |
|
504 bsubject = true; |
|
505 } |
|
506 if (!bbody && aDoc->field(i).name().contains("Body")) |
|
507 { |
|
508 body.append(aDoc->field(i).value()); |
|
509 bbody = true; |
|
510 } |
|
511 if (bsubject && bbody) |
|
512 break; |
|
513 } |
|
514 if (subject.length()) |
|
515 { |
|
516 firstrow.append(subject); |
|
517 } |
|
518 else |
|
519 { |
|
520 firstrow.append(body); |
|
424 } |
521 } |
425 if (firstrow.length() == 0) |
522 if (firstrow.length() == 0) |
426 firstrow = baseclass; |
523 { |
524 firstrow = " ";// space if subject and body are missing |
|
525 } |
|
427 liststr << firstrow << secondrow; |
526 liststr << firstrow << secondrow; |
428 listitem->setData(mIconArray.at(4), Qt::DecorationRole); |
527 listitem->setData(mIconArray.at(4), Qt::DecorationRole); |
429 |
|
430 } |
528 } |
431 else if (aDoc->baseAppClass().contains("email")) |
529 else if (aDoc->baseAppClass().contains("email")) |
432 { |
530 { |
433 int index = aDoc->fieldCount(); |
531 firstrow.append(filterDoc(aDoc, "Subject")); |
434 for (int i = 0; i < index; i++) |
532 liststr << firstrow << secondrow; |
435 { |
533 } |
436 if (aDoc->field(i).name().contains("GivenName")) |
534 else if (aDoc->baseAppClass().contains("calendar")) |
437 { |
535 { |
438 firstrow = aDoc->field(i).value(); |
536 firstrow.append(filterDoc(aDoc, "Description")); |
439 break; |
|
440 } |
|
441 } |
|
442 if (firstrow.length() == 0) |
537 if (firstrow.length() == 0) |
443 firstrow = baseclass; |
538 { |
444 liststr << firstrow << secondrow; |
539 firstrow = hbTrId("txt_calendar_preview_unnamed"); |
445 } |
540 } |
446 else if (aDoc->baseAppClass().contains("calendar")) |
541 |
447 { |
|
448 int index = aDoc->fieldCount(); |
|
449 for (int i = 0; i < index; i++) |
|
450 { |
|
451 if (aDoc->field(i).name().contains("Description")) |
|
452 { |
|
453 firstrow = aDoc->field(i).value(); |
|
454 break; |
|
455 } |
|
456 } |
|
457 if (firstrow.length() == 0) |
|
458 firstrow = baseclass; |
|
459 liststr << firstrow << secondrow; |
542 liststr << firstrow << secondrow; |
460 listitem->setData(mIconArray.at(6), Qt::DecorationRole); |
543 listitem->setData(mIconArray.at(6), Qt::DecorationRole); |
461 } |
544 } |
462 else if (aDoc->baseAppClass().contains("notes")) |
545 else if (aDoc->baseAppClass().contains("notes")) |
463 { |
546 { |
464 int index = aDoc->fieldCount(); |
547 firstrow.append(filterDoc(aDoc, "Memo")); |
465 for (int i = 0; i < index; i++) |
|
466 { |
|
467 if (aDoc->field(i).name().contains("Memo")) |
|
468 { |
|
469 firstrow = aDoc->field(i).value(); |
|
470 break; |
|
471 } |
|
472 } |
|
473 if (firstrow.length() == 0) |
548 if (firstrow.length() == 0) |
474 firstrow = baseclass; |
549 { |
550 firstrow = hbTrId("txt_notes_dblist_unnamed"); |
|
551 } |
|
475 liststr << firstrow << secondrow; |
552 liststr << firstrow << secondrow; |
476 } |
553 } |
477 else if (aDoc->baseAppClass().contains("applications")) |
554 else if (aDoc->baseAppClass().contains("applications")) |
478 { |
555 { |
479 |
|
480 liststr << secondrow; |
556 liststr << secondrow; |
481 bool ok; |
557 bool ok; |
482 listitem->setData(getAppIconFromAppId(TUid::Uid(aDoc->docId().toInt( |
558 listitem->setData(getAppIconFromAppId(TUid::Uid(aDoc->docId().toInt( |
483 &ok, 16))), Qt::DecorationRole); |
559 &ok, 16))), Qt::DecorationRole); |
484 } |
560 } |
485 else if (aDoc->baseAppClass().contains("bookmark")) |
561 else if (aDoc->baseAppClass().contains("bookmark")) |
486 { |
562 { |
487 int index = aDoc->fieldCount(); |
563 firstrow.append(filterDoc(aDoc, "Name")); |
488 for (int i = 0; i < index; i++) |
|
489 { |
|
490 if (aDoc->field(i).name().contains("Name")) |
|
491 { |
|
492 firstrow = aDoc->field(i).value(); |
|
493 break; |
|
494 } |
|
495 } |
|
496 if (firstrow.length() == 0) |
564 if (firstrow.length() == 0) |
497 firstrow = baseclass; |
565 { |
566 firstrow = "UnKnown"; |
|
567 } |
|
498 liststr << firstrow << secondrow; |
568 liststr << firstrow << secondrow; |
499 } |
569 } |
500 else if (aDoc->baseAppClass().contains("file")) |
570 else if (aDoc->baseAppClass().contains("file")) |
501 { |
571 { |
502 int index = aDoc->fieldCount(); |
572 firstrow.append(filterDoc(aDoc, "BaseName")); |
503 for (int i = 0; i < index; i++) |
|
504 { |
|
505 if (aDoc->field(i).name().contains("FullName")) |
|
506 { |
|
507 firstrow = aDoc->field(i).value(); |
|
508 break; |
|
509 } |
|
510 } |
|
511 if (firstrow.length() == 0) |
573 if (firstrow.length() == 0) |
512 firstrow = baseclass; |
574 firstrow = aDoc->baseAppClass(); |
513 liststr << firstrow << secondrow; |
575 liststr << firstrow << secondrow; |
514 listitem->setData(mIconArray.at(9), Qt::DecorationRole); |
576 listitem->setData(mIconArray.at(9), Qt::DecorationRole); |
515 } |
577 } |
516 |
578 |
517 listitem->setData(liststr, Qt::DisplayRole); |
579 listitem->setData(liststr, Qt::DisplayRole); |
518 listitem->setData(aDoc->docId(), Qt::UserRole); |
580 listitem->setData(aDoc->docId(), Qt::UserRole); |
519 listitem->setData(aDoc->baseAppClass(), Qt::UserRole + 1); |
581 listitem->setData(aDoc->baseAppClass(), Qt::UserRole + 1); |
520 |
582 |
521 mModel->appendRow(listitem); |
583 mModel->appendRow(listitem); |
584 |
|
585 delete aDoc; |
|
586 } |
|
587 // --------------------------------------------------------------------------- |
|
588 // SearchProgressiveState::getSettingCategory |
|
589 // --------------------------------------------------------------------------- |
|
590 // |
|
591 void SearchProgressiveState::getSettingCategory(int item, bool avalue) |
|
592 { |
|
593 mSelectedCategory.insert(item, avalue); |
|
594 } |
|
595 // --------------------------------------------------------------------------- |
|
596 // SearchProgressiveState::getrowsInserted |
|
597 // --------------------------------------------------------------------------- |
|
598 // |
|
599 void SearchProgressiveState::getrowsInserted() |
|
600 { |
|
522 mResultparser++; |
601 mResultparser++; |
523 if (mResultparser < mResultcount) |
602 if (mResultparser < mResultcount) |
524 { |
603 { |
525 |
604 PERF_CAT_GETDOC_TIME_RESTART |
526 mSearchHandler->getDocumentAsyncAtIndex(mResultparser); |
605 mSearchHandler->getDocumentAsyncAtIndex(mResultparser); |
527 } |
606 } |
528 else |
607 else |
529 { |
608 { |
530 |
609 PERF_CAT_GETDOC_ACCUMULATOR_ENDLOG |
531 searchOnCategory(mSearchString); |
610 searchOnCategory(mSearchString); |
532 } |
611 } |
533 } |
612 } |
534 // --------------------------------------------------------------------------- |
613 // --------------------------------------------------------------------------- |
535 // SearchProgressiveState::_selectedcategory |
614 // SearchProgressiveState::getrowsRemoved |
536 // --------------------------------------------------------------------------- |
615 // --------------------------------------------------------------------------- |
537 // |
616 // |
538 void SearchProgressiveState::getSettingCategory(int item, bool avalue) |
617 void SearchProgressiveState::getrowsRemoved() |
539 { |
618 { |
540 |
619 if (mModel->rowCount() != 0) |
541 mSelectedCategory.insert(item, avalue); |
620 { |
542 |
621 mModel->removeRow(0); |
622 } |
|
623 else |
|
624 { |
|
625 mListView->reset(); |
|
626 if (mOriginalString.length()) |
|
627 { |
|
628 mDatabasecount = 0; |
|
629 mSearchString = mOriginalString; |
|
630 mSearchString.append('*'); |
|
631 searchOnCategory(mSearchString); |
|
632 } |
|
633 } |
|
543 } |
634 } |
544 // --------------------------------------------------------------------------- |
635 // --------------------------------------------------------------------------- |
545 // SearchProgressiveState::openResultitem |
636 // SearchProgressiveState::openResultitem |
546 // --------------------------------------------------------------------------- |
637 // --------------------------------------------------------------------------- |
547 // |
638 // |
548 void SearchProgressiveState::openResultitem(QModelIndex index) |
639 void SearchProgressiveState::openResultitem(QModelIndex index) |
549 { |
640 { |
550 QStandardItem* item = mModel->itemFromIndex(index); |
641 QStandardItem* item = mModel->itemFromIndex(index); |
551 QString baseclass = item->data(Qt::UserRole + 1).toString(); |
642 QString baseclass = item->data(Qt::UserRole + 1).toString(); |
643 |
|
644 QVariant retValue; |
|
552 bool t; |
645 bool t; |
553 int uid = (item->data(Qt::UserRole)).toInt(&t); |
646 if (baseclass.contains("contact")) |
554 |
647 { |
555 if (index.row() == mLinkindex) |
648 |
556 { |
649 mRequest = mAiwMgr->create("com.nokia.services.phonebookservices", |
557 // emit linkItemClicked(); |
650 "Fetch", "open(int)", false); |
558 } |
651 connect(mRequest, SIGNAL(requestOk(const QVariant&)), this, |
559 else |
652 SLOT(handleOk(const QVariant&))); |
560 { |
653 // Connect error handling signal or apply lastError function instead. |
561 XQServiceRequest *mSndEdit; |
654 connect(mRequest, SIGNAL(requestError(int,const QString&)), this, |
562 QVariant retValue; |
655 SLOT(handleError(int,const QString&))); |
563 |
656 |
564 if (baseclass.contains("contact")) |
657 if (!mRequest) |
565 { |
658 { |
566 mSndEdit = new XQServiceRequest( |
659 qDebug() << "AIW-ERROR: NULL request"; |
567 "com.nokia.services.phonebookservices.Fetch", |
660 return; |
568 "open(int)", false); |
661 } |
569 *mSndEdit << uid; |
662 |
570 retValue = mSndEdit->send(); |
663 int uid = (item->data(Qt::UserRole)).toInt(&t); |
571 } |
664 QList<QVariant> args; |
572 else if (baseclass.contains("msg")) |
665 args << uid; |
573 { |
666 mRequest->setArguments(args); |
574 mSndEdit = new XQServiceRequest( |
667 // Make the request |
575 "com.nokia.services.hbserviceprovider.conversationview", |
668 if (!mRequest->send()) |
576 "openConversationView(qint64,int)", false); |
669 { |
577 *mSndEdit << uid << 0; |
670 qDebug() << "AIW-ERROR: Send failed" << mRequest->lastError(); |
578 retValue = mSndEdit->send(); |
671 } |
579 } |
672 delete mRequest; |
580 } |
673 |
674 } |
|
675 else if (baseclass.contains("msg")) |
|
676 { |
|
677 int uid = (item->data(Qt::UserRole)).toInt(&t); |
|
678 |
|
679 mRequest = mAiwMgr->create("com.nokia.services.hbserviceprovider", |
|
680 "conversationview", "view(qint64)", false); |
|
681 connect(mRequest, SIGNAL(requestOk(const QVariant&)), this, |
|
682 SLOT(handleOk(const QVariant&))); |
|
683 // Connect error handling signal or apply lastError function instead. |
|
684 connect(mRequest, SIGNAL(requestError(int,const QString&)), this, |
|
685 SLOT(handleError(int,const QString&))); |
|
686 |
|
687 if (!mRequest) |
|
688 { |
|
689 qDebug() << "AIW-ERROR: NULL request"; |
|
690 return; |
|
691 } |
|
692 |
|
693 QList<QVariant> args; |
|
694 args << uid; |
|
695 retValue = mRequest->send(); |
|
696 delete mRequest; |
|
697 } |
|
698 else if (baseclass.contains("video")) |
|
699 { |
|
700 QString uid = item->data(Qt::UserRole).toString(); |
|
701 mRequest = mAiwMgr->create("com.nokia.videos", "IVideoView", |
|
702 "playMedia(QString)", false); |
|
703 connect(mRequest, SIGNAL(requestOk(const QVariant&)), this, |
|
704 SLOT(handleOk(const QVariant&))); |
|
705 // Connect error handling signal or apply lastError function instead. |
|
706 connect(mRequest, SIGNAL(requestError(int,const QString&)), this, |
|
707 SLOT(handleError(int,const QString&))); |
|
708 |
|
709 QList<QVariant> args; |
|
710 args << uid; |
|
711 retValue = mRequest->send(); |
|
712 delete mRequest; |
|
713 } |
|
714 |
|
715 } |
|
716 // --------------------------------------------------------------------------- |
|
717 // SearchProgressiveState::handleOk |
|
718 // --------------------------------------------------------------------------- |
|
719 // |
|
720 void SearchProgressiveState::handleOk(const QVariant& /*var*/) |
|
721 { |
|
722 |
|
723 } |
|
724 // --------------------------------------------------------------------------- |
|
725 // SearchProgressiveState::handleError |
|
726 // --------------------------------------------------------------------------- |
|
727 // |
|
728 void SearchProgressiveState::handleError(int /*ret*/, const QString& /*var*/) |
|
729 { |
|
730 |
|
581 } |
731 } |
582 // --------------------------------------------------------------------------- |
732 // --------------------------------------------------------------------------- |
583 // SearchProgressiveState::createSuggestionLink |
733 // SearchProgressiveState::createSuggestionLink |
584 // --------------------------------------------------------------------------- |
734 // --------------------------------------------------------------------------- |
585 // |
735 // |
586 void SearchProgressiveState::createSuggestionLink(bool aFlag) |
736 void SearchProgressiveState::createSuggestionLink(bool aFlag) |
587 { |
737 { |
588 QStandardItem* listitem = new QStandardItem(); |
738 QStandardItem* listitem = new QStandardItem(); |
589 /* QString displaystr; |
|
590 QString searchStr(mSearchString);*/ |
|
591 QString htmlKeyword = QString("<u>%1</u>").arg(mOriginalString); |
739 QString htmlKeyword = QString("<u>%1</u>").arg(mOriginalString); |
592 /* QString htmlServiceProvider = QString("in Google");*/ |
|
593 |
|
594 if (!aFlag) |
740 if (!aFlag) |
595 { |
741 { |
596 QString linkString = QString(hbTrId( |
742 QString linkString = QString(hbTrId( |
597 "txt_search_list_search_for_1_on_2").arg(htmlKeyword)); |
743 "txt_search_list_search_for_1_on_2").arg(htmlKeyword)); |
598 mLinkindex = mModel->rowCount(); |
744 mLinkindex = mModel->rowCount(); |
599 listitem->setData(linkString, Qt::DisplayRole); |
745 listitem->setData(linkString, Qt::DisplayRole); |
600 /* HbFrameBackground* background = new HbFrameBackground( |
746 |
601 "qtg_fr_button_function_latched", HbFrameDrawer::NinePieces); |
|
602 listitem->setData(*background, Qt::BackgroundRole); |
|
603 */ |
|
604 mModel->appendRow(listitem); |
747 mModel->appendRow(listitem); |
605 } |
748 } |
606 |
749 |
607 } |
750 } |
608 // --------------------------------------------------------------------------- |
751 // --------------------------------------------------------------------------- |
620 mModel->appendRow(listitem); |
763 mModel->appendRow(listitem); |
621 } |
764 } |
622 |
765 |
623 } |
766 } |
624 // --------------------------------------------------------------------------- |
767 // --------------------------------------------------------------------------- |
625 // SearchProgressiveState::noResultsFound |
768 // SearchProgressiveState::clear |
626 // --------------------------------------------------------------------------- |
769 // --------------------------------------------------------------------------- |
627 // |
770 // |
628 void SearchProgressiveState::clear() |
771 void SearchProgressiveState::clear() |
629 { |
772 { |
630 if (mModel) |
773 if (mModel) |
631 { |
774 { |
632 mModel->clear(); |
775 mModel->removeRows(0, mModel->rowCount()); |
633 } |
776 } |
634 } |
777 } |
635 // --------------------------------------------------------------------------- |
778 // --------------------------------------------------------------------------- |
636 // SearchProgressiveState::noResultsFound |
779 // SearchProgressiveState::searchOnCategory |
637 // --------------------------------------------------------------------------- |
780 // --------------------------------------------------------------------------- |
638 // |
781 // |
639 void SearchProgressiveState::searchOnCategory(const QString aKeyword) |
782 void SearchProgressiveState::searchOnCategory(const QString aKeyword) |
640 { |
783 { |
784 #ifdef OST_TRACE_COMPILER_IN_USE |
|
785 if( mDatabasecount != 0 ){//Search just started. |
|
786 PERF_CAT_UI_ENDLOG |
|
787 } |
|
788 PERF_CAT_UI_TIME_RESTART |
|
789 #endif |
|
641 mResultparser = 0; |
790 mResultparser = 0; |
642 mResultcount = 0; |
791 mResultcount = 0; |
643 if (mDatabasecount < mTemplist.count()) |
792 if (mDatabasecount < mTemplist.count()) |
644 { |
793 { |
645 QString str = mTemplist.at(mDatabasecount); |
794 QString str = mTemplist.at(mDatabasecount); |
646 mSearchHandler->setCategory(mTemplist.at(mDatabasecount)); |
795 if (str.contains("selectall")) |
796 { |
|
797 // mSearchHandler = mSearchHandlerList.at(0); |
|
798 } |
|
799 else if (str.contains("contact")) |
|
800 { |
|
801 mSearchHandler = mSearchHandlerList.at(1); |
|
802 } |
|
803 else if (str.contains("media")) |
|
804 { |
|
805 mSearchHandler = mSearchHandlerList.at(2); |
|
806 } |
|
807 else if (str.contains("msg")) |
|
808 { |
|
809 mSearchHandler = mSearchHandlerList.at(3); |
|
810 } |
|
811 else if (str.contains("email")) |
|
812 { |
|
813 mSearchHandler = mSearchHandlerList.at(4); |
|
814 } |
|
815 else if (str.contains("calendar")) |
|
816 { |
|
817 mSearchHandler = mSearchHandlerList.at(5); |
|
818 } |
|
819 else if (str.contains("notes")) |
|
820 { |
|
821 mSearchHandler = mSearchHandlerList.at(6); |
|
822 } |
|
823 else if (str.contains("applications")) |
|
824 { |
|
825 mSearchHandler = mSearchHandlerList.at(7); |
|
826 } |
|
827 else if (str.contains("file")) |
|
828 { |
|
829 mSearchHandler = mSearchHandlerList.at(8); |
|
830 } |
|
831 else if (str.contains("bookmark")) |
|
832 { |
|
833 mSearchHandler = mSearchHandlerList.at(9); |
|
834 } |
|
835 // mSearchHandler->setCategory(mTemplist.at(mDatabasecount)); |
|
647 mDatabasecount++; |
836 mDatabasecount++; |
648 if (mSearchHandler->isPrepared()) |
837 if (mSearchHandler->isPrepared()) |
649 { |
838 { |
650 |
839 PERF_CAT_API_TIME_RESTART |
651 mSearchHandler->searchAsync(aKeyword, "_aggregate"); |
840 mSearchHandler->searchAsync(aKeyword, "_aggregate"); |
652 } |
841 } |
653 } |
842 } |
654 else if (mDatabasecount >= mTemplist.count()) |
843 else if (mDatabasecount >= mTemplist.count()) |
655 { |
844 { |
845 PERF_TOTAL_UI_ENDLOG |
|
656 if (mListView->indexCount() == 0 && aKeyword.length() != 0) |
846 if (mListView->indexCount() == 0 && aKeyword.length() != 0) |
657 { |
847 { |
658 noResultsFound(mOriginalString); |
848 noResultsFound(mOriginalString); |
659 createSuggestionLink(0); |
849 createSuggestionLink(0); |
660 } |
850 } |
666 // SearchProgressiveState::startNewSearch |
856 // SearchProgressiveState::startNewSearch |
667 // --------------------------------------------------------------------------- |
857 // --------------------------------------------------------------------------- |
668 // |
858 // |
669 void SearchProgressiveState::startNewSearch(const QString &aKeyword) |
859 void SearchProgressiveState::startNewSearch(const QString &aKeyword) |
670 { |
860 { |
671 |
861 PERF_CAT_TOTAL_TIME_RESTART |
672 if (mSearchHandler) |
862 |
673 { |
863 mOriginalString = aKeyword.trimmed(); |
674 mSearchHandler->cancelLastSearch(); |
864 for (int i = 0; i < mSearchHandlerList.count(); i++) |
865 { |
|
866 mSearchHandlerList.at(i)->cancelLastSearch(); |
|
867 } |
|
868 if (mModel->rowCount() != 0) |
|
869 { |
|
675 clear(); |
870 clear(); |
676 } |
871 } |
677 mOriginalString = aKeyword.trimmed(); |
872 else if (mOriginalString.length()) |
678 if (mOriginalString.length()) |
|
679 { |
873 { |
680 mDatabasecount = 0; |
874 mDatabasecount = 0; |
681 mTemplist.clear(); |
875 mLinkindex = 0; |
682 mSearchString = mOriginalString; |
876 mSearchString = mOriginalString; |
683 mSearchString.append('*'); |
877 mSearchString.append('*'); |
684 QMapIterator<int, bool> i(mSelectedCategory); |
|
685 while (i.hasNext()) |
|
686 { |
|
687 i.next(); |
|
688 if (i.value()) |
|
689 { |
|
690 switch (i.key()) |
|
691 { |
|
692 case 0: |
|
693 { |
|
694 break; |
|
695 } |
|
696 case 1: //Contacts |
|
697 { |
|
698 mTemplist.append("contact"); |
|
699 break; |
|
700 } |
|
701 case 2://Media |
|
702 { |
|
703 mTemplist.append("media"); |
|
704 break; |
|
705 } |
|
706 case 3://Messages& emails |
|
707 { |
|
708 mTemplist.append("msg"); |
|
709 //mTemplist.append("email"); |
|
710 break; |
|
711 } |
|
712 case 4://Calender& notes |
|
713 { |
|
714 mTemplist.append("calendar"); |
|
715 //mTemplist.append("notes"); |
|
716 break; |
|
717 } |
|
718 case 5://Applications |
|
719 { |
|
720 mTemplist.append("applications"); |
|
721 break; |
|
722 } |
|
723 case 6://All other files |
|
724 { |
|
725 mTemplist.append("file"); |
|
726 mTemplist.append("bookmark"); |
|
727 break; |
|
728 } |
|
729 } |
|
730 } |
|
731 } |
|
732 searchOnCategory(mSearchString); |
878 searchOnCategory(mSearchString); |
733 } |
879 } |
734 } |
880 } |
735 // --------------------------------------------------------------------------- |
881 // --------------------------------------------------------------------------- |
736 // SearchProgressiveState::setSettings |
882 // SearchProgressiveState::setSettings |
784 } |
930 } |
785 } |
931 } |
786 } |
932 } |
787 } |
933 } |
788 // --------------------------------------------------------------------------- |
934 // --------------------------------------------------------------------------- |
935 // SearchProgressiveState::setSelectedCategories |
|
936 // --------------------------------------------------------------------------- |
|
937 // |
|
938 void SearchProgressiveState::setSelectedCategories() |
|
939 { |
|
940 mTemplist.clear(); |
|
941 QMapIterator<int, bool> i(mSelectedCategory); |
|
942 while (i.hasNext()) |
|
943 { |
|
944 i.next(); |
|
945 if (i.value()) |
|
946 { |
|
947 switch (i.key()) |
|
948 { |
|
949 case 0: |
|
950 { |
|
951 //mTemplist.append("selectall"); |
|
952 break; |
|
953 } |
|
954 case 1: //Contacts |
|
955 { |
|
956 mTemplist.append("contact"); |
|
957 break; |
|
958 } |
|
959 case 2://Media |
|
960 { |
|
961 mTemplist.append("media"); |
|
962 break; |
|
963 } |
|
964 case 3://Messages& emails |
|
965 { |
|
966 mTemplist.append("msg"); |
|
967 //mTemplist.append("email"); |
|
968 break; |
|
969 } |
|
970 case 4://Calender& notes |
|
971 { |
|
972 mTemplist.append("calendar"); |
|
973 mTemplist.append("notes"); |
|
974 break; |
|
975 } |
|
976 case 5://Applications |
|
977 { |
|
978 mTemplist.append("applications"); |
|
979 break; |
|
980 } |
|
981 case 6://Bookmarks |
|
982 { |
|
983 mTemplist.append("bookmark"); |
|
984 break; |
|
985 } |
|
986 case 7://All other files |
|
987 { |
|
988 mTemplist.append("file"); |
|
989 break; |
|
990 } |
|
991 } |
|
992 } |
|
993 } |
|
994 } |
|
995 // --------------------------------------------------------------------------- |
|
789 // SearchProgressiveState::cancelSearch |
996 // SearchProgressiveState::cancelSearch |
790 // --------------------------------------------------------------------------- |
997 // --------------------------------------------------------------------------- |
791 // |
998 // |
792 void SearchProgressiveState::cancelSearch() |
999 void SearchProgressiveState::cancelSearch() |
793 { |
1000 { |
794 if(mSearchHandler) |
1001 for (int i = 0; i < mSearchHandlerList.count(); i++) |
795 { |
1002 { |
796 mSearchHandler->cancelLastSearch(); |
1003 mSearchHandlerList.at(i)->cancelLastSearch(); |
797 } |
1004 } |
798 } |
1005 } |
799 // --------------------------------------------------------------------------- |
1006 // --------------------------------------------------------------------------- |
800 // SearchProgressiveState::getAppIconFromAppId |
1007 // SearchProgressiveState::getAppIconFromAppId |
801 // --------------------------------------------------------------------------- |
1008 // --------------------------------------------------------------------------- |
818 CleanupStack::Pop(2); //for trap |
1025 CleanupStack::Pop(2); //for trap |
819 } |
1026 } |
820 ); |
1027 ); |
821 if (err == KErrNone) |
1028 if (err == KErrNone) |
822 { |
1029 { |
823 aknIcon = CAknIcon::NewL(); |
1030 TRAPD( err1, |
824 aknIcon->SetBitmap(bitmap); |
1031 {aknIcon = CAknIcon::NewL(); |
825 aknIcon->SetMask(mask); |
1032 aknIcon->SetBitmap(bitmap); |
1033 aknIcon->SetMask(mask);}); |
|
1034 if (err1 == KErrNone) |
|
1035 { |
|
1036 |
|
1037 } |
|
826 } |
1038 } |
827 } |
1039 } |
828 if (aknIcon) |
1040 if (aknIcon) |
829 { |
1041 { |
830 CleanupStack::PushL(aknIcon); |
|
831 |
|
832 //need to disable compression to properly convert the bitmap |
1042 //need to disable compression to properly convert the bitmap |
833 AknIconUtils::DisableCompression(aknIcon->Bitmap()); |
1043 AknIconUtils::DisableCompression(aknIcon->Bitmap()); |
834 |
1044 |
835 AknIconUtils::SetSize(aknIcon->Bitmap(), TSize( |
1045 AknIconUtils::SetSize(aknIcon->Bitmap(), TSize( |
836 defaultIconSize.width(), defaultIconSize.height()), |
1046 defaultIconSize.width(), defaultIconSize.height()), |
842 pixmap.setAlphaChannel(mask); |
1052 pixmap.setAlphaChannel(mask); |
843 } |
1053 } |
844 else |
1054 else |
845 { |
1055 { |
846 CFbsBitmap *temp(NULL); |
1056 CFbsBitmap *temp(NULL); |
847 temp = copyBitmapLC(aknIcon->Bitmap()); |
1057 TRAPD( err, |
848 pixmap = fromSymbianCFbsBitmap(temp); |
1058 {temp = copyBitmapLC(aknIcon->Bitmap()); |
849 CleanupStack::PopAndDestroy(); |
1059 pixmap = fromSymbianCFbsBitmap(temp); |
850 |
1060 CleanupStack::PopAndDestroy();}); |
851 temp = copyBitmapLC(aknIcon->Mask()); |
1061 if (err == KErrNone) |
852 QPixmap mask = fromSymbianCFbsBitmap(temp); |
1062 { |
853 CleanupStack::PopAndDestroy(); |
1063 TRAPD( err1, |
854 |
1064 {temp = copyBitmapLC(aknIcon->Mask()); |
855 pixmap.setAlphaChannel(mask); |
1065 QPixmap mask = fromSymbianCFbsBitmap(temp); |
1066 CleanupStack::PopAndDestroy(); |
|
1067 pixmap.setAlphaChannel(mask);}); |
|
1068 if (err1 == KErrNone) |
|
1069 { |
|
1070 |
|
1071 } |
|
1072 } |
|
1073 |
|
856 } |
1074 } |
857 |
1075 |
858 pixmap = pixmap.scaled(defaultIconSize, |
1076 pixmap = pixmap.scaled(defaultIconSize, |
859 Qt::KeepAspectRatioByExpanding); |
1077 Qt::KeepAspectRatioByExpanding); |
860 CleanupStack::PopAndDestroy(aknIcon); |
|
861 icon = HbIcon(QIcon(pixmap)); |
1078 icon = HbIcon(QIcon(pixmap)); |
862 } |
1079 } |
863 return icon; |
1080 return icon; |
864 } |
1081 } |
865 // --------------------------------------------------------------------------- |
1082 // --------------------------------------------------------------------------- |
938 bmpGc->BitBlt(TPoint(0, 0), input); |
1155 bmpGc->BitBlt(TPoint(0, 0), input); |
939 delete bmpGc; |
1156 delete bmpGc; |
940 CleanupStack::PopAndDestroy(bitmapDevice); |
1157 CleanupStack::PopAndDestroy(bitmapDevice); |
941 return bmp; |
1158 return bmp; |
942 } |
1159 } |
1160 // --------------------------------------------------------------------------- |
|
1161 // SearchProgressiveState::filterDoc |
|
1162 // --------------------------------------------------------------------------- |
|
1163 // |
|
1164 QString SearchProgressiveState::filterDoc(const QCPixDocument* aDoc, |
|
1165 const QString& filter) |
|
1166 { |
|
1167 for (int i = 0; i < aDoc->fieldCount(); i++) |
|
1168 { |
|
1169 if (aDoc->field(i).name().contains(filter)) |
|
1170 { |
|
1171 return aDoc->field(i).value(); |
|
1172 } |
|
1173 } |
|
1174 return NULL; |
|
1175 } |