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