37
|
1 |
/*
|
|
2 |
* Copyright (c) 2002-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: Filtered landmarks list provider
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
// SYSTEM INCLUDES
|
|
19 |
#include <EPos_CPosLmPartialReadParameters.h>
|
|
20 |
#include <EPos_CPosLandmark.h>
|
|
21 |
#include <EPos_TPosLmSortPref.h>
|
|
22 |
#include <EPos_CPosLandmarkDatabase.h>
|
|
23 |
#include <EPos_CPosLmItemIterator.h>
|
|
24 |
#include <EPos_CPosLmSearchCriteria.h>
|
|
25 |
#include <EPos_CPosLandmarkSearch.h>
|
|
26 |
#include <e32math.h>
|
|
27 |
#include <EPos_CPosLmCompositeCriteria.h>
|
|
28 |
#include <EPos_CPosLmCategoryCriteria.h>
|
|
29 |
#include <EPos_CPosLmIdListCriteria.h>
|
|
30 |
#include <EPos_CPosLmTextCriteria.h>
|
|
31 |
#include <AknWaitDialog.h>
|
|
32 |
#include <lmkui.rsg>
|
|
33 |
|
|
34 |
// USER INCLUDES
|
|
35 |
#include "CLmkSearchedLmListProvider.h"
|
|
36 |
#include "CLmkLandmarkUiItem.h"
|
|
37 |
#include "CLmkAOOperation.h"
|
|
38 |
#include "MLmkSelectorIconMgr.h"
|
|
39 |
#include <lmkerrors.h>
|
|
40 |
#include "Debug.h"
|
|
41 |
|
|
42 |
// CONSTANTS
|
|
43 |
_LIT(KSpaceTextCriteria,"* ");
|
|
44 |
_LIT(KDefaultTextCriteria,"*");
|
|
45 |
|
|
46 |
#if defined(_DEBUG)
|
|
47 |
/// Unnamed namespace for local definitions
|
|
48 |
namespace
|
|
49 |
{
|
|
50 |
_LIT( KPanicMsg, "CLmkSearchedLmListProvider" );
|
|
51 |
void Panic(TPanicCode aReason)
|
|
52 |
{
|
|
53 |
User::Panic(KPanicMsg, aReason);
|
|
54 |
}
|
|
55 |
} // namespace
|
|
56 |
#endif
|
|
57 |
|
|
58 |
// ============================ MEMBER FUNCTIONS ===============================
|
|
59 |
|
|
60 |
// -----------------------------------------------------------------------------
|
|
61 |
// CLmkSearchedLmListProvider::CLmkSearchedLmListProvider
|
|
62 |
// C++ constructor can NOT contain any code, that
|
|
63 |
// might leave.
|
|
64 |
// -----------------------------------------------------------------------------
|
|
65 |
//
|
|
66 |
CLmkSearchedLmListProvider::CLmkSearchedLmListProvider(
|
|
67 |
CPosLandmarkDatabase& aDb, CPosLmSearchCriteria& aCriteria) :
|
|
68 |
CLmkLmItemListProvider(aDb), iCriteria(aCriteria),
|
|
69 |
iIsSecondSearchStarted(EFalse)
|
|
70 |
{
|
|
71 |
}
|
|
72 |
|
|
73 |
// -----------------------------------------------------------------------------
|
|
74 |
// CLmkSearchedLmListProvider::ConstructL
|
|
75 |
// Symbian 2nd phase constructor can leave.
|
|
76 |
// -----------------------------------------------------------------------------
|
|
77 |
//
|
|
78 |
void CLmkSearchedLmListProvider::ConstructL()
|
|
79 |
{
|
|
80 |
// base class 2nd phase constructor
|
|
81 |
CLmkLmItemListProvider::BaseConstructL();
|
|
82 |
|
|
83 |
iReadParams = CPosLmPartialReadParameters::NewLC();
|
|
84 |
CleanupStack::Pop(); // iReadParams
|
|
85 |
iReadParams->SetRequestedAttributes(CPosLandmark::ELandmarkName
|
|
86 |
| CPosLandmark::EIcon | CPosLandmark::ECategoryInfo);
|
|
87 |
|
|
88 |
iSearch = CPosLandmarkSearch::NewL(iDb);
|
|
89 |
}
|
|
90 |
|
|
91 |
// -----------------------------------------------------------------------------
|
|
92 |
// CLmkSearchedLmListProvider::NewL
|
|
93 |
// Two-phased constructor.
|
|
94 |
// -----------------------------------------------------------------------------
|
|
95 |
//
|
|
96 |
CLmkSearchedLmListProvider* CLmkSearchedLmListProvider::NewL(
|
|
97 |
CPosLandmarkDatabase& aDb, CPosLmSearchCriteria& aCriteria)
|
|
98 |
{
|
|
99 |
CLmkSearchedLmListProvider* self =
|
|
100 |
new (ELeave) CLmkSearchedLmListProvider(aDb, aCriteria);
|
|
101 |
|
|
102 |
CleanupStack::PushL(self);
|
|
103 |
self->ConstructL();
|
|
104 |
CleanupStack::Pop();
|
|
105 |
|
|
106 |
return self;
|
|
107 |
}
|
|
108 |
|
|
109 |
// ---------------------------------------------------------
|
|
110 |
// CLmkSearchedLmListProvider::~CLmkSearchedLmListProvider
|
|
111 |
// ---------------------------------------------------------
|
|
112 |
//
|
|
113 |
CLmkSearchedLmListProvider::~CLmkSearchedLmListProvider()
|
|
114 |
{
|
|
115 |
delete iReadParams;
|
|
116 |
delete iSearch;
|
|
117 |
if (iSearchAO)
|
|
118 |
{
|
|
119 |
iSearchAO->StopOperation();
|
|
120 |
}
|
|
121 |
delete iSearchAO;
|
|
122 |
}
|
|
123 |
|
|
124 |
// ---------------------------------------------------------
|
|
125 |
// CLmkSearchedLmListProvider::ItemAtL
|
|
126 |
// ---------------------------------------------------------
|
|
127 |
//
|
|
128 |
CLmkUiItemBase* CLmkSearchedLmListProvider::ItemAtL(TInt aIndex)
|
|
129 |
{
|
|
130 |
__ASSERT_DEBUG( iIconMgr, Panic( KLmkPanicNullMember ) );
|
|
131 |
//landmark with updated icon, if associated with one cat.
|
|
132 |
CPosLandmark* landmark = GetLandmarkLC(aIndex);
|
|
133 |
TPtrC mbmFile;
|
|
134 |
TInt iconFileIndex = -1;
|
|
135 |
TInt iconListIndex = -1;
|
|
136 |
TInt iconMasktIndex = -1;
|
|
137 |
TInt result = landmark->GetIcon(mbmFile, iconFileIndex, iconMasktIndex);
|
|
138 |
if (result == KErrNone)
|
|
139 |
{
|
|
140 |
TRAPD(err, iconListIndex =
|
|
141 |
iIconMgr->GetIconL( mbmFile, iconFileIndex ) );
|
|
142 |
if (err == KErrNotFound) // icon file not found -> fallback to default
|
|
143 |
{
|
|
144 |
iconListIndex = iIconMgr->GetDefaultIconL(
|
|
145 |
MLmkSelectorIconMgr::ELandmarkDefaultIcon);
|
|
146 |
}
|
|
147 |
}
|
|
148 |
else
|
|
149 |
{
|
|
150 |
iconListIndex = iIconMgr->GetDefaultIconL(
|
|
151 |
MLmkSelectorIconMgr::ELandmarkDefaultIcon);
|
|
152 |
}
|
|
153 |
|
|
154 |
CLmkLandmarkUiItem* uiItem = CLmkLandmarkUiItem::NewL(landmark,
|
|
155 |
iconListIndex);
|
|
156 |
CleanupStack::Pop(); // landmark, ownership transferred
|
|
157 |
return uiItem;
|
|
158 |
}
|
|
159 |
|
|
160 |
// ---------------------------------------------------------
|
|
161 |
// CLmkSearchedLmListProvider::PrepareListL
|
|
162 |
// ---------------------------------------------------------
|
|
163 |
//
|
|
164 |
void CLmkSearchedLmListProvider::PrepareListL()
|
|
165 |
{
|
|
166 |
DEBUG( CLmkSearchedLmListProvider::PrepareListL start );
|
|
167 |
iCount = 0;
|
|
168 |
|
|
169 |
iDb.SetPartialReadParametersL(*iReadParams);
|
|
170 |
|
|
171 |
TPosLmSortPref sortOrder(CPosLandmark::ELandmarkName,
|
|
172 |
TPosLmSortPref::EAscending);
|
|
173 |
CPosLmOperation* operation = iSearch->StartLandmarkSearchL(iCriteria,
|
|
174 |
sortOrder);
|
|
175 |
CleanupStack::PushL(operation);
|
|
176 |
if (iSearchAO)
|
|
177 |
{
|
|
178 |
iSearchAO->StopOperation();
|
|
179 |
delete iSearchAO; // cancel possibly pending operation
|
|
180 |
iSearchAO = NULL;
|
|
181 |
}
|
|
182 |
iSearchAO = CLmkAOOperation::NewL(operation, *this,
|
|
183 |
MLmkAOOperationObserver::ESearch, iOperationNotInUse);
|
|
184 |
iOperationNotInUse = ETrue;
|
|
185 |
CleanupStack::Pop(operation); // ownership transferred
|
|
186 |
iSearchAO->StartOperation();
|
|
187 |
DEBUG( CLmkSearchedLmListProvider::PrepareListL End );
|
|
188 |
}
|
|
189 |
|
|
190 |
// -----------------------------------------------------------------------------
|
|
191 |
// CLmkSearchedLmListProvider::PrepareListL
|
|
192 |
// -----------------------------------------------------------------------------
|
|
193 |
//
|
|
194 |
TBool CLmkSearchedLmListProvider::PrepareListL(const TDesC& aSearchPattern,
|
|
195 |
TBool aSearchOnlyInPreviousMatches)
|
|
196 |
{
|
|
197 |
iCount = 0;
|
|
198 |
iRequestFromFindBox = ETrue;
|
|
199 |
iOperationNotInUse = ETrue;
|
|
200 |
iIsSecondSearchStarted = EFalse;
|
|
201 |
DEBUG1( CLmkSearchedLmListProvider::PrepareListL 2 start with aSearchPattern = %d,aSearchPattern.Length());
|
|
202 |
|
|
203 |
if (aSearchPattern.Compare(KDefaultTextCriteria) == 0
|
|
204 |
|| aSearchPattern.Length() <= 0)
|
|
205 |
{
|
|
206 |
PrepareListL();
|
|
207 |
iRequestFromFindBox = EFalse;
|
|
208 |
return ETrue;
|
|
209 |
}
|
|
210 |
|
|
211 |
// We need to cancel if we are searching/reading landmarks.
|
|
212 |
if (iSearchAO)
|
|
213 |
{
|
|
214 |
iSearchAO->StopOperation();
|
|
215 |
delete iSearchAO; // cancel possibly pending operation
|
|
216 |
iSearchAO = NULL;
|
|
217 |
}
|
|
218 |
|
|
219 |
// Create the composite criterion
|
|
220 |
CPosLmCompositeCriteria* compCrit = CPosLmCompositeCriteria::NewLC(
|
|
221 |
CPosLmCompositeCriteria::ECompositionOR);
|
|
222 |
|
|
223 |
// Create the text search criterion and add it to composite
|
|
224 |
CPosLmTextCriteria* textCrit1 = CPosLmTextCriteria::NewLC();
|
|
225 |
|
|
226 |
const TInt KExtraChars = 3; // 2 chars wildcards
|
|
227 |
HBufC* filterBuf = HBufC::NewLC(aSearchPattern.Length() + KExtraChars);
|
|
228 |
TPtr filter = filterBuf->Des();
|
|
229 |
filter.Copy(KSpaceTextCriteria);
|
|
230 |
filter.Append(aSearchPattern);
|
|
231 |
|
|
232 |
textCrit1->SetTextL(filter);
|
|
233 |
textCrit1->SetAttributesToSearch(CPosLandmark::ELandmarkName);
|
|
234 |
|
|
235 |
User::LeaveIfError(compCrit->AddArgument(textCrit1));
|
|
236 |
// Ownership of the text criterion has been passed to the composite
|
|
237 |
CleanupStack::PopAndDestroy(filterBuf);
|
|
238 |
CleanupStack::Pop(textCrit1);
|
|
239 |
|
|
240 |
// Create the text search criterion and add it to composite
|
|
241 |
CPosLmTextCriteria* textCrit2 = CPosLmTextCriteria::NewLC();
|
|
242 |
textCrit2->SetTextL(aSearchPattern);
|
|
243 |
textCrit2->SetAttributesToSearch(CPosLandmark::ELandmarkName);
|
|
244 |
|
|
245 |
User::LeaveIfError(compCrit->AddArgument(textCrit2));
|
|
246 |
// Ownership of the text criterion has been passed to the composite
|
|
247 |
CleanupStack::Pop(textCrit2);
|
|
248 |
|
|
249 |
iDb.SetPartialReadParametersL(*iReadParams);
|
|
250 |
|
|
251 |
TPosLmSortPref sortOrder(CPosLandmark::ELandmarkName,
|
|
252 |
TPosLmSortPref::EAscending);
|
|
253 |
// Start the search
|
|
254 |
// Create search operation
|
|
255 |
CPosLmOperation* operation = iSearch->StartLandmarkSearchL(*compCrit,
|
|
256 |
sortOrder, aSearchOnlyInPreviousMatches);
|
|
257 |
|
|
258 |
CleanupStack::PopAndDestroy(compCrit);
|
|
259 |
CleanupStack::PushL(operation);
|
|
260 |
|
|
261 |
iSearchAO = CLmkAOOperation::NewL(operation, *this,
|
|
262 |
MLmkAOOperationObserver::ESearch, ETrue);
|
|
263 |
CleanupStack::Pop(operation); // ownership transferred
|
|
264 |
|
|
265 |
iSearchAO->StartOperation();
|
|
266 |
DEBUG( CLmkSearchedLmListProvider::PrepareListL 2 End );
|
|
267 |
return ETrue;
|
|
268 |
}
|
|
269 |
|
|
270 |
// ---------------------------------------------------------
|
|
271 |
// CLmkSearchedLmListProvider::StartSecondSearchL
|
|
272 |
// ---------------------------------------------------------
|
|
273 |
//
|
|
274 |
void CLmkSearchedLmListProvider::StartSecondSearchL()
|
|
275 |
{
|
|
276 |
DEBUG( CLmkSearchedLmListProvider::StartSecondSearchL start );
|
|
277 |
|
|
278 |
iIsSecondSearchStarted = ETrue;
|
|
279 |
|
|
280 |
// Create the composite criterion
|
|
281 |
CPosLmCompositeCriteria* compCrit = CPosLmCompositeCriteria::NewLC(
|
|
282 |
CPosLmCompositeCriteria::ECompositionAND);
|
|
283 |
|
|
284 |
// Create the category search criterion and add it to composite
|
|
285 |
CPosLmCategoryCriteria* catCrit = CPosLmCategoryCriteria::NewLC();
|
|
286 |
catCrit->SetCategoryItemId(
|
|
287 |
(static_cast<CPosLmCategoryCriteria&> (iCriteria)).CategoryItemId());
|
|
288 |
|
|
289 |
User::LeaveIfError(compCrit->AddArgument(catCrit));
|
|
290 |
// Ownership of the category criterion has been passed to the composite
|
|
291 |
CleanupStack::Pop(catCrit);
|
|
292 |
|
|
293 |
// Create the text search criterion and add it to composite
|
|
294 |
CPosLmIdListCriteria* idListCrit = CPosLmIdListCriteria::NewLC();
|
|
295 |
idListCrit->SetLandmarkIdsL(iIdArray);
|
|
296 |
|
|
297 |
User::LeaveIfError(compCrit->AddArgument(idListCrit));
|
|
298 |
// Ownership of the text criterion has been passed to the composite
|
|
299 |
CleanupStack::Pop(idListCrit);
|
|
300 |
|
|
301 |
iDb.SetPartialReadParametersL(*iReadParams);
|
|
302 |
|
|
303 |
TPosLmSortPref sortOrder(CPosLandmark::ELandmarkName,
|
|
304 |
TPosLmSortPref::EAscending);
|
|
305 |
// Start the search
|
|
306 |
// Create search operation
|
|
307 |
CPosLmOperation* operation = iSearch->StartLandmarkSearchL(*compCrit,
|
|
308 |
sortOrder);
|
|
309 |
|
|
310 |
CleanupStack::PopAndDestroy(compCrit);
|
|
311 |
CleanupStack::PushL(operation);
|
|
312 |
|
|
313 |
iSearchAO = CLmkAOOperation::NewL(operation, *this,
|
|
314 |
MLmkAOOperationObserver::ESearch, ETrue);
|
|
315 |
CleanupStack::Pop(operation); // ownership transferred
|
|
316 |
|
|
317 |
iSearchAO->StartOperation();
|
|
318 |
DEBUG( CLmkSearchedLmListProvider::StartSecondSearchL End );
|
|
319 |
}
|
|
320 |
|
|
321 |
// ---------------------------------------------------------
|
|
322 |
// CLmkSearchedLmListProvider::HandleOperationL
|
|
323 |
// ---------------------------------------------------------
|
|
324 |
//
|
|
325 |
void CLmkSearchedLmListProvider::HandleOperationL(TOperationTypes aType,
|
|
326 |
TReal32 aProgress, TInt aStatus)
|
|
327 |
{
|
|
328 |
DEBUG1( CLmkSearchedLmListProvider::HandleOperationL start aType=%d,aType);
|
|
329 |
if (aType == MLmkAOOperationObserver::EDeleteLandmarks)
|
|
330 |
{
|
|
331 |
return;
|
|
332 |
}
|
|
333 |
if (aType == MLmkAOOperationObserver::ERemoveCategory)
|
|
334 |
{
|
|
335 |
return;
|
|
336 |
}
|
|
337 |
if (aType == MLmkAOOperationObserver::ESearch)
|
|
338 |
{
|
|
339 |
ReadItemsToArrayL();
|
|
340 |
if (aStatus == KErrNone)
|
|
341 |
{
|
|
342 |
if (iSearchAO)
|
|
343 |
{
|
|
344 |
iSearchAO->StopOperation();
|
|
345 |
delete iSearchAO;
|
|
346 |
iSearchAO = NULL;
|
|
347 |
}
|
|
348 |
|
|
349 |
// reset operation values
|
|
350 |
iOperationCmd = ELmkCmdStopOperation;//temp default value
|
|
351 |
iCount = 0;
|
|
352 |
|
|
353 |
DEBUG2( CLmkSearchedLmListProvider::HandleOperationL iRequestFromFindBox=%d iIsSecondSearchStarted=%d
|
|
354 |
,iRequestFromFindBox,iIsSecondSearchStarted);
|
|
355 |
|
|
356 |
if (iRequestFromFindBox && iIsSecondSearchStarted == EFalse)
|
|
357 |
{
|
|
358 |
DEBUG( CLmkSearchedLmListProvider::HandleOperationL start secondsearch );
|
|
359 |
StartSecondSearchL();
|
|
360 |
return;
|
|
361 |
}
|
|
362 |
|
|
363 |
DEBUG( CLmkSearchedLmListProvider::HandleOperationL refresh list );
|
|
364 |
|
|
365 |
iIsSecondSearchStarted = EFalse;
|
|
366 |
|
|
367 |
if (iOperationNotInUse == EFalse)
|
|
368 |
{
|
|
369 |
NotifyObservers(ELmkEventItemAdditionComplete);
|
|
370 |
}
|
|
371 |
else
|
|
372 |
{
|
|
373 |
if (iRequestFromFindBox)
|
|
374 |
{
|
|
375 |
NotifyObservers(ELmkEventFindListReady);
|
|
376 |
}
|
|
377 |
else
|
|
378 |
{
|
|
379 |
NotifyObservers(ELmkEventListReady);
|
|
380 |
}
|
|
381 |
}
|
|
382 |
|
|
383 |
iOperationNotInUse = ETrue;
|
|
384 |
|
|
385 |
if (iCatDelete)
|
|
386 |
{
|
|
387 |
NotifyObservers(ELmkEventCategoryDeleted);
|
|
388 |
iCatDelete = EFalse;
|
|
389 |
}
|
|
390 |
else if (iCatUpdate)
|
|
391 |
{
|
|
392 |
NotifyObservers(ELmkEventCategoryUpdated);
|
|
393 |
iCatUpdate = EFalse;
|
|
394 |
}
|
|
395 |
|
|
396 |
if (iItemsDeleted < iItemsToDelete)
|
|
397 |
{
|
|
398 |
PrepareForDeleteL();
|
|
399 |
}
|
|
400 |
else
|
|
401 |
{
|
|
402 |
if (iWaitNote)
|
|
403 |
{
|
|
404 |
iWaitNote->ProcessFinishedL();
|
|
405 |
iWaitNote = NULL;
|
|
406 |
}
|
|
407 |
}
|
|
408 |
return;
|
|
409 |
} // end of if ( aStatus == KErrNone )
|
|
410 |
|
|
411 |
if (iCount == ELmkStepOne || iCount == ELmkStepTwo)
|
|
412 |
{
|
|
413 |
if (iOperationNotInUse == EFalse)
|
|
414 |
{
|
|
415 |
NotifyObservers(ELmkEventItemAdditionComplete);
|
|
416 |
}
|
|
417 |
else
|
|
418 |
{
|
|
419 |
if (iRequestFromFindBox)
|
|
420 |
{
|
|
421 |
NotifyObservers(ELmkEventFindListReady);
|
|
422 |
}
|
|
423 |
else
|
|
424 |
{
|
|
425 |
NotifyObservers(ELmkEventListReady);
|
|
426 |
}
|
|
427 |
}
|
|
428 |
iRequestFromFindBox = EFalse;
|
|
429 |
iOperationNotInUse = EFalse;
|
|
430 |
}
|
|
431 |
}
|
|
432 |
else
|
|
433 |
{ // This is not this classes' operation
|
|
434 |
CLmkLmItemListProvider::HandleOperationL(aType, aProgress, aStatus);
|
|
435 |
}
|
|
436 |
}
|
|
437 |
|
|
438 |
// ---------------------------------------------------------
|
|
439 |
// CLmkSearchedLmListProvider::HandleDatabaseEvent
|
|
440 |
// ---------------------------------------------------------
|
|
441 |
//
|
|
442 |
void CLmkSearchedLmListProvider::HandleDatabaseEvent(TPosLmEvent& aEvent)
|
|
443 |
{
|
|
444 |
iCatDelete = EFalse;
|
|
445 |
|
|
446 |
TBool needRefresh = ETrue;
|
|
447 |
|
|
448 |
// check any items are selected to do operations like iconchanges or add to category.
|
|
449 |
if (iSelectedItemsCount > 0 && iOperationCmd != ELmkCmdAddToCat
|
|
450 |
&& iOperationCmd != ERemoveFromCat)
|
|
451 |
{
|
|
452 |
iCount++;
|
|
453 |
if (iSelectedItemsCount == iCount)
|
|
454 |
{
|
|
455 |
iSelectedItemsCount = 0;
|
|
456 |
iCount = 0;
|
|
457 |
}
|
|
458 |
needRefresh = EFalse;
|
|
459 |
}
|
|
460 |
|
|
461 |
switch (aEvent.iEventType)
|
|
462 |
{
|
|
463 |
case EPosLmEventLandmarkUpdated: // lm icon changes, lm renaming
|
|
464 |
case EPosLmEventLandmarkUnknownChanges: // lm multiple deletion, lm add to category
|
|
465 |
case EPosLmEventUnknownChanges:
|
|
466 |
case EPosLmEventLandmarkCreated:
|
|
467 |
case EPosLmEventCategoryDeleted:
|
|
468 |
case EPosLmEventCategoryUpdated:
|
|
469 |
{
|
|
470 |
iOperationNotInUse = EFalse;
|
|
471 |
if (aEvent.iEventType == EPosLmEventCategoryDeleted)
|
|
472 |
{
|
|
473 |
iCatDelete = ETrue;
|
|
474 |
}
|
|
475 |
if (aEvent.iEventType == EPosLmEventCategoryUpdated)
|
|
476 |
{
|
|
477 |
iCatUpdate = ETrue;
|
|
478 |
}
|
|
479 |
|
|
480 |
if (needRefresh)
|
|
481 |
{
|
|
482 |
if (iSearchAO)
|
|
483 |
{
|
|
484 |
iSearchAO->StopOperation();
|
|
485 |
delete iSearchAO;
|
|
486 |
iSearchAO = NULL;
|
|
487 |
}
|
|
488 |
iOperationNotInUse = EFalse;
|
|
489 |
TInt err = KErrNone;
|
|
490 |
do
|
|
491 |
{
|
|
492 |
TRAP( err, PrepareListL() );
|
|
493 |
}
|
|
494 |
while (err == KErrLocked);
|
|
495 |
if (err)
|
|
496 |
{
|
|
497 |
HandleError(err);
|
|
498 |
}
|
|
499 |
}
|
|
500 |
else
|
|
501 |
{
|
|
502 |
NotifyObservers(ELmkEventListReady);
|
|
503 |
}
|
|
504 |
break;
|
|
505 |
}
|
|
506 |
case EPosLmEventLandmarkDeleted:
|
|
507 |
{
|
|
508 |
TInt index = iIdArray.Find(aEvent.iLandmarkItemId);
|
|
509 |
if (index != KErrNotFound && index < iIdArray.Count())
|
|
510 |
{
|
|
511 |
iIdArray.Remove(index);
|
|
512 |
NotifyObservers(ELmkEventListReady);
|
|
513 |
}
|
|
514 |
break;
|
|
515 |
}
|
|
516 |
default:
|
|
517 |
{ // Not interesting event for this provider
|
|
518 |
break;
|
|
519 |
}
|
|
520 |
}
|
|
521 |
// Remember to call base class observer method too
|
|
522 |
CLmkLmItemListProvider::HandleDatabaseEvent(aEvent);
|
|
523 |
}
|
|
524 |
|
|
525 |
// ---------------------------------------------------------
|
|
526 |
// CLmkSearchedLmListProvider::ReadItemsToArrayL
|
|
527 |
// ---------------------------------------------------------
|
|
528 |
//
|
|
529 |
void CLmkSearchedLmListProvider::ReadItemsToArrayL()
|
|
530 |
{
|
|
531 |
iIdArray.Reset();
|
|
532 |
CPosLmItemIterator* iterator = iSearch->MatchIteratorL();
|
|
533 |
CleanupStack::PushL(iterator);
|
|
534 |
iCount = iterator->NumOfItemsL();
|
|
535 |
if (iCount > 0)
|
|
536 |
{ // can only be called if there are some items
|
|
537 |
iterator->GetItemIdsL(iIdArray, 0, iCount); // array is first reseted
|
|
538 |
}
|
|
539 |
CleanupStack::PopAndDestroy(iterator);
|
|
540 |
}
|
|
541 |
|
|
542 |
// ---------------------------------------------------------
|
|
543 |
// CLmkSearchedLmListProvider::RemoveLandmarksL
|
|
544 |
// ---------------------------------------------------------
|
|
545 |
//
|
|
546 |
void CLmkSearchedLmListProvider::RemoveLandmarksL(
|
|
547 |
const RArray<TPosLmItemId>& aSelectedItems)
|
|
548 |
{
|
|
549 |
iItemsToDelete = aSelectedItems.Count();
|
|
550 |
iSelectedForDelete.Reset();
|
|
551 |
for (TInt i = 0; i < iItemsToDelete; i++)
|
|
552 |
iSelectedForDelete.Append(aSelectedItems[i]);
|
|
553 |
iItemsDeleted = 0;
|
|
554 |
iIsRemoveLandmarks = ETrue;
|
|
555 |
|
|
556 |
if (iWaitNote)
|
|
557 |
{
|
|
558 |
delete iWaitNote;
|
|
559 |
iWaitNote = NULL;
|
|
560 |
}
|
|
561 |
PrepareForDeleteL();
|
|
562 |
}
|
|
563 |
|
|
564 |
// ---------------------------------------------------------
|
|
565 |
// CLmkSearchedLmListProvider::PrepareForDelete
|
|
566 |
// ---------------------------------------------------------
|
|
567 |
//
|
|
568 |
void CLmkSearchedLmListProvider::PrepareForDeleteL()
|
|
569 |
{
|
|
570 |
RArray<TPosLmItemId> lmItemsChunk;
|
|
571 |
TInt count = iItemsDeleted;
|
|
572 |
if (iItemsToDelete > (iItemsDeleted + 10))
|
|
573 |
{
|
|
574 |
iItemsDeleted = iItemsDeleted + 10;
|
|
575 |
}
|
|
576 |
else
|
|
577 |
{
|
|
578 |
iItemsDeleted = iItemsDeleted + (iItemsToDelete - iItemsDeleted);
|
|
579 |
}
|
|
580 |
|
|
581 |
for (TInt i = count; i < iItemsDeleted; i++)
|
|
582 |
{
|
|
583 |
lmItemsChunk.Append(iSelectedForDelete[i]);
|
|
584 |
}
|
|
585 |
|
|
586 |
CPosLmOperation* operation = NULL;
|
|
587 |
if (iType == MLmkAOOperationObserver::EDeleteLandmarks)
|
|
588 |
{
|
|
589 |
operation = iDb.RemoveLandmarksL(lmItemsChunk);
|
|
590 |
}
|
|
591 |
if (iType == MLmkAOOperationObserver::ERemoveCategory)
|
|
592 |
{
|
|
593 |
CPosLmCategoryManager* mgr = CPosLmCategoryManager::NewL(iDb);
|
|
594 |
CleanupStack::PushL(mgr);
|
|
595 |
operation = mgr->RemoveCategoryFromLandmarksL(iCategoryId,
|
|
596 |
lmItemsChunk);
|
|
597 |
CleanupStack::PopAndDestroy();//mgr
|
|
598 |
}
|
|
599 |
User::LeaveIfNull(operation);
|
|
600 |
|
|
601 |
CleanupStack::PushL(operation);
|
|
602 |
iSearchAO = CLmkAOOperation::NewL(operation, *this, iType, EFalse);
|
|
603 |
CleanupStack::Pop(operation); // ownership transferred
|
|
604 |
|
|
605 |
if (iSearchAO)
|
|
606 |
{
|
|
607 |
iSearchAO->StartOperation();
|
|
608 |
|
|
609 |
if (!iWaitNote)
|
|
610 |
{
|
|
611 |
iWaitNote = new (ELeave) CAknWaitDialog(NULL, ETrue);
|
|
612 |
if (!iWaitNote->ExecuteLD(R_LMK_PROCESSING_WAIT_NOTE))
|
|
613 |
{
|
|
614 |
iSearchAO->StopOperation();
|
|
615 |
delete iSearchAO;
|
|
616 |
iSearchAO = NULL;
|
|
617 |
iWaitNote = NULL;
|
|
618 |
}
|
|
619 |
}
|
|
620 |
}
|
|
621 |
|
|
622 |
lmItemsChunk.Close();
|
|
623 |
}
|
|
624 |
|
|
625 |
// End of File
|