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: This file contains the methods implementing the core |
|
15 * functionality of landmarks editor |
|
16 * |
|
17 */ |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include <AknSettingCache.h> |
|
21 #include <AiwServiceHandler.h> // AIW |
|
22 #include <AiwCommon.hrh> // AIW |
|
23 #include <featmgr.h> |
|
24 #include <aknlayoutscalable_avkon.cdl.h> |
|
25 #include <layoutmetadata.cdl.h> |
|
26 #include <aknmessagequerydialog.h> |
|
27 #include <AknIconUtils.h> |
|
28 #include <AknWaitDialog.h> |
|
29 #include <aknlists.h> |
|
30 #include <StringLoader.h> |
|
31 #include <AknQueryDialog.h> |
|
32 #include <eikcapc.h> |
|
33 #include <eikmenup.h> |
|
34 #include <hlplch.h> |
|
35 #include <sendnorm.rsg> // R_SENDUI_MENU |
|
36 #include <lmkui.rsg> |
|
37 #include <CLmkEditorDlg.h> |
|
38 #include <EPos_CPosLandmark.h> |
|
39 #include <EPos_CPosLandmarkDatabase.h> |
|
40 #include <epos_poslandmarkserialization.h> |
|
41 #include <bldvariant.hrh> |
|
42 #include <AknDef.h> |
|
43 #include <sysutil.h> |
|
44 |
|
45 #include <baclipb.h> // for CClipboard |
|
46 #include <txtrich.h> |
|
47 #include <txtetext.h> |
|
48 #include <s32std.h> |
|
49 |
|
50 #include "CLmkUiUtils.h" |
|
51 #include "landmarks.hrh" |
|
52 #include "LmkConsts.h" |
|
53 #include "LmkUID.h" |
|
54 #include "CLmkLocationService.h" |
|
55 #include "CLmkDbUtils.h" |
|
56 #include "CLmkEditorFieldArray.h" |
|
57 #include "MLmkEditorField.h" |
|
58 #include "LmkNotes.h" |
|
59 #include "CLmkDlgCategorySelectorImpl.h" |
|
60 #include <csxhelp/lm.hlp.hrh> |
|
61 #include "CLmkSender.h" |
|
62 #include "clmkgotourlcmd.h" |
|
63 #include "clmkcallcmd.h" |
|
64 #include "CLmkEditorImpl.h" |
|
65 #include "CLmkEditorTextField.h" |
|
66 #include "lmkicondialog.h" |
|
67 #include "CLmkEditorListField.h" |
|
68 #include "CLmkEditorCoordinateField.h" |
|
69 #include <Landmarks.rsg> |
|
70 #include <uriutils.h> |
|
71 #include "LmkListProviderFactory.h" |
|
72 #include "CLmkListProviderBase.h" |
|
73 #include <locnotprefplugindomaincrkeys.h> |
|
74 #include "clmkcentralrepository.h" |
|
75 #include "CLmkEditorNumberField.h" |
|
76 #include "lmkwaitdlglauncher.h" // Wait dialog launcher |
|
77 #include "LmkEditorFieldFactory.h" |
|
78 #include <locationvariationdomaincrkeys.h> |
|
79 #include <lmkerrors.h> |
|
80 |
|
81 // CONSTANTS |
|
82 /// Unnamed namespace for local definitions |
|
83 namespace { |
|
84 //const TInt KMaxCatCntForInfoPopUp (3); |
|
85 const TInt KHOffsetCatInfoPopup ( 100 ); |
|
86 const TInt KVOffsetCatInfoPopup ( 30 ); |
|
87 //const TInt KMinCatLenForInfoPopUp ( 11 ); |
|
88 //const TInt KMaxCatSizeForInfoPopUp ( 135 ); |
|
89 #if defined(_DEBUG) |
|
90 _LIT( KPanicMsg, "CLmkEditorImpl"); |
|
91 |
|
92 void Panic( TPanicCode aReason ) |
|
93 { |
|
94 User::Panic( KPanicMsg, aReason ); |
|
95 } |
|
96 #endif |
|
97 } // namespace |
|
98 |
|
99 // ================= LOCAL FUNCTIONS ======================= |
|
100 static void CleanupArray(TAny* aArray) |
|
101 { |
|
102 ( static_cast<RPointerArray<CPosLandmark>*>( aArray ) )->ResetAndDestroy(); |
|
103 } |
|
104 // ============================ MEMBER FUNCTIONS =============================== |
|
105 |
|
106 // ----------------------------------------------------------------------------- |
|
107 // CLmkEditorImpl::CLmkEditorImpl |
|
108 // C++ default constructor can NOT contain any code, that |
|
109 // might leave. |
|
110 // ----------------------------------------------------------------------------- |
|
111 // |
|
112 CLmkEditorImpl::CLmkEditorImpl( |
|
113 CPosLandmarkDatabase& aDb, |
|
114 CLmkSender& aSender, |
|
115 TLmkEditorMode aEditorMode ) |
|
116 : iDb( aDb ), |
|
117 iSender( aSender ), |
|
118 iEditorMode( aEditorMode ), |
|
119 iIsEditing(EFalse), |
|
120 iResetWebAddrSize(ETrue), |
|
121 iIsCategorySelctorOpen(EFalse) |
|
122 { |
|
123 } |
|
124 |
|
125 // ----------------------------------------------------------------------------- |
|
126 // CLmkEditorImpl::ConstructL |
|
127 // Symbian 2nd phase constructor can leave. |
|
128 // ----------------------------------------------------------------------------- |
|
129 // |
|
130 void CLmkEditorImpl::ConstructL( |
|
131 TPosLmItemId aLandmarkId, |
|
132 TLmkEditorAttributes aAttributes ) |
|
133 { |
|
134 CommonConstructL(aAttributes); |
|
135 |
|
136 iLandmark = iDb.ReadLandmarkLC(aLandmarkId); |
|
137 |
|
138 iLmkFields = CLmkFields::NewL( iLabelArray, |
|
139 iDb, |
|
140 aAttributes, |
|
141 aLandmarkId, |
|
142 iLandmark , |
|
143 iJapaneseInputMode); |
|
144 ChangeContextImageL(); |
|
145 iEditorFieldArray = CLmkEditorFieldArray::NewL( *iLmkFields, *this ); |
|
146 CleanupStack::Pop(iLandmark); |
|
147 |
|
148 if(iLandmark) |
|
149 { |
|
150 iIsLmOwned = ETrue; |
|
151 } |
|
152 } |
|
153 |
|
154 // ----------------------------------------------------------------------------- |
|
155 // CLmkEditorImpl::ConstructL |
|
156 // Symbian 2nd phase constructor can leave. |
|
157 // ----------------------------------------------------------------------------- |
|
158 // |
|
159 void CLmkEditorImpl::ConstructL( |
|
160 CPosLandmark* aLandmark, |
|
161 TLmkEditorAttributes aAttributes ) |
|
162 { |
|
163 CommonConstructL(aAttributes); |
|
164 |
|
165 iLmkFields = CLmkFields::NewL( iLabelArray, |
|
166 iDb, |
|
167 aAttributes, |
|
168 aLandmark->LandmarkId(), |
|
169 aLandmark, |
|
170 iJapaneseInputMode ); |
|
171 iLandmark = aLandmark; |
|
172 |
|
173 ChangeContextImageL(); |
|
174 iEditorFieldArray = CLmkEditorFieldArray::NewL( *iLmkFields, *this ); |
|
175 } |
|
176 |
|
177 // ----------------------------------------------------------------------------- |
|
178 // CLmkEditorImpl::ConstructL |
|
179 // Symbian 2nd phase constructor can leave. |
|
180 // ----------------------------------------------------------------------------- |
|
181 // |
|
182 void CLmkEditorImpl::ConstructL( |
|
183 TPosLmItemId* aLandmarkId, |
|
184 CPosLandmark* aLandmark, |
|
185 TLmkEditorAttributes aAttributes ) |
|
186 { |
|
187 CommonConstructL(aAttributes); |
|
188 |
|
189 iLmkFields = CLmkFields::NewL( iLabelArray, |
|
190 iDb, |
|
191 aAttributes, |
|
192 *aLandmarkId, |
|
193 aLandmark, |
|
194 iJapaneseInputMode ); |
|
195 iLandmarkItemId = aLandmarkId; |
|
196 iLandmark = aLandmark; |
|
197 ChangeContextImageL(); |
|
198 iEditorFieldArray = CLmkEditorFieldArray::NewL( *iLmkFields, *this ); |
|
199 } |
|
200 |
|
201 // ----------------------------------------------------------------------------- |
|
202 // CLmkEditorImpl::CommonConstructL |
|
203 // ----------------------------------------------------------------------------- |
|
204 // |
|
205 void CLmkEditorImpl::CommonConstructL(TLmkEditorAttributes& aAttributes) |
|
206 { |
|
207 iLandmarkItemId = NULL; // Set to NULL by default. Use only where needed. |
|
208 iLmkUiUtils = CLmkUiUtils::NewL(); |
|
209 iLmkUiUtils->ReadLmkUiResourceFileL(); |
|
210 CAknForm::ConstructL( R_LMK_EDITOR_MENUBAR ); |
|
211 |
|
212 iLmkUiUtils->StoreNaviPaneL(); // store old navi pane |
|
213 iLmkUiUtils->CreateDefaultNaviPaneL(); |
|
214 // For setting Japanese input mode |
|
215 CAknSettingCache& cache = CAknEnv::Static()->SettingCache(); |
|
216 TLanguage currentLanguage = cache.InputLanguage(); |
|
217 if ( currentLanguage == ELangJapanese ) |
|
218 { |
|
219 iJapaneseInputMode = ETrue; |
|
220 } |
|
221 else |
|
222 { |
|
223 iJapaneseInputMode = EFalse; |
|
224 } |
|
225 CreateLabelArrayL(); |
|
226 ConstructContextMenuL(); |
|
227 |
|
228 // launching browser |
|
229 iLmkGoToURLCmd = CLmkGoToURLCmd::NewL(); |
|
230 // Launching Call UI |
|
231 iLmkCallCmd = CLmkCallCmd::NewL(); |
|
232 iLmkCallCmd->AttachMenuPaneL( R_LMK_EDITOR_CALL_SUBMENU, R_LMK_EDITOR_AIW_INTEREST); |
|
233 // Create AIW interest |
|
234 iLmkCallCmd->AttachInterestL( R_LMK_EDITOR_AIW_INTEREST ); |
|
235 // By default enable map and navigation feature |
|
236 iMapNavFeature = ETrue; |
|
237 |
|
238 iMapNavInterface = CLmkMapNavigationInterface::NewL( iDb); |
|
239 iCatInfoPopupNote = NULL; |
|
240 iRepository = CLmkCentralRepository::NewL( KLocSystemofMeasurements,this); |
|
241 |
|
242 // Create the wait dialog launcher |
|
243 iWaitDialogLauncher = CLmkWaitDialogLauncher::NewL(); |
|
244 iWaitDialogLauncher->SetObserver(this); |
|
245 |
|
246 iIsLmOwned = EFalse; |
|
247 |
|
248 // Check if the Coordinates has to be hidden |
|
249 CheckHideCoordinateL(); |
|
250 |
|
251 if( iIsHideCoordinate ) |
|
252 { |
|
253 aAttributes&= ~CLmkEditorDlg::ELmkLatitude; |
|
254 aAttributes&= ~CLmkEditorDlg::ELmkLongitude; |
|
255 aAttributes&= ~CLmkEditorDlg::ELmkPositionAccuracy; |
|
256 aAttributes&= ~CLmkEditorDlg::ELmkAltitude; |
|
257 aAttributes&= ~CLmkEditorDlg::ELmkAltitudeAccuracy; |
|
258 } |
|
259 } |
|
260 |
|
261 // ----------------------------------------------------------------------------- |
|
262 // CLmkEditorImpl::NewL |
|
263 // Two-phased constructor. |
|
264 // ----------------------------------------------------------------------------- |
|
265 // |
|
266 EXPORT_C CLmkEditorImpl* CLmkEditorImpl::NewL( |
|
267 CPosLandmarkDatabase& aDb, |
|
268 CLmkSender& aSender, |
|
269 TLmkEditorAttributes aAttributes, |
|
270 TLmkEditorMode aEditorMode, |
|
271 TPosLmItemId aLandmarkId ) |
|
272 { |
|
273 CLmkEditorImpl* self = |
|
274 new( ELeave ) CLmkEditorImpl( aDb, aSender, aEditorMode ); |
|
275 |
|
276 CleanupStack::PushL( self ); |
|
277 self->ConstructL( aLandmarkId, aAttributes ); |
|
278 CleanupStack::Pop(); //self |
|
279 return self; |
|
280 } |
|
281 |
|
282 // ----------------------------------------------------------------------------- |
|
283 // CLmkEditorImpl::NewL |
|
284 // Two-phased constructor. |
|
285 // ----------------------------------------------------------------------------- |
|
286 // |
|
287 EXPORT_C CLmkEditorImpl* CLmkEditorImpl::NewL( |
|
288 CPosLandmarkDatabase& aDb, |
|
289 CLmkSender& aSender, |
|
290 TLmkEditorAttributes aAttributes, |
|
291 TLmkEditorMode aEditorMode, |
|
292 CPosLandmark* aLandmark ) |
|
293 { |
|
294 CLmkEditorImpl* self = |
|
295 new( ELeave ) CLmkEditorImpl( aDb, aSender, aEditorMode ); |
|
296 |
|
297 CleanupStack::PushL( self ); |
|
298 self->ConstructL( aLandmark, aAttributes ); |
|
299 CleanupStack::Pop(); //self |
|
300 return self; |
|
301 } |
|
302 |
|
303 // ----------------------------------------------------------------------------- |
|
304 // CLmkEditorImpl::NewL |
|
305 // Two-phased constructor. |
|
306 // ----------------------------------------------------------------------------- |
|
307 // |
|
308 EXPORT_C CLmkEditorImpl* CLmkEditorImpl::NewL( |
|
309 CPosLandmarkDatabase& aDb, |
|
310 CLmkSender& aSender, |
|
311 TLmkEditorAttributes aAttributes, |
|
312 TLmkEditorMode aEditorMode, |
|
313 TPosLmItemId* aLandmarkId, |
|
314 CPosLandmark* aLandmark ) |
|
315 { |
|
316 CLmkEditorImpl* self = |
|
317 new( ELeave ) CLmkEditorImpl( aDb, aSender, aEditorMode ); |
|
318 |
|
319 CleanupStack::PushL( self ); |
|
320 self->ConstructL( aLandmarkId, aLandmark, aAttributes ); |
|
321 CleanupStack::Pop(); //self |
|
322 return self; |
|
323 } |
|
324 |
|
325 // ----------------------------------------------------------------------------- |
|
326 // CLmkEditorImpl::~CLmkEditorImpl() |
|
327 // ----------------------------------------------------------------------------- |
|
328 // |
|
329 CLmkEditorImpl::~CLmkEditorImpl() |
|
330 { |
|
331 delete iWaitDialogLauncher; |
|
332 |
|
333 CEikButtonGroupContainer* cba = CEikButtonGroupContainer::Current(); |
|
334 cba->RemoveCommandObserver(KMskCommandPos); |
|
335 |
|
336 if( iLmkUiUtils ) |
|
337 { |
|
338 iLmkUiUtils->SetOldContextIcon(); |
|
339 iLmkUiUtils->RestoreOldTitlePane(); |
|
340 } |
|
341 |
|
342 delete iLmkUiUtils; |
|
343 delete iLmkFields; |
|
344 iLabelArray.ResetAndDestroy(); |
|
345 iCategoryNames.Close(); |
|
346 iLabelArray.Close(); |
|
347 delete iEditorFieldArray; |
|
348 delete iLocationService; |
|
349 |
|
350 if (iContextMenuBar) |
|
351 { |
|
352 iEikonEnv->EikAppUi()->RemoveFromStack(iContextMenuBar); |
|
353 delete iContextMenuBar; |
|
354 } |
|
355 delete iLmkGoToURLCmd; |
|
356 delete iLmkCallCmd; |
|
357 iMapNavInterface->Release(); |
|
358 delete iCatInfoPopupNote; |
|
359 delete iRepository; |
|
360 if(iIsLmOwned && iLandmark) |
|
361 delete iLandmark; |
|
362 } |
|
363 |
|
364 // ----------------------------------------------------------------------------- |
|
365 // CLmkEditorImpl::SetMopParent |
|
366 // ----------------------------------------------------------------------------- |
|
367 // |
|
368 EXPORT_C void CLmkEditorImpl::SetMopParent( |
|
369 MObjectProvider* aParent ) |
|
370 { |
|
371 CCoeControl::SetMopParent( aParent ); |
|
372 } |
|
373 |
|
374 // ----------------------------------------------------------------------------- |
|
375 // CLmkEditorImpl::SetHelpContext |
|
376 // ----------------------------------------------------------------------------- |
|
377 // |
|
378 EXPORT_C void CLmkEditorImpl::SetHelpContext( TCoeHelpContext aContext ) |
|
379 { |
|
380 iHelpContext = aContext; |
|
381 } |
|
382 |
|
383 // ----------------------------------------------------------------------------- |
|
384 // CLmkEditorImpl::ExecuteL |
|
385 // ----------------------------------------------------------------------------- |
|
386 // |
|
387 EXPORT_C TInt CLmkEditorImpl::ExecuteLD() |
|
388 { |
|
389 CleanupStack::PushL( this ); |
|
390 AttachAIWMenuInterestL(); |
|
391 CleanupStack::Pop();//this |
|
392 if (iEditorMode == CLmkEditorDlg::ELmkEditor) |
|
393 { |
|
394 iIsEditing = ETrue; |
|
395 return CAknForm::ExecuteLD( R_LMK_EDITOR_DIALOG ); |
|
396 } |
|
397 else // viewer/receive state of editor |
|
398 { |
|
399 iIsEditing = EFalse; |
|
400 return CAknForm::ExecuteLD( R_LMK_VIEWER_DIALOG ); |
|
401 } |
|
402 } |
|
403 |
|
404 // ----------------------------------------------------------------------------- |
|
405 // CLmkEditorImpl::DisableMapAndNavigationMenuOptions |
|
406 // ----------------------------------------------------------------------------- |
|
407 // |
|
408 EXPORT_C void CLmkEditorImpl::DisableMapAndNavigationMenuOptions() |
|
409 { |
|
410 iMapNavFeature = EFalse; |
|
411 } |
|
412 |
|
413 // ----------------------------------------------------------------------------- |
|
414 // CLmkEditorImpl::DynInitMenuPaneL |
|
415 // ----------------------------------------------------------------------------- |
|
416 // |
|
417 void CLmkEditorImpl::DynInitMenuPaneL( |
|
418 TInt aResourceId, |
|
419 CEikMenuPane* aMenuPane ) |
|
420 { |
|
421 switch( aResourceId ) |
|
422 { |
|
423 case R_AVKON_FORM_MENUPANE: |
|
424 { |
|
425 CAknForm::DynInitMenuPaneL( aResourceId, aMenuPane ); |
|
426 TBool isLandmarkDataEmpty = EFalse; |
|
427 TBool dimClearPos = ETrue; |
|
428 |
|
429 // Disable Map and Navigation feature when opted not to show |
|
430 if( !iMapNavFeature ) |
|
431 { |
|
432 isLandmarkDataEmpty = ETrue; |
|
433 } |
|
434 else |
|
435 { |
|
436 isLandmarkDataEmpty = ArePositionFieldEmptyL(); |
|
437 } |
|
438 |
|
439 if( isLandmarkDataEmpty ) |
|
440 { |
|
441 // delete the show on map & Navigate To options |
|
442 aMenuPane->DeleteMenuItem( ELmkShowOnMapPlaceHolder ); |
|
443 aMenuPane->DeleteMenuItem( ELmkNavigateToPlaceHolder ); |
|
444 } |
|
445 else if( IsEditable() ) |
|
446 { |
|
447 // delete the Navigate To option for editor |
|
448 aMenuPane->DeleteMenuItem( ELmkNavigateToPlaceHolder ); |
|
449 } |
|
450 |
|
451 if( IsEditable() ) |
|
452 { |
|
453 dimClearPos = ArePositionFieldEmptyL(); |
|
454 } |
|
455 |
|
456 if( dimClearPos || iIsHideCoordinate) |
|
457 { |
|
458 aMenuPane->SetItemDimmed( ELmkCmdClearPosInfo, ETrue ); |
|
459 } |
|
460 |
|
461 if( iMapNavFeature ) |
|
462 { |
|
463 iMapNavInterface->AttachMenuPaneL( aMenuPane, R_LMK_EDITOR_MENU, ELmkCmdMnNav ); |
|
464 } |
|
465 |
|
466 // Send menu is handled by the sender: |
|
467 if ( FeatureManager::FeatureSupported( KFeatureIdLandmarksConverter ) ) |
|
468 { |
|
469 aMenuPane->SetItemDimmed(ELmkCmdSendDummy, EFalse); |
|
470 iSender.DisplaySendMenuL( *aMenuPane, 1 ); |
|
471 } |
|
472 else |
|
473 { |
|
474 aMenuPane->SetItemDimmed(ELmkCmdSendDummy, ETrue); |
|
475 } |
|
476 |
|
477 if ( FeatureManager::FeatureSupported( KFeatureIdLocationFrameworkCore )) |
|
478 { |
|
479 aMenuPane->SetItemDimmed( ELmkCmdCurrentLocation,!IsEditable()); |
|
480 } |
|
481 else |
|
482 { |
|
483 aMenuPane->SetItemDimmed( ELmkCmdCurrentLocation, ETrue ); |
|
484 } |
|
485 |
|
486 if ( FeatureManager::FeatureSupported( KFeatureIdHelp )&& |
|
487 !iIsHideHelp ) |
|
488 { |
|
489 aMenuPane->SetItemDimmed( EAknCmdHelp, EFalse ); |
|
490 } |
|
491 else |
|
492 { |
|
493 aMenuPane->SetItemDimmed( EAknCmdHelp, ETrue ); |
|
494 } |
|
495 |
|
496 //only in edit mode |
|
497 aMenuPane->SetItemDimmed( ELmkCmdSelectCategories, !IsEditable() ); |
|
498 aMenuPane->SetItemDimmed( ELmkCmdChangeIcon, !IsEditable() ); |
|
499 |
|
500 |
|
501 //additional commands always dimmed in this class: |
|
502 aMenuPane->SetItemDimmed( ELmkCmdSaveLm, ETrue ); |
|
503 // Only in view mode |
|
504 aMenuPane->SetItemDimmed( ELmkCmdEditLm, IsEditable() ); |
|
505 //allways dimmed |
|
506 aMenuPane->SetItemDimmed( EAknFormCmdEdit, ETrue ); |
|
507 aMenuPane->SetItemDimmed( EAknFormCmdSave, ETrue ); |
|
508 aMenuPane->SetItemDimmed( EAknFormCmdLabel, ETrue ); |
|
509 aMenuPane->SetItemDimmed( EAknFormCmdAdd, ETrue ); |
|
510 aMenuPane->SetItemDimmed( EAknFormCmdDelete, ETrue ); |
|
511 aMenuPane->SetItemDimmed( ELmkCmdCategories, ETrue ); |
|
512 aMenuPane->SetItemDimmed( ELmkCmdEditTextLm, ETrue ); |
|
513 |
|
514 if(IsEditable()) |
|
515 { |
|
516 aMenuPane->SetItemDimmed( ELmkCmdCall, ETrue ); |
|
517 aMenuPane->SetItemDimmed( ELmkCmdGoToUrl, ETrue ); |
|
518 } |
|
519 else |
|
520 { |
|
521 MLmkFieldData* field = iLmkFields->GetField(EPhoneNumber); |
|
522 if(field) |
|
523 { |
|
524 TInt id = field->UniqueFieldIdentity(); |
|
525 MLmkEditorField* control = iEditorFieldArray->Find( id ); |
|
526 if ((!control) || GetFieldTextLengthL( *control ) <= 0 ) |
|
527 { |
|
528 aMenuPane->SetItemDimmed( ELmkCmdCall, ETrue ); |
|
529 } |
|
530 |
|
531 MLmkFieldData* field2 = iLmkFields->GetField(EWebAddress); |
|
532 if( field2 ) |
|
533 { |
|
534 TInt id2 = field2->UniqueFieldIdentity(); |
|
535 control = iEditorFieldArray->Find( id2 ); |
|
536 if ( (!control) || GetFieldTextLengthL( *control ) <= 0 ) |
|
537 { |
|
538 aMenuPane->SetItemDimmed( ELmkCmdGoToUrl, ETrue ); |
|
539 } |
|
540 } |
|
541 } |
|
542 } |
|
543 break; |
|
544 } |
|
545 case R_SENDUI_MENU: // Dynamically created send ui menu |
|
546 { |
|
547 // Send menu is handled by the sender: |
|
548 if ( FeatureManager::FeatureSupported( KFeatureIdLandmarksConverter ) ) |
|
549 { |
|
550 iSender.DisplaySendCascadeMenuL( *aMenuPane ); |
|
551 } |
|
552 break; |
|
553 } |
|
554 case R_LMK_EDITOR_CONTEXT_MENU: |
|
555 { |
|
556 MLmkEditorField* field = |
|
557 iEditorFieldArray->Find( IdOfFocusControl() ); |
|
558 TUint type = field->LandmarkItemField().FieldType(); |
|
559 |
|
560 if ( type != EPhoneNumber ) |
|
561 { |
|
562 aMenuPane->SetItemDimmed( ELmkEditMenuAiwId, ETrue ); |
|
563 } |
|
564 if ( type != EWebAddress ) |
|
565 { |
|
566 aMenuPane->SetItemDimmed( ELmkCmdGoToUrl, ETrue ); |
|
567 } |
|
568 |
|
569 if ( type == EPhoneNumber ) |
|
570 { |
|
571 if ( GetFieldTextLengthL( *field ) <= 0 ) |
|
572 { |
|
573 aMenuPane->SetItemDimmed( ELmkEditMenuAiwId, ETrue ); |
|
574 } |
|
575 } |
|
576 if ( type == EWebAddress ) |
|
577 { |
|
578 if ( GetFieldTextLengthL( *field ) <= 0 ) |
|
579 { |
|
580 aMenuPane->SetItemDimmed( ELmkCmdGoToUrl, ETrue ); |
|
581 } |
|
582 } |
|
583 break; |
|
584 } |
|
585 case R_LMK_EDITOR_CALL_SUBMENU: |
|
586 { |
|
587 // Initialize the AIW menu service |
|
588 iLmkCallCmd->InitializeMenuPaneL( |
|
589 *aMenuPane, |
|
590 aResourceId, |
|
591 ELmkCmdLast // Must not overlap with the other menu ids! |
|
592 ); |
|
593 break; |
|
594 } |
|
595 default: |
|
596 { |
|
597 break; |
|
598 } |
|
599 } |
|
600 iMapNavInterface->HandleMenuOperationL(aResourceId, aMenuPane, ELmkCmdMnNav); |
|
601 } |
|
602 |
|
603 // ----------------------------------------------------------------------------- |
|
604 // CLmkEditorImpl::IsLandmarkDataEmptyL |
|
605 // ----------------------------------------------------------------------------- |
|
606 // |
|
607 TBool CLmkEditorImpl::IsLandmarkDataEmptyL(CPosLandmark* aLandmark) |
|
608 { |
|
609 // verify that destination landmark has coordinates |
|
610 TLocality loc; |
|
611 TBool isValid = (KErrNone == aLandmark->GetPosition(loc)); |
|
612 isValid &= !Math::IsNaN(loc.Latitude()) && !Math::IsNaN(loc.Longitude()); |
|
613 return isValid; |
|
614 |
|
615 /* if (!isValid) |
|
616 { |
|
617 // verify that destination landmark has address info |
|
618 TPositionFieldId fieldId = aLandmark->FirstPositionFieldId(); |
|
619 while (fieldId != EPositionFieldNone) |
|
620 { |
|
621 if (fieldId > EPositionFieldAddressCapabilitiesBegin && fieldId |
|
622 < EPositionFieldBuildingTelephone) |
|
623 { |
|
624 TPtrC field; |
|
625 aLandmark->GetPositionField(fieldId, field); |
|
626 if (field.Length()) |
|
627 { |
|
628 isValid = ETrue; |
|
629 break; |
|
630 } |
|
631 } |
|
632 fieldId = aLandmark->NextPositionFieldId(fieldId); |
|
633 } |
|
634 } |
|
635 return !isValid;*/ |
|
636 } |
|
637 |
|
638 // ----------------------------------------------------------------------------- |
|
639 // CLmkEditorImpl::ProcessCommandL |
|
640 // ----------------------------------------------------------------------------- |
|
641 // |
|
642 void CLmkEditorImpl::ProcessCommandL( TInt aCommandId ) |
|
643 { |
|
644 // Hide the context sensitive menu here |
|
645 HideMenu(); |
|
646 iContextMenuBar->StopDisplayingMenuBar(); |
|
647 |
|
648 CAknDialog::ProcessCommandL( aCommandId ); |
|
649 TInt aiwCmd = iMapNavInterface->GetServiceCmdByMenuCmd(aCommandId); |
|
650 |
|
651 // Handles Map and Navigation commands |
|
652 if(KAiwCmdNone != aiwCmd) |
|
653 { |
|
654 // Landmark array to pass to M&N interface |
|
655 RPointerArray<CPosLandmark> lmkArray; |
|
656 switch(aiwCmd) |
|
657 { |
|
658 case KAiwCmdMnShowMap: |
|
659 { |
|
660 CPosLandmark* landmark = GetCurrentEditedLandmarkL(); |
|
661 lmkArray.Append(landmark); |
|
662 CleanupStack::PushL( TCleanupItem( CleanupArray, &lmkArray ) ); |
|
663 iMapNavInterface->ShowLandmarksOnMapL(lmkArray, aCommandId, |
|
664 CLmkMapNavigationInterface::EByLmkView); |
|
665 CleanupStack::PopAndDestroy(); //lmkArray |
|
666 break; |
|
667 } |
|
668 case KAiwCmdMnNavigateTo: |
|
669 { |
|
670 CPosLandmark* landmark = GetCurrentEditedLandmarkL(); |
|
671 lmkArray.Append(landmark); |
|
672 CleanupStack::PushL( TCleanupItem( CleanupArray, &lmkArray ) ); |
|
673 iMapNavInterface->NavigateToLandmarkL(lmkArray[0],aCommandId); |
|
674 CleanupStack::PopAndDestroy(); //lmkArray |
|
675 break; |
|
676 } |
|
677 } |
|
678 lmkArray.Reset(); |
|
679 return; |
|
680 } |
|
681 switch ( aCommandId ) |
|
682 { |
|
683 case EAknCmdHelp: |
|
684 { |
|
685 HlpLauncher::LaunchHelpApplicationL( iEikonEnv->WsSession(), |
|
686 static_cast<CAknAppUi*>( |
|
687 iCoeEnv->AppUi() )->AppHelpContextL() ); |
|
688 break; |
|
689 } |
|
690 // these all are same: save & exit |
|
691 case EAknSoftkeyBack: |
|
692 case EAknSoftkeyExit: |
|
693 case EEikCmdExit: |
|
694 case EAknCmdExit: |
|
695 { |
|
696 CAknForm::OkToExitL( aCommandId ); |
|
697 iLmkUiUtils->RestoreOldNaviPaneL(); |
|
698 CEikAppUi* appUi = iEikonEnv->EikAppUi(); |
|
699 // Close this dialog first |
|
700 delete this; |
|
701 // Exit application |
|
702 static_cast<MEikCommandObserver*>(appUi)->ProcessCommandL(aCommandId); |
|
703 break; |
|
704 } |
|
705 case ELmkCmdDeleteLm: |
|
706 { |
|
707 if ( LmkNotes::LandmarkConfirmationQueryL( iEikonEnv ) ) |
|
708 { |
|
709 iLmkFields->DeleteLandmarkL(); |
|
710 iLmkUiUtils->RestoreOldNaviPaneL(); |
|
711 iIsEditing = EFalse; |
|
712 delete this; |
|
713 } |
|
714 break; |
|
715 } |
|
716 case ELmkCmdSelectCategories: |
|
717 { |
|
718 if(!iIsCategorySelctorOpen) |
|
719 { |
|
720 iIsCategorySelctorOpen = ETrue; |
|
721 SelectCategoriesCmdL(); |
|
722 } |
|
723 break; |
|
724 } |
|
725 case ELmkCmdChangeIcon: |
|
726 { |
|
727 ChangeIconCmdL(); |
|
728 break; |
|
729 } |
|
730 case ELmkCmdCurrentLocation: |
|
731 { |
|
732 CurrentLocationCmdL(); |
|
733 break; |
|
734 } |
|
735 case ELmkCmdSendVia1: |
|
736 case ELmkCmdSendVia2: |
|
737 case ELmkCmdSendVia3: |
|
738 case ELmkCmdSendVia4: |
|
739 case ELmkCmdSendVia5: |
|
740 case ELmkCmdSendVia6: |
|
741 case ELmkCmdSendVia7: |
|
742 case ELmkCmdSendVia8: |
|
743 case ELmkCmdSendVia9: |
|
744 case ELmkCmdSendVia10: |
|
745 case ELmkCmdSend: |
|
746 { |
|
747 if ( !IsNameFieldEmptyL() ) |
|
748 { |
|
749 // Obtain the current landmark object |
|
750 CPosLandmark* lmk = GetCurrentEditedLandmarkL(); |
|
751 CleanupStack::PushL( lmk ); |
|
752 iSender.SendSingleLandmarkL(*lmk); |
|
753 CleanupStack::PopAndDestroy( lmk ); |
|
754 } |
|
755 else |
|
756 { |
|
757 DoNotSaveFormDataL(); |
|
758 } |
|
759 break; |
|
760 } |
|
761 case ELmkCmdGoToUrl: |
|
762 { |
|
763 // Get URL field |
|
764 MLmkFieldData* field = iLmkFields->GetField(EWebAddress); |
|
765 if(field) |
|
766 { |
|
767 TInt id = field->UniqueFieldIdentity(); |
|
768 MLmkEditorField* control = iEditorFieldArray->Find( id ); |
|
769 if(control) |
|
770 { |
|
771 HBufC* fieldText = control->ControlTextL(); |
|
772 CleanupStack::PushL( fieldText ); |
|
773 TPtr urlPtr = fieldText->Des(); |
|
774 if ( urlPtr.Length() > 0 ) |
|
775 { |
|
776 iLmkGoToURLCmd->LaunchBrowserL( urlPtr ); |
|
777 } |
|
778 CleanupStack::PopAndDestroy( fieldText ); |
|
779 } |
|
780 } |
|
781 break; |
|
782 } |
|
783 case ELmkCmdEditLm: |
|
784 { |
|
785 if(!iIsEditing) |
|
786 { |
|
787 LaunchLmkEditorL(); |
|
788 } |
|
789 break; |
|
790 } |
|
791 case ELmkCmdCall: |
|
792 case ELmkCmdLast: |
|
793 { |
|
794 MLmkFieldData* field = iLmkFields->GetField(EPhoneNumber); |
|
795 if(field) |
|
796 { |
|
797 TInt id = field->UniqueFieldIdentity(); |
|
798 MLmkEditorField* control = iEditorFieldArray->Find( id ); |
|
799 if(control) |
|
800 { |
|
801 HBufC* fieldText = control->ControlTextL(); |
|
802 CleanupStack::PushL( fieldText ); |
|
803 if ( fieldText && fieldText->Length() > 0 ) |
|
804 { |
|
805 //Check if any active character or not |
|
806 TPtr ptr = fieldText->Des(); |
|
807 ptr.Trim(); |
|
808 if (ptr.Length() > 0) |
|
809 { |
|
810 //modified for 3.2, since command is not coming |
|
811 //from menu item, hence need to pass diff command. |
|
812 //this code needs some more modification to make it |
|
813 //genericly work for all the commands. |
|
814 iLmkCallCmd->ExecuteAIWCallCmdL( ELmkCmdCall, ptr ); |
|
815 } |
|
816 } |
|
817 CleanupStack::PopAndDestroy( fieldText ); |
|
818 } |
|
819 } |
|
820 break; |
|
821 } |
|
822 case ELmkCmdShow: |
|
823 { |
|
824 MLmkEditorField* field = |
|
825 iEditorFieldArray->Find( IdOfFocusControl() ); |
|
826 TUint type = field->LandmarkItemField().FieldType(); |
|
827 if (type == ECategories ) |
|
828 { |
|
829 if(iCalegorySelectionFlag) // Receive mode |
|
830 { |
|
831 CategoriesCmdFromXmlL(); |
|
832 } |
|
833 else |
|
834 { |
|
835 CategoriesCmdL(); // View mode |
|
836 } |
|
837 } |
|
838 break; |
|
839 } |
|
840 case ELmkCmdClearPosInfo: |
|
841 { |
|
842 ClearPositionInfoL(); |
|
843 break; |
|
844 } |
|
845 default: |
|
846 { |
|
847 CAknForm::ProcessCommandL( aCommandId ); |
|
848 break; |
|
849 } |
|
850 } |
|
851 } |
|
852 |
|
853 // ----------------------------------------------------------------------------- |
|
854 // CLmkEditorImpl::HandleControlStateChangeL |
|
855 // ----------------------------------------------------------------------------- |
|
856 // |
|
857 void CLmkEditorImpl::HandleControlStateChangeL( TInt aControlId ) |
|
858 { |
|
859 MLmkEditorField* changedField = iEditorFieldArray->Find( aControlId ); |
|
860 if ( changedField ) |
|
861 { |
|
862 if ( changedField->LandmarkItemField().IsTitleField() ) |
|
863 { |
|
864 HBufC* title = changedField->ControlTextL(); |
|
865 CleanupStack::PushL( title ); |
|
866 if ( !title ) |
|
867 { |
|
868 title = HBufC::New(0); |
|
869 } |
|
870 iLmkUiUtils->ChangeTitlePaneL( title ); |
|
871 CleanupStack::Pop(); //title |
|
872 } |
|
873 } |
|
874 } |
|
875 |
|
876 // ----------------------------------------------------------------------------- |
|
877 // CLmkEditorImpl::DoNotSaveFormDataL |
|
878 // ----------------------------------------------------------------------------- |
|
879 // |
|
880 void CLmkEditorImpl::DoNotSaveFormDataL() |
|
881 { |
|
882 if ( !iIsEndKey ) |
|
883 { |
|
884 LmkNotes::InformationNoteL( iEikonEnv, R_LMK_EMPTY_LANDMARK_NAME_NOTE ); |
|
885 } |
|
886 MLmkFieldData* field = iLmkFields->GetField(EName); |
|
887 if( field ) |
|
888 { |
|
889 TInt id = field->UniqueFieldIdentity(); |
|
890 TryChangeFocusL(id); |
|
891 } |
|
892 CAknForm::SetInitialCurrentLine(); |
|
893 } |
|
894 |
|
895 // ----------------------------------------------------------------------------- |
|
896 // CLmkEditorImpl::GetHelpContext |
|
897 // ----------------------------------------------------------------------------- |
|
898 // |
|
899 void CLmkEditorImpl::GetHelpContext( TCoeHelpContext& aContext ) const |
|
900 { |
|
901 if ( iHelpContext.iContext.Length() > 0 ) |
|
902 { |
|
903 aContext.iContext = iHelpContext.iContext; |
|
904 aContext.iMajor = iHelpContext.iMajor; |
|
905 } |
|
906 else if ( iEditorMode == CLmkEditorDlg::ELmkViewer ) |
|
907 { |
|
908 aContext.iContext = KLM_HLP_LM_VIEWER; |
|
909 aContext.iMajor = TUid::Uid( KLmkAppUID3 ); |
|
910 } |
|
911 else |
|
912 { |
|
913 aContext.iContext = KLM_HLP_LM_EDITOR; |
|
914 aContext.iMajor = TUid::Uid( KLmkAppUID3 ); |
|
915 } |
|
916 } |
|
917 |
|
918 // ----------------------------------------------------------------------------- |
|
919 // CLmkEditorImpl::OfferKeyEventL |
|
920 // ----------------------------------------------------------------------------- |
|
921 // |
|
922 TKeyResponse CLmkEditorImpl::OfferKeyEventL( const TKeyEvent& aKeyEvent, |
|
923 TEventCode aType ) |
|
924 { |
|
925 /** |
|
926 * By def, dialog opens in view mode |
|
927 * selecting 'edit' option from (either from context menu/options menu) |
|
928 * to edit landmark fields |
|
929 * |
|
930 */ |
|
931 if (IsEditable()) |
|
932 { |
|
933 //always dimmed for the editor |
|
934 DimmMiddleSoftKey(); |
|
935 } |
|
936 if ( aKeyEvent.iCode == EKeyOK ) |
|
937 { |
|
938 MLmkEditorField* field = |
|
939 iEditorFieldArray->Find( IdOfFocusControl() ); |
|
940 TUint type = field->LandmarkItemField().FieldType(); |
|
941 // check the editor mode |
|
942 if (IsEditable()) // edit mode |
|
943 { |
|
944 if ( type == ECategory || type == ECategories ) |
|
945 { |
|
946 if(!iIsCategorySelctorOpen) |
|
947 { |
|
948 iIsCategorySelctorOpen = ETrue; |
|
949 SelectCategoriesCmdL(); |
|
950 } |
|
951 |
|
952 return EKeyWasConsumed; |
|
953 } |
|
954 } |
|
955 else |
|
956 {// view or receive mode |
|
957 if ( type == ECategory || type == ECategories ) |
|
958 { |
|
959 if(iCalegorySelectionFlag) // Receive mode |
|
960 { |
|
961 CategoriesCmdFromXmlL(); |
|
962 return EKeyWasConsumed; |
|
963 } |
|
964 else |
|
965 { |
|
966 CategoriesCmdL(); // View mode |
|
967 return EKeyWasConsumed; |
|
968 } |
|
969 } |
|
970 else // focus is on any other landmark field |
|
971 { |
|
972 if ( !iCalegorySelectionFlag )// No context menu for receive mode |
|
973 { |
|
974 if(!iIsEditing) |
|
975 { |
|
976 LaunchLmkEditorL(); |
|
977 return EKeyWasConsumed; |
|
978 } |
|
979 /* |
|
980 //Launch context sensitive menu bar here |
|
981 if ( iContextMenuBar ) |
|
982 { |
|
983 iContextMenuBar->TryDisplayMenuBarL(); |
|
984 return EKeyWasConsumed; |
|
985 } |
|
986 */ |
|
987 } |
|
988 } |
|
989 } |
|
990 } |
|
991 else if( aKeyEvent.iCode == EKeyBackspace ) |
|
992 { |
|
993 if( !IsEditable() && iIsLmkReceiveMode == EFalse ) |
|
994 { |
|
995 ProcessCommandL( ELmkCmdDeleteLm ); |
|
996 return EKeyWasConsumed; |
|
997 } |
|
998 } |
|
999 else if ( aKeyEvent.iCode == EKeyPhoneEnd ) |
|
1000 { |
|
1001 iIsEndKey = ETrue; |
|
1002 OkToExitL(EAknSoftkeyDone); |
|
1003 } |
|
1004 else // for 'sendkey' handling |
|
1005 { |
|
1006 if ( aKeyEvent.iCode == EKeyPhoneSend && (!IsEditable()) && (!Layout_Meta_Data::IsPenEnabled()) ) |
|
1007 { |
|
1008 // Get Landmark's telephone number |
|
1009 TPosLmItemId lmId = iLmkFields->LandmarkId(); |
|
1010 CPosLandmark* landmark = iDb.ReadLandmarkLC(lmId); |
|
1011 // Get phone num field |
|
1012 if (landmark->IsPositionFieldAvailable( |
|
1013 ELmkPositionFieldPhoneNumber) ) |
|
1014 { |
|
1015 TPtrC telnumPtr; |
|
1016 if ( (landmark->GetPositionField( |
|
1017 ELmkPositionFieldPhoneNumber, |
|
1018 telnumPtr ) == KErrNone) && (telnumPtr.Length() > 0 )) |
|
1019 { |
|
1020 iLmkCallCmd->ExecuteAIWCallCmdL( ELmkCmdCall,telnumPtr ); |
|
1021 } |
|
1022 else |
|
1023 { |
|
1024 // Get name |
|
1025 TPtrC lmkNamePtr; |
|
1026 if ( landmark->GetLandmarkName ( lmkNamePtr ) == KErrNone ) |
|
1027 { |
|
1028 LmkNotes::InformationNotewithTextL( iEikonEnv, |
|
1029 R_LMK_NOTE_NO_NUMBER_TO_NAME, |
|
1030 lmkNamePtr); |
|
1031 } |
|
1032 } |
|
1033 } |
|
1034 CleanupStack::PopAndDestroy(landmark); |
|
1035 } |
|
1036 } |
|
1037 |
|
1038 if ( aType == EEventKey && ( aKeyEvent.iCode == EKeyEnter || aKeyEvent.iScanCode == EStdKeyEnter )) |
|
1039 { |
|
1040 TBool isCategoryField = EFalse; |
|
1041 MLmkEditorField* field = iEditorFieldArray->Find( IdOfFocusControl() ); |
|
1042 TUint type = field->LandmarkItemField().FieldType(); |
|
1043 |
|
1044 if ( type == ECategory || type == ECategories ) |
|
1045 isCategoryField = ETrue; |
|
1046 |
|
1047 // check the editor mode and category field focus |
|
1048 if ( IsEditable() == EFalse || isCategoryField ) |
|
1049 { |
|
1050 TKeyEvent enterKeyEvent( aKeyEvent ); |
|
1051 enterKeyEvent.iCode = EKeyOK; |
|
1052 CEikButtonGroupContainer* cba = CEikButtonGroupContainer::Current(); |
|
1053 return cba->OfferKeyEventL( enterKeyEvent, aType ); |
|
1054 } |
|
1055 } |
|
1056 |
|
1057 TKeyResponse response= CAknForm::OfferKeyEventL( aKeyEvent, aType ); |
|
1058 return response; |
|
1059 } |
|
1060 |
|
1061 // ----------------------------------------------------------------------------- |
|
1062 // CLmkEditorImpl::NotifyL |
|
1063 // ----------------------------------------------------------------------------- |
|
1064 // |
|
1065 void CLmkEditorImpl::NotifyL( const TInt aStatus ) |
|
1066 { |
|
1067 // Stop the running wait dialog |
|
1068 TInt buttonId = iWaitDialogLauncher->StopWaitDialogL(); |
|
1069 if( EEikBidCancel != buttonId ) |
|
1070 { |
|
1071 switch( aStatus ) |
|
1072 { |
|
1073 case KErrNone: |
|
1074 case KPositionPartialUpdate: |
|
1075 { |
|
1076 if(iLocationService) |
|
1077 { |
|
1078 TPosition position = iLocationService->CurrentPosition(); |
|
1079 SetCurrentLocationL( position ); |
|
1080 } |
|
1081 break; |
|
1082 } |
|
1083 default: |
|
1084 { |
|
1085 break; |
|
1086 } |
|
1087 } |
|
1088 } |
|
1089 delete iLocationService; |
|
1090 iLocationService = NULL; |
|
1091 } |
|
1092 |
|
1093 // ----------------------------------------------------------------------------- |
|
1094 // CLmkEditorImpl::NotifyErrorL |
|
1095 // ----------------------------------------------------------------------------- |
|
1096 // |
|
1097 void CLmkEditorImpl::NotifyErrorL( TInt aErrorCode ) |
|
1098 { |
|
1099 |
|
1100 // Stop the running wait dialog |
|
1101 TInt buttonId = iWaitDialogLauncher->StopWaitDialogL(); |
|
1102 |
|
1103 delete iLocationService; |
|
1104 iLocationService = NULL; |
|
1105 |
|
1106 if( EEikBidCancel != buttonId ) |
|
1107 { |
|
1108 switch( aErrorCode ) |
|
1109 { |
|
1110 case KPositionQualityLoss: |
|
1111 case KErrTimedOut: |
|
1112 case KErrNotFound: // No PSY selected. |
|
1113 case KErrUnknown: |
|
1114 case KErrCancel: |
|
1115 case KErrArgument: |
|
1116 default: |
|
1117 // The above errors are because of location request failures |
|
1118 // Ask user to retry location request |
|
1119 { |
|
1120 if ( LmkNotes::MessageQueryWithLinkL(iEikonEnv,R_LMK_MSG_QUERY_HEADING_PANE_TEXT, |
|
1121 R_LMK_CONF_RETRY_LOCATION_REQUEST,R_LMK_REQUEST_FAIL_MORE_INFO, |
|
1122 MessageQueryCallBack) ) |
|
1123 { |
|
1124 if( iLocationService ) |
|
1125 { |
|
1126 delete iLocationService; |
|
1127 iLocationService = NULL; |
|
1128 } |
|
1129 CurrentLocationCmdL(); |
|
1130 } |
|
1131 } |
|
1132 } |
|
1133 } |
|
1134 } |
|
1135 |
|
1136 // ----------------------------------------------------------------------------- |
|
1137 // CLmkEditorImpl::CreateCustomControlL |
|
1138 // ----------------------------------------------------------------------------- |
|
1139 // |
|
1140 SEikControlInfo CLmkEditorImpl::CreateCustomControlL( TInt /*aControlType*/ ) |
|
1141 { |
|
1142 SEikControlInfo ctrl; |
|
1143 ctrl.iControl = NULL; |
|
1144 ctrl.iTrailerTextId = 0; |
|
1145 ctrl.iFlags = 0; |
|
1146 /*switch( aControlType ) |
|
1147 { |
|
1148 case EDistanceEditorType: |
|
1149 { |
|
1150 ctrl.iControl = new(ELeave) CLmkDistanceEditor(); |
|
1151 break; |
|
1152 } |
|
1153 default: |
|
1154 { |
|
1155 break; |
|
1156 } |
|
1157 }*/ |
|
1158 return ctrl; |
|
1159 } |
|
1160 |
|
1161 // ---------------------------------------------------- |
|
1162 // CLmkEditorImpl::ConvertCustomControlTypeToBaseControlType |
|
1163 // ---------------------------------------------------- |
|
1164 // |
|
1165 MEikDialogPageObserver::TFormControlTypes |
|
1166 CLmkEditorImpl::ConvertCustomControlTypeToBaseControlType( |
|
1167 TInt aControlType ) const |
|
1168 { |
|
1169 switch( aControlType ) |
|
1170 { |
|
1171 case EDistanceEditorType: |
|
1172 { |
|
1173 return MEikDialogPageObserver::EMfneDerived; |
|
1174 //break; |
|
1175 } |
|
1176 default: |
|
1177 { |
|
1178 return MEikDialogPageObserver::EUnknownType; |
|
1179 //break; |
|
1180 } |
|
1181 } |
|
1182 } |
|
1183 |
|
1184 // ----------------------------------------------------------------------------- |
|
1185 // CLmkEditorImpl::PreLayoutDynInitL |
|
1186 // ----------------------------------------------------------------------------- |
|
1187 // |
|
1188 void CLmkEditorImpl::PreLayoutDynInitL() |
|
1189 { |
|
1190 CAknForm::PreLayoutDynInitL(); |
|
1191 |
|
1192 // When adding fields the form must be editable: |
|
1193 //SetEditableL(ETrue); |
|
1194 if (iCalegorySelectionFlag && iCategoryNames.Count() >= 1) |
|
1195 iEditorFieldArray->SetCategoryName(iCategoryNames[0]); |
|
1196 iEditorFieldArray->CreateFieldsFromLmkL(); |
|
1197 //SetEditableL(EFalse); |
|
1198 //CAknForm::SetInitialCurrentLine(); |
|
1199 } |
|
1200 |
|
1201 // ----------------------------------------------------------------------------- |
|
1202 // CLmkEditorImpl::PostLayoutDynInitL |
|
1203 // ----------------------------------------------------------------------------- |
|
1204 // |
|
1205 void CLmkEditorImpl::PostLayoutDynInitL() |
|
1206 { |
|
1207 CAknForm::PostLayoutDynInitL(); |
|
1208 |
|
1209 MLmkFieldData* fields = iLmkFields->GetField( EName ); |
|
1210 if ( fields ) |
|
1211 { |
|
1212 TPtrC name = fields->TextData(); |
|
1213 |
|
1214 //ChangeTitle |
|
1215 HBufC* title = name.Alloc(); |
|
1216 CleanupStack::PushL( title ); |
|
1217 iLmkUiUtils->StoreTitlePaneL(); // save old title pane |
|
1218 iLmkUiUtils->ChangeTitlePaneL( title ); //take ownership |
|
1219 CleanupStack::Pop( title ); //title |
|
1220 } |
|
1221 |
|
1222 SetEditableL( iEditorMode == CLmkEditorDlg::ELmkEditor ); |
|
1223 CEikButtonGroupContainer* cba = CEikButtonGroupContainer::Current(); |
|
1224 cba->UpdateCommandObserverL(KMskCommandPos,*this); |
|
1225 if (!IsEditable()) |
|
1226 { |
|
1227 AddMskCommandL(R_LM_MSK_EDIT,ELmkCmdEditLm); |
|
1228 } |
|
1229 else |
|
1230 { |
|
1231 //only for editor |
|
1232 DimmMiddleSoftKey(); |
|
1233 if (iFieldTypeToFocus == ECategory || iFieldTypeToFocus == ECategories) |
|
1234 { |
|
1235 AddMskCommandL(R_LM_MSK_EDIT,ELmkCmdSelectCategories); |
|
1236 } |
|
1237 } |
|
1238 } |
|
1239 |
|
1240 // ----------------------------------------------------------------------------- |
|
1241 // CLmkEditorImpl::OkToExitL |
|
1242 // ----------------------------------------------------------------------------- |
|
1243 // |
|
1244 TBool CLmkEditorImpl::OkToExitL( TInt aKeyCode ) |
|
1245 { |
|
1246 TBool ret = EFalse; |
|
1247 switch ( aKeyCode ) |
|
1248 { |
|
1249 case EAknSoftkeyDone: |
|
1250 { |
|
1251 if ( IsEditable() ) |
|
1252 { |
|
1253 if ( iEditorFieldArray->AreAllFieldsEmptyL() ) |
|
1254 { |
|
1255 |
|
1256 if( iLandmark && iIsHideCoordinate ) |
|
1257 { |
|
1258 TLocality locality; |
|
1259 iLandmark->GetPosition( locality ); |
|
1260 if( !Math::IsNaN( locality.Latitude() )) |
|
1261 { |
|
1262 DoNotSaveFormDataL(); |
|
1263 iIsEndKey = EFalse; |
|
1264 // Stay back in the editor mode |
|
1265 break; |
|
1266 } |
|
1267 } |
|
1268 |
|
1269 TRAPD(err,CPosLandmark* landmark = iDb.ReadLandmarkLC(iLmkFields->LandmarkId());CleanupStack::PopAndDestroy( landmark )); |
|
1270 if (err == KErrNotFound) |
|
1271 { |
|
1272 // The Landmark is not in the database.Dont save the |
|
1273 // landmark. Just return |
|
1274 // Don't save when all landmark fields are empty |
|
1275 iLmkUiUtils->RestoreOldNaviPaneL(); |
|
1276 ret = ETrue; |
|
1277 } |
|
1278 else |
|
1279 { |
|
1280 // The landmark is in the database. Hence, confirm |
|
1281 // from the user whether he wants to delete the |
|
1282 // landmark |
|
1283 if ( LmkNotes::LandmarkConfirmationQueryL( iEikonEnv ) ) |
|
1284 { |
|
1285 iLmkFields->DeleteLandmarkL(); |
|
1286 iLmkUiUtils->RestoreOldNaviPaneL(); |
|
1287 ret = ETrue; |
|
1288 } |
|
1289 else |
|
1290 { |
|
1291 // Stay back in the editor mode |
|
1292 ret = EFalse; |
|
1293 } |
|
1294 } |
|
1295 |
|
1296 } |
|
1297 else |
|
1298 { |
|
1299 if(!ValidateContentL()) |
|
1300 { |
|
1301 ret = EFalse; |
|
1302 return ret; |
|
1303 } |
|
1304 else |
|
1305 { |
|
1306 /** |
|
1307 * Do not save landmark if disc space is not |
|
1308 * enough |
|
1309 */ |
|
1310 TRAPD( err, iEditorFieldArray->SaveFieldsL() ); |
|
1311 if ( err == KErrDiskFull ) |
|
1312 { |
|
1313 ret = EFalse; |
|
1314 LmkNotes::OutOfMemoryNoteL( iEikonEnv ); |
|
1315 delete this; |
|
1316 return ret; |
|
1317 } |
|
1318 |
|
1319 if ( iLandmarkItemId ) |
|
1320 { |
|
1321 *iLandmarkItemId = iLmkFields->LandmarkId(); |
|
1322 } |
|
1323 iLmkUiUtils->RestoreOldNaviPaneL(); |
|
1324 ret = ETrue; |
|
1325 } |
|
1326 } |
|
1327 } |
|
1328 else |
|
1329 { |
|
1330 iLmkUiUtils->RestoreOldNaviPaneL(); |
|
1331 ret = ETrue; |
|
1332 } |
|
1333 break; |
|
1334 } |
|
1335 default: |
|
1336 break; |
|
1337 } |
|
1338 if ( !ret ) |
|
1339 { |
|
1340 ret = CAknForm::OkToExitL( aKeyCode ); |
|
1341 } |
|
1342 return ret; |
|
1343 } |
|
1344 |
|
1345 // ----------------------------------------------------------------------------- |
|
1346 // CLmkEditorImpl::CreateLineL |
|
1347 // ----------------------------------------------------------------------------- |
|
1348 // |
|
1349 CCoeControl* CLmkEditorImpl::CreateLineL( |
|
1350 const TDesC& aCaption, |
|
1351 TInt aControlId, |
|
1352 TInt aControlType ) |
|
1353 { |
|
1354 return CreateLineByTypeL( |
|
1355 aCaption, aControlId, aControlType, NULL ); |
|
1356 } |
|
1357 |
|
1358 // ----------------------------------------------------------------------------- |
|
1359 // CLmkEditorImpl::LineControl |
|
1360 // ----------------------------------------------------------------------------- |
|
1361 // |
|
1362 CEikCaptionedControl* CLmkEditorImpl::LineControl( TInt aControlId ) const |
|
1363 { |
|
1364 return Line( aControlId ); |
|
1365 } |
|
1366 |
|
1367 // ----------------------------------------------------------------------------- |
|
1368 // CLmkEditorImpl::DeleteControl |
|
1369 // ----------------------------------------------------------------------------- |
|
1370 // |
|
1371 void CLmkEditorImpl::DeleteControl( TInt aControlId ) |
|
1372 { |
|
1373 DeleteLine( aControlId ); |
|
1374 } |
|
1375 |
|
1376 // ----------------------------------------------------------------------------- |
|
1377 // CLmkEditorImpl::TryChangeFocusL |
|
1378 // ----------------------------------------------------------------------------- |
|
1379 // |
|
1380 void CLmkEditorImpl::TryChangeFocusL( TInt aControlId ) |
|
1381 { |
|
1382 if ( ControlOrNull( aControlId ) ) |
|
1383 { |
|
1384 TryChangeFocusToL( aControlId ); |
|
1385 } |
|
1386 } |
|
1387 |
|
1388 // ----------------------------------------------------------------------------- |
|
1389 // CLmkEditorImpl::SetCurrentLineCaptionL |
|
1390 // ----------------------------------------------------------------------------- |
|
1391 // |
|
1392 void CLmkEditorImpl::SetCurrentLineCaptionL( |
|
1393 TInt aControlId, |
|
1394 const TDesC& aText ) |
|
1395 { |
|
1396 CEikCaptionedControl* ctl = Line(aControlId); |
|
1397 if (ctl) |
|
1398 { |
|
1399 ctl->SetCaptionL(aText); |
|
1400 ctl->DrawDeferred(); |
|
1401 } |
|
1402 } |
|
1403 |
|
1404 // ----------------------------------------------------------------------------- |
|
1405 // CLmkEditorImpl::Control |
|
1406 // ----------------------------------------------------------------------------- |
|
1407 // |
|
1408 CCoeControl* CLmkEditorImpl::Control( TInt aControlId ) const |
|
1409 { |
|
1410 return ControlOrNull( aControlId ); |
|
1411 } |
|
1412 |
|
1413 // ----------------------------------------------------------------------------- |
|
1414 // CLmkEditorImpl::SetEditableL |
|
1415 // ----------------------------------------------------------------------------- |
|
1416 // |
|
1417 void CLmkEditorImpl::SetEditableL( TBool aState ) |
|
1418 { |
|
1419 CAknForm::SetEditableL( aState ); |
|
1420 } |
|
1421 |
|
1422 // ----------------------------------------------------------------------------- |
|
1423 // CLmkEditorImpl::Database |
|
1424 // ----------------------------------------------------------------------------- |
|
1425 // |
|
1426 CPosLandmarkDatabase& CLmkEditorImpl::Database() |
|
1427 { |
|
1428 return iDb; |
|
1429 } |
|
1430 |
|
1431 // ----------------------------------------------------------------------------- |
|
1432 // CLmkEditorImpl::GetCurrentEditedLandmarkL |
|
1433 // ----------------------------------------------------------------------------- |
|
1434 // |
|
1435 CPosLandmark* CLmkEditorImpl::GetCurrentEditedLandmarkL() |
|
1436 { |
|
1437 iEditorFieldArray->SaveFieldsToBufferL(); |
|
1438 CArrayPtrFlat<MLmkFieldData>& fieldArray = iLmkFields->Fields(); |
|
1439 TInt count( fieldArray.Count() ); |
|
1440 CPosLandmark* lmk = NULL; |
|
1441 if( iLandmark ) |
|
1442 { |
|
1443 HBufC8* lmBuf = PosLandmarkSerialization::PackL( *iLandmark ); |
|
1444 CleanupStack::PushL( lmBuf ); |
|
1445 lmk = PosLandmarkSerialization::UnpackL( lmBuf->Des() ); |
|
1446 CleanupStack::PopAndDestroy( lmBuf ); |
|
1447 } |
|
1448 else |
|
1449 { |
|
1450 lmk = CPosLandmark::NewL(); |
|
1451 } |
|
1452 |
|
1453 TBool isPosFieldPresent=EFalse; |
|
1454 |
|
1455 TLocationData locationData; // to store editor position data |
|
1456 |
|
1457 //Position data |
|
1458 TLocality locality = TLocality(); // empty locality |
|
1459 |
|
1460 locationData.iLatitude = locality.Latitude(); |
|
1461 locationData.iLongitude = locality.Longitude(); |
|
1462 locationData.iAltitude = locality.Altitude(); |
|
1463 locationData.iHorizontalAccuracy = locality.HorizontalAccuracy(); |
|
1464 locationData.iVerticalAccuracy = locality.VerticalAccuracy(); |
|
1465 |
|
1466 for ( TInt i = 0; i < count; i++ ) |
|
1467 { |
|
1468 switch( fieldArray[i]->FieldType() ) |
|
1469 { |
|
1470 case EName: |
|
1471 { |
|
1472 lmk->SetLandmarkNameL( fieldArray[i]->TextData() ); |
|
1473 HBufC* path = fieldArray[i]->IconPath(); |
|
1474 if ( path && path->Length() > 0 && |
|
1475 fieldArray[i]->IconId() != KErrNotFound ) |
|
1476 { |
|
1477 // Get the default Mask index |
|
1478 lmk->SetIconL( *path, fieldArray[i]->IconId() , KLmkDefaultId+1); |
|
1479 } |
|
1480 |
|
1481 break; |
|
1482 } |
|
1483 case ECategory: |
|
1484 case ECategories: |
|
1485 { |
|
1486 //Add categories to landmark |
|
1487 RArray<TPosLmItemId>& categories = |
|
1488 fieldArray[i]->Categories(); |
|
1489 TInt Tcount( categories.Count() ); |
|
1490 for ( TInt j=0; j < Tcount; j++ ) |
|
1491 { |
|
1492 lmk->AddCategoryL( categories[j] ); |
|
1493 } |
|
1494 break; |
|
1495 } |
|
1496 case EDescription: |
|
1497 { |
|
1498 lmk->SetLandmarkDescriptionL( fieldArray[i]->TextData() ); |
|
1499 break; |
|
1500 } |
|
1501 //these all are same |
|
1502 case EStreet: |
|
1503 case EPostCode: |
|
1504 case ECity: |
|
1505 case EStateProvince: |
|
1506 case ECountry: |
|
1507 case EPhoneNumber: |
|
1508 case EWebAddress: |
|
1509 { |
|
1510 lmk->SetPositionFieldL( |
|
1511 fieldArray[i]->PositionFieldId(), |
|
1512 fieldArray[i]->TextData() ); |
|
1513 break; |
|
1514 } |
|
1515 case ELatitude: |
|
1516 { |
|
1517 isPosFieldPresent = ETrue; |
|
1518 locationData.iLatitude = fieldArray[i]->DoubleData(); |
|
1519 break; |
|
1520 } |
|
1521 case ELongitude: |
|
1522 { |
|
1523 isPosFieldPresent = ETrue; |
|
1524 locationData.iLongitude = fieldArray[i]->DoubleData(); |
|
1525 break; |
|
1526 } |
|
1527 case EPositionAccuracy: |
|
1528 { |
|
1529 locationData.iHorizontalAccuracy = |
|
1530 fieldArray[i]->FloatData(); |
|
1531 break; |
|
1532 } |
|
1533 case EAltitude: |
|
1534 { |
|
1535 locationData.iAltitude = fieldArray[i]->FloatData(); |
|
1536 break; |
|
1537 } |
|
1538 case EAltitudeAccuracy: |
|
1539 { |
|
1540 locationData.iVerticalAccuracy = fieldArray[i]->FloatData(); |
|
1541 break; |
|
1542 } |
|
1543 default: |
|
1544 { |
|
1545 break; |
|
1546 } |
|
1547 } |
|
1548 } |
|
1549 |
|
1550 if( isPosFieldPresent ) |
|
1551 { |
|
1552 // remove the old values to set new values |
|
1553 lmk->RemoveLandmarkAttributes(CPosLandmark::EPosition); |
|
1554 |
|
1555 if (!Math::IsNaN(locationData.iLatitude) && |
|
1556 !Math::IsNaN(locationData.iLongitude)) |
|
1557 { |
|
1558 if (!Math::IsNaN(locationData.iAltitude)) |
|
1559 { |
|
1560 locality.SetCoordinate( |
|
1561 locationData.iLatitude, |
|
1562 locationData.iLongitude, |
|
1563 locationData.iAltitude); |
|
1564 |
|
1565 if (!Math::IsNaN(locationData.iVerticalAccuracy)) |
|
1566 { |
|
1567 if( locationData.iVerticalAccuracy > 0 ) |
|
1568 locality.SetVerticalAccuracy(locationData.iVerticalAccuracy); |
|
1569 } |
|
1570 } |
|
1571 else |
|
1572 { |
|
1573 locality.SetCoordinate( |
|
1574 locationData.iLatitude, |
|
1575 locationData.iLongitude); |
|
1576 } |
|
1577 |
|
1578 if (!Math::IsNaN(locationData.iHorizontalAccuracy)) |
|
1579 { |
|
1580 if( locationData.iHorizontalAccuracy > 0 ) |
|
1581 locality.SetHorizontalAccuracy(locationData.iHorizontalAccuracy); |
|
1582 } |
|
1583 // save position if at least lat/lon are entered |
|
1584 lmk->SetPositionL(locality); |
|
1585 } |
|
1586 } |
|
1587 |
|
1588 return lmk; |
|
1589 } |
|
1590 |
|
1591 // ----------------------------------------------------------------------------- |
|
1592 // CLmkEditorImpl::CreateLabelArrayL |
|
1593 // ----------------------------------------------------------------------------- |
|
1594 // |
|
1595 void CLmkEditorImpl::CreateLabelArrayL() |
|
1596 { |
|
1597 |
|
1598 if ( iJapaneseInputMode ) |
|
1599 { |
|
1600 // Display in Japanese order |
|
1601 CreateLabelArrayForJapaneseModeL(); |
|
1602 } |
|
1603 else |
|
1604 { // Normal mode |
|
1605 CreateLabelArrayForNormalModeL(); |
|
1606 } |
|
1607 } |
|
1608 |
|
1609 // ----------------------------------------------------------------------------- |
|
1610 // CLmkEditorImpl::CreateLabelArrayForNormalModeL() |
|
1611 // ----------------------------------------------------------------------------- |
|
1612 // |
|
1613 void CLmkEditorImpl::CreateLabelArrayForNormalModeL() |
|
1614 { |
|
1615 CreateLabelL( R_LMK_NAME_LABEL, EName ); |
|
1616 CreateLabelL( R_LMK_CATEGORY_LABEL, ECategory ); |
|
1617 CreateLabelL( R_LMK_CATEGORIES_LABEL, ECategories ); |
|
1618 CreateLabelL( R_LMK_DESCRIPTION_LABEL, EDescription ); |
|
1619 CreateLabelL( R_LMK_STREET_LABEL, EStreet ); |
|
1620 CreateLabelL( R_LMK_POST_CODE_LABEL, EPostCode ); |
|
1621 CreateLabelL( R_LMK_CITY_LABEL, ECity ); |
|
1622 CreateLabelL( R_LMK_STATE_PROVINCE_LABEL, EStateProvince ); |
|
1623 CreateLabelL( R_LMK_COUNTRY_LABEL, ECountry ); |
|
1624 CreateLabelL( R_LMK_PHONE_NUMBER_LABEL, EPhoneNumber ); |
|
1625 CreateLabelL( R_LMK_WEB_ADDRESS_LABEL, EWebAddress ); |
|
1626 CreateLabelL( R_LMK_LATITUDE_LABEL, ELatitude ); |
|
1627 CreateLabelL( R_LMK_LONGITUDE_LABEL, ELongitude ); |
|
1628 CreateLabelL( R_LMK_POSITION_ACCURACY_LABEL, EPositionAccuracy ); |
|
1629 CreateLabelL( R_LMK_ALTITUDE_LABEL, EAltitude ); |
|
1630 CreateLabelL( R_LMK_ALTITUDE_ACCURACY_LABEL, EAltitudeAccuracy ); |
|
1631 } |
|
1632 |
|
1633 // ----------------------------------------------------------------------------- |
|
1634 // CLmkEditorImpl::CreateLabelArrayForJapaneseModeL() |
|
1635 // ----------------------------------------------------------------------------- |
|
1636 // |
|
1637 void CLmkEditorImpl::CreateLabelArrayForJapaneseModeL() |
|
1638 { |
|
1639 CreateLabelL( R_LMK_NAME_LABEL, ENameJapaneseMode); |
|
1640 CreateLabelL( R_LMK_CATEGORY_LABEL, ECategoryJapaneseMode ); |
|
1641 CreateLabelL( R_LMK_CATEGORIES_LABEL, ECategoriesJapaneseMode ); |
|
1642 CreateLabelL( R_LMK_DESCRIPTION_LABEL, EDescriptionJapaneseMode ); |
|
1643 CreateLabelL( R_LMK_POST_CODE_LABEL, EPostCodeJapaneseMode ); |
|
1644 CreateLabelL( R_LMK_STATE_PROVINCE_LABEL, EStateProvinceJapaneseMode ); |
|
1645 CreateLabelL( R_LMK_CITY_LABEL, ECityJapaneseMode ); |
|
1646 CreateLabelL( R_LMK_STREET_LABEL, EStreetJapaneseMode ); |
|
1647 CreateLabelL( R_LMK_COUNTRY_LABEL, ECountryJapaneseMode ); |
|
1648 CreateLabelL( R_LMK_PHONE_NUMBER_LABEL, EPhoneNumberJapaneseMode ); |
|
1649 CreateLabelL( R_LMK_WEB_ADDRESS_LABEL, EWebAddressJapaneseMode ); |
|
1650 CreateLabelL( R_LMK_LATITUDE_LABEL, ELatitudeJapaneseMode ); |
|
1651 CreateLabelL( R_LMK_LONGITUDE_LABEL, ELongitudeJapaneseMode ); |
|
1652 CreateLabelL( R_LMK_POSITION_ACCURACY_LABEL, EPositionAccuracyJapaneseMode ); |
|
1653 CreateLabelL( R_LMK_ALTITUDE_LABEL, EAltitudeJapaneseMode ); |
|
1654 CreateLabelL( R_LMK_ALTITUDE_ACCURACY_LABEL, EAltitudeAccuracyJapaneseMode ); |
|
1655 } |
|
1656 |
|
1657 // ----------------------------------------------------------------------------- |
|
1658 // CLmkEditorImpl::CreateLabelL |
|
1659 // ----------------------------------------------------------------------------- |
|
1660 // |
|
1661 void CLmkEditorImpl::CreateLabelL( TInt iResourceId, TInt iPos ) |
|
1662 { |
|
1663 HBufC* label = iCoeEnv->AllocReadResourceL( iResourceId ); |
|
1664 CleanupStack::PushL( label ); |
|
1665 User::LeaveIfError( iLabelArray.Insert( label, iPos ) ); |
|
1666 CleanupStack::Pop(); //label |
|
1667 } |
|
1668 |
|
1669 |
|
1670 // ----------------------------------------------------------------------------- |
|
1671 // CLmkEditorImpl::IsNameFieldEmptyL |
|
1672 // ----------------------------------------------------------------------------- |
|
1673 // |
|
1674 TBool CLmkEditorImpl::IsNameFieldEmptyL() |
|
1675 { |
|
1676 const MLmkEditorField* field = &iEditorFieldArray->FieldAt( 0 ); |
|
1677 HBufC* fieldText = field->ControlTextL(); |
|
1678 TBool ret( ETrue ); |
|
1679 if ( fieldText && fieldText->Length() > 0 ) |
|
1680 { |
|
1681 //Check if any active character or not |
|
1682 TPtr16 ptr = fieldText->Des(); |
|
1683 ptr.Trim(); |
|
1684 if (ptr.Length() == 0) |
|
1685 { |
|
1686 ret = ETrue; |
|
1687 } |
|
1688 else |
|
1689 { |
|
1690 ret = EFalse; |
|
1691 } |
|
1692 } |
|
1693 delete fieldText; |
|
1694 return ret; |
|
1695 } |
|
1696 |
|
1697 |
|
1698 // ----------------------------------------------------------------------------- |
|
1699 // CLmkEditorImpl::ValidateContentL() |
|
1700 // ----------------------------------------------------------------------------- |
|
1701 // |
|
1702 TBool CLmkEditorImpl::ValidateContentL() |
|
1703 { |
|
1704 TBool result = ETrue; |
|
1705 if(IsFieldEmptyL( ELatitude ) && !IsFieldEmptyL( ELongitude )) |
|
1706 { |
|
1707 LmkNotes::InformationNoteL( iEikonEnv,R_LMK_ERROR_CHECK_NOTE ); |
|
1708 DoNotSaveDataL(ELatitude); |
|
1709 result = EFalse; |
|
1710 } |
|
1711 else if (!IsFieldEmptyL( ELatitude ) && IsFieldEmptyL( ELongitude )) |
|
1712 { |
|
1713 LmkNotes::InformationNoteL( iEikonEnv, R_LMK_ERROR_CHECK_NOTE ); |
|
1714 DoNotSaveDataL(ELongitude); |
|
1715 result = EFalse; |
|
1716 } |
|
1717 else if(IsFieldEmptyL( ELatitude ) && !IsFieldEmptyL( EPositionAccuracy )) |
|
1718 { |
|
1719 LmkNotes::InformationNoteL( iEikonEnv, R_LMK_ERROR_POS_ACC_CHECK_NOTE ); |
|
1720 DoNotSaveDataL(ELatitude); |
|
1721 result = EFalse; |
|
1722 } |
|
1723 else if (IsFieldEmptyL( ELongitude ) && !IsFieldEmptyL( EPositionAccuracy )) |
|
1724 { |
|
1725 LmkNotes::InformationNoteL( iEikonEnv, R_LMK_ERROR_POS_ACC_CHECK_NOTE ); |
|
1726 DoNotSaveDataL(ELongitude); |
|
1727 result = EFalse; |
|
1728 } |
|
1729 else if (IsFieldEmptyL( EAltitude ) && !IsFieldEmptyL( EAltitudeAccuracy )) |
|
1730 { |
|
1731 LmkNotes::InformationNoteL( iEikonEnv, R_LMK_ERROR_ALT_ACC_CHECK_NOTE ); |
|
1732 DoNotSaveDataL(EAltitude); |
|
1733 result = EFalse; |
|
1734 } |
|
1735 else if ((IsFieldEmptyL( ELatitude ) || IsFieldEmptyL( ELongitude )) && !IsFieldEmptyL( EAltitude )) |
|
1736 { |
|
1737 LmkNotes::InformationNoteL( iEikonEnv, R_LMK_ERROR_ALTITUDE_CHECK_NOTE ); |
|
1738 DoNotSaveDataL(ELatitude); |
|
1739 result = EFalse; |
|
1740 } |
|
1741 else if (IsInvalidUriL()) |
|
1742 { |
|
1743 LmkNotes::InformationNoteL( iEikonEnv, R_LMK_ERROR_URL_ILLEGAL_NOTE ); |
|
1744 DoNotSaveDataL(EWebAddress); |
|
1745 result = EFalse; |
|
1746 } |
|
1747 else if ( IsNameFieldEmptyL() ) |
|
1748 { |
|
1749 DoNotSaveFormDataL(); |
|
1750 iIsEndKey = EFalse; |
|
1751 result = EFalse; |
|
1752 } |
|
1753 return result; |
|
1754 |
|
1755 } |
|
1756 |
|
1757 // ----------------------------------------------------------------------------- |
|
1758 // CLmkEditorImpl::IsFieldEmptyL() |
|
1759 // ----------------------------------------------------------------------------- |
|
1760 // |
|
1761 TBool CLmkEditorImpl::IsFieldEmptyL(const TUint16 aFieldType) |
|
1762 { |
|
1763 TInt fldId; |
|
1764 MLmkFieldData* field = iLmkFields->GetField(aFieldType); |
|
1765 if(field) |
|
1766 { |
|
1767 fldId = field->UniqueFieldIdentity(); |
|
1768 } |
|
1769 else |
|
1770 { |
|
1771 return EFalse; |
|
1772 } |
|
1773 |
|
1774 MLmkEditorField* fld = iEditorFieldArray->Find(fldId ); |
|
1775 if(!fld) |
|
1776 { |
|
1777 return ETrue; |
|
1778 } |
|
1779 |
|
1780 TReal val; |
|
1781 switch(aFieldType) |
|
1782 { |
|
1783 case ELatitude: |
|
1784 case ELongitude: |
|
1785 { |
|
1786 val = fld->FieldValue(); |
|
1787 } |
|
1788 break; |
|
1789 case EPositionAccuracy: |
|
1790 case EAltitudeAccuracy: |
|
1791 case EAltitude: |
|
1792 { |
|
1793 val = fld->FieldValue(); |
|
1794 } |
|
1795 break; |
|
1796 } |
|
1797 return Math::IsNaN(val); |
|
1798 } |
|
1799 |
|
1800 |
|
1801 // ----------------------------------------------------------------------------- |
|
1802 // CLmkEditorImpl::DoNotSaveDataL() |
|
1803 // ----------------------------------------------------------------------------- |
|
1804 // |
|
1805 void CLmkEditorImpl::DoNotSaveDataL(const TUint16 aFieldType) |
|
1806 { |
|
1807 if( iIsEditing ) |
|
1808 { |
|
1809 MLmkFieldData* fields = iLmkFields->GetField(aFieldType); |
|
1810 if(fields) |
|
1811 { |
|
1812 TInt id = fields->UniqueFieldIdentity(); |
|
1813 TryChangeFocusL(id); |
|
1814 } |
|
1815 } |
|
1816 } |
|
1817 // ----------------------------------------------------------------------------- |
|
1818 // CLmkEditorImpl::OkToExitL |
|
1819 // ----------------------------------------------------------------------------- |
|
1820 // |
|
1821 TBool CLmkEditorImpl::OkToExitL() |
|
1822 { |
|
1823 TBool result = ETrue; |
|
1824 |
|
1825 if ( iEditorFieldArray->AreAllFieldsEmptyL() ) |
|
1826 { |
|
1827 iLmkFields->DeleteLandmarkL(); |
|
1828 } |
|
1829 else |
|
1830 { |
|
1831 if ( IsNameFieldEmptyL() ) |
|
1832 { |
|
1833 DoNotSaveFormDataL(); |
|
1834 result = EFalse; |
|
1835 } |
|
1836 else |
|
1837 { |
|
1838 TRAPD( err, iEditorFieldArray->SaveFieldsL() ); |
|
1839 if ( err == KErrDiskFull ) |
|
1840 { |
|
1841 result = EFalse; |
|
1842 LmkNotes::OutOfMemoryNoteL( iEikonEnv ); |
|
1843 delete this; |
|
1844 return result; |
|
1845 } |
|
1846 if ( iLandmarkItemId ) |
|
1847 { |
|
1848 *iLandmarkItemId = iLmkFields->LandmarkId(); |
|
1849 } |
|
1850 } |
|
1851 } |
|
1852 |
|
1853 return result; |
|
1854 } |
|
1855 |
|
1856 // ----------------------------------------------------------------------------- |
|
1857 // CLmkEditorImpl::SelectCategoriesCmdL |
|
1858 // ----------------------------------------------------------------------------- |
|
1859 // |
|
1860 void CLmkEditorImpl::SelectCategoriesCmdL() |
|
1861 { |
|
1862 if(iCatInfoPopupNote) |
|
1863 { |
|
1864 iCatInfoPopupNote->HideInfoPopupNote(); |
|
1865 } |
|
1866 MLmkFieldData* fields = iLmkFields->GetField( ECategory ); |
|
1867 if ( !fields ) |
|
1868 { |
|
1869 fields = iLmkFields->GetField( ECategories ); |
|
1870 } |
|
1871 |
|
1872 if ( fields ) |
|
1873 { |
|
1874 CLmkDlgCategorySelectorImpl* dlg = CLmkDlgCategorySelectorImpl::NewL( |
|
1875 iDb, ETrue ); |
|
1876 CleanupStack::PushL( dlg ); |
|
1877 dlg->SetEmptyDlgLabel(R_LMK_EMPTY_NO_CATEGORIES ,R_LMK_GUIDE_CREATE_LANDMARK); |
|
1878 RArray<TPosLmItemId>& categories = fields->Categories(); |
|
1879 if ( dlg->ExecuteL( categories ) ) |
|
1880 { |
|
1881 iEditorFieldArray->UpdateFieldsL( ECategory ); |
|
1882 iEditorFieldArray->UpdateFieldsL( ECategories ); |
|
1883 } |
|
1884 CleanupStack::PopAndDestroy( dlg ); |
|
1885 iIsCategorySelctorOpen = EFalse; |
|
1886 DrawNow(); |
|
1887 // ShowMultipleCategoriesInfoPopupL(ETrue); |
|
1888 } |
|
1889 } |
|
1890 |
|
1891 // ----------------------------------------------------------------------------- |
|
1892 // CLmkEditorImpl::CurrentLocationCmdL |
|
1893 // ----------------------------------------------------------------------------- |
|
1894 // |
|
1895 void CLmkEditorImpl::CurrentLocationCmdL() |
|
1896 { |
|
1897 if(ShowQueryIfLocationFieldsAlreadyFilledL()) |
|
1898 { |
|
1899 return; |
|
1900 } |
|
1901 HBufC* srvName = StringLoader::LoadLC( |
|
1902 R_LMK_SERVICE_RULE_NAME, |
|
1903 const_cast< CCoeEnv *>( iCoeEnv )); |
|
1904 iLocationService = CLmkLocationService::NewL(*srvName); |
|
1905 CleanupStack::PopAndDestroy( srvName ); //srvName |
|
1906 iLocationService->SetObserver( *this ); |
|
1907 iLocationService->LocationRequestL(); |
|
1908 |
|
1909 TRAPD( error, iWaitDialogLauncher->StartWaitDialogL()); |
|
1910 if( error ) |
|
1911 { |
|
1912 delete iLocationService; |
|
1913 iLocationService = NULL; |
|
1914 |
|
1915 User::Leave( error ); |
|
1916 } |
|
1917 } |
|
1918 |
|
1919 // ----------------------------------------------------------------------------- |
|
1920 // CLmkEditorImpl::ChangeIconCmdL |
|
1921 // ----------------------------------------------------------------------------- |
|
1922 // |
|
1923 void CLmkEditorImpl::ChangeIconCmdL() |
|
1924 { |
|
1925 TInt lSelectedIconIndex(0); |
|
1926 CLmkIconMapDialog* dialog = new(ELeave) CLmkIconMapDialog( lSelectedIconIndex ); |
|
1927 MLmkFieldData* nameField; |
|
1928 if (dialog->ExecuteLD(R_LMK_ICON_TABLE_DIALOG) ) |
|
1929 { |
|
1930 // icon file also contains masks, therefore 2* |
|
1931 TInt iconIndex = 2*lSelectedIconIndex; |
|
1932 RFs fs; |
|
1933 User::LeaveIfError(fs.Connect()); |
|
1934 CleanupClosePushL( fs ); |
|
1935 |
|
1936 if ( SysUtil::DiskSpaceBelowCriticalLevelL( &fs, sizeof( CPosLandmark ), EDriveC ) ) |
|
1937 { |
|
1938 CleanupStack::PopAndDestroy(); // fs |
|
1939 User::LeaveNoMemory(); |
|
1940 } |
|
1941 else |
|
1942 { |
|
1943 nameField = iLmkFields->GetField( EName ); |
|
1944 TFileName* iconFile = CLmkUiUtils::LmkUiIconFileLC(); |
|
1945 if( nameField && iconFile ) |
|
1946 { |
|
1947 nameField->SetIconId( iconIndex + EMbmLmkuiQgn_prop_lm_transport); |
|
1948 nameField->SetIconPathL( *iconFile ); |
|
1949 |
|
1950 //Update context icon |
|
1951 CEikImage* image = new(ELeave) CEikImage(); |
|
1952 CleanupStack::PushL( image ); |
|
1953 image->CreatePictureFromFileL( *iconFile, |
|
1954 nameField->IconId(), |
|
1955 iconIndex + EMbmLmkuiQgn_prop_lm_transport_mask); |
|
1956 |
|
1957 iLmkUiUtils->UpdateContextIconL( image ); |
|
1958 |
|
1959 // Added for appending Icon to Name label |
|
1960 CLmkUiUtils::ChangeLmNameLabelIconL (*this, *nameField); |
|
1961 CleanupStack::Pop(); //image |
|
1962 CleanupStack::PopAndDestroy();//iconFile |
|
1963 DrawNow(); |
|
1964 } |
|
1965 } |
|
1966 CleanupStack::PopAndDestroy(); // fs |
|
1967 } |
|
1968 } |
|
1969 |
|
1970 // ----------------------------------------------------------------------------- |
|
1971 // CLmkEditorImpl::CategoriesCmdL |
|
1972 // ----------------------------------------------------------------------------- |
|
1973 // |
|
1974 void CLmkEditorImpl::CategoriesCmdL() |
|
1975 { |
|
1976 MLmkFieldData* categoryField = iLmkFields->GetField( ECategories ); |
|
1977 if ( !categoryField ) |
|
1978 { |
|
1979 categoryField = iLmkFields->GetField( ECategory ); |
|
1980 if ( !categoryField ) |
|
1981 { |
|
1982 return; |
|
1983 } |
|
1984 } |
|
1985 else |
|
1986 { |
|
1987 RArray<TPosLmItemId> categories = categoryField->Categories(); |
|
1988 TInt count( categories.Count() ); |
|
1989 |
|
1990 // Do not launch the popup for displaying one category name |
|
1991 if (count <=1 ) |
|
1992 { |
|
1993 //Launch context sensitive menu bar here |
|
1994 if ( iContextMenuBar ) |
|
1995 { |
|
1996 iContextMenuBar->TryDisplayMenuBarL(); |
|
1997 } |
|
1998 return; |
|
1999 } |
|
2000 |
|
2001 HBufC* catName; |
|
2002 // show the category list in a message query |
|
2003 HBufC* message = HBufC::NewLC( (KPosLmMaxCategoryNameLength * count) + 1); |
|
2004 TPtr msgPtr = message->Des(); |
|
2005 CDesC16ArrayFlat* desArr = new (ELeave) CDesC16ArrayFlat(count); |
|
2006 CleanupStack::PushL(desArr); |
|
2007 // fill up the array with category´s names from the engine. |
|
2008 for ( TInt i = 0; i < count; i++ ) |
|
2009 { |
|
2010 catName = CLmkDbUtils::CategoryNameL( iDb, categories[i] ); |
|
2011 CleanupStack::PushL( catName ); |
|
2012 desArr->AppendL(catName->Des()); |
|
2013 CleanupStack::PopAndDestroy( catName ); //name |
|
2014 } |
|
2015 desArr->Sort(); |
|
2016 for ( TInt i = 0; i < count; i++ ) |
|
2017 { |
|
2018 msgPtr.Append((*desArr)[i]); |
|
2019 if ( i != ( count - 1 ) ) |
|
2020 { |
|
2021 msgPtr.Append(_L("\n")); |
|
2022 } |
|
2023 } |
|
2024 LmkNotes::MessageQueryL( iEikonEnv, msgPtr, count ); |
|
2025 CleanupStack::Pop();//desArr |
|
2026 delete desArr; |
|
2027 CleanupStack::PopAndDestroy( message ); //message |
|
2028 } |
|
2029 } |
|
2030 |
|
2031 // ----------------------------------------------------------------------------- |
|
2032 // CLmkEditorImpl::SetCurrentLocationL |
|
2033 // ----------------------------------------------------------------------------- |
|
2034 // |
|
2035 void CLmkEditorImpl::SetCurrentLocationL( const TPosition& aPosition ) |
|
2036 { |
|
2037 MLmkFieldData* latitude = iLmkFields->GetField( ELatitude ); |
|
2038 if(latitude) |
|
2039 { |
|
2040 latitude->SetTReal( aPosition.Latitude() ); |
|
2041 |
|
2042 MLmkFieldData* longitude = iLmkFields->GetField( ELongitude ); |
|
2043 if(longitude) |
|
2044 longitude->SetTReal( aPosition.Longitude() ); |
|
2045 } |
|
2046 |
|
2047 MLmkFieldData* altitude = iLmkFields->GetField( EAltitude ); |
|
2048 if(altitude) |
|
2049 { |
|
2050 altitude->SetTReal( aPosition.Altitude() ); |
|
2051 } |
|
2052 |
|
2053 MLmkFieldData* horizontalAccuracy = |
|
2054 iLmkFields->GetField( EPositionAccuracy ); |
|
2055 if(horizontalAccuracy) |
|
2056 { |
|
2057 horizontalAccuracy->SetTReal( aPosition.HorizontalAccuracy() ); |
|
2058 } |
|
2059 |
|
2060 MLmkFieldData* verticalAccuracy = |
|
2061 iLmkFields->GetField( EAltitudeAccuracy ); |
|
2062 if(verticalAccuracy) |
|
2063 { |
|
2064 verticalAccuracy->SetTReal( aPosition.VerticalAccuracy() ); |
|
2065 } |
|
2066 |
|
2067 TRAP_IGNORE(iLandmark->SetPositionL(aPosition)); |
|
2068 |
|
2069 iEditorFieldArray->UpdateFieldsL( EAllEditorItems ); |
|
2070 |
|
2071 DrawNow(); |
|
2072 } |
|
2073 |
|
2074 // ----------------------------------------------------------------------------- |
|
2075 // CLmkEditorImpl::ChangeContextImageL |
|
2076 // ----------------------------------------------------------------------------- |
|
2077 // |
|
2078 void CLmkEditorImpl::ChangeContextImageL() |
|
2079 { |
|
2080 MLmkFieldData* nameField = iLmkFields->GetField( EName ); |
|
2081 if( nameField ) |
|
2082 { |
|
2083 CEikImage* image = new(ELeave) CEikImage(); |
|
2084 CleanupStack::PushL( image ); |
|
2085 TFileName* defaultIconFile = CLmkUiUtils::LmkUiIconFileLC(); |
|
2086 // No need to add iconFile to cleanupstack since it is a member variable from CLmkFieldData class |
|
2087 HBufC *iconFile = nameField->IconPath(); |
|
2088 TInt err = KErrNotFound; |
|
2089 CFbsBitmap* bitmap; |
|
2090 CFbsBitmap* mask; |
|
2091 if ( nameField->IconId() != KErrNotFound ) |
|
2092 { |
|
2093 TRAP(err,AknIconUtils::CreateIconL( bitmap, mask, |
|
2094 *iconFile, nameField->IconId(), |
|
2095 nameField->IconId()+1 );); |
|
2096 } |
|
2097 // If the Icon File doesn't exist the CreateIconL in the if statement above will |
|
2098 // Leave with KErrNotFound in which case the default Icon should be loaded. |
|
2099 // Also when the Landmarks itself doesn't have a valid Icon, the default Icon is |
|
2100 // loaded. |
|
2101 if ( err != KErrNone ) |
|
2102 { |
|
2103 AknIconUtils::CreateIconL( bitmap, mask, |
|
2104 *defaultIconFile, KLmkDefaultId, |
|
2105 KLmkDefaultId+1 ); |
|
2106 } |
|
2107 image->SetBitmap( bitmap ); |
|
2108 image->SetMask( mask ); |
|
2109 iLmkUiUtils->SwapNewContextIconL( image ); |
|
2110 CleanupStack::PopAndDestroy(); //defaultIconFile |
|
2111 CleanupStack::Pop(); //image |
|
2112 } |
|
2113 } |
|
2114 |
|
2115 // ---------------------------------------------------------------------------- |
|
2116 // CLmkEditorImpl::AttachAIWMenuInterestL |
|
2117 // ---------------------------------------------------------------------------- |
|
2118 // |
|
2119 void CLmkEditorImpl::AttachAIWMenuInterestL() |
|
2120 { |
|
2121 if(iMapNavFeature) |
|
2122 { |
|
2123 iMapNavInterface->AttachAIWInterestL(R_LMK_EDITOR_MENU, R_LMK_EDITOR_AIW_INTEREST_SHOWONMAP); |
|
2124 if (iEditorMode != CLmkEditorDlg::ELmkEditor) |
|
2125 { |
|
2126 iMapNavInterface->AttachAIWInterestL(R_LMK_EDITOR_MENU, R_LMK_EDITOR_AIW_INTEREST_NAVIGATETO); |
|
2127 } |
|
2128 } |
|
2129 } |
|
2130 |
|
2131 // ----------------------------------------------------------------------------- |
|
2132 // CLmkEditorImpl::HandleResourceChange() |
|
2133 // ----------------------------------------------------------------------------- |
|
2134 // |
|
2135 void CLmkEditorImpl::HandleResourceChange (TInt aType) |
|
2136 { |
|
2137 CAknForm::HandleResourceChange(aType); |
|
2138 } |
|
2139 |
|
2140 // ----------------------------------------------------------------------------- |
|
2141 // CLmkEditorImpl::CategoriesCmdFromXmlL |
|
2142 // ----------------------------------------------------------------------------- |
|
2143 // |
|
2144 void CLmkEditorImpl::CategoriesCmdFromXmlL() |
|
2145 { |
|
2146 TInt count = iCategoryNames.Count(); |
|
2147 if ( count <= 1 ) |
|
2148 { |
|
2149 return; |
|
2150 } |
|
2151 CDesC16ArrayFlat* desArr = new (ELeave) CDesC16ArrayFlat(count); |
|
2152 CleanupStack::PushL(desArr); |
|
2153 // fill up the array with category´s names from the engine. |
|
2154 for ( TInt i = 0; i < count; i++ ) |
|
2155 { |
|
2156 desArr->AppendL(iCategoryNames[i]); |
|
2157 } |
|
2158 |
|
2159 desArr->Sort(); |
|
2160 // show the category list in a message query |
|
2161 HBufC* message = HBufC::NewLC((KPosLmMaxCategoryNameLength * iCategoryNames.Count()) + 1); |
|
2162 TPtr msgPtr = message->Des(); |
|
2163 for ( TInt i = 0; i < count; i++ ) |
|
2164 { |
|
2165 msgPtr.Append((*desArr)[i]); |
|
2166 if ( i != ( count - 1 )) |
|
2167 { |
|
2168 msgPtr.Append(_L("\n")); |
|
2169 } |
|
2170 } |
|
2171 LmkNotes::MessageQueryL( iEikonEnv, msgPtr, count ); |
|
2172 CleanupStack::PopAndDestroy( 2 ); //message ,desArr |
|
2173 } |
|
2174 |
|
2175 // ----------------------------------------------------------------------------- |
|
2176 // CLmkEditorImpl::ConstructContextMenuL() |
|
2177 // ----------------------------------------------------------------------------- |
|
2178 // |
|
2179 void CLmkEditorImpl::ConstructContextMenuL() |
|
2180 { |
|
2181 CEikMenuBar* newMenuBar = new(ELeave) CEikMenuBar(); |
|
2182 CleanupStack::PushL(newMenuBar); |
|
2183 newMenuBar->ConstructL(this, NULL, R_LMK_EDITOR_CONTEXT_MENUBAR); |
|
2184 iEikonEnv->EikAppUi()->AddToStackL(newMenuBar, ECoeStackPriorityMenu, ECoeStackFlagRefusesFocus); |
|
2185 iContextMenuBar = newMenuBar; |
|
2186 CleanupStack::Pop(newMenuBar); |
|
2187 } |
|
2188 |
|
2189 // ----------------------------------------------------------------------------- |
|
2190 // CLmkEditorImpl::GetFieldTextLengthL |
|
2191 // ----------------------------------------------------------------------------- |
|
2192 // |
|
2193 TInt CLmkEditorImpl::GetFieldTextLengthL( MLmkEditorField& afield) |
|
2194 { |
|
2195 HBufC* fieldText = afield.ControlTextL(); |
|
2196 TInt fieldLen (0); |
|
2197 if ( fieldText ) |
|
2198 { |
|
2199 if ( fieldText->Length() > 0) |
|
2200 {// Remove any blank spaces if any |
|
2201 TPtr16 ptr = fieldText->Des(); |
|
2202 ptr.Trim(); |
|
2203 fieldLen = ptr.Length(); |
|
2204 } |
|
2205 } |
|
2206 delete fieldText; |
|
2207 return fieldLen; |
|
2208 } |
|
2209 // ----------------------------------------------------------------------------- |
|
2210 // CLmkEditorImpl::UpdateViewDlgL |
|
2211 // ----------------------------------------------------------------------------- |
|
2212 // |
|
2213 void CLmkEditorImpl::UpdateViewDlgL() |
|
2214 { |
|
2215 |
|
2216 CPosLandmark* landmark; |
|
2217 TInt id = iLmkFields->LandmarkId(); |
|
2218 landmark = iDb.ReadLandmarkLC(id); |
|
2219 TLocality locality; |
|
2220 landmark->GetPosition(locality); |
|
2221 TRAP_IGNORE(iLandmark->SetPositionL(locality)); |
|
2222 CArrayPtrFlat<MLmkFieldData>& fieldArray = iLmkFields->Fields(); |
|
2223 CArrayPtrFlat<MLmkEditorField>& editorFieldArray = |
|
2224 iEditorFieldArray->GetFieldArray(); |
|
2225 TInt count = fieldArray.Count(); |
|
2226 TInt postn = KErrNotFound; |
|
2227 TInt ctrlid = KErrNotFound; |
|
2228 for (TInt i(0);i<count;i++) |
|
2229 { |
|
2230 TUint fieldType = fieldArray[i]->FieldType(); |
|
2231 MLmkEditorField* fld = iEditorFieldArray->Find(fieldArray[i]->UniqueFieldIdentity(),&postn,&ctrlid); |
|
2232 |
|
2233 switch(fieldType) |
|
2234 { |
|
2235 case EName: |
|
2236 { |
|
2237 UpdateNameEditorControlL(fld,landmark,fieldArray[i]); |
|
2238 break; |
|
2239 } |
|
2240 case ECategory: |
|
2241 case ECategories: |
|
2242 { |
|
2243 UpdateCategoryEditorControlL( fld, fieldArray[i],ctrlid,postn,*landmark); |
|
2244 break; |
|
2245 } |
|
2246 case EDescription: |
|
2247 { |
|
2248 UpdateDesEditorControlL(fld,landmark,fieldArray[i],ctrlid,postn); |
|
2249 break; |
|
2250 } |
|
2251 //these all are same |
|
2252 case EStreet: |
|
2253 case EPostCode: |
|
2254 case ECity: |
|
2255 case EStateProvince: |
|
2256 case ECountry: |
|
2257 case EPhoneNumber: |
|
2258 case EWebAddress: |
|
2259 { |
|
2260 UpdateTextEditorControlL(fld,landmark,fieldArray[i], |
|
2261 fieldType,ctrlid,postn); |
|
2262 break; |
|
2263 } |
|
2264 case ELatitude: |
|
2265 { |
|
2266 UpdateCoordinateEditorControlL(fld,fieldArray[i], |
|
2267 locality.Latitude(), |
|
2268 ctrlid,postn); |
|
2269 break; |
|
2270 } |
|
2271 case ELongitude: |
|
2272 { |
|
2273 UpdateCoordinateEditorControlL(fld,fieldArray[i], |
|
2274 locality.Longitude(), |
|
2275 ctrlid,postn); |
|
2276 break; |
|
2277 } |
|
2278 case EPositionAccuracy: |
|
2279 { |
|
2280 UpdateNumberEditorControlL(fld,fieldArray[i], |
|
2281 locality.HorizontalAccuracy(),ctrlid,postn); |
|
2282 break; |
|
2283 } |
|
2284 case EAltitude: |
|
2285 { |
|
2286 UpdateNumberEditorControlL(fld,fieldArray[i], |
|
2287 locality.Altitude(),ctrlid,postn); |
|
2288 break; |
|
2289 } |
|
2290 case EAltitudeAccuracy: |
|
2291 { |
|
2292 UpdateNumberEditorControlL(fld,fieldArray[i], |
|
2293 locality.VerticalAccuracy(),ctrlid,postn); |
|
2294 break; |
|
2295 } |
|
2296 default: |
|
2297 { |
|
2298 break; |
|
2299 } |
|
2300 } |
|
2301 } |
|
2302 iEditorFieldArray->UpdateFieldsL(); |
|
2303 CleanupStack::PopAndDestroy( landmark ); |
|
2304 DrawNow(); |
|
2305 if(!IsEditable()) |
|
2306 { |
|
2307 //only for landmarks viewer |
|
2308 UpdateMskOnArrowMoveForViewerL(); |
|
2309 //ShowMultipleCategoriesInfoPopupL(ETrue); |
|
2310 } |
|
2311 } |
|
2312 // ----------------------------------------------------------------------------- |
|
2313 // CLmkEditorImpl::ActivateL |
|
2314 // ----------------------------------------------------------------------------- |
|
2315 // |
|
2316 void CLmkEditorImpl::ActivateL() |
|
2317 { |
|
2318 if (iEditorMode == CLmkEditorDlg::ELmkEditor |
|
2319 && iIsEditing) |
|
2320 { |
|
2321 MLmkFieldData* fields = iLmkFields->GetField(iFieldTypeToFocus); |
|
2322 if(fields) |
|
2323 { |
|
2324 TInt id = fields->UniqueFieldIdentity(); |
|
2325 TryChangeFocusL(id); |
|
2326 if (iFieldTypeToFocus == ECategories || iFieldTypeToFocus == ECategory) |
|
2327 { |
|
2328 // ShowMultipleCategoriesInfoPopupL(EFalse); |
|
2329 } |
|
2330 } |
|
2331 } |
|
2332 CCoeControl::ActivateL(); |
|
2333 } |
|
2334 // ----------------------------------------------------------------------------- |
|
2335 // CLmkEditorImpl::UpdateTextEditorControlL |
|
2336 // ----------------------------------------------------------------------------- |
|
2337 // |
|
2338 void CLmkEditorImpl::UpdateTextEditorControlL |
|
2339 (MLmkEditorField* aEditorField, |
|
2340 CPosLandmark* aLandmark, |
|
2341 MLmkFieldData* fieldData, |
|
2342 TUint aFiledType, |
|
2343 TInt aPrevControlId, |
|
2344 TInt aPos |
|
2345 ) |
|
2346 { |
|
2347 |
|
2348 TPositionFieldId fieldId = EPositionFieldNone; |
|
2349 switch(aFiledType) |
|
2350 { |
|
2351 case EStreet: |
|
2352 fieldId = EPositionFieldStreet; |
|
2353 break; |
|
2354 case EPostCode: |
|
2355 fieldId = EPositionFieldPostalCode ; |
|
2356 break; |
|
2357 case ECity: |
|
2358 fieldId = EPositionFieldCity; |
|
2359 break; |
|
2360 case EStateProvince: |
|
2361 fieldId = EPositionFieldState; |
|
2362 break; |
|
2363 case ECountry: |
|
2364 fieldId = EPositionFieldCountry; |
|
2365 break; |
|
2366 case EPhoneNumber: |
|
2367 fieldId = ELmkPositionFieldPhoneNumber; |
|
2368 break; |
|
2369 case EWebAddress: |
|
2370 fieldId = ELmkPositionFieldWebAddress; |
|
2371 break; |
|
2372 } |
|
2373 TPtrC text; |
|
2374 if ( aLandmark->GetPositionField( |
|
2375 fieldId, text ) == KErrNone ) |
|
2376 { |
|
2377 if (IsEditable() && text.Length() == 0 && aFiledType == EWebAddress) |
|
2378 { |
|
2379 //return if web address field and field is empty and its an editor |
|
2380 return; |
|
2381 } |
|
2382 fieldData->SetTextL(text); |
|
2383 if(!IsEditable()) |
|
2384 { |
|
2385 aEditorField = AddOrDeleteLineL( aEditorField,fieldData,aPrevControlId, |
|
2386 fieldData->UniqueFieldIdentity(), aPos); |
|
2387 } |
|
2388 if(aEditorField) |
|
2389 { |
|
2390 //now modify the text for display |
|
2391 CLmkEditorTextField* field = static_cast<CLmkEditorTextField*>(aEditorField); |
|
2392 HBufC* buff = HBufC::NewLC(text.Length()); |
|
2393 TPtr dispTxt = buff->Des(); |
|
2394 if(!IsEditable()) |
|
2395 { |
|
2396 TPtr des1 = CLmkFields::RemoveEnterCharacter( text ); |
|
2397 dispTxt.Copy(des1); |
|
2398 } |
|
2399 else |
|
2400 { |
|
2401 dispTxt.Copy(text); |
|
2402 } |
|
2403 if(aFiledType == EWebAddress) |
|
2404 { |
|
2405 TInt position; |
|
2406 if((position = field->IsWebUrlProtocolPreFixedL(dispTxt))!= |
|
2407 KErrNotFound) |
|
2408 { |
|
2409 field->TrimPrefixesFromWebUrlL( dispTxt, position +1 ); |
|
2410 } |
|
2411 } |
|
2412 TPtrC ptr; |
|
2413 ptr.Set(dispTxt); |
|
2414 field->SetControlTextL(ptr); |
|
2415 CleanupStack::PopAndDestroy( buff ); |
|
2416 } |
|
2417 |
|
2418 } |
|
2419 } |
|
2420 // ----------------------------------------------------------------------------- |
|
2421 // CLmkEditorImpl::UpdateDesEditorControlL |
|
2422 // ----------------------------------------------------------------------------- |
|
2423 // |
|
2424 void CLmkEditorImpl::UpdateDesEditorControlL |
|
2425 (MLmkEditorField* aEditorField, |
|
2426 CPosLandmark* aLandmark, |
|
2427 MLmkFieldData* fieldData, |
|
2428 TInt aPrevControlId, |
|
2429 TInt aPos |
|
2430 ) |
|
2431 { |
|
2432 TPtrC text; |
|
2433 aLandmark->GetLandmarkDescription(text); |
|
2434 fieldData->SetTextL(text); |
|
2435 TPtrC dispTxt; |
|
2436 if(!IsEditable()) |
|
2437 { |
|
2438 TPtr des1 = CLmkFields::RemoveEnterCharacter( text ); |
|
2439 dispTxt.Set(des1); |
|
2440 aEditorField = AddOrDeleteLineL( aEditorField,fieldData,aPrevControlId, |
|
2441 fieldData->UniqueFieldIdentity(), aPos); |
|
2442 } |
|
2443 else |
|
2444 { |
|
2445 dispTxt.Set(text); |
|
2446 } |
|
2447 CLmkEditorTextField* field = static_cast<CLmkEditorTextField*>(aEditorField); |
|
2448 if(aEditorField) |
|
2449 { |
|
2450 field->Control()->SetTextL(&dispTxt); |
|
2451 field->Control()->DrawDeferred(); |
|
2452 } |
|
2453 } |
|
2454 // ----------------------------------------------------------------------------- |
|
2455 // CLmkEditorImpl::UpdateCategoryEditorControlL |
|
2456 // ----------------------------------------------------------------------------- |
|
2457 // |
|
2458 void CLmkEditorImpl::UpdateCategoryEditorControlL |
|
2459 ( |
|
2460 MLmkEditorField* aEditorField, |
|
2461 MLmkFieldData* fieldData, |
|
2462 TInt aPrevControlId, |
|
2463 TInt aPos, |
|
2464 CPosLandmark& aLandmark |
|
2465 ) |
|
2466 { |
|
2467 RArray<TPosLmItemId>& categories = fieldData->Categories(); |
|
2468 aLandmark.GetCategoriesL(categories); |
|
2469 TInt count( categories.Count() ); |
|
2470 |
|
2471 if ( count <= 1 ) |
|
2472 { |
|
2473 fieldData->SetFieldType( ECategory ); |
|
2474 } |
|
2475 else |
|
2476 { |
|
2477 fieldData->SetFieldType( ECategories ); |
|
2478 } |
|
2479 if(!IsEditable()) |
|
2480 { |
|
2481 aEditorField = AddOrDeleteLineL( aEditorField,fieldData,aPrevControlId, |
|
2482 fieldData->UniqueFieldIdentity(), aPos); |
|
2483 } |
|
2484 } |
|
2485 // ----------------------------------------------------------------------------- |
|
2486 // CLmkEditorImpl::UpdateCoordinateEditorControlL |
|
2487 // ----------------------------------------------------------------------------- |
|
2488 // |
|
2489 void CLmkEditorImpl::UpdateCoordinateEditorControlL |
|
2490 ( |
|
2491 MLmkEditorField* aEditorField, |
|
2492 MLmkFieldData* fieldData, |
|
2493 TReal aValue, |
|
2494 TInt aPrevControlId, |
|
2495 TInt aPos |
|
2496 ) |
|
2497 { |
|
2498 fieldData->SetTReal( aValue ); |
|
2499 if(!IsEditable()) |
|
2500 { |
|
2501 aEditorField = AddOrDeleteLineL( aEditorField,fieldData,aPrevControlId, |
|
2502 fieldData->UniqueFieldIdentity(), aPos); |
|
2503 } |
|
2504 } |
|
2505 // ----------------------------------------------------------------------------- |
|
2506 // CLmkEditorImpl::UpdateNumberEditorControlL |
|
2507 // ----------------------------------------------------------------------------- |
|
2508 // |
|
2509 void CLmkEditorImpl::UpdateNumberEditorControlL |
|
2510 ( |
|
2511 MLmkEditorField* aEditorField, |
|
2512 MLmkFieldData* fieldData, |
|
2513 TReal32 aValue, |
|
2514 TInt aPrevControlId, |
|
2515 TInt aPos |
|
2516 ) |
|
2517 { |
|
2518 fieldData->SetTReal( aValue ); |
|
2519 |
|
2520 if(!IsEditable()) |
|
2521 { |
|
2522 aEditorField = AddOrDeleteLineL( aEditorField,fieldData,aPrevControlId, |
|
2523 fieldData->UniqueFieldIdentity(), aPos); |
|
2524 } |
|
2525 } |
|
2526 |
|
2527 // ----------------------------------------------------------------------------- |
|
2528 // CLmkEditorImpl::UpdateNameEditorControl |
|
2529 // ----------------------------------------------------------------------------- |
|
2530 // |
|
2531 void CLmkEditorImpl::UpdateNameEditorControlL |
|
2532 ( |
|
2533 MLmkEditorField* aEditorField, |
|
2534 CPosLandmark* aLandmark, |
|
2535 MLmkFieldData* fieldData |
|
2536 ) |
|
2537 { |
|
2538 |
|
2539 if( aEditorField && aLandmark && fieldData ) |
|
2540 { |
|
2541 //name field icon updation |
|
2542 TInt iconIden = -1; |
|
2543 TInt iconMaskIndex = -1; |
|
2544 TPtrC iconFile; |
|
2545 CLmkEditorTextField* field = static_cast<CLmkEditorTextField*>(aEditorField); |
|
2546 if( aLandmark->GetIcon( iconFile, iconIden, iconMaskIndex ) && field ) |
|
2547 { |
|
2548 if( iconIden > 0 ) |
|
2549 { |
|
2550 fieldData->SetIconId( iconIden ); |
|
2551 fieldData->SetIconPathL( iconFile ); |
|
2552 CEikImage* image = new( ELeave ) CEikImage(); |
|
2553 CleanupStack::PushL( image ); |
|
2554 image->CreatePictureFromFileL( iconFile, |
|
2555 iconIden, iconMaskIndex ); |
|
2556 iLmkUiUtils->UpdateContextIconL( image ); |
|
2557 CLmkUiUtils::ChangeLmNameLabelIconL ( *this, *fieldData ); |
|
2558 CleanupStack::Pop(); //image |
|
2559 field->CaptionedControl()->DrawDeferred(); |
|
2560 } |
|
2561 //text control updation |
|
2562 TPtrC text; |
|
2563 aLandmark->GetLandmarkName( text ); |
|
2564 TPtrC dispTxt; |
|
2565 if( !IsEditable() ) |
|
2566 { |
|
2567 TPtr des1 = CLmkFields::RemoveEnterCharacter( text ); |
|
2568 dispTxt.Set(des1); |
|
2569 } |
|
2570 else |
|
2571 { |
|
2572 dispTxt.Set(text); |
|
2573 } |
|
2574 field->Control()->SetTextL( &dispTxt ); |
|
2575 fieldData->SetTextL( text ); |
|
2576 HBufC* buff = dispTxt.AllocL(); |
|
2577 iLmkUiUtils->ChangeTitlePaneL( buff ); |
|
2578 field->Control()->DrawDeferred(); |
|
2579 } |
|
2580 } |
|
2581 } |
|
2582 |
|
2583 // ----------------------------------------------------------------------------- |
|
2584 // CLmkEditorImpl::SetFieldTypeToFocusInEditMode |
|
2585 // ----------------------------------------------------------------------------- |
|
2586 // |
|
2587 void CLmkEditorImpl::SetFieldTypeToFocusInEditMode(TUint aFieldType) |
|
2588 { |
|
2589 iFieldTypeToFocus = aFieldType; |
|
2590 } |
|
2591 // ----------------------------------------------------------------------------- |
|
2592 // CLmkEditorImpl::IsDlgEditing |
|
2593 // ----------------------------------------------------------------------------- |
|
2594 // |
|
2595 TBool CLmkEditorImpl::IsDlgEditing() |
|
2596 { |
|
2597 return iIsEditing; |
|
2598 } |
|
2599 // ----------------------------------------------------------------------------- |
|
2600 // CLmkEditorImpl::SetDlgEditing |
|
2601 // ----------------------------------------------------------------------------- |
|
2602 // |
|
2603 void CLmkEditorImpl::SetDlgEditing(TBool aEditing) |
|
2604 { |
|
2605 iIsEditing = aEditing; |
|
2606 } |
|
2607 // ----------------------------------------------------------------------------- |
|
2608 // CLmkEditorImpl::SetDlgEditing |
|
2609 // ----------------------------------------------------------------------------- |
|
2610 // |
|
2611 TInt CLmkEditorImpl::EditMode() |
|
2612 { |
|
2613 return iEditorMode; |
|
2614 } |
|
2615 // ----------------------------------------------------------------------------- |
|
2616 // CLmkEditorImpl::UpdateMskOnArrowMoveForViewerL |
|
2617 // ----------------------------------------------------------------------------- |
|
2618 // |
|
2619 void CLmkEditorImpl::UpdateMskOnArrowMoveForViewerL() |
|
2620 { |
|
2621 TBool cmdAdded = EFalse; |
|
2622 MLmkEditorField* field = |
|
2623 iEditorFieldArray->Find( IdOfFocusControl() ); |
|
2624 TUint type = field->LandmarkItemField().FieldType(); |
|
2625 switch(type) |
|
2626 { |
|
2627 case ECategories: |
|
2628 { |
|
2629 AddMskCommandL(R_LM_MSK_SHOW,ELmkCmdShow); |
|
2630 cmdAdded = ETrue; |
|
2631 break; |
|
2632 } |
|
2633 case EPhoneNumber: |
|
2634 { |
|
2635 HBufC* fieldText = field->ControlTextL(); |
|
2636 CleanupStack::PushL( fieldText ); |
|
2637 if ( fieldText && fieldText->Length() > 0 ) |
|
2638 { |
|
2639 AddMskCommandL(R_LM_MSK_CALL,ELmkCmdLast); |
|
2640 cmdAdded = ETrue; |
|
2641 } |
|
2642 CleanupStack::PopAndDestroy( fieldText ); |
|
2643 break; |
|
2644 } |
|
2645 case EWebAddress: |
|
2646 { |
|
2647 HBufC* fieldText = field->ControlTextL(); |
|
2648 CleanupStack::PushL( fieldText ); |
|
2649 if ( fieldText && fieldText->Length() > 0 ) |
|
2650 { |
|
2651 AddMskCommandL(R_LM_MSK_BROWSE,ELmkCmdGoToUrl); |
|
2652 cmdAdded = ETrue; |
|
2653 } |
|
2654 CleanupStack::PopAndDestroy( fieldText ); |
|
2655 break; |
|
2656 } |
|
2657 default: |
|
2658 { |
|
2659 //nothing |
|
2660 break; |
|
2661 } |
|
2662 } |
|
2663 if (!cmdAdded) |
|
2664 { |
|
2665 AddMskCommandL(R_LM_MSK_EDIT,ELmkCmdEditLm); |
|
2666 } |
|
2667 } |
|
2668 |
|
2669 // ----------------------------------------------------------------------------- |
|
2670 // CLmkEditorImpl::AddMskCommandL |
|
2671 // ----------------------------------------------------------------------------- |
|
2672 // |
|
2673 void CLmkEditorImpl::AddMskCommandL(TInt aResourceId, |
|
2674 TLmkAppCmdId aCommandId) |
|
2675 { |
|
2676 |
|
2677 HBufC* mskTxt = NULL; |
|
2678 mskTxt = StringLoader::LoadLC( aResourceId, iEikonEnv ); |
|
2679 CEikButtonGroupContainer* cba = CEikButtonGroupContainer::Current(); |
|
2680 cba->RemoveCommandFromStack(KMskCommandPos,iMskCmdId); |
|
2681 iMskCmdId = aCommandId; |
|
2682 iCurrentResourceId = aResourceId; |
|
2683 cba->AddCommandToStackL(KMskCommandPos,iMskCmdId,mskTxt->Des()); |
|
2684 cba->MakeCommandVisible(iMskCmdId,ETrue); |
|
2685 CleanupStack::PopAndDestroy( mskTxt ); |
|
2686 } |
|
2687 // ----------------------------------------------------------------------------- |
|
2688 // CLmkEditorImpl::AddMskCommandL |
|
2689 // ----------------------------------------------------------------------------- |
|
2690 // |
|
2691 void CLmkEditorImpl::DimmMiddleSoftKey() |
|
2692 { |
|
2693 /*This is required, since there was an error, |
|
2694 where the menu item appears if there are not items |
|
2695 in the lis, after pressing the middle key.Hence, if |
|
2696 dummy msk is added to the resource, it fixes the error, |
|
2697 now this dummy button needs to be disabled.Check the |
|
2698 dialog resource in editor.rss*/ |
|
2699 CEikButtonGroupContainer* cba = CEikButtonGroupContainer::Current(); |
|
2700 cba->MakeCommandVisible(EAknSoftkeyContextOptions,EFalse); |
|
2701 } |
|
2702 |
|
2703 |
|
2704 // ----------------------------------------------------------------------------- |
|
2705 // CLmkEditorImpl::ShowMultipleCategoriesInfoPopupL |
|
2706 // ----------------------------------------------------------------------------- |
|
2707 // |
|
2708 /*void CLmkEditorImpl::ShowMultipleCategoriesInfoPopupL(TBool aRefresh) |
|
2709 { |
|
2710 if (iCatInfoPopupNote && aRefresh) |
|
2711 { |
|
2712 delete iCatInfoPopupNote; |
|
2713 iCatInfoPopupNote = NULL; |
|
2714 } |
|
2715 |
|
2716 if (!iCatInfoPopupNote) |
|
2717 { |
|
2718 |
|
2719 if(!IsCategoryField()) |
|
2720 { |
|
2721 return; |
|
2722 } |
|
2723 MLmkFieldData* categoryField = iLmkFields->GetField( ECategories ); |
|
2724 if ( !categoryField ) |
|
2725 { |
|
2726 categoryField = iLmkFields->GetField( ECategory ); |
|
2727 if ( !categoryField ) |
|
2728 { |
|
2729 return; |
|
2730 } |
|
2731 } |
|
2732 RArray<TPosLmItemId> categories = categoryField->Categories(); |
|
2733 |
|
2734 // This function is also called from message viewer, where the |
|
2735 // landmarks object is populated from xml file instead of db, |
|
2736 // hence the category id's will be dummy and must not be used, |
|
2737 // to get the category name, instead, get the category names |
|
2738 // from the xml file (iCategoryNames). |
|
2739 |
|
2740 TInt count( categories.Count() ); |
|
2741 TBool isNotFromMessageViewer(EFalse); |
|
2742 count = iCategoryNames.Count(); |
|
2743 if ( count == 0 ) // hack to determine from where the call coming. |
|
2744 { |
|
2745 //not called from message viewer |
|
2746 isNotFromMessageViewer = ETrue; |
|
2747 count = categories.Count(); |
|
2748 } |
|
2749 // Do not launch the popup for displaying one category name |
|
2750 if (count <=1 ) |
|
2751 { |
|
2752 return; |
|
2753 } |
|
2754 |
|
2755 // ==================================================================== |
|
2756 // Get Font for Formatting the infoPopUp strings |
|
2757 // ==================================================================== |
|
2758 |
|
2759 // Get parameter and table limits for popup preview text window |
|
2760 TAknLayoutScalableParameterLimits limits = |
|
2761 AknLayoutScalable_Avkon::popup_preview_text_window_ParamLimits(); |
|
2762 |
|
2763 TAknLayoutScalableTableLimits tableLimits = |
|
2764 AknLayoutScalable_Avkon::popup_preview_text_window_t_Limits(); |
|
2765 |
|
2766 // Get layout rects |
|
2767 TRect rectScreen = iAvkonAppUi->ApplicationRect(); |
|
2768 TInt mainPaneVariety = Layout_Meta_Data::IsLandscapeOrientation() ? 4 : 1; |
|
2769 |
|
2770 TAknWindowLineLayout lineLayout = |
|
2771 AknLayoutScalable_Avkon::main_pane( mainPaneVariety ).LayoutLine(); |
|
2772 TAknLayoutRect layoutRect; |
|
2773 layoutRect.LayoutRect(rectScreen, lineLayout); |
|
2774 TRect rectMainPane = layoutRect.Rect(); |
|
2775 |
|
2776 // Use first variety to be able to get the font for text parsing |
|
2777 TInt index = 0; |
|
2778 if ( Layout_Meta_Data::IsLandscapeOrientation() ) |
|
2779 { |
|
2780 index += 5; |
|
2781 } |
|
2782 TInt firstVariety = Min( Max( index, limits.FirstVariety() ), limits.LastVariety() ); |
|
2783 |
|
2784 TAknWindowLineLayout lineLayout2 = |
|
2785 AknLayoutScalable_Avkon::main_pane( mainPaneVariety ).LayoutLine(); |
|
2786 TAknLayoutRect layoutRect2; |
|
2787 layoutRect2.LayoutRect(rectScreen, lineLayout2); |
|
2788 TRect rectPopupWindow = layoutRect2.Rect(); |
|
2789 |
|
2790 TInt firstIndex = tableLimits.FirstIndex(); |
|
2791 TInt firstLineVariety = AknLayoutScalable_Avkon:: |
|
2792 popup_preview_text_window_t_ParamLimits( firstIndex ).FirstVariety(); |
|
2793 |
|
2794 TAknTextLineLayout popupTextLayout = |
|
2795 AknLayoutScalable_Avkon::popup_preview_text_window_t( |
|
2796 firstIndex, firstLineVariety ); |
|
2797 |
|
2798 TAknLayoutText layoutText; |
|
2799 layoutText.LayoutText( rectPopupWindow, popupTextLayout ); |
|
2800 TRect rectText = layoutText.TextRect(); |
|
2801 |
|
2802 TInt infoPopupWidth = KMaxCatSizeForInfoPopUp; |
|
2803 TInt infoPopupLength = KMinCatLenForInfoPopUp; |
|
2804 |
|
2805 if(rectText.Height() > 25) |
|
2806 { |
|
2807 infoPopupWidth = KMaxCatSizeForInfoPopUp + 80; |
|
2808 } |
|
2809 else if(rectText.Height() > 23) |
|
2810 { |
|
2811 infoPopupWidth = KMaxCatSizeForInfoPopUp + 55; |
|
2812 } |
|
2813 else if(rectText.Height() > 16) |
|
2814 { |
|
2815 infoPopupWidth = KMaxCatSizeForInfoPopUp + 10; |
|
2816 infoPopupLength++; |
|
2817 } |
|
2818 |
|
2819 // Prepare font to format the popupInfo string |
|
2820 const CFont *font = layoutText.Font(); |
|
2821 |
|
2822 // =================================================================== |
|
2823 // =================================================================== |
|
2824 |
|
2825 HBufC* catName = NULL; |
|
2826 // show the category list in a message query |
|
2827 HBufC* message = HBufC::NewLC( (KPosLmMaxCategoryNameLength * count) + 1); |
|
2828 TPtr msgPtr = message->Des(); |
|
2829 CDesC16ArrayFlat* desArr = new (ELeave) CDesC16ArrayFlat(count); |
|
2830 CleanupStack::PushL(desArr); |
|
2831 // fill up the array with category´s names from the engine. |
|
2832 for ( TInt i = 0; i < count; i++ ) |
|
2833 { |
|
2834 if ( !isNotFromMessageViewer ) |
|
2835 { |
|
2836 catName = HBufC::NewL( KPosLmMaxCategoryNameLength + 1); |
|
2837 catName->Des().Copy(iCategoryNames[i]); |
|
2838 } |
|
2839 else |
|
2840 { |
|
2841 catName = CLmkDbUtils::CategoryNameL( iDb, categories[i] ); |
|
2842 } |
|
2843 CleanupStack::PushL( catName ); |
|
2844 |
|
2845 TPtr des = catName->Des(); |
|
2846 |
|
2847 TInt textWidth = font->TextWidthInPixels( des ); |
|
2848 TInt textLength = des.Length(); |
|
2849 |
|
2850 // check the length of category name string to format for InfoPopUp. |
|
2851 if(textLength > infoPopupLength && textWidth > infoPopupWidth) |
|
2852 { |
|
2853 |
|
2854 // set the string as per KMinCatLenForInfoPopUp |
|
2855 if(textLength > infoPopupLength + 9) |
|
2856 { |
|
2857 textLength = infoPopupLength + 9; |
|
2858 des = des.Mid(0, textLength); |
|
2859 } |
|
2860 |
|
2861 textWidth = font->TextWidthInPixels( des ); |
|
2862 |
|
2863 for(TInt ctr=textLength; ctr >= (infoPopupLength-1);ctr--) |
|
2864 { |
|
2865 des = des.Mid(0, ctr); |
|
2866 textWidth = font->TextWidthInPixels( des ); |
|
2867 if(textWidth <= infoPopupWidth) |
|
2868 { |
|
2869 break; |
|
2870 } |
|
2871 } |
|
2872 |
|
2873 // loading the "..." string |
|
2874 HBufC* endString = StringLoader::LoadLC(R_LM_EDITOR_MANY_CATEGORIES); |
|
2875 |
|
2876 // appending the "..." string at end |
|
2877 des.Append(endString->Des()); |
|
2878 |
|
2879 // appendig formatted string into category string array |
|
2880 desArr->AppendL(des); |
|
2881 CleanupStack::PopAndDestroy(endString); // endString |
|
2882 } |
|
2883 else |
|
2884 { |
|
2885 desArr->AppendL(des); |
|
2886 } |
|
2887 CleanupStack::PopAndDestroy( catName ); //name |
|
2888 } |
|
2889 desArr->Sort(); |
|
2890 HBufC* catTxt = NULL; |
|
2891 |
|
2892 for ( TInt i = 0; i < desArr->Count(); i++ ) |
|
2893 { |
|
2894 if (i <KMaxCatCntForInfoPopUp) |
|
2895 { |
|
2896 msgPtr.Append((*desArr)[i]); |
|
2897 if ( i != ( count - 1 ) ) |
|
2898 { |
|
2899 msgPtr.Append(_L("\n")); |
|
2900 } |
|
2901 } |
|
2902 } |
|
2903 |
|
2904 if (count > KMaxCatCntForInfoPopUp) |
|
2905 { |
|
2906 |
|
2907 catTxt = StringLoader::LoadLC( R_LM_EDITOR_MANY_CATEGORIES, iEikonEnv ); |
|
2908 msgPtr.Append(catTxt->Des()); |
|
2909 CleanupStack::PopAndDestroy(catTxt );//catTxt |
|
2910 } |
|
2911 TPoint pt1; |
|
2912 iCatInfoPopupNote = LmkNotes::ShowDelayedInfoPopupL(msgPtr,pt1); |
|
2913 UpdateCatInfoNotePosition(); |
|
2914 iCatInfoPopupNote->ShowInfoPopupNote(); |
|
2915 CleanupStack::Pop();//desArr |
|
2916 delete desArr; |
|
2917 CleanupStack::PopAndDestroy( message ); //message |
|
2918 } |
|
2919 else |
|
2920 { |
|
2921 UpdateCatInfoNotePosition(); |
|
2922 iCatInfoPopupNote->ShowInfoPopupNote(); |
|
2923 } |
|
2924 } |
|
2925 */ |
|
2926 |
|
2927 // ----------------------------------------------------------------------------- |
|
2928 // CLmkEditorImpl::ShowQueryIfLocationFieldsAlreadyFilledL |
|
2929 // ----------------------------------------------------------------------------- |
|
2930 // |
|
2931 TBool CLmkEditorImpl::ShowQueryIfLocationFieldsAlreadyFilledL() |
|
2932 { |
|
2933 TBool result = EFalse; |
|
2934 TRealX lati; |
|
2935 lati.SetNaN(); |
|
2936 TRealX longi; |
|
2937 longi.SetNaN(); |
|
2938 |
|
2939 MLmkFieldData* lat = iLmkFields->GetField(ELatitude); |
|
2940 if(lat) |
|
2941 { |
|
2942 //get latitude control id |
|
2943 TInt id = lat->UniqueFieldIdentity(); |
|
2944 MLmkEditorField* latcontrol = iEditorFieldArray->Find( id ); |
|
2945 //get latitude control current text |
|
2946 lati = static_cast<CLmkEditorCoordinateField*>(latcontrol)->FieldValue(); |
|
2947 |
|
2948 MLmkFieldData* lon = iLmkFields->GetField(ELongitude); |
|
2949 if(lon) |
|
2950 { |
|
2951 //get longitude control id |
|
2952 id = lon->UniqueFieldIdentity(); |
|
2953 MLmkEditorField* longcontrol = iEditorFieldArray->Find( id ); |
|
2954 //get longitude control current text |
|
2955 longi = static_cast<CLmkEditorCoordinateField*>(longcontrol)->FieldValue(); |
|
2956 } |
|
2957 |
|
2958 if ( (!lati.IsNaN()) && (!longi.IsNaN())) |
|
2959 { |
|
2960 if ( !LmkNotes::ShowOwerriteLocationQueryL( iEikonEnv ) ) |
|
2961 { |
|
2962 result = ETrue; |
|
2963 } |
|
2964 } |
|
2965 } |
|
2966 return result; |
|
2967 } |
|
2968 |
|
2969 // ----------------------------------------------------------------------------- |
|
2970 // CLmkEditorImpl::IsInvalidUriL |
|
2971 // ----------------------------------------------------------------------------- |
|
2972 // |
|
2973 TBool CLmkEditorImpl::IsInvalidUriL() |
|
2974 { |
|
2975 TBool ret = EFalse; |
|
2976 MLmkFieldData* fields = iLmkFields->GetField( EWebAddress ); |
|
2977 if(fields) |
|
2978 { |
|
2979 MLmkEditorField* fld = iEditorFieldArray->Find(fields->UniqueFieldIdentity()); |
|
2980 if(fld) |
|
2981 { |
|
2982 HBufC* webaddr = HBufC::NewLC(KMaxBufferLen); |
|
2983 CLmkEditorTextField* field = static_cast<CLmkEditorTextField*>(fld); |
|
2984 TPtr ptr = webaddr->Des(); |
|
2985 field->Control()->GetText(ptr); |
|
2986 ret = UriUtils::HasInvalidChars(ptr); |
|
2987 CleanupStack::PopAndDestroy();//webaddr |
|
2988 } |
|
2989 } |
|
2990 return ret; |
|
2991 } |
|
2992 |
|
2993 // ----------------------------------------------------------------------------- |
|
2994 // CLmkEditorImpl::HandleListProviderEvent |
|
2995 // ----------------------------------------------------------------------------- |
|
2996 // |
|
2997 void CLmkEditorImpl::HandleListProviderEvent(TLmkListProviderEventType /*aEvent*/ ) |
|
2998 { |
|
2999 TRAPD(err,CPosLandmark* landmark = iDb.ReadLandmarkLC(iLmkFields->LandmarkId());CleanupStack::PopAndDestroy( landmark )); |
|
3000 if (err == KErrNotFound) |
|
3001 { |
|
3002 TRAP_IGNORE(DeleteSelfL()); |
|
3003 } |
|
3004 else |
|
3005 { |
|
3006 //update the landmark viewer/editor |
|
3007 TRAP_IGNORE(UpdateViewDlgL()); |
|
3008 } |
|
3009 } |
|
3010 |
|
3011 // ----------------------------------------------------------------------------- |
|
3012 // CLmkEditorImpl::HandleListProviderError |
|
3013 // ----------------------------------------------------------------------------- |
|
3014 // |
|
3015 void CLmkEditorImpl::HandleListProviderError( TInt /*aError*/ ) |
|
3016 { |
|
3017 //if error do nothing |
|
3018 } |
|
3019 |
|
3020 // ----------------------------------------------------------------------------- |
|
3021 // CLmkEditorImpl::LaunchLmkEditorL |
|
3022 // ----------------------------------------------------------------------------- |
|
3023 // |
|
3024 void CLmkEditorImpl::LaunchLmkEditorL() |
|
3025 { |
|
3026 CEikButtonGroupContainer* cba = CEikButtonGroupContainer::Current(); |
|
3027 cba->RemoveCommandFromStack( KMskCommandPos, iMskCmdId ); |
|
3028 // Launch editor |
|
3029 TLmkEditorAttributes attributeFlags( CLmkEditorDlg::ELmkAll ); |
|
3030 // Check if the Landmark is alreayd present in the database. Incase, |
|
3031 // a landmark is associated with the editor and if it is not |
|
3032 // added to the Database, then the viewer would be launched with |
|
3033 // the lanmark content |
|
3034 if( KPosLmNullItemId == iLmkFields->LandmarkId() && iLandmark ) |
|
3035 { |
|
3036 iEditor = CLmkEditorImpl::NewL( iDb, |
|
3037 iSender, |
|
3038 attributeFlags, |
|
3039 CLmkEditorDlg::ELmkEditor, |
|
3040 iLandmark ); |
|
3041 } |
|
3042 else |
|
3043 { |
|
3044 iEditor = CLmkEditorImpl::NewL( iDb, |
|
3045 iSender, |
|
3046 attributeFlags, |
|
3047 CLmkEditorDlg::ELmkEditor, |
|
3048 iLmkFields->LandmarkId() ); |
|
3049 } |
|
3050 |
|
3051 |
|
3052 MLmkEditorField* field = iEditorFieldArray->Find( IdOfFocusControl() ); |
|
3053 iFieldTypeToFocus = field->LandmarkItemField().FieldType(); |
|
3054 iEditor->SetFieldTypeToFocusInEditMode( iFieldTypeToFocus ); |
|
3055 iEditor->SetDlgEditing( ETrue ); |
|
3056 iIsEditing = ETrue; |
|
3057 if( !iMapNavFeature ) |
|
3058 { |
|
3059 iEditor->DisableMapAndNavigationMenuOptions(); |
|
3060 } |
|
3061 iEditor->ExecuteLD(); |
|
3062 iEditor->SetDlgEditing( EFalse ); |
|
3063 iIsEditing = EFalse; |
|
3064 TInt err = KErrNone; |
|
3065 TRAP( err, CPosLandmark* landmark = iDb.ReadLandmarkLC( iLmkFields->LandmarkId() ); CleanupStack::PopAndDestroy( landmark ) ); |
|
3066 if (err == KErrNotFound) |
|
3067 { |
|
3068 iLmkUiUtils->RestoreOldNaviPaneL(); |
|
3069 delete this; |
|
3070 return; |
|
3071 } |
|
3072 AddMskCommandL( iCurrentResourceId, iMskCmdId ); |
|
3073 } |
|
3074 |
|
3075 // ----------------------------------------------------------------------------- |
|
3076 // CLmkEditorImpl::DeleteSelfL |
|
3077 // ----------------------------------------------------------------------------- |
|
3078 // |
|
3079 void CLmkEditorImpl::DeleteSelfL() |
|
3080 { |
|
3081 iLmkUiUtils->RestoreOldNaviPaneL(); |
|
3082 if(iEditor) |
|
3083 { |
|
3084 //delete only editor,if editor instance is present, |
|
3085 //viewer will be deleted in ProcessCommandL, where |
|
3086 //editor was created. |
|
3087 delete iEditor; |
|
3088 iEditor = NULL; |
|
3089 } |
|
3090 else |
|
3091 { |
|
3092 delete this; |
|
3093 } |
|
3094 } |
|
3095 |
|
3096 // ----------------------------------------------------------------------------- |
|
3097 // CLmkEditorImpl::HandleCentralRepositoryChangeL() |
|
3098 // ----------------------------------------------------------------------------- |
|
3099 // |
|
3100 void CLmkEditorImpl::HandleCentralRepositoryChangeL() |
|
3101 { |
|
3102 //change unit for position accuracy |
|
3103 MLmkFieldData* fldData = iLmkFields->GetField( EPositionAccuracy ); |
|
3104 if(fldData) |
|
3105 { |
|
3106 TInt id1 = fldData->UniqueFieldIdentity(); |
|
3107 CLmkEditorNumberField* field = static_cast<CLmkEditorNumberField*>(iEditorFieldArray->Find( id1 )); |
|
3108 if(field) |
|
3109 field->HandleUnitChangeL(); |
|
3110 } |
|
3111 |
|
3112 //change altitude unit |
|
3113 MLmkFieldData* fldData1 = iLmkFields->GetField( EAltitude ); |
|
3114 if(fldData1) |
|
3115 { |
|
3116 TInt id2 = fldData1->UniqueFieldIdentity(); |
|
3117 CLmkEditorNumberField* field1 = static_cast<CLmkEditorNumberField*>(iEditorFieldArray->Find( id2 )); |
|
3118 if(field1) |
|
3119 field1->HandleUnitChangeL(); |
|
3120 } |
|
3121 |
|
3122 //change altitude accuracy unit |
|
3123 MLmkFieldData* fldData2 = iLmkFields->GetField( EAltitudeAccuracy ); |
|
3124 if(fldData2) |
|
3125 { |
|
3126 TInt id3 = fldData2->UniqueFieldIdentity(); |
|
3127 CLmkEditorNumberField* field2 = static_cast<CLmkEditorNumberField*>(iEditorFieldArray->Find( id3 )); |
|
3128 if(field2) |
|
3129 field2->HandleUnitChangeL(); |
|
3130 } |
|
3131 } |
|
3132 |
|
3133 // ----------------------------------------------------------------------------- |
|
3134 // CLmkEditorImpl::UpdateCatInfoNotePosition() |
|
3135 // ----------------------------------------------------------------------------- |
|
3136 // |
|
3137 void CLmkEditorImpl::UpdateCatInfoNotePosition() |
|
3138 { |
|
3139 //this is only to set the position of the |
|
3140 //cat info note. |
|
3141 if(iCatInfoPopupNote && IsCategoryField()) |
|
3142 { |
|
3143 CEikCaptionedControl* tmpline = CurrentLine(); |
|
3144 TPoint pt1 = tmpline->PositionRelativeToScreen(); |
|
3145 pt1.iX+=KHOffsetCatInfoPopup; |
|
3146 pt1.iY+=KVOffsetCatInfoPopup; |
|
3147 iCatInfoPopupNote->SetPositionAndAlignment(pt1,EHLeftVTop); |
|
3148 } |
|
3149 } |
|
3150 |
|
3151 // ----------------------------------------------------------------------------- |
|
3152 // CLmkEditorImpl::IsCategoryField() |
|
3153 // ----------------------------------------------------------------------------- |
|
3154 // |
|
3155 TBool CLmkEditorImpl::IsCategoryField() |
|
3156 { |
|
3157 //to check whether the current focussed field is a |
|
3158 //category field. |
|
3159 TBool result = ETrue; |
|
3160 MLmkEditorField* field = |
|
3161 iEditorFieldArray->Find( IdOfFocusControl() ); |
|
3162 TUint type = field->LandmarkItemField().FieldType(); |
|
3163 if(type != ECategories && type != ECategory) |
|
3164 { |
|
3165 result = EFalse; |
|
3166 } |
|
3167 return result; |
|
3168 } |
|
3169 |
|
3170 |
|
3171 #ifdef RD_SCALABLE_UI_V2 |
|
3172 // ----------------------------------------------------------------------------- |
|
3173 // CLmkEditorImpl::HandleDialogPageEventL |
|
3174 // ----------------------------------------------------------------------------- |
|
3175 // |
|
3176 |
|
3177 void CLmkEditorImpl::HandleDialogPageEventL(TInt /*aEventID*/) |
|
3178 { |
|
3179 /* |
|
3180 if(IsEditable()) |
|
3181 { |
|
3182 //editor |
|
3183 HandleEditorCommandL(); |
|
3184 } |
|
3185 */ |
|
3186 } |
|
3187 |
|
3188 #endif //RD_SCALABLE_UI_V2 |
|
3189 |
|
3190 // ----------------------------------------------------------------------------- |
|
3191 // CLmkEditorImpl::LineChangedL |
|
3192 // ----------------------------------------------------------------------------- |
|
3193 // |
|
3194 |
|
3195 void CLmkEditorImpl::LineChangedL(TInt /*aControlId*/) |
|
3196 { |
|
3197 |
|
3198 //hide the category info pop-up if active |
|
3199 if(iCatInfoPopupNote) |
|
3200 { |
|
3201 iCatInfoPopupNote->HideInfoPopupNote(); |
|
3202 } |
|
3203 MLmkEditorField* field = iEditorFieldArray->Find( IdOfFocusControl() ); |
|
3204 __ASSERT_DEBUG( field, Panic( KLmkPanicNullMember ) ); |
|
3205 TUint type = field->LandmarkItemField().FieldType(); |
|
3206 if (IsEditable()) |
|
3207 { |
|
3208 //editor |
|
3209 if ( type == ECategory || type == ECategories ) |
|
3210 { |
|
3211 AddMskCommandL(R_LM_MSK_EDIT,ELmkCmdSelectCategories); |
|
3212 } |
|
3213 else |
|
3214 { |
|
3215 CEikButtonGroupContainer* cba = CEikButtonGroupContainer::Current(); |
|
3216 cba->MakeCommandVisible(iMskCmdId,EFalse); |
|
3217 } |
|
3218 } |
|
3219 else |
|
3220 { |
|
3221 //viewer |
|
3222 UpdateMskOnArrowMoveForViewerL(); |
|
3223 } |
|
3224 if ( type == ECategory || type == ECategories ) |
|
3225 { |
|
3226 // ShowMultipleCategoriesInfoPopupL(IdOfFocusControl()); |
|
3227 } |
|
3228 |
|
3229 } |
|
3230 |
|
3231 // ----------------------------------------------------------------------------- |
|
3232 // CLmkEditorImpl::ClearPositionInfoL() |
|
3233 // ----------------------------------------------------------------------------- |
|
3234 // |
|
3235 void CLmkEditorImpl::ClearPositionInfoL() |
|
3236 { |
|
3237 //clear latitude |
|
3238 MLmkFieldData* lat = iLmkFields->GetField(ELatitude); |
|
3239 if(lat) |
|
3240 { |
|
3241 TInt id = lat->UniqueFieldIdentity(); |
|
3242 MLmkEditorField* latcontrol = iEditorFieldArray->Find( id ); |
|
3243 if(latcontrol) |
|
3244 { |
|
3245 latcontrol->ResetL(); |
|
3246 } |
|
3247 } |
|
3248 //clear longitude |
|
3249 MLmkFieldData* lon = iLmkFields->GetField(ELongitude); |
|
3250 if(lon) |
|
3251 { |
|
3252 TInt id = lon->UniqueFieldIdentity(); |
|
3253 MLmkEditorField* longcontrol = iEditorFieldArray->Find( id ); |
|
3254 if(longcontrol) |
|
3255 { |
|
3256 longcontrol->ResetL(); |
|
3257 } |
|
3258 } |
|
3259 //clear position accuracy |
|
3260 MLmkFieldData* fldData = iLmkFields->GetField( EPositionAccuracy ); |
|
3261 if(fldData) |
|
3262 { |
|
3263 TInt id1 = fldData->UniqueFieldIdentity(); |
|
3264 CLmkEditorNumberField* field = static_cast<CLmkEditorNumberField*>(iEditorFieldArray->Find( id1 )); |
|
3265 if(field) |
|
3266 { |
|
3267 field->ResetL(); |
|
3268 } |
|
3269 } |
|
3270 //clear altitude |
|
3271 MLmkFieldData* fldData1 = iLmkFields->GetField( EAltitude ); |
|
3272 if(fldData1) |
|
3273 { |
|
3274 TInt id2 = fldData1->UniqueFieldIdentity(); |
|
3275 CLmkEditorNumberField* field1 = static_cast<CLmkEditorNumberField*>(iEditorFieldArray->Find( id2 )); |
|
3276 if(field1) |
|
3277 { |
|
3278 field1->ResetL(); |
|
3279 } |
|
3280 } |
|
3281 //clear altitude accuracy |
|
3282 MLmkFieldData* fldData2 = iLmkFields->GetField( EAltitudeAccuracy ); |
|
3283 if(fldData2) |
|
3284 { |
|
3285 TInt id3 = fldData2->UniqueFieldIdentity(); |
|
3286 CLmkEditorNumberField* field2 = static_cast<CLmkEditorNumberField*>(iEditorFieldArray->Find( id3 )); |
|
3287 if(field2) |
|
3288 { |
|
3289 field2->ResetL(); |
|
3290 } |
|
3291 } |
|
3292 |
|
3293 DrawNow(); |
|
3294 |
|
3295 } |
|
3296 |
|
3297 // ----------------------------------------------------------------------------- |
|
3298 // CLmkEditorImpl::ArePositionFieldEmptyL() |
|
3299 // ----------------------------------------------------------------------------- |
|
3300 // |
|
3301 TBool CLmkEditorImpl::ArePositionFieldEmptyL() |
|
3302 { |
|
3303 return (IsFieldEmptyL( ELatitude ) && IsFieldEmptyL( ELongitude ) && IsFieldEmptyL( EAltitude ) |
|
3304 && IsFieldEmptyL( EAltitudeAccuracy ) && IsFieldEmptyL( EPositionAccuracy)) ? ETrue : EFalse; |
|
3305 } |
|
3306 |
|
3307 #ifdef RD_SCALABLE_UI_V2 |
|
3308 // ----------------------------------------------------------------------------- |
|
3309 // CLmkEditorImpl::HandleEditorCommandL() |
|
3310 // ----------------------------------------------------------------------------- |
|
3311 // |
|
3312 void CLmkEditorImpl::HandleEditorCommandL() |
|
3313 { |
|
3314 MLmkEditorField* field = iEditorFieldArray->Find( IdOfFocusControl() ); |
|
3315 __ASSERT_DEBUG( field, Panic( KLmkPanicNullMember ) ); |
|
3316 |
|
3317 TUint type = field->LandmarkItemField().FieldType(); |
|
3318 switch(type) |
|
3319 { |
|
3320 case ECategories: |
|
3321 case ECategory: |
|
3322 { |
|
3323 ProcessCommandL( ELmkCmdSelectCategories ); |
|
3324 break; |
|
3325 } |
|
3326 } |
|
3327 } |
|
3328 #endif //RD_SCALABLE_UI_V2 |
|
3329 |
|
3330 // ----------------------------------------------------------------------------- |
|
3331 // CLmkAppLmItemSelectorImpl::HandleDialogDismissed |
|
3332 // ----------------------------------------------------------------------------- |
|
3333 // |
|
3334 void CLmkEditorImpl::HandleDialogDismissed( TInt aButtonId ) |
|
3335 { |
|
3336 if( EEikBidCancel == aButtonId ) |
|
3337 { |
|
3338 delete iLocationService; |
|
3339 iLocationService = NULL; |
|
3340 } |
|
3341 } |
|
3342 // ----------------------------------------------------------------------------- |
|
3343 // CLmkEditorImpl::InsertLineL() |
|
3344 // ----------------------------------------------------------------------------- |
|
3345 // |
|
3346 MLmkEditorField* CLmkEditorImpl::InsertLineL( MLmkFieldData* aFieldData, |
|
3347 TInt aPrevControlId) |
|
3348 { |
|
3349 MLmkEditorField* editorField = NULL; |
|
3350 //data present, but control not present |
|
3351 TryChangeFocusL(aPrevControlId); |
|
3352 editorField = LmkEditorFieldFactory::CreateFieldL( |
|
3353 *aFieldData, *this ); |
|
3354 CleanupStack::PushL( editorField ); |
|
3355 if ( editorField ) |
|
3356 { |
|
3357 editorField->SetEditableL(EFalse); |
|
3358 iEditorFieldArray->GetFieldArray().AppendL( editorField ); |
|
3359 editorField->ActivateL(); |
|
3360 } |
|
3361 CleanupStack::Pop(); //editorField |
|
3362 return editorField; |
|
3363 } |
|
3364 |
|
3365 // ----------------------------------------------------------------------------- |
|
3366 // CLmkEditorImpl::DeleteLineL() |
|
3367 // ----------------------------------------------------------------------------- |
|
3368 // |
|
3369 void CLmkEditorImpl::DeleteLineL( MLmkEditorField* aEditorField, |
|
3370 TInt aCtrlId , TInt aPos) |
|
3371 { |
|
3372 //data not present but control present |
|
3373 //iEditorFieldArray->GetFieldArray().Delete( aPos-1 ); |
|
3374 iEditorFieldArray->GetFieldArray().Delete( aPos ); |
|
3375 delete aEditorField; |
|
3376 aEditorField=NULL; |
|
3377 DeleteLine(aCtrlId); |
|
3378 } |
|
3379 |
|
3380 // ----------------------------------------------------------------------------- |
|
3381 // CLmkEditorImpl::AddOrDeleteLineL() |
|
3382 // ----------------------------------------------------------------------------- |
|
3383 // |
|
3384 MLmkEditorField* CLmkEditorImpl::AddOrDeleteLineL( MLmkEditorField* aEditorField, |
|
3385 MLmkFieldData* aFieldData , |
|
3386 TInt aPrevControlId, |
|
3387 TInt aCtrlId , TInt aPos) |
|
3388 { |
|
3389 TBool valPresent = iEditorFieldArray->CheckIfFieldIsEmpty(*aFieldData); |
|
3390 |
|
3391 if(valPresent && !aEditorField) |
|
3392 { |
|
3393 aEditorField = InsertLineL( aFieldData, aPrevControlId); |
|
3394 } |
|
3395 else if(!valPresent && aEditorField) |
|
3396 { |
|
3397 DeleteLineL(aEditorField, aCtrlId,aPos); |
|
3398 aEditorField = NULL; |
|
3399 } |
|
3400 return aEditorField; |
|
3401 } |
|
3402 |
|
3403 // ----------------------------------------------------------------------------- |
|
3404 // CLmkEditorImpl::MessageQueryCallBack() |
|
3405 // ----------------------------------------------------------------------------- |
|
3406 // |
|
3407 TInt CLmkEditorImpl::MessageQueryCallBack( TAny* /*aPtr*/ ) |
|
3408 { |
|
3409 TInt result = KErrNone; |
|
3410 CEikonEnv* env = CEikonEnv::Static(); |
|
3411 TRAP_IGNORE(result = LmkNotes::GenericMessageQueryL(env,R_LMK_REQUEST_FAIL_INFO_TEXT, |
|
3412 R_LMK_MSG_QUERY_HEADING_PANE_TEXT)); |
|
3413 return result; |
|
3414 } |
|
3415 |
|
3416 // --------------------------------------------------------- |
|
3417 // CLmkEditorImpl::CheckHideCoordinateL() |
|
3418 // --------------------------------------------------------- |
|
3419 // |
|
3420 void CLmkEditorImpl::CheckHideCoordinateL() |
|
3421 { |
|
3422 TInt coordinateSettingValue = ELocCoordinatesNotHidden; |
|
3423 TInt helpSettingValue = ELocHelpNotHidden; |
|
3424 CRepository* repository = CRepository::NewL( TUid::Uid( KCRUidLocLocalVariation) ); |
|
3425 CleanupStack::PushL( repository ); |
|
3426 User::LeaveIfError( repository->Get( KLocHideCoordinates, |
|
3427 coordinateSettingValue )); |
|
3428 User::LeaveIfError( repository->Get( KLocHideHelp, |
|
3429 helpSettingValue )); |
|
3430 CleanupStack::PopAndDestroy( repository ); |
|
3431 |
|
3432 if( ELocCoordinatesHidden == coordinateSettingValue ) |
|
3433 iIsHideCoordinate = ETrue; |
|
3434 else |
|
3435 iIsHideCoordinate = EFalse; |
|
3436 |
|
3437 if( ELocHelpHidden == helpSettingValue ) |
|
3438 iIsHideHelp = ETrue; |
|
3439 else |
|
3440 iIsHideHelp = EFalse; |
|
3441 |
|
3442 } |
|
3443 |
|
3444 // --------------------------------------------------------- |
|
3445 // CLmkEditorImpl::HandlePointerEventL() |
|
3446 // --------------------------------------------------------- |
|
3447 // |
|
3448 void CLmkEditorImpl::HandlePointerEventL(const TPointerEvent& aPointerEvent) |
|
3449 { |
|
3450 if (aPointerEvent.iType == TPointerEvent::EButton1Up && iIsDragging |
|
3451 == EFalse) |
|
3452 { |
|
3453 MLmkEditorField* field = iEditorFieldArray->Find(IdOfFocusControl()); |
|
3454 TUint type = field->LandmarkItemField().FieldType(); |
|
3455 |
|
3456 // check the editor mode |
|
3457 if (IsEditable()) // edit mode |
|
3458 { |
|
3459 if (type == ECategory || type == ECategories) |
|
3460 { |
|
3461 if (!iIsCategorySelctorOpen) |
|
3462 { |
|
3463 iIsCategorySelctorOpen = ETrue; |
|
3464 SelectCategoriesCmdL(); |
|
3465 } |
|
3466 } |
|
3467 } |
|
3468 else |
|
3469 {// view or receive mode |
|
3470 if (type == ECategory || type == ECategories) |
|
3471 { |
|
3472 if (iCalegorySelectionFlag) // Receive mode |
|
3473 { |
|
3474 CategoriesCmdFromXmlL(); |
|
3475 } |
|
3476 else |
|
3477 { |
|
3478 CategoriesCmdL(); // View mode |
|
3479 } |
|
3480 } |
|
3481 else // focus is on any other landmark field |
|
3482 { |
|
3483 if (!iCalegorySelectionFlag)// No context menu for receive mode |
|
3484 { |
|
3485 if (!iIsEditing) |
|
3486 { |
|
3487 LaunchLmkEditorL(); |
|
3488 } |
|
3489 } |
|
3490 } |
|
3491 } |
|
3492 } |
|
3493 else |
|
3494 { |
|
3495 CAknForm::HandlePointerEventL(aPointerEvent); |
|
3496 |
|
3497 if (aPointerEvent.iType == TPointerEvent::EButton1Down) |
|
3498 { |
|
3499 iIsDragging = EFalse; |
|
3500 } |
|
3501 |
|
3502 if (aPointerEvent.iType == TPointerEvent::EDrag) |
|
3503 { |
|
3504 iIsDragging = ETrue; |
|
3505 } |
|
3506 } |
|
3507 } |
|
3508 |
|
3509 // End of File |
|
3510 |
|