1 /* |
|
2 * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 #include "searchhandler.h" |
|
19 #include <qcpixsearcher.h> |
|
20 #include <qcpixdocument.h> |
|
21 |
|
22 CSearchHandler::CSearchHandler() |
|
23 { |
|
24 iSearchInterface = QCPixSearcher::newInstance("root","_aggregate"); |
|
25 iSearchInterface->connect(iSearchInterface, SIGNAL(handleSearchResults(int,int)), this, SLOT(__handleSearchResult(int,int))); |
|
26 iSearchInterface->connect(iSearchInterface, SIGNAL(handleDocument(int,QCPixDocument*)), this, SLOT(__getDocumentAsync(int,QCPixDocument*))); |
|
27 } |
|
28 |
|
29 void CSearchHandler::__handleSearchResult(int aError, int estimatedResultCount) |
|
30 { |
|
31 qDebug() << aError << estimatedResultCount; |
|
32 iSearchresultCount= estimatedResultCount; |
|
33 emit handleAsyncSearchResult(aError, estimatedResultCount); |
|
34 } |
|
35 |
|
36 void CSearchHandler::__getDocumentAsync(int aError, QCPixDocument* aDocument ) |
|
37 { |
|
38 emit handleDocument( aError, aDocument ); |
|
39 } |
|
40 |
|
41 QCPixDocument* CSearchHandler::getDocumentAtIndex(int aIndex) |
|
42 { |
|
43 return iSearchInterface->getDocument( aIndex ); |
|
44 } |
|
45 |
|
46 void CSearchHandler::search(QString aSearchString) |
|
47 { |
|
48 qDebug() << "CSearchHandler::search Enter"; |
|
49 iSearchresultCount = iSearchInterface->search( aSearchString ); |
|
50 emit handleSearchResult( KErrNone, iSearchresultCount ); |
|
51 qDebug() << "CSearchHandler::search Exit"; |
|
52 } |
|
53 |
|
54 CSearchHandler::~CSearchHandler() |
|
55 { |
|
56 delete iSearchInterface; |
|
57 } |
|
58 |
|
59 int CSearchHandler::getSearchResultCount() |
|
60 { |
|
61 return iSearchresultCount; |
|
62 } |
|
63 |
|
64 void CSearchHandler::getDocumentAsyncAtIndex( int aIndex ) |
|
65 { |
|
66 iSearchInterface->getDocumentAsync( aIndex ); |
|
67 } |
|
68 |
|
69 void CSearchHandler::searchAsync(QString aSearchString) |
|
70 { |
|
71 iSearchInterface->searchAsync( aSearchString ); |
|
72 } |
|
73 |
|
74 void CSearchHandler::cancelLastSearch() |
|
75 { |
|
76 iSearchInterface->cancelSearch(); |
|
77 } |
|