32 // |
32 // |
33 InDeviceHandler::~InDeviceHandler() |
33 InDeviceHandler::~InDeviceHandler() |
34 { |
34 { |
35 if (mSearchInterface) |
35 if (mSearchInterface) |
36 { |
36 { |
|
37 disconnect(mSearchInterface, SIGNAL(handleSearchResults(int,int)), |
|
38 this, SLOT(getSearchResult(int,int))); |
|
39 disconnect(mSearchInterface, |
|
40 SIGNAL(handleDocument(int,CpixDocument*)), this, |
|
41 SLOT(getDocumentAsync(int,CpixDocument*))); |
|
42 disconnect(mSearchInterface, |
|
43 SIGNAL(handleDocument(int,CpixDocument*)), this, |
|
44 SLOT(getDocumentAsync(int,CpixDocument*))); |
37 delete mSearchInterface; |
45 delete mSearchInterface; |
38 |
46 } |
39 } |
47 } |
40 } |
|
41 |
|
42 // --------------------------------------------------------------------------- |
48 // --------------------------------------------------------------------------- |
43 // InDeviceHandler::getSearchResult(int aError, int estimatedResultCount) |
49 // InDeviceHandler::getSearchResult(int aError, int estimatedResultCount) |
44 // aError: error code |
50 // aError: error code |
45 // estimatedResultCount: number of hits |
51 // estimatedResultCount: number of hits |
46 // --------------------------------------------------------------------------- |
52 // --------------------------------------------------------------------------- |
47 // |
53 // |
48 void InDeviceHandler::getSearchResult(int aError, int estimatedResultCount) |
54 void InDeviceHandler::getSearchResult(int aError, int estimatedResultCount) |
49 { |
55 { |
50 qDebug() << aError << estimatedResultCount; |
|
51 mSearchResultCount = estimatedResultCount; |
56 mSearchResultCount = estimatedResultCount; |
52 emit handleAsyncSearchResult(aError, estimatedResultCount); |
57 emit handleAsyncSearchResult(aError, estimatedResultCount); |
53 } |
58 } |
54 // --------------------------------------------------------------------------- |
59 // --------------------------------------------------------------------------- |
55 // InDeviceHandler::getDocumentAsync(int aError, CpixDocument* aDocument) |
60 // InDeviceHandler::getDocumentAsync(int aError, CpixDocument* aDocument) |
60 void InDeviceHandler::getDocumentAsync(int aError, CpixDocument* aDocument) |
65 void InDeviceHandler::getDocumentAsync(int aError, CpixDocument* aDocument) |
61 { |
66 { |
62 emit handleDocument(aError, aDocument); |
67 emit handleDocument(aError, aDocument); |
63 } |
68 } |
64 // --------------------------------------------------------------------------- |
69 // --------------------------------------------------------------------------- |
|
70 // InDeviceHandler::getBatchDocumentAsync(int aError, CpixDocument* aDocument) |
|
71 // aError: error code |
|
72 // aDocument: holding the result item |
|
73 // --------------------------------------------------------------------------- |
|
74 // |
|
75 void InDeviceHandler::getBatchDocumentAsync(int aError, int aCount, |
|
76 CpixDocument** aDocument) |
|
77 { |
|
78 emit handleBatchDocument(aError, aCount, aDocument); |
|
79 } |
|
80 // --------------------------------------------------------------------------- |
65 // InDeviceHandler::getDocumentAtIndex(int aIndex) |
81 // InDeviceHandler::getDocumentAtIndex(int aIndex) |
66 // aIndex: item index to be found |
82 // aIndex: item index to be found |
67 // --------------------------------------------------------------------------- |
83 // --------------------------------------------------------------------------- |
68 // |
84 // |
69 CpixDocument* InDeviceHandler::getDocumentAtIndex(int aIndex) |
85 CpixDocument* InDeviceHandler::getDocumentAtIndex(int aIndex) |
112 { |
127 { |
113 // handle the exception |
128 // handle the exception |
114 return; |
129 return; |
115 } |
130 } |
116 } |
131 } |
117 |
132 } |
|
133 // --------------------------------------------------------------------------- |
|
134 // InDeviceHandler::getBatchDocumentAsyncAtIndex |
|
135 // aIndex : index of item to be found async |
|
136 // aCount : number of result items |
|
137 // --------------------------------------------------------------------------- |
|
138 // |
|
139 void InDeviceHandler::getBatchDocumentAsyncAtIndex(int aIndex, int aCount) |
|
140 { |
|
141 if (mSearchInterface) |
|
142 { |
|
143 try |
|
144 { |
|
145 mSearchInterface->batchdocumentAsync(aIndex, aCount); |
|
146 } |
|
147 catch (...) |
|
148 { |
|
149 // handle the exception |
|
150 return; |
|
151 } |
|
152 } |
118 } |
153 } |
119 // --------------------------------------------------------------------------- |
154 // --------------------------------------------------------------------------- |
120 // InDeviceHandler::searchAsync |
155 // InDeviceHandler::searchAsync |
121 // aSearchAsyncString: string to be searched |
156 // aSearchAsyncString: string to be searched |
122 // async |
157 // async |
181 DEFAULT_SEARCH_FIELD); |
215 DEFAULT_SEARCH_FIELD); |
182 } |
216 } |
183 else |
217 else |
184 { |
218 { |
185 mSearchInterface = CpixSearcher::newInstance("root", |
219 mSearchInterface = CpixSearcher::newInstance("root", |
186 DEFAULT_SEARCH_FIELD); |
220 DEFAULT_SEARCH_FIELD); |
187 } |
221 } |
188 if (mSearchInterface) |
222 if (mSearchInterface) |
189 { |
223 { |
190 try |
224 connect(mSearchInterface, SIGNAL(handleSearchResults(int,int)), this, |
191 { |
225 SLOT(getSearchResult(int,int))); |
192 mSearchInterface->connect(mSearchInterface, |
226 connect(mSearchInterface, SIGNAL(handleDocument(int,CpixDocument*)), |
193 SIGNAL(handleSearchResults(int,int)), this, |
227 this, SLOT(getDocumentAsync(int,CpixDocument*))); |
194 SLOT(getSearchResult(int,int))); |
228 connect(mSearchInterface, |
195 } |
229 SIGNAL(handleBatchDocuments(int,int,CpixDocument**)), this, |
196 catch (...) |
230 SLOT(getBatchDocumentAsync(int,int,CpixDocument**))); |
197 { |
|
198 // handle the exception |
|
199 } |
|
200 |
|
201 try |
|
202 { |
|
203 mSearchInterface->connect(mSearchInterface, |
|
204 SIGNAL(handleDocument(int,CpixDocument*)), this, |
|
205 SLOT(getDocumentAsync(int,CpixDocument*))); |
|
206 } |
|
207 catch (...) |
|
208 { |
|
209 // handle the exception |
|
210 } |
|
211 } |
231 } |
212 } |
232 } |
213 |
233 |
214 // --------------------------------------------------------------------------- |
234 // --------------------------------------------------------------------------- |
215 // InDeviceHandler::isPrepared() |
235 // InDeviceHandler::isPrepared() |