|
1 /* |
|
2 * Copyright (c) 2002-2005 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: This file contains methods of selector's base class |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 // INCLUDE FILES |
|
24 #include <aknsfld.h> |
|
25 #include <lmkui.rsg> |
|
26 #include <StringLoader.h> |
|
27 #include <AknQueryDialog.h> |
|
28 #include <EPos_CPosLandmarkDatabase.h> |
|
29 #include <sysutil.h> |
|
30 #include "landmarks.hrh" |
|
31 #include "LmkConsts.h" |
|
32 #include "LmkNotes.h" |
|
33 #include "CLmkDbUtils.h" |
|
34 #include "CLmkLocationService.h" |
|
35 #include <CLmkEditorDlg.h> // TLmkEditorAttributes, TLmkEditorMode |
|
36 #include "CLmkLmItemListProvider.h" |
|
37 #include "CLmkLmItemListMemento.h" |
|
38 #include "CLmkEditorImpl.h" |
|
39 #include "CLmkAppLmItemSelectorImpl.h" |
|
40 #include "CLmkLocSettingLauncher.h" |
|
41 #include "lmkicondialog.h" |
|
42 #include "lmkwaitdlglauncher.h" // Wait dialog launcher |
|
43 #include <lmkerrors.h> |
|
44 |
|
45 |
|
46 const TInt KFatClusterSize = 2048; |
|
47 |
|
48 #if defined(_DEBUG) |
|
49 |
|
50 // CONSTANTS |
|
51 /// Unnamed namespace for local definitions |
|
52 namespace { |
|
53 |
|
54 _LIT( KPanicMsg, "CLmkAppLmItemSelectorImpl" ); |
|
55 |
|
56 void Panic( TPanicCode aReason ) |
|
57 { |
|
58 User::Panic( KPanicMsg, aReason ); |
|
59 } |
|
60 } // namespace |
|
61 |
|
62 #endif |
|
63 // ============================ MEMBER FUNCTIONS =============================== |
|
64 |
|
65 // ----------------------------------------------------------------------------- |
|
66 // CLmkAppLmItemSelectorImpl::CLmkAppLmItemSelectorImpl |
|
67 // C++ default constructor can NOT contain any code, that |
|
68 // might leave. |
|
69 // ----------------------------------------------------------------------------- |
|
70 // |
|
71 CLmkAppLmItemSelectorImpl::CLmkAppLmItemSelectorImpl( |
|
72 CPosLandmarkDatabase& aDb, |
|
73 CLmkSender& aSender, |
|
74 TBool aFindBox ) |
|
75 : CLmkAppSelectorImplBase( aDb, aFindBox ), |
|
76 iSender( aSender ), |
|
77 iNewListBoxItemAdded(EFalse) |
|
78 { |
|
79 } |
|
80 |
|
81 // ----------------------------------------------------------------------------- |
|
82 // CLmkAppLmItemSelectorImpl::BaseConstructL |
|
83 // Symbian 2nd phase constructor can leave. |
|
84 // ----------------------------------------------------------------------------- |
|
85 // |
|
86 void CLmkAppLmItemSelectorImpl::BaseConstructL() |
|
87 { |
|
88 CLmkAppSelectorImplBase::BaseConstructL(); |
|
89 iDbUtils = CLmkDbUtils::NewL( iDb, *this, ETrue ); |
|
90 iWaitDialogLauncher = CLmkWaitDialogLauncher::NewL(); |
|
91 iWaitDialogLauncher->SetObserver(this); |
|
92 } |
|
93 |
|
94 // ----------------------------------------------------------------------------- |
|
95 // CLmkAppLmItemSelectorImpl::~CLmkAppLmItemSelectorImpl |
|
96 // ----------------------------------------------------------------------------- |
|
97 // |
|
98 CLmkAppLmItemSelectorImpl::~CLmkAppLmItemSelectorImpl() |
|
99 { |
|
100 delete iWaitDialogLauncher; |
|
101 delete iLocationService; |
|
102 delete iDbUtils; |
|
103 delete iLauncher; |
|
104 iMarkedItemIds.Close(); |
|
105 } |
|
106 |
|
107 // ----------------------------------------------------------------------------- |
|
108 // CLmkAppLmItemSelectorImpl::LmItemListProvider |
|
109 // ----------------------------------------------------------------------------- |
|
110 // |
|
111 CLmkLmItemListProvider& CLmkAppLmItemSelectorImpl::LmItemListProvider() |
|
112 { |
|
113 __ASSERT_DEBUG( iListProvider, Panic( KLmkPanicNullMember ) ); |
|
114 return static_cast<CLmkLmItemListProvider&>( *iListProvider ); |
|
115 } |
|
116 |
|
117 // ----------------------------------------------------------------------------- |
|
118 // CLmkAppLmItemSelectorImpl::CurrentCategoryId |
|
119 // ----------------------------------------------------------------------------- |
|
120 // |
|
121 TInt CLmkAppLmItemSelectorImpl::CurrentCategoryId() |
|
122 { |
|
123 TInt catId = KPosLmNullItemId; |
|
124 TRAP_IGNORE(catId = SelectedIdL()); |
|
125 return catId; |
|
126 } |
|
127 |
|
128 // ----------------------------------------------------------------------------- |
|
129 // CLmkAppLmItemSelectorImpl::ChangeIconCmdL |
|
130 // ----------------------------------------------------------------------------- |
|
131 // |
|
132 void CLmkAppLmItemSelectorImpl::ChangeIconCmdL() |
|
133 { |
|
134 |
|
135 TInt lSelectedIconIndex(0); |
|
136 CLmkIconMapDialog* dialog = new(ELeave) CLmkIconMapDialog( lSelectedIconIndex ); |
|
137 if (dialog->ExecuteLD(R_LMK_ICON_TABLE_DIALOG) ) |
|
138 { |
|
139 if(lSelectedIconIndex >= 0) |
|
140 { |
|
141 // icon file also contains masks, therefore 2* |
|
142 TInt iconIndex = 2*lSelectedIconIndex; |
|
143 TInt maskIndex = 2*lSelectedIconIndex; |
|
144 |
|
145 RArray<TPosLmItemId>& markedItemIds = MarkedItemIdsL(); |
|
146 RFs fs; |
|
147 User::LeaveIfError(fs.Connect()); |
|
148 CleanupClosePushL( fs ); |
|
149 |
|
150 if ( SysUtil::DiskSpaceBelowCriticalLevelL( &fs, sizeof( CPosLandmark ), EDriveC ) ) |
|
151 { |
|
152 CleanupStack::PopAndDestroy(); // fs |
|
153 User::LeaveNoMemory(); |
|
154 } |
|
155 else |
|
156 { |
|
157 TInt markedCount = markedItemIds.Count(); |
|
158 if ( markedCount ) |
|
159 { |
|
160 LmItemListProvider().SetSelectedItemsCount(markedCount); |
|
161 ChangeIconsL( markedItemIds, iconIndex + EMbmLmkuiQgn_prop_lm_transport, maskIndex + EMbmLmkuiQgn_prop_lm_transport_mask); // subclass implements |
|
162 iListBox->ClearSelection(); |
|
163 } |
|
164 else |
|
165 { |
|
166 LmItemListProvider().SetSelectedItemsCount(1); |
|
167 ChangeIconL( SelectedIdL(),(iconIndex + EMbmLmkuiQgn_prop_lm_transport),(maskIndex + EMbmLmkuiQgn_prop_lm_transport_mask)); // subclass implements |
|
168 } |
|
169 } |
|
170 CleanupStack::PopAndDestroy(); // fs |
|
171 } |
|
172 } |
|
173 lSelectedIconIndex = 0; |
|
174 |
|
175 } |
|
176 |
|
177 // ----------------------------------------------------------------------------- |
|
178 // CLmkAppLmItemSelectorImpl::MementoL |
|
179 // ----------------------------------------------------------------------------- |
|
180 // |
|
181 MLmkListMemento* CLmkAppLmItemSelectorImpl::MementoL() |
|
182 { |
|
183 CLmkLmItemListMemento* memento = CLmkLmItemListMemento::NewL(); |
|
184 return memento; |
|
185 } |
|
186 |
|
187 // ----------------------------------------------------------------------------- |
|
188 // CLmkAppLmItemSelectorImpl::ProcessCommandL |
|
189 // ----------------------------------------------------------------------------- |
|
190 // |
|
191 void CLmkAppLmItemSelectorImpl::ProcessCommandL( TInt aCommandId ) |
|
192 { |
|
193 switch( aCommandId ) |
|
194 { |
|
195 case ELmkCmdNewLmCurrentLocation: |
|
196 { |
|
197 RequestCurrenLocationL(); |
|
198 break; |
|
199 } |
|
200 case ELmkCmdNewLmEmpty: |
|
201 { |
|
202 NewLandmarkCmdL(); |
|
203 break; |
|
204 } |
|
205 case ELmkCmdDeleteLm: |
|
206 { |
|
207 // This is left empty intentionally, if subclasses do not |
|
208 // implement handling of this command then deletion using |
|
209 // backspace key is not supported for that selector. |
|
210 break; |
|
211 } |
|
212 case ELmkCmdLaunchPositionSettings: |
|
213 { |
|
214 LaunchPosSettingsL(); |
|
215 break; |
|
216 } |
|
217 default: |
|
218 { |
|
219 break; |
|
220 } |
|
221 } |
|
222 } |
|
223 |
|
224 // ----------------------------------------------------------------------------- |
|
225 // CLmkAppLmItemSelectorImpl::NotifyL |
|
226 // ----------------------------------------------------------------------------- |
|
227 // |
|
228 void CLmkAppLmItemSelectorImpl::NotifyL( const TInt aStatus ) |
|
229 { |
|
230 // Stop the running wait dialog |
|
231 TInt buttonId = iWaitDialogLauncher->StopWaitDialogL(); |
|
232 if( EEikBidCancel != buttonId ) |
|
233 { |
|
234 switch( aStatus ) |
|
235 { |
|
236 case KErrNone: |
|
237 case KPositionPartialUpdate: |
|
238 { |
|
239 if(iLocationService) |
|
240 { |
|
241 TPosition position = iLocationService->CurrentPosition(); |
|
242 CreateLmkFromCurrentLocationL( position ); |
|
243 } |
|
244 break; |
|
245 } |
|
246 default: |
|
247 { |
|
248 break; |
|
249 } |
|
250 } |
|
251 } |
|
252 delete iLocationService; |
|
253 iLocationService = NULL; |
|
254 } |
|
255 |
|
256 // ----------------------------------------------------------------------------- |
|
257 // CLmkAppLmItemSelectorImpl::NotifyErrorL |
|
258 // ----------------------------------------------------------------------------- |
|
259 // |
|
260 void CLmkAppLmItemSelectorImpl::NotifyErrorL( TInt aErrorCode ) |
|
261 { |
|
262 |
|
263 // Stop the running wait dialog |
|
264 TInt buttonId = iWaitDialogLauncher->StopWaitDialogL(); |
|
265 |
|
266 delete iLocationService; |
|
267 iLocationService = NULL; |
|
268 |
|
269 if( EEikBidCancel != buttonId ) |
|
270 { |
|
271 switch( aErrorCode ) |
|
272 { |
|
273 case KPositionQualityLoss: |
|
274 case KErrTimedOut: |
|
275 case KErrNotFound: // No PSY selected. |
|
276 case KErrUnknown: |
|
277 case KErrCancel: |
|
278 case KErrArgument: |
|
279 default: |
|
280 // The above errors are because of location request failures |
|
281 // Ask user to retry location request |
|
282 { |
|
283 if ( LmkNotes::MessageQueryWithLinkL(iEnv,R_LMK_MSG_QUERY_HEADING_PANE_TEXT, |
|
284 R_LMK_CONF_RETRY_LOCATION_REQUEST,R_LMK_REQUEST_FAIL_MORE_INFO, |
|
285 MessageQueryCallBack) ) |
|
286 { |
|
287 if( iLocationService ) |
|
288 { |
|
289 delete iLocationService; |
|
290 iLocationService = NULL; |
|
291 } |
|
292 RequestCurrenLocationL(); |
|
293 } |
|
294 } |
|
295 } |
|
296 } |
|
297 } |
|
298 |
|
299 // ----------------------------------------------------------------------------- |
|
300 // CLmkAppLmItemSelectorImpl::SelectedIdL |
|
301 // ----------------------------------------------------------------------------- |
|
302 // |
|
303 TPosLmItemId CLmkAppLmItemSelectorImpl::SelectedIdL() |
|
304 { |
|
305 __ASSERT_DEBUG( iListBox, Panic( KLmkPanicNullMember ) ); |
|
306 TPosLmItemId selected( KPosLmNullItemId ); |
|
307 TInt currentItemIndex = iListBox->CurrentItemIndex(); |
|
308 if ( iFindBox ) |
|
309 { |
|
310 CAknFilteredTextListBoxModel* model = |
|
311 static_cast<CAknFilteredTextListBoxModel*>( iListBox->Model() ); |
|
312 TInt filteredItemIndex = |
|
313 model->Filter()->FilteredItemIndex( currentItemIndex ); |
|
314 LmItemListProvider().GetSelectedItemId( selected, filteredItemIndex ); |
|
315 } |
|
316 else |
|
317 { |
|
318 LmItemListProvider().GetSelectedItemId( selected, currentItemIndex ); |
|
319 } |
|
320 return selected; |
|
321 } |
|
322 |
|
323 // ----------------------------------------------------------------------------- |
|
324 // CLmkAppLmItemSelectorImpl::MarkedItemIdsL |
|
325 // ----------------------------------------------------------------------------- |
|
326 // |
|
327 RArray<TPosLmItemId>& CLmkAppLmItemSelectorImpl::MarkedItemIdsL() |
|
328 { |
|
329 __ASSERT_DEBUG( iListBox, Panic( KLmkPanicNullMember ) ); |
|
330 const CArrayFix<TInt>* markedIndexes = NULL; |
|
331 if ( iFindBox ) |
|
332 { |
|
333 CAknFilteredTextListBoxModel* model = |
|
334 static_cast<CAknFilteredTextListBoxModel*>( iListBox->Model() ); |
|
335 model->Filter()->UpdateSelectionIndexesL(); |
|
336 markedIndexes = model->Filter()->SelectionIndexes(); |
|
337 } |
|
338 else |
|
339 { |
|
340 markedIndexes = iListBox->SelectionIndexes(); |
|
341 } |
|
342 if( markedIndexes->Count() == LmItemListProvider().ItemCount() ) |
|
343 { |
|
344 LmItemListProvider().GetAllItemIdsL( iMarkedItemIds ); |
|
345 } |
|
346 else |
|
347 { |
|
348 LmItemListProvider().GetSelectedItemIdsL( iMarkedItemIds, *markedIndexes ); |
|
349 } |
|
350 return iMarkedItemIds; |
|
351 } |
|
352 |
|
353 // ----------------------------------------------------------------------------- |
|
354 // CLmkAppLmItemSelectorImpl::NewLandmarkCmdL |
|
355 // ----------------------------------------------------------------------------- |
|
356 // |
|
357 void CLmkAppLmItemSelectorImpl::NewLandmarkCmdL() |
|
358 { |
|
359 CPosLandmark* landmark = CPosLandmark::NewL(); |
|
360 CleanupStack::PushL( landmark ); |
|
361 InitialLandmarkL( landmark ); |
|
362 |
|
363 TInt BytesToWrite = CalculateLandmarkDisksize(*landmark); |
|
364 TChar DriveName = 'c'; |
|
365 DiskSpaceBelowCriticalLevelL(BytesToWrite, DriveName); |
|
366 |
|
367 ExecuteNewLandmarkEditorL( *landmark ); |
|
368 CleanupStack::PopAndDestroy( landmark ); |
|
369 } |
|
370 |
|
371 // ----------------------------------------------------------------------------- |
|
372 // CLmkAppLmItemSelectorImpl::DiskSpaceBelowCriticalLevelL |
|
373 // ----------------------------------------------------------------------------- |
|
374 // |
|
375 void CLmkAppLmItemSelectorImpl::DiskSpaceBelowCriticalLevelL( |
|
376 TInt aBytesToWrite, TChar aDrive) |
|
377 { |
|
378 RFs iFs; // File session |
|
379 User::LeaveIfError(iFs.Connect()); |
|
380 |
|
381 // Resource value is in kilobytes, convert to bytes. (* 1024) |
|
382 TInt iCriticalDiskLevel = 120 * 1024; |
|
383 TVolumeInfo* volumeInfo = new(ELeave) TVolumeInfo; |
|
384 CleanupStack::PushL(volumeInfo); |
|
385 TInt drive; |
|
386 |
|
387 User::LeaveIfError(iFs.CharToDrive(aDrive, drive)); |
|
388 User::LeaveIfError(iFs.Volume(*volumeInfo, drive)); |
|
389 |
|
390 // RFs allocates bytes in steps of 2048 bytes. Calculate the actual |
|
391 // bytes to write according to this. |
|
392 TInt bytesInLastCluster = aBytesToWrite % KFatClusterSize; |
|
393 TInt paddedBytesToFillCluster = 0; |
|
394 if (bytesInLastCluster > 0) |
|
395 { |
|
396 paddedBytesToFillCluster = KFatClusterSize - bytesInLastCluster; |
|
397 } |
|
398 |
|
399 TInt64* bytesToWrite= new(ELeave) TInt64(aBytesToWrite + paddedBytesToFillCluster); |
|
400 CleanupStack::PushL(bytesToWrite); |
|
401 TInt64* freeAfterWrite = new(ELeave) TInt64((*volumeInfo).iFree - (*bytesToWrite)); |
|
402 CleanupStack::PushL(freeAfterWrite); |
|
403 TInt64* limit = new(ELeave) TInt64(iCriticalDiskLevel); |
|
404 CleanupStack::PushL(limit); |
|
405 iFs.Close(); |
|
406 if ((*freeAfterWrite) < (*limit)) |
|
407 { |
|
408 User::Leave(KErrDiskFull); |
|
409 } |
|
410 CleanupStack::PopAndDestroy(4);//volumeInfo |
|
411 } |
|
412 |
|
413 // ----------------------------------------------------------------------------- |
|
414 // CLmkAppLmItemSelectorImpl::CalculateLandmarkDisksize |
|
415 // ----------------------------------------------------------------------------- |
|
416 // |
|
417 TInt CLmkAppLmItemSelectorImpl::CalculateLandmarkDisksize( |
|
418 const CPosLandmark& aLandmark) |
|
419 { |
|
420 // Constant for estimating disk size |
|
421 const TReal bytesToDisk = 4.4; |
|
422 // A bare landmark takes 44 bytes on disk |
|
423 const TInt bareLm = 44; |
|
424 // Adding 73 bytes when landmark have an icon. |
|
425 const TInt iconIncluded = 73; |
|
426 |
|
427 // Method variables |
|
428 TInt err = KErrNone; |
|
429 TReal result = 0; |
|
430 |
|
431 // Bare landmark |
|
432 result += bareLm * bytesToDisk; |
|
433 |
|
434 // Estimate location |
|
435 TLocality loc; |
|
436 err = aLandmark.GetPosition(loc); |
|
437 if (!err) |
|
438 { |
|
439 if (!TRealX(loc.Latitude()).IsNaN()) |
|
440 { |
|
441 // TReal64 |
|
442 result += bytesToDisk * bytesToDisk * 4; |
|
443 } |
|
444 if (!TRealX(loc.Longitude()).IsNaN()) |
|
445 { |
|
446 // TReal64 |
|
447 result += bytesToDisk * bytesToDisk * 4; |
|
448 } |
|
449 if (!TRealX(loc.Altitude()).IsNaN()) |
|
450 { |
|
451 // TReal32 |
|
452 result += bytesToDisk * bytesToDisk * 2; |
|
453 } |
|
454 if (!TRealX(loc.HorizontalAccuracy()).IsNaN()) |
|
455 { |
|
456 // TReal32 |
|
457 result += bytesToDisk * bytesToDisk * 2; |
|
458 } |
|
459 if (!TRealX(loc.VerticalAccuracy()).IsNaN()) |
|
460 { |
|
461 // TReal32 |
|
462 result += bytesToDisk * bytesToDisk * 2; |
|
463 } |
|
464 } |
|
465 |
|
466 // Calculate landmark coverage radius |
|
467 TReal32 real; |
|
468 err = aLandmark.GetCoverageRadius(real); |
|
469 if (!err) |
|
470 { |
|
471 result += bytesToDisk * bytesToDisk * 2; |
|
472 } |
|
473 |
|
474 // Calculate landmark name |
|
475 TPtrC des; |
|
476 err = aLandmark.GetLandmarkName(des); |
|
477 if (!err) |
|
478 { |
|
479 result += des.Length() * bytesToDisk * 2; |
|
480 } |
|
481 |
|
482 // Calculate landmark description |
|
483 err = aLandmark.GetLandmarkDescription(des); |
|
484 if (!err) |
|
485 { |
|
486 result += des.Length() * bytesToDisk * 2; |
|
487 } |
|
488 |
|
489 // Icon |
|
490 // Constants for adding a icon |
|
491 TInt iconIndex; |
|
492 TInt maskIndex; |
|
493 err = aLandmark.GetIcon(des, iconIndex, maskIndex); |
|
494 if (!err) |
|
495 { |
|
496 result += iconIncluded; |
|
497 } |
|
498 |
|
499 // Calculating position fields |
|
500 TInt nrFields = aLandmark.NumOfAvailablePositionFields(); |
|
501 TPositionFieldId fid = aLandmark.FirstPositionFieldId(); |
|
502 for (TInt j = 0; j < nrFields; j++) |
|
503 { |
|
504 err = aLandmark.GetPositionField(fid, des); |
|
505 if (!err) |
|
506 { |
|
507 result += des.Length() * bytesToDisk; |
|
508 } |
|
509 |
|
510 fid = aLandmark.NextPositionFieldId(fid); |
|
511 } |
|
512 |
|
513 return static_cast<TInt> (result); |
|
514 } |
|
515 |
|
516 // ----------------------------------------------------------------------------- |
|
517 // CLmkAppLmItemSelectorImpl::ExecuteNewLandmarkEditorL |
|
518 // ----------------------------------------------------------------------------- |
|
519 // |
|
520 void CLmkAppLmItemSelectorImpl::ExecuteNewLandmarkEditorL( |
|
521 CPosLandmark& aLandmark ) |
|
522 { |
|
523 TLmkEditorAttributes attributeFlags( CLmkEditorDlg::ELmkAll ); |
|
524 TLmkEditorMode editorMode( CLmkEditorDlg::ELmkEditor ); |
|
525 |
|
526 iNewLmkItemId = 0; |
|
527 |
|
528 if(iDlg) |
|
529 { |
|
530 delete iDlg; |
|
531 iDlg = NULL; |
|
532 } |
|
533 iDlg = CLmkEditorImpl::NewL( iDb, |
|
534 iSender, |
|
535 attributeFlags, |
|
536 editorMode, |
|
537 &iNewLmkItemId, |
|
538 &aLandmark ); |
|
539 if(iDlg->ExecuteLD()) |
|
540 { |
|
541 iNewListBoxItemAdded = ETrue; |
|
542 } |
|
543 iDlg = NULL; |
|
544 TInt searchTextLength = iSearchBox->TextLength(); |
|
545 iSearchBox->ResetL(); |
|
546 if( !iNewLmkItemId && searchTextLength > 0 ) |
|
547 { |
|
548 ProcessCommandL( ELmkCmdFindBoxSearchAfresh ); |
|
549 } |
|
550 iSearchBox->DrawNow(); |
|
551 } |
|
552 |
|
553 // ----------------------------------------------------------------------------- |
|
554 // CLmkAppLmItemSelectorImpl::RequestCurrenLocationL |
|
555 // ----------------------------------------------------------------------------- |
|
556 // |
|
557 void CLmkAppLmItemSelectorImpl::RequestCurrenLocationL() |
|
558 { |
|
559 HBufC* srvName = StringLoader::LoadLC( |
|
560 R_LMK_SERVICE_RULE_NAME, const_cast<CEikonEnv *>( iEnv )); |
|
561 |
|
562 iLocationService = CLmkLocationService::NewL(*srvName); |
|
563 CleanupStack::PopAndDestroy(srvName); //srvName |
|
564 iLocationService->SetObserver( *this ); |
|
565 |
|
566 iLocationService->LocationRequestL(); |
|
567 |
|
568 TRAPD( error, iWaitDialogLauncher->StartWaitDialogL()); |
|
569 if( error ) |
|
570 { |
|
571 delete iLocationService; |
|
572 iLocationService = NULL; |
|
573 |
|
574 User::Leave( error ); |
|
575 } |
|
576 } |
|
577 |
|
578 // ----------------------------------------------------------------------------- |
|
579 // CLmkAppLmItemSelectorImpl::CreateLmkFromCurrentLocationL |
|
580 // ----------------------------------------------------------------------------- |
|
581 // |
|
582 void CLmkAppLmItemSelectorImpl::CreateLmkFromCurrentLocationL( |
|
583 const TPosition& aPosition) |
|
584 { |
|
585 CPosLandmark* landmark = CPosLandmark::NewL(); |
|
586 CleanupStack::PushL( landmark ); |
|
587 landmark->SetPositionL( aPosition ); |
|
588 InitialLandmarkL( landmark ); |
|
589 ExecuteNewLandmarkEditorL( *landmark ); |
|
590 CleanupStack::PopAndDestroy( landmark ); |
|
591 } |
|
592 |
|
593 // ----------------------------------------------------------------------------- |
|
594 // CLmkAppLmItemSelectorImpl::UpdateMarkIndexAfterAdditionL |
|
595 // ----------------------------------------------------------------------------- |
|
596 // |
|
597 void CLmkAppLmItemSelectorImpl::UpdateMarkIndexAfterAdditionL( |
|
598 TInt aIndexToBeSelected ) |
|
599 { |
|
600 __ASSERT_DEBUG( iListBox, Panic( KLmkPanicNullMember ) ); |
|
601 CListBoxView* lListBoxView = ( CListBoxView* )NULL; |
|
602 lListBoxView = iListBox->View(); |
|
603 if( lListBoxView ) |
|
604 { |
|
605 //Fetching the array of marked item |
|
606 CArrayFix<TInt>* lActualSelectionArray = (CArrayFix<TInt>*)lListBoxView->SelectionIndexes(); |
|
607 if( lActualSelectionArray && (lActualSelectionArray->Count() > 0) ) |
|
608 { |
|
609 TInt lCnt(0); |
|
610 TInt lSelectedIndexCnt = lActualSelectionArray->Count(); |
|
611 /*Sorting these array item in Accessding order |
|
612 *Because user may marked the item in any order |
|
613 */ |
|
614 TKeyArrayFix lKeyArrayFix(0,ECmpTInt); |
|
615 lActualSelectionArray->Sort(lKeyArrayFix); |
|
616 |
|
617 /*Declaring a local array.which will hold selected indexs. |
|
618 *this need because if we change any selection in the listbox |
|
619 *that will effect the original array.That may crash the logic |
|
620 */ |
|
621 CArrayFix<TInt>* lLocalArray = (CArrayFix<TInt>*)NULL; |
|
622 lLocalArray = new( ELeave ) CArrayFixFlat<TInt>(iListBox->Model()->NumberOfItems()); |
|
623 |
|
624 //Copying the indexs from the original array to the local array |
|
625 while( lSelectedIndexCnt > 0) |
|
626 { |
|
627 lLocalArray->AppendL( lActualSelectionArray->At(lCnt) ); |
|
628 lCnt++; |
|
629 lSelectedIndexCnt--; |
|
630 } |
|
631 |
|
632 lSelectedIndexCnt = lLocalArray->Count(); |
|
633 while( lSelectedIndexCnt > 0 ) |
|
634 { |
|
635 TInt lToSelectIndex(0); |
|
636 lToSelectIndex = lLocalArray->At( lSelectedIndexCnt - 1 ); |
|
637 /*if the currently added item index is less than or equals to |
|
638 *marked index then only change the selection |
|
639 */ |
|
640 if( aIndexToBeSelected <= lToSelectIndex ) |
|
641 { |
|
642 lListBoxView->DeselectItem( lToSelectIndex ); |
|
643 lListBoxView->SelectItemL( lToSelectIndex + 1 ); |
|
644 } |
|
645 lSelectedIndexCnt--; |
|
646 } |
|
647 |
|
648 delete lLocalArray; |
|
649 lLocalArray = ( CArrayFix<TInt>* )NULL; |
|
650 } |
|
651 } |
|
652 } |
|
653 |
|
654 // ----------------------------------------------------------------------------- |
|
655 // CLmkAppLmItemSelectorImpl::HandleScreenSizeChange |
|
656 // ----------------------------------------------------------------------------- |
|
657 // |
|
658 void CLmkAppLmItemSelectorImpl::HandleScreenSizeChange() |
|
659 { |
|
660 } |
|
661 // ----------------------------------------------------------------------------- |
|
662 // CLmkAppLmItemSelectorImpl::HandleLmCreated |
|
663 // ----------------------------------------------------------------------------- |
|
664 // |
|
665 void CLmkAppLmItemSelectorImpl::HandleLmCreated(TPosLmItemId aNewLmkItemId) |
|
666 { |
|
667 iNewLmkItemId = aNewLmkItemId; |
|
668 iNewListBoxItemAdded = ETrue; |
|
669 } |
|
670 // ----------------------------------------------------------------------------- |
|
671 // CLmkAppLmItemSelectorImpl::LaunchPosSettingsL |
|
672 // ----------------------------------------------------------------------------- |
|
673 // |
|
674 EXPORT_C void CLmkAppLmItemSelectorImpl::LaunchPosSettingsL() |
|
675 { |
|
676 if(!iLauncher) |
|
677 { |
|
678 iLauncher = CLmkLocSettingsLauncher::NewL(); |
|
679 } |
|
680 iLauncher->LaunchL(); |
|
681 } |
|
682 |
|
683 // ----------------------------------------------------------------------------- |
|
684 // CLmkAppLmItemSelectorImpl::StoreIdTobeFocussedAfterDeletion |
|
685 // ----------------------------------------------------------------------------- |
|
686 // |
|
687 void CLmkAppLmItemSelectorImpl::StoreIdTobeFocussedAfterDeletion( RArray<TPosLmItemId>& markedItemIds ) |
|
688 { |
|
689 TInt markedCount = markedItemIds.Count(); |
|
690 TInt index = iListBox->CurrentItemIndex(); |
|
691 TInt cnt = LmItemListProvider().ItemCount(); |
|
692 TBool bItemSelected = iListBox->View()->ItemIsSelected(index); |
|
693 iFocusItemIdAfterDeletion = KPosLmNullItemId; |
|
694 if(bItemSelected) |
|
695 { |
|
696 for( TInt i=index+1;i<cnt;i++) |
|
697 { |
|
698 if(!iListBox->View()->ItemIsSelected(i)) |
|
699 { |
|
700 index = i; |
|
701 break; |
|
702 } |
|
703 } |
|
704 } |
|
705 if( index < cnt) |
|
706 { |
|
707 LmItemListProvider().GetSelectedItemId(iFocusItemIdAfterDeletion,index); |
|
708 } |
|
709 } |
|
710 // ----------------------------------------------------------------------------- |
|
711 // CLmkAppLmItemSelectorImpl::SetFocusToItemAfterDeletionOfMarkedItems |
|
712 // ----------------------------------------------------------------------------- |
|
713 // |
|
714 void CLmkAppLmItemSelectorImpl::SetFocusToItemAfterDeletionOfMarkedItems() |
|
715 { |
|
716 //check if the focus to be moved to the item after deleting the marked item. |
|
717 if( iFocusItemIdAfterDeletion != KPosLmNullItemId) |
|
718 { |
|
719 //get the new index position of this item, after deletion. |
|
720 TInt index = LmItemListProvider().SelectedIndex(iFocusItemIdAfterDeletion); |
|
721 if ( index != KErrNotFound && |
|
722 index < iListBox->Model()->NumberOfItems() ) |
|
723 { |
|
724 iListBox->SetCurrentItemIndex( index ); |
|
725 } |
|
726 else |
|
727 { |
|
728 iListBox->SetCurrentItemIndex( 0 ); |
|
729 } |
|
730 } |
|
731 iFocusItemIdAfterDeletion = KPosLmNullItemId; |
|
732 } |
|
733 // ----------------------------------------------------------------------------- |
|
734 // CLmkAppLmItemSelectorImpl::HandleDialogDismissed |
|
735 // ----------------------------------------------------------------------------- |
|
736 // |
|
737 void CLmkAppLmItemSelectorImpl::HandleDialogDismissed( TInt aButtonId ) |
|
738 { |
|
739 if( EEikBidCancel == aButtonId ) |
|
740 { |
|
741 delete iLocationService; |
|
742 iLocationService = NULL; |
|
743 } |
|
744 } |
|
745 |
|
746 // ----------------------------------------------------------------------------- |
|
747 // CLmkAppLmItemSelectorImpl::MessageQueryCallBack() |
|
748 // ----------------------------------------------------------------------------- |
|
749 // |
|
750 TInt CLmkAppLmItemSelectorImpl::MessageQueryCallBack( TAny* /*aPtr*/ ) |
|
751 { |
|
752 TInt result = KErrNone; |
|
753 CEikonEnv* env = CEikonEnv::Static(); |
|
754 TRAP_IGNORE(LmkNotes::GenericMessageQueryL(env,R_LMK_REQUEST_FAIL_INFO_TEXT, |
|
755 R_LMK_MSG_QUERY_HEADING_PANE_TEXT)); |
|
756 return result; |
|
757 } |
|
758 |
|
759 // End of File |