diff -r 522cd55cc3d7 -r 3c271c9e6618 landmarksui/uicontrols/src/CLmkEditorImpl.cpp --- a/landmarksui/uicontrols/src/CLmkEditorImpl.cpp Tue Feb 02 00:16:03 2010 +0200 +++ b/landmarksui/uicontrols/src/CLmkEditorImpl.cpp Fri Feb 19 22:45:00 2010 +0200 @@ -1,20 +1,20 @@ /* -* Copyright (c) 2002-2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: This file contains the methods implementing the core -* functionality of landmarks editor -* -*/ + * Copyright (c) 2002-2010 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. + * This component and the accompanying materials are made available + * under the terms of "Eclipse Public License v1.0" + * which accompanies this distribution, and is available + * at the URL "http://www.eclipse.org/legal/epl-v10.html". + * + * Initial Contributors: + * Nokia Corporation - initial contribution. + * + * Contributors: + * + * Description: This file contains the methods implementing the core + * functionality of landmarks editor + * + */ // INCLUDE FILES #include @@ -77,30 +77,30 @@ #include "LmkEditorFieldFactory.h" #include #include +#include "Debug.h" // CONSTANTS /// Unnamed namespace for local definitions -namespace { - //const TInt KMaxCatCntForInfoPopUp (3); - const TInt KHOffsetCatInfoPopup ( 100 ); - const TInt KVOffsetCatInfoPopup ( 30 ); - //const TInt KMinCatLenForInfoPopUp ( 11 ); - //const TInt KMaxCatSizeForInfoPopUp ( 135 ); - #if defined(_DEBUG) -_LIT( KPanicMsg, "CLmkEditorImpl"); +namespace + { + const TInt KHOffsetCatInfoPopup(100); + const TInt KVOffsetCatInfoPopup(30); +#if defined(_DEBUG) + _LIT( KPanicMsg, "CLmkEditorImpl"); -void Panic( TPanicCode aReason ) - { - User::Panic( KPanicMsg, aReason ); - } - #endif -} // namespace + void Panic(TPanicCode aReason) + { + User::Panic(KPanicMsg, aReason); + } +#endif + } // namespace // ================= LOCAL FUNCTIONS ======================= static void CleanupArray(TAny* aArray) { - ( static_cast*>( aArray ) )->ResetAndDestroy(); + (static_cast*> (aArray))->ResetAndDestroy(); } + // ============================ MEMBER FUNCTIONS =============================== // ----------------------------------------------------------------------------- @@ -109,16 +109,10 @@ // might leave. // ----------------------------------------------------------------------------- // -CLmkEditorImpl::CLmkEditorImpl( - CPosLandmarkDatabase& aDb, - CLmkSender& aSender, - TLmkEditorMode aEditorMode ) - : iDb( aDb ), - iSender( aSender ), - iEditorMode( aEditorMode ), - iIsEditing(EFalse), - iResetWebAddrSize(ETrue), - iIsCategorySelctorOpen(EFalse) +CLmkEditorImpl::CLmkEditorImpl(CPosLandmarkDatabase& aDb, + CLmkSender& aSender, TLmkEditorMode aEditorMode) : + iDb(aDb), iSender(aSender), iEditorMode(aEditorMode), iIsEditing(EFalse), + iResetWebAddrSize(ETrue), iIsCategorySelctorOpen(EFalse) { } @@ -127,28 +121,24 @@ // Symbian 2nd phase constructor can leave. // ----------------------------------------------------------------------------- // -void CLmkEditorImpl::ConstructL( - TPosLmItemId aLandmarkId, - TLmkEditorAttributes aAttributes ) +void CLmkEditorImpl::ConstructL(TPosLmItemId aLandmarkId, + TLmkEditorAttributes aAttributes) { + DEBUG( CLmkEditorImpl::ConstructL Editing/Viewing Existing Landmark with LandmarkId ) CommonConstructL(aAttributes); - - iLandmark = iDb.ReadLandmarkLC(aLandmarkId); - - iLmkFields = CLmkFields::NewL( iLabelArray, - iDb, - aAttributes, - aLandmarkId, - iLandmark , - iJapaneseInputMode); + iLandmark = iDb.ReadLandmarkLC(aLandmarkId); + iLmkFields = CLmkFields::NewL(iLabelArray, iDb, aAttributes, aLandmarkId, + iLandmark, iJapaneseInputMode); ChangeContextImageL(); - iEditorFieldArray = CLmkEditorFieldArray::NewL( *iLmkFields, *this ); + iEditorFieldArray = CLmkEditorFieldArray::NewL(*iLmkFields, *this); CleanupStack::Pop(iLandmark); - - if(iLandmark) - { - iIsLmOwned = ETrue; - } + if (iLandmark) + { + iIsLmOwned = ETrue; + } + iListProvider = LmkListProviderFactory::CreateProviderL( iDb, ELandmarkSelector ); + iListProvider->AddObserverL( *this ); + iListProvider->InitializeL(); } // ----------------------------------------------------------------------------- @@ -156,46 +146,35 @@ // Symbian 2nd phase constructor can leave. // ----------------------------------------------------------------------------- // -void CLmkEditorImpl::ConstructL( - CPosLandmark* aLandmark, - TLmkEditorAttributes aAttributes ) +void CLmkEditorImpl::ConstructL(CPosLandmark* aLandmark, + TLmkEditorAttributes aAttributes) { + DEBUG( CLmkEditorImpl::ConstructL Editing/Viewing Existing Landmark with Landmark Object ); CommonConstructL(aAttributes); - - iLmkFields = CLmkFields::NewL( iLabelArray, - iDb, - aAttributes, - aLandmark->LandmarkId(), - aLandmark, - iJapaneseInputMode ); + iLmkFields = CLmkFields::NewL(iLabelArray, iDb, aAttributes, + aLandmark->LandmarkId(), aLandmark, iJapaneseInputMode); iLandmark = aLandmark; - ChangeContextImageL(); - iEditorFieldArray = CLmkEditorFieldArray::NewL( *iLmkFields, *this ); + iEditorFieldArray = CLmkEditorFieldArray::NewL(*iLmkFields, *this); } // ----------------------------------------------------------------------------- // CLmkEditorImpl::ConstructL // Symbian 2nd phase constructor can leave. +// Empty Landmark Editor // ----------------------------------------------------------------------------- // -void CLmkEditorImpl::ConstructL( - TPosLmItemId* aLandmarkId, - CPosLandmark* aLandmark, - TLmkEditorAttributes aAttributes ) +void CLmkEditorImpl::ConstructL(TPosLmItemId* aLandmarkId, + CPosLandmark* aLandmark, TLmkEditorAttributes aAttributes) { + DEBUG( CLmkEditorImpl::ConstructL Empty Landmarks Editor Construction ); CommonConstructL(aAttributes); - - iLmkFields = CLmkFields::NewL( iLabelArray, - iDb, - aAttributes, - *aLandmarkId, - aLandmark, - iJapaneseInputMode ); - iLandmarkItemId = aLandmarkId; - iLandmark = aLandmark; + iLmkFields = CLmkFields::NewL(iLabelArray, iDb, aAttributes, + *aLandmarkId, aLandmark, iJapaneseInputMode); + iLandmarkItemId = aLandmarkId; + iLandmark = aLandmark; ChangeContextImageL(); - iEditorFieldArray = CLmkEditorFieldArray::NewL( *iLmkFields, *this ); + iEditorFieldArray = CLmkEditorFieldArray::NewL(*iLmkFields, *this); } // ----------------------------------------------------------------------------- @@ -204,20 +183,21 @@ // void CLmkEditorImpl::CommonConstructL(TLmkEditorAttributes& aAttributes) { - iLandmarkItemId = NULL; // Set to NULL by default. Use only where needed. + DEBUG( CLmkEditorImpl::CommonConstructL Start ) + iLandmarkItemId = NULL; // Set to NULL by default. Use only where needed. iLmkUiUtils = CLmkUiUtils::NewL(); iLmkUiUtils->ReadLmkUiResourceFileL(); - CAknForm::ConstructL( R_LMK_EDITOR_MENUBAR ); + CAknForm::ConstructL(R_LMK_EDITOR_MENUBAR); iLmkUiUtils->StoreNaviPaneL(); // store old navi pane iLmkUiUtils->CreateDefaultNaviPaneL(); // For setting Japanese input mode CAknSettingCache& cache = CAknEnv::Static()->SettingCache(); - TLanguage currentLanguage = cache.InputLanguage(); - if ( currentLanguage == ELangJapanese ) - { - iJapaneseInputMode = ETrue; - } + TLanguage currentLanguage = cache.InputLanguage(); + if (currentLanguage == ELangJapanese) + { + iJapaneseInputMode = ETrue; + } else { iJapaneseInputMode = EFalse; @@ -229,33 +209,35 @@ iLmkGoToURLCmd = CLmkGoToURLCmd::NewL(); // Launching Call UI iLmkCallCmd = CLmkCallCmd::NewL(); - iLmkCallCmd->AttachMenuPaneL( R_LMK_EDITOR_CALL_SUBMENU, R_LMK_EDITOR_AIW_INTEREST); - // Create AIW interest - iLmkCallCmd->AttachInterestL( R_LMK_EDITOR_AIW_INTEREST ); - // By default enable map and navigation feature + iLmkCallCmd->AttachMenuPaneL(R_LMK_EDITOR_CALL_SUBMENU, + R_LMK_EDITOR_AIW_INTEREST); + // Create AIW interest + iLmkCallCmd->AttachInterestL(R_LMK_EDITOR_AIW_INTEREST); + // By default enable map and navigation feature iMapNavFeature = ETrue; - iMapNavInterface = CLmkMapNavigationInterface::NewL( iDb); + iMapNavInterface = CLmkMapNavigationInterface::NewL(iDb); iCatInfoPopupNote = NULL; - iRepository = CLmkCentralRepository::NewL( KLocSystemofMeasurements,this); + iRepository = CLmkCentralRepository::NewL(KLocSystemofMeasurements, this); // Create the wait dialog launcher iWaitDialogLauncher = CLmkWaitDialogLauncher::NewL(); iWaitDialogLauncher->SetObserver(this); iIsLmOwned = EFalse; - + // Check if the Coordinates has to be hidden - CheckHideCoordinateL(); - - if( iIsHideCoordinate ) + CheckHideCoordinateL(); + + if (iIsHideCoordinate) { - aAttributes&= ~CLmkEditorDlg::ELmkLatitude; - aAttributes&= ~CLmkEditorDlg::ELmkLongitude; - aAttributes&= ~CLmkEditorDlg::ELmkPositionAccuracy; - aAttributes&= ~CLmkEditorDlg::ELmkAltitude; - aAttributes&= ~CLmkEditorDlg::ELmkAltitudeAccuracy; + aAttributes &= ~CLmkEditorDlg::ELmkLatitude; + aAttributes &= ~CLmkEditorDlg::ELmkLongitude; + aAttributes &= ~CLmkEditorDlg::ELmkPositionAccuracy; + aAttributes &= ~CLmkEditorDlg::ELmkAltitude; + aAttributes &= ~CLmkEditorDlg::ELmkAltitudeAccuracy; } + DEBUG( CLmkEditorImpl::CommonConstructL End ) } // ----------------------------------------------------------------------------- @@ -263,18 +245,15 @@ // Two-phased constructor. // ----------------------------------------------------------------------------- // -EXPORT_C CLmkEditorImpl* CLmkEditorImpl::NewL( - CPosLandmarkDatabase& aDb, - CLmkSender& aSender, - TLmkEditorAttributes aAttributes, - TLmkEditorMode aEditorMode, - TPosLmItemId aLandmarkId ) +EXPORT_C CLmkEditorImpl* CLmkEditorImpl::NewL(CPosLandmarkDatabase& aDb, + CLmkSender& aSender, TLmkEditorAttributes aAttributes, + TLmkEditorMode aEditorMode, TPosLmItemId aLandmarkId) { - CLmkEditorImpl* self = - new( ELeave ) CLmkEditorImpl( aDb, aSender, aEditorMode ); + CLmkEditorImpl* self = new (ELeave) CLmkEditorImpl(aDb, aSender, + aEditorMode); - CleanupStack::PushL( self ); - self->ConstructL( aLandmarkId, aAttributes ); + CleanupStack::PushL(self); + self->ConstructL(aLandmarkId, aAttributes); CleanupStack::Pop(); //self return self; } @@ -284,18 +263,15 @@ // Two-phased constructor. // ----------------------------------------------------------------------------- // -EXPORT_C CLmkEditorImpl* CLmkEditorImpl::NewL( - CPosLandmarkDatabase& aDb, - CLmkSender& aSender, - TLmkEditorAttributes aAttributes, - TLmkEditorMode aEditorMode, - CPosLandmark* aLandmark ) +EXPORT_C CLmkEditorImpl* CLmkEditorImpl::NewL(CPosLandmarkDatabase& aDb, + CLmkSender& aSender, TLmkEditorAttributes aAttributes, + TLmkEditorMode aEditorMode, CPosLandmark* aLandmark) { - CLmkEditorImpl* self = - new( ELeave ) CLmkEditorImpl( aDb, aSender, aEditorMode ); + CLmkEditorImpl* self = new (ELeave) CLmkEditorImpl(aDb, aSender, + aEditorMode); - CleanupStack::PushL( self ); - self->ConstructL( aLandmark, aAttributes ); + CleanupStack::PushL(self); + self->ConstructL(aLandmark, aAttributes); CleanupStack::Pop(); //self return self; } @@ -305,19 +281,16 @@ // Two-phased constructor. // ----------------------------------------------------------------------------- // -EXPORT_C CLmkEditorImpl* CLmkEditorImpl::NewL( - CPosLandmarkDatabase& aDb, - CLmkSender& aSender, - TLmkEditorAttributes aAttributes, - TLmkEditorMode aEditorMode, - TPosLmItemId* aLandmarkId, - CPosLandmark* aLandmark ) +EXPORT_C CLmkEditorImpl* CLmkEditorImpl::NewL(CPosLandmarkDatabase& aDb, + CLmkSender& aSender, TLmkEditorAttributes aAttributes, + TLmkEditorMode aEditorMode, TPosLmItemId* aLandmarkId, + CPosLandmark* aLandmark) { - CLmkEditorImpl* self = - new( ELeave ) CLmkEditorImpl( aDb, aSender, aEditorMode ); + CLmkEditorImpl* self = new (ELeave) CLmkEditorImpl(aDb, aSender, + aEditorMode); - CleanupStack::PushL( self ); - self->ConstructL( aLandmarkId, aLandmark, aAttributes ); + CleanupStack::PushL(self); + self->ConstructL(aLandmarkId, aLandmark, aAttributes); CleanupStack::Pop(); //self return self; } @@ -329,11 +302,11 @@ CLmkEditorImpl::~CLmkEditorImpl() { delete iWaitDialogLauncher; - - CEikButtonGroupContainer* cba = CEikButtonGroupContainer::Current(); - cba->RemoveCommandObserver(KMskCommandPos); - - if( iLmkUiUtils ) + + CEikButtonGroupContainer* cba = CEikButtonGroupContainer::Current(); + cba->RemoveCommandObserver(KMskCommandPos); + + if (iLmkUiUtils) { iLmkUiUtils->SetOldContextIcon(); iLmkUiUtils->RestoreOldTitlePane(); @@ -355,27 +328,33 @@ delete iLmkGoToURLCmd; delete iLmkCallCmd; iMapNavInterface->Release(); - delete iCatInfoPopupNote; - delete iRepository; - if(iIsLmOwned && iLandmark) - delete iLandmark; + delete iCatInfoPopupNote; + + if(iListProvider) + { + iListProvider->RemoveObserver(*this); + delete iListProvider; + } + + delete iRepository; + if (iIsLmOwned && iLandmark) + delete iLandmark; } // ----------------------------------------------------------------------------- // CLmkEditorImpl::SetMopParent // ----------------------------------------------------------------------------- // -EXPORT_C void CLmkEditorImpl::SetMopParent( - MObjectProvider* aParent ) +EXPORT_C void CLmkEditorImpl::SetMopParent(MObjectProvider* aParent) { - CCoeControl::SetMopParent( aParent ); + CCoeControl::SetMopParent(aParent); } // ----------------------------------------------------------------------------- // CLmkEditorImpl::SetHelpContext // ----------------------------------------------------------------------------- // -EXPORT_C void CLmkEditorImpl::SetHelpContext( TCoeHelpContext aContext ) +EXPORT_C void CLmkEditorImpl::SetHelpContext(TCoeHelpContext aContext) { iHelpContext = aContext; } @@ -386,19 +365,19 @@ // EXPORT_C TInt CLmkEditorImpl::ExecuteLD() { - CleanupStack::PushL( this ); + CleanupStack::PushL(this); AttachAIWMenuInterestL(); CleanupStack::Pop();//this if (iEditorMode == CLmkEditorDlg::ELmkEditor) - { - iIsEditing = ETrue; - return CAknForm::ExecuteLD( R_LMK_EDITOR_DIALOG ); - } + { + iIsEditing = ETrue; + return CAknForm::ExecuteLD(R_LMK_EDITOR_DIALOG); + } else // viewer/receive state of editor - { - iIsEditing = EFalse; - return CAknForm::ExecuteLD( R_LMK_VIEWER_DIALOG ); - } + { + iIsEditing = EFalse; + return CAknForm::ExecuteLD(R_LMK_VIEWER_DIALOG); + } } // ----------------------------------------------------------------------------- @@ -406,198 +385,201 @@ // ----------------------------------------------------------------------------- // EXPORT_C void CLmkEditorImpl::DisableMapAndNavigationMenuOptions() - { - iMapNavFeature = EFalse; - } + { + iMapNavFeature = EFalse; + } // ----------------------------------------------------------------------------- // CLmkEditorImpl::DynInitMenuPaneL // ----------------------------------------------------------------------------- // -void CLmkEditorImpl::DynInitMenuPaneL( - TInt aResourceId, - CEikMenuPane* aMenuPane ) +void CLmkEditorImpl::DynInitMenuPaneL(TInt aResourceId, + CEikMenuPane* aMenuPane) { - switch( aResourceId ) + switch (aResourceId) { case R_AVKON_FORM_MENUPANE: { - CAknForm::DynInitMenuPaneL( aResourceId, aMenuPane ); + CAknForm::DynInitMenuPaneL(aResourceId, aMenuPane); TBool isLandmarkDataEmpty = EFalse; TBool dimClearPos = ETrue; - // Disable Map and Navigation feature when opted not to show - if( !iMapNavFeature ) - { - isLandmarkDataEmpty = ETrue; - } - else - { - isLandmarkDataEmpty = ArePositionFieldEmptyL(); - } - - if( isLandmarkDataEmpty ) - { - // delete the show on map & Navigate To options - aMenuPane->DeleteMenuItem( ELmkShowOnMapPlaceHolder ); - aMenuPane->DeleteMenuItem( ELmkNavigateToPlaceHolder ); - } - else if( IsEditable() ) - { - // delete the Navigate To option for editor - aMenuPane->DeleteMenuItem( ELmkNavigateToPlaceHolder ); - } + // Disable Map and Navigation feature when opted not to show + if (!iMapNavFeature) + { + isLandmarkDataEmpty = ETrue; + } + else if (iLandmark && iIsHideCoordinate) + { + isLandmarkDataEmpty = IsLandmarkDataEmptyL(iLandmark); + } + else + { + isLandmarkDataEmpty = ArePositionFieldEmptyL(); + } - if( IsEditable() ) - { - dimClearPos = ArePositionFieldEmptyL(); - } - - if( dimClearPos || iIsHideCoordinate) - { - aMenuPane->SetItemDimmed( ELmkCmdClearPosInfo, ETrue ); - } + if (isLandmarkDataEmpty) + { + // delete the show on map & Navigate To options + aMenuPane->DeleteMenuItem(ELmkShowOnMapPlaceHolder); + aMenuPane->DeleteMenuItem(ELmkNavigateToPlaceHolder); + } + else if (IsEditable()) + { + // delete the Navigate To option for editor + aMenuPane->DeleteMenuItem(ELmkNavigateToPlaceHolder); + } - if( iMapNavFeature ) - { - iMapNavInterface->AttachMenuPaneL( aMenuPane, R_LMK_EDITOR_MENU, ELmkCmdMnNav ); - } + if (IsEditable()) + { + dimClearPos = ArePositionFieldEmptyL(); + } + + if (dimClearPos || iIsHideCoordinate) + { + aMenuPane->SetItemDimmed(ELmkCmdClearPosInfo, ETrue); + } + + if (iMapNavFeature) + { + iMapNavInterface->AttachMenuPaneL(aMenuPane, + R_LMK_EDITOR_MENU, ELmkCmdMnNav); + } // Send menu is handled by the sender: - if ( FeatureManager::FeatureSupported( KFeatureIdLandmarksConverter ) ) - { - aMenuPane->SetItemDimmed(ELmkCmdSendDummy, EFalse); - iSender.DisplaySendMenuL( *aMenuPane, 1 ); - } - else - { - aMenuPane->SetItemDimmed(ELmkCmdSendDummy, ETrue); - } + if (FeatureManager::FeatureSupported(KFeatureIdLandmarksConverter)) + { + aMenuPane->SetItemDimmed(ELmkCmdSendDummy, EFalse); + iSender.DisplaySendMenuL(*aMenuPane, 1); + } + else + { + aMenuPane->SetItemDimmed(ELmkCmdSendDummy, ETrue); + } - if ( FeatureManager::FeatureSupported( KFeatureIdLocationFrameworkCore )) - { - aMenuPane->SetItemDimmed( ELmkCmdCurrentLocation,!IsEditable()); - } - else - { - aMenuPane->SetItemDimmed( ELmkCmdCurrentLocation, ETrue ); - } + if (FeatureManager::FeatureSupported( + KFeatureIdLocationFrameworkCore)) + { + aMenuPane->SetItemDimmed(ELmkCmdCurrentLocation, + !IsEditable()); + } + else + { + aMenuPane->SetItemDimmed(ELmkCmdCurrentLocation, ETrue); + } - if ( FeatureManager::FeatureSupported( KFeatureIdHelp )&& - !iIsHideHelp ) - { - aMenuPane->SetItemDimmed( EAknCmdHelp, EFalse ); - } - else - { - aMenuPane->SetItemDimmed( EAknCmdHelp, ETrue ); - } + if (FeatureManager::FeatureSupported(KFeatureIdHelp) + && !iIsHideHelp) + { + aMenuPane->SetItemDimmed(EAknCmdHelp, EFalse); + } + else + { + aMenuPane->SetItemDimmed(EAknCmdHelp, ETrue); + } //only in edit mode - aMenuPane->SetItemDimmed( ELmkCmdSelectCategories, !IsEditable() ); - aMenuPane->SetItemDimmed( ELmkCmdChangeIcon, !IsEditable() ); - + aMenuPane->SetItemDimmed(ELmkCmdSelectCategories, !IsEditable()); + aMenuPane->SetItemDimmed(ELmkCmdChangeIcon, !IsEditable()); //additional commands always dimmed in this class: - aMenuPane->SetItemDimmed( ELmkCmdSaveLm, ETrue ); + aMenuPane->SetItemDimmed(ELmkCmdSaveLm, ETrue); // Only in view mode - aMenuPane->SetItemDimmed( ELmkCmdEditLm, IsEditable() ); - //allways dimmed - aMenuPane->SetItemDimmed( EAknFormCmdEdit, ETrue ); - aMenuPane->SetItemDimmed( EAknFormCmdSave, ETrue ); - aMenuPane->SetItemDimmed( EAknFormCmdLabel, ETrue ); - aMenuPane->SetItemDimmed( EAknFormCmdAdd, ETrue ); - aMenuPane->SetItemDimmed( EAknFormCmdDelete, ETrue ); - aMenuPane->SetItemDimmed( ELmkCmdCategories, ETrue ); - aMenuPane->SetItemDimmed( ELmkCmdEditTextLm, ETrue ); + aMenuPane->SetItemDimmed(ELmkCmdEditLm, IsEditable()); + //allways dimmed + aMenuPane->SetItemDimmed(EAknFormCmdEdit, ETrue); + aMenuPane->SetItemDimmed(EAknFormCmdSave, ETrue); + aMenuPane->SetItemDimmed(EAknFormCmdLabel, ETrue); + aMenuPane->SetItemDimmed(EAknFormCmdAdd, ETrue); + aMenuPane->SetItemDimmed(EAknFormCmdDelete, ETrue); + aMenuPane->SetItemDimmed(ELmkCmdCategories, ETrue); + aMenuPane->SetItemDimmed(ELmkCmdEditTextLm, ETrue); - if(IsEditable()) - { - aMenuPane->SetItemDimmed( ELmkCmdCall, ETrue ); - aMenuPane->SetItemDimmed( ELmkCmdGoToUrl, ETrue ); - } - else - { - MLmkFieldData* field = iLmkFields->GetField(EPhoneNumber); - if(field) - { - TInt id = field->UniqueFieldIdentity(); - MLmkEditorField* control = iEditorFieldArray->Find( id ); - if ((!control) || GetFieldTextLengthL( *control ) <= 0 ) - { - aMenuPane->SetItemDimmed( ELmkCmdCall, ETrue ); - } - - MLmkFieldData* field2 = iLmkFields->GetField(EWebAddress); - if( field2 ) + if (IsEditable()) + { + aMenuPane->SetItemDimmed(ELmkCmdCall, ETrue); + aMenuPane->SetItemDimmed(ELmkCmdGoToUrl, ETrue); + } + else + { + MLmkFieldData* field = iLmkFields->GetField(EPhoneNumber); + if (field) + { + TInt id = field->UniqueFieldIdentity(); + MLmkEditorField* control = iEditorFieldArray->Find(id); + if ((!control) || GetFieldTextLengthL(*control) <= 0) + { + aMenuPane->SetItemDimmed(ELmkCmdCall, ETrue); + } + + MLmkFieldData* field2 = iLmkFields->GetField(EWebAddress); + if (field2) { TInt id2 = field2->UniqueFieldIdentity(); - control = iEditorFieldArray->Find( id2 ); - if ( (!control) || GetFieldTextLengthL( *control ) <= 0 ) + control = iEditorFieldArray->Find(id2); + if ((!control) || GetFieldTextLengthL(*control) <= 0) { - aMenuPane->SetItemDimmed( ELmkCmdGoToUrl, ETrue ); + aMenuPane->SetItemDimmed(ELmkCmdGoToUrl, ETrue); } } - } - } + } + } break; } case R_SENDUI_MENU: // Dynamically created send ui menu { // Send menu is handled by the sender: - if ( FeatureManager::FeatureSupported( KFeatureIdLandmarksConverter ) ) - { - iSender.DisplaySendCascadeMenuL( *aMenuPane ); - } + if (FeatureManager::FeatureSupported(KFeatureIdLandmarksConverter)) + { + iSender.DisplaySendCascadeMenuL(*aMenuPane); + } break; } - case R_LMK_EDITOR_CONTEXT_MENU: - { - MLmkEditorField* field = - iEditorFieldArray->Find( IdOfFocusControl() ); - TUint type = field->LandmarkItemField().FieldType(); - - if ( type != EPhoneNumber ) - { - aMenuPane->SetItemDimmed( ELmkEditMenuAiwId, ETrue ); - } - if ( type != EWebAddress ) - { - aMenuPane->SetItemDimmed( ELmkCmdGoToUrl, ETrue ); - } + case R_LMK_EDITOR_CONTEXT_MENU: + { + MLmkEditorField* field = iEditorFieldArray->Find( + IdOfFocusControl()); + TUint type = field->LandmarkItemField().FieldType(); - if ( type == EPhoneNumber ) - { - if ( GetFieldTextLengthL( *field ) <= 0 ) - { - aMenuPane->SetItemDimmed( ELmkEditMenuAiwId, ETrue ); - } - } - if ( type == EWebAddress ) - { - if ( GetFieldTextLengthL( *field ) <= 0 ) - { - aMenuPane->SetItemDimmed( ELmkCmdGoToUrl, ETrue ); - } - } - break; - } + if (type != EPhoneNumber) + { + aMenuPane->SetItemDimmed(ELmkEditMenuAiwId, ETrue); + } + if (type != EWebAddress) + { + aMenuPane->SetItemDimmed(ELmkCmdGoToUrl, ETrue); + } + if (type == EPhoneNumber) + { + if (GetFieldTextLengthL(*field) <= 0) + { + aMenuPane->SetItemDimmed(ELmkEditMenuAiwId, ETrue); + } + } + if (type == EWebAddress) + { + if (GetFieldTextLengthL(*field) <= 0) + { + aMenuPane->SetItemDimmed(ELmkCmdGoToUrl, ETrue); + } + } + break; + } case R_LMK_EDITOR_CALL_SUBMENU: - { - // Initialize the AIW menu service - iLmkCallCmd->InitializeMenuPaneL( - *aMenuPane, - aResourceId, - ELmkCmdLast // Must not overlap with the other menu ids! - ); + { + // Initialize the AIW menu service + // Must not overlap with other menu ids + iLmkCallCmd->InitializeMenuPaneL(*aMenuPane, aResourceId, + ELmkCmdLast); break; - } + } default: { break; } } - iMapNavInterface->HandleMenuOperationL(aResourceId, aMenuPane, ELmkCmdMnNav); + iMapNavInterface->HandleMenuOperationL(aResourceId, aMenuPane, + ELmkCmdMnNav); } // ----------------------------------------------------------------------------- @@ -610,116 +592,118 @@ TLocality loc; TBool isValid = (KErrNone == aLandmark->GetPosition(loc)); isValid &= !Math::IsNaN(loc.Latitude()) && !Math::IsNaN(loc.Longitude()); - return isValid; - -/* if (!isValid) - { - // verify that destination landmark has address info - TPositionFieldId fieldId = aLandmark->FirstPositionFieldId(); - while (fieldId != EPositionFieldNone) - { - if (fieldId > EPositionFieldAddressCapabilitiesBegin && fieldId - < EPositionFieldBuildingTelephone) - { - TPtrC field; - aLandmark->GetPositionField(fieldId, field); - if (field.Length()) - { - isValid = ETrue; - break; - } - } - fieldId = aLandmark->NextPositionFieldId(fieldId); - } - } - return !isValid;*/ + return !isValid; + + /* if (!isValid) + { + // verify that destination landmark has address info + TPositionFieldId fieldId = aLandmark->FirstPositionFieldId(); + while (fieldId != EPositionFieldNone) + { + if (fieldId > EPositionFieldAddressCapabilitiesBegin && fieldId + < EPositionFieldBuildingTelephone) + { + TPtrC field; + aLandmark->GetPositionField(fieldId, field); + if (field.Length()) + { + isValid = ETrue; + break; + } + } + fieldId = aLandmark->NextPositionFieldId(fieldId); + } + } + return !isValid;*/ } // ----------------------------------------------------------------------------- // CLmkEditorImpl::ProcessCommandL // ----------------------------------------------------------------------------- // -void CLmkEditorImpl::ProcessCommandL( TInt aCommandId ) +void CLmkEditorImpl::ProcessCommandL(TInt aCommandId) { + DEBUG1( CLmkEditorImpl::ProcessCommandL aCommandId=%d, aCommandId ); // Hide the context sensitive menu here HideMenu(); iContextMenuBar->StopDisplayingMenuBar(); - CAknDialog::ProcessCommandL( aCommandId ); + CAknDialog::ProcessCommandL(aCommandId); TInt aiwCmd = iMapNavInterface->GetServiceCmdByMenuCmd(aCommandId); // Handles Map and Navigation commands - if(KAiwCmdNone != aiwCmd) - { - // Landmark array to pass to M&N interface - RPointerArray lmkArray; - switch(aiwCmd) - { - case KAiwCmdMnShowMap: - { - CPosLandmark* landmark = GetCurrentEditedLandmarkL(); - lmkArray.Append(landmark); - CleanupStack::PushL( TCleanupItem( CleanupArray, &lmkArray ) ); - iMapNavInterface->ShowLandmarksOnMapL(lmkArray, aCommandId, - CLmkMapNavigationInterface::EByLmkView); - CleanupStack::PopAndDestroy(); //lmkArray - break; - } - case KAiwCmdMnNavigateTo: - { - CPosLandmark* landmark = GetCurrentEditedLandmarkL(); - lmkArray.Append(landmark); - CleanupStack::PushL( TCleanupItem( CleanupArray, &lmkArray ) ); - iMapNavInterface->NavigateToLandmarkL(lmkArray[0],aCommandId); - CleanupStack::PopAndDestroy(); //lmkArray - break; - } - } - lmkArray.Reset(); - return; - } - switch ( aCommandId ) + if (KAiwCmdNone != aiwCmd) + { + // Landmark array to pass to M&N interface + RPointerArray lmkArray; + switch (aiwCmd) + { + case KAiwCmdMnShowMap: + { + CPosLandmark* landmark = GetCurrentEditedLandmarkL(); + lmkArray.Append(landmark); + CleanupStack::PushL(TCleanupItem(CleanupArray, &lmkArray)); + iMapNavInterface->ShowLandmarksOnMapL(lmkArray, aCommandId, + CLmkMapNavigationInterface::EByLmkView); + CleanupStack::PopAndDestroy(); //lmkArray + break; + } + case KAiwCmdMnNavigateTo: + { + CPosLandmark* landmark = GetCurrentEditedLandmarkL(); + lmkArray.Append(landmark); + CleanupStack::PushL(TCleanupItem(CleanupArray, &lmkArray)); + iMapNavInterface->NavigateToLandmarkL(lmkArray[0], aCommandId); + CleanupStack::PopAndDestroy(); //lmkArray + break; + } + } + lmkArray.Reset(); + return; + } + switch (aCommandId) { case EAknCmdHelp: { - HlpLauncher::LaunchHelpApplicationL( iEikonEnv->WsSession(), - static_cast( - iCoeEnv->AppUi() )->AppHelpContextL() ); + HlpLauncher::LaunchHelpApplicationL( + iEikonEnv->WsSession(), + static_cast (iCoeEnv->AppUi())->AppHelpContextL()); break; } - // these all are same: save & exit + // these all are same: save & exit case EAknSoftkeyBack: case EAknSoftkeyExit: case EEikCmdExit: case EAknCmdExit: { - CAknForm::OkToExitL( aCommandId ); + CAknForm::OkToExitL(aCommandId); iLmkUiUtils->RestoreOldNaviPaneL(); CEikAppUi* appUi = iEikonEnv->EikAppUi(); // Close this dialog first delete this; // Exit application - static_cast(appUi)->ProcessCommandL(aCommandId); + static_cast (appUi)->ProcessCommandL( + aCommandId); break; } case ELmkCmdDeleteLm: { - if ( LmkNotes::LandmarkConfirmationQueryL( iEikonEnv ) ) + if (LmkNotes::LandmarkConfirmationQueryL(iEikonEnv)) { iLmkFields->DeleteLandmarkL(); iLmkUiUtils->RestoreOldNaviPaneL(); iIsEditing = EFalse; - delete this; + delete this; } break; } case ELmkCmdSelectCategories: { - if(!iIsCategorySelctorOpen) - { - iIsCategorySelctorOpen = ETrue; - SelectCategoriesCmdL(); - } + if (!iIsCategorySelctorOpen) + { + iIsCategorySelctorOpen = ETrue; + SelectCategoriesCmdL(); + } break; } case ELmkCmdChangeIcon: @@ -744,13 +728,13 @@ case ELmkCmdSendVia10: case ELmkCmdSend: { - if ( !IsNameFieldEmptyL() ) + if (!IsNameFieldEmptyL()) { // Obtain the current landmark object CPosLandmark* lmk = GetCurrentEditedLandmarkL(); - CleanupStack::PushL( lmk ); + CleanupStack::PushL(lmk); iSender.SendSingleLandmarkL(*lmk); - CleanupStack::PopAndDestroy( lmk ); + CleanupStack::PopAndDestroy(lmk); } else { @@ -759,92 +743,92 @@ break; } case ELmkCmdGoToUrl: - { - // Get URL field - MLmkFieldData* field = iLmkFields->GetField(EWebAddress); - if(field) - { - TInt id = field->UniqueFieldIdentity(); - MLmkEditorField* control = iEditorFieldArray->Find( id ); - if(control) - { - HBufC* fieldText = control->ControlTextL(); - CleanupStack::PushL( fieldText ); - TPtr urlPtr = fieldText->Des(); - if ( urlPtr.Length() > 0 ) - { - iLmkGoToURLCmd->LaunchBrowserL( urlPtr ); - } - CleanupStack::PopAndDestroy( fieldText ); - } - } - break; - } + { + // Get URL field + MLmkFieldData* field = iLmkFields->GetField(EWebAddress); + if (field) + { + TInt id = field->UniqueFieldIdentity(); + MLmkEditorField* control = iEditorFieldArray->Find(id); + if (control) + { + HBufC* fieldText = control->ControlTextL(); + CleanupStack::PushL(fieldText); + TPtr urlPtr = fieldText->Des(); + if (urlPtr.Length() > 0) + { + iLmkGoToURLCmd->LaunchBrowserL(urlPtr); + } + CleanupStack::PopAndDestroy(fieldText); + } + } + break; + } case ELmkCmdEditLm: - { - if(!iIsEditing) - { - LaunchLmkEditorL(); - } - break; - } + { + if (!iIsEditing) + { + LaunchLmkEditorL(); + } + break; + } case ELmkCmdCall: - case ELmkCmdLast: - { - MLmkFieldData* field = iLmkFields->GetField(EPhoneNumber); - if(field) - { - TInt id = field->UniqueFieldIdentity(); - MLmkEditorField* control = iEditorFieldArray->Find( id ); - if(control) - { - HBufC* fieldText = control->ControlTextL(); - CleanupStack::PushL( fieldText ); - if ( fieldText && fieldText->Length() > 0 ) - { - //Check if any active character or not - TPtr ptr = fieldText->Des(); - ptr.Trim(); - if (ptr.Length() > 0) - { - //modified for 3.2, since command is not coming - //from menu item, hence need to pass diff command. - //this code needs some more modification to make it - //genericly work for all the commands. - iLmkCallCmd->ExecuteAIWCallCmdL( ELmkCmdCall, ptr ); - } - } - CleanupStack::PopAndDestroy( fieldText ); - } - } - break; - } + case ELmkCmdLast: + { + MLmkFieldData* field = iLmkFields->GetField(EPhoneNumber); + if (field) + { + TInt id = field->UniqueFieldIdentity(); + MLmkEditorField* control = iEditorFieldArray->Find(id); + if (control) + { + HBufC* fieldText = control->ControlTextL(); + CleanupStack::PushL(fieldText); + if (fieldText && fieldText->Length() > 0) + { + //Check if any active character or not + TPtr ptr = fieldText->Des(); + ptr.Trim(); + if (ptr.Length() > 0) + { + //modified for 3.2, since command is not coming + //from menu item, hence need to pass diff command. + //this code needs some more modification to make it + //genericly work for all the commands. + iLmkCallCmd->ExecuteAIWCallCmdL(ELmkCmdCall, ptr); + } + } + CleanupStack::PopAndDestroy(fieldText); + } + } + break; + } case ELmkCmdShow: - { - MLmkEditorField* field = - iEditorFieldArray->Find( IdOfFocusControl() ); - TUint type = field->LandmarkItemField().FieldType(); - if (type == ECategories ) - { - if(iCalegorySelectionFlag) // Receive mode - { - CategoriesCmdFromXmlL(); - } - else - { - CategoriesCmdL(); // View mode - } - } - break; - } + { + MLmkEditorField* field = iEditorFieldArray->Find( + IdOfFocusControl()); + TUint type = field->LandmarkItemField().FieldType(); + if (type == ECategories) + { + if (iCalegorySelectionFlag) // Receive mode + { + CategoriesCmdFromXmlL(); + } + else + { + CategoriesCmdL(); // View mode + } + } + break; + } case ELmkCmdClearPosInfo: - { - ClearPositionInfoL(); - break; - } + { + ClearPositionInfoL(); + break; + } default: { - CAknForm::ProcessCommandL( aCommandId ); + CAknForm::ProcessCommandL(aCommandId); break; } } @@ -854,20 +838,20 @@ // CLmkEditorImpl::HandleControlStateChangeL // ----------------------------------------------------------------------------- // -void CLmkEditorImpl::HandleControlStateChangeL( TInt aControlId ) +void CLmkEditorImpl::HandleControlStateChangeL(TInt aControlId) { - MLmkEditorField* changedField = iEditorFieldArray->Find( aControlId ); - if ( changedField ) + MLmkEditorField* changedField = iEditorFieldArray->Find(aControlId); + if (changedField) { - if ( changedField->LandmarkItemField().IsTitleField() ) + if (changedField->LandmarkItemField().IsTitleField()) { HBufC* title = changedField->ControlTextL(); - CleanupStack::PushL( title ); - if ( !title ) + CleanupStack::PushL(title); + if (!title) { title = HBufC::New(0); } - iLmkUiUtils->ChangeTitlePaneL( title ); + iLmkUiUtils->ChangeTitlePaneL(title); CleanupStack::Pop(); //title } } @@ -879,16 +863,16 @@ // void CLmkEditorImpl::DoNotSaveFormDataL() { - if ( !iIsEndKey ) - { - LmkNotes::InformationNoteL( iEikonEnv, R_LMK_EMPTY_LANDMARK_NAME_NOTE ); - } + if (!iIsEndKey) + { + LmkNotes::InformationNoteL(iEikonEnv, R_LMK_EMPTY_LANDMARK_NAME_NOTE); + } MLmkFieldData* field = iLmkFields->GetField(EName); - if( field ) + if (field) { TInt id = field->UniqueFieldIdentity(); - TryChangeFocusL(id); - } + TryChangeFocusL(id); + } CAknForm::SetInitialCurrentLine(); } @@ -896,22 +880,22 @@ // CLmkEditorImpl::GetHelpContext // ----------------------------------------------------------------------------- // -void CLmkEditorImpl::GetHelpContext( TCoeHelpContext& aContext ) const +void CLmkEditorImpl::GetHelpContext(TCoeHelpContext& aContext) const { - if ( iHelpContext.iContext.Length() > 0 ) + if (iHelpContext.iContext.Length() > 0) { aContext.iContext = iHelpContext.iContext; aContext.iMajor = iHelpContext.iMajor; } - else if ( iEditorMode == CLmkEditorDlg::ELmkViewer ) + else if (iEditorMode == CLmkEditorDlg::ELmkViewer) { aContext.iContext = KLM_HLP_LM_VIEWER; - aContext.iMajor = TUid::Uid( KLmkAppUID3 ); + aContext.iMajor = TUid::Uid(KLmkAppUID3); } else { aContext.iContext = KLM_HLP_LM_EDITOR; - aContext.iMajor = TUid::Uid( KLmkAppUID3 ); + aContext.iMajor = TUid::Uid(KLmkAppUID3); } } @@ -919,142 +903,87 @@ // CLmkEditorImpl::OfferKeyEventL // ----------------------------------------------------------------------------- // -TKeyResponse CLmkEditorImpl::OfferKeyEventL( const TKeyEvent& aKeyEvent, - TEventCode aType ) +TKeyResponse CLmkEditorImpl::OfferKeyEventL(const TKeyEvent& aKeyEvent, + TEventCode aType) { - /** - * By def, dialog opens in view mode - * selecting 'edit' option from (either from context menu/options menu) - * to edit landmark fields - * - */ + /** + * By def, dialog opens in view mode + * selecting 'edit' option from (either from context menu/options menu) + * to edit landmark fields + * + */ if (IsEditable()) - { - //always dimmed for the editor - DimmMiddleSoftKey(); - } - if ( aKeyEvent.iCode == EKeyOK ) - { - MLmkEditorField* field = - iEditorFieldArray->Find( IdOfFocusControl() ); - TUint type = field->LandmarkItemField().FieldType(); - // check the editor mode - if (IsEditable()) // edit mode - { - if ( type == ECategory || type == ECategories ) - { - if(!iIsCategorySelctorOpen) - { - iIsCategorySelctorOpen = ETrue; - SelectCategoriesCmdL(); - } + { + //always dimmed for the editor + DimmMiddleSoftKey(); + } + else if (aKeyEvent.iCode == EKeyBackspace) + { + if (!IsEditable() && iIsLmkReceiveMode == EFalse) + { + ProcessCommandL(ELmkCmdDeleteLm); + return EKeyWasConsumed; + } + } + else if (aKeyEvent.iCode == EKeyPhoneEnd) + { + iIsEndKey = ETrue; + OkToExitL(EAknSoftkeyDone); + } + else // for 'sendkey' handling + { + if (aKeyEvent.iCode == EKeyPhoneSend && (!IsEditable()) + && (!Layout_Meta_Data::IsPenEnabled())) + { + // Get Landmark's telephone number + TPosLmItemId lmId = iLmkFields->LandmarkId(); + CPosLandmark* landmark = iDb.ReadLandmarkLC(lmId); + // Get phone num field + if (landmark->IsPositionFieldAvailable( + ELmkPositionFieldPhoneNumber)) + { + TPtrC telnumPtr; + if ((landmark->GetPositionField(ELmkPositionFieldPhoneNumber, + telnumPtr) == KErrNone) && (telnumPtr.Length() > 0)) + { + iLmkCallCmd->ExecuteAIWCallCmdL(ELmkCmdCall, telnumPtr); + } + else + { + // Get name + TPtrC lmkNamePtr; + if (landmark->GetLandmarkName(lmkNamePtr) == KErrNone) + { + LmkNotes::InformationNotewithTextL(iEikonEnv, + R_LMK_NOTE_NO_NUMBER_TO_NAME, lmkNamePtr); + } + } + } + CleanupStack::PopAndDestroy(landmark); + } + } - return EKeyWasConsumed; - } - } - else - {// view or receive mode - if ( type == ECategory || type == ECategories ) - { - if(iCalegorySelectionFlag) // Receive mode - { - CategoriesCmdFromXmlL(); - return EKeyWasConsumed; - } - else - { - CategoriesCmdL(); // View mode - return EKeyWasConsumed; - } - } - else // focus is on any other landmark field - { - if ( !iCalegorySelectionFlag )// No context menu for receive mode - { - if(!iIsEditing) - { - LaunchLmkEditorL(); - return EKeyWasConsumed; - } -/* - //Launch context sensitive menu bar here - if ( iContextMenuBar ) - { - iContextMenuBar->TryDisplayMenuBarL(); - return EKeyWasConsumed; - } -*/ - } - } - } - } - else if( aKeyEvent.iCode == EKeyBackspace ) - { - if( !IsEditable() && iIsLmkReceiveMode == EFalse ) - { - ProcessCommandL( ELmkCmdDeleteLm ); - return EKeyWasConsumed; - } - } - else if ( aKeyEvent.iCode == EKeyPhoneEnd ) - { - iIsEndKey = ETrue; - OkToExitL(EAknSoftkeyDone); - } - else // for 'sendkey' handling - { - if ( aKeyEvent.iCode == EKeyPhoneSend && (!IsEditable()) && (!Layout_Meta_Data::IsPenEnabled()) ) - { - // Get Landmark's telephone number - TPosLmItemId lmId = iLmkFields->LandmarkId(); - CPosLandmark* landmark = iDb.ReadLandmarkLC(lmId); - // Get phone num field - if (landmark->IsPositionFieldAvailable( - ELmkPositionFieldPhoneNumber) ) - { - TPtrC telnumPtr; - if ( (landmark->GetPositionField( - ELmkPositionFieldPhoneNumber, - telnumPtr ) == KErrNone) && (telnumPtr.Length() > 0 )) - { - iLmkCallCmd->ExecuteAIWCallCmdL( ELmkCmdCall,telnumPtr ); - } - else - { - // Get name - TPtrC lmkNamePtr; - if ( landmark->GetLandmarkName ( lmkNamePtr ) == KErrNone ) - { - LmkNotes::InformationNotewithTextL( iEikonEnv, - R_LMK_NOTE_NO_NUMBER_TO_NAME, - lmkNamePtr); - } - } - } - CleanupStack::PopAndDestroy(landmark); - } - } + if (aType == EEventKey && (aKeyEvent.iCode == EKeyEnter + || aKeyEvent.iScanCode == EStdKeyEnter)) + { + TBool isCategoryField = EFalse; + MLmkEditorField* field = iEditorFieldArray->Find(IdOfFocusControl()); + TUint type = field->LandmarkItemField().FieldType(); + + if (type == ECategory || type == ECategories) + isCategoryField = ETrue; - if ( aType == EEventKey && ( aKeyEvent.iCode == EKeyEnter || aKeyEvent.iScanCode == EStdKeyEnter )) - { - TBool isCategoryField = EFalse; - MLmkEditorField* field = iEditorFieldArray->Find( IdOfFocusControl() ); - TUint type = field->LandmarkItemField().FieldType(); - - if ( type == ECategory || type == ECategories ) - isCategoryField = ETrue; - - // check the editor mode and category field focus - if ( IsEditable() == EFalse || isCategoryField ) - { - TKeyEvent enterKeyEvent( aKeyEvent ); - enterKeyEvent.iCode = EKeyOK; - CEikButtonGroupContainer* cba = CEikButtonGroupContainer::Current(); - return cba->OfferKeyEventL( enterKeyEvent, aType ); - } - } - - TKeyResponse response= CAknForm::OfferKeyEventL( aKeyEvent, aType ); + // check the editor mode and category field focus + if (IsEditable() == EFalse || isCategoryField) + { + TKeyEvent enterKeyEvent(aKeyEvent); + enterKeyEvent.iCode = EKeyOK; + CEikButtonGroupContainer* cba = + CEikButtonGroupContainer::Current(); + return cba->OfferKeyEventL(enterKeyEvent, aType); + } + } + TKeyResponse response = CAknForm::OfferKeyEventL(aKeyEvent, aType); return response; } @@ -1062,74 +991,74 @@ // CLmkEditorImpl::NotifyL // ----------------------------------------------------------------------------- // -void CLmkEditorImpl::NotifyL( const TInt aStatus ) - { +void CLmkEditorImpl::NotifyL(const TInt aStatus) + { // Stop the running wait dialog - TInt buttonId = iWaitDialogLauncher->StopWaitDialogL(); - if( EEikBidCancel != buttonId ) - { - switch( aStatus ) - { + TInt buttonId = iWaitDialogLauncher->StopWaitDialogL(); + if (EEikBidCancel != buttonId) + { + switch (aStatus) + { case KErrNone: case KPositionPartialUpdate: { - if(iLocationService) - { - TPosition position = iLocationService->CurrentPosition(); - SetCurrentLocationL( position ); - } + if (iLocationService) + { + TPosition position = iLocationService->CurrentPosition(); + SetCurrentLocationL(position); + } break; } default: { break; } - } - } + } + } delete iLocationService; iLocationService = NULL; - } + } // ----------------------------------------------------------------------------- // CLmkEditorImpl::NotifyErrorL // ----------------------------------------------------------------------------- // -void CLmkEditorImpl::NotifyErrorL( TInt aErrorCode ) +void CLmkEditorImpl::NotifyErrorL(TInt aErrorCode) { - // Stop the running wait dialog - TInt buttonId = iWaitDialogLauncher->StopWaitDialogL(); + TInt buttonId = iWaitDialogLauncher->StopWaitDialogL(); delete iLocationService; iLocationService = NULL; - if( EEikBidCancel != buttonId ) - { - switch( aErrorCode ) - { - case KPositionQualityLoss: - case KErrTimedOut: - case KErrNotFound: // No PSY selected. - case KErrUnknown: - case KErrCancel: - case KErrArgument: - default: - // The above errors are because of location request failures - // Ask user to retry location request - { - if ( LmkNotes::MessageQueryWithLinkL(iEikonEnv,R_LMK_MSG_QUERY_HEADING_PANE_TEXT, - R_LMK_CONF_RETRY_LOCATION_REQUEST,R_LMK_REQUEST_FAIL_MORE_INFO, - MessageQueryCallBack) ) - { - if( iLocationService ) - { - delete iLocationService; - iLocationService = NULL; - } - CurrentLocationCmdL(); - } - } - } + if (EEikBidCancel != buttonId) + { + switch (aErrorCode) + { + case KPositionQualityLoss: + case KErrTimedOut: + case KErrNotFound: // No PSY selected. + case KErrUnknown: + case KErrCancel: + case KErrArgument: + default: + // The above errors are because of location request failures + // Ask user to retry location request + { + if (LmkNotes::MessageQueryWithLinkL(iEikonEnv, + R_LMK_MSG_QUERY_HEADING_PANE_TEXT, + R_LMK_CONF_RETRY_LOCATION_REQUEST, + R_LMK_REQUEST_FAIL_MORE_INFO, MessageQueryCallBack)) + { + if (iLocationService) + { + delete iLocationService; + iLocationService = NULL; + } + CurrentLocationCmdL(); + } + } + } } } @@ -1137,24 +1066,24 @@ // CLmkEditorImpl::CreateCustomControlL // ----------------------------------------------------------------------------- // -SEikControlInfo CLmkEditorImpl::CreateCustomControlL( TInt /*aControlType*/ ) +SEikControlInfo CLmkEditorImpl::CreateCustomControlL(TInt /*aControlType*/) { SEikControlInfo ctrl; ctrl.iControl = NULL; ctrl.iTrailerTextId = 0; ctrl.iFlags = 0; /*switch( aControlType ) - { - case EDistanceEditorType: - { - ctrl.iControl = new(ELeave) CLmkDistanceEditor(); - break; - } - default: - { - break; - } - }*/ + { + case EDistanceEditorType: + { + ctrl.iControl = new(ELeave) CLmkDistanceEditor(); + break; + } + default: + { + break; + } + }*/ return ctrl; } @@ -1162,11 +1091,10 @@ // CLmkEditorImpl::ConvertCustomControlTypeToBaseControlType // ---------------------------------------------------- // -MEikDialogPageObserver::TFormControlTypes -CLmkEditorImpl::ConvertCustomControlTypeToBaseControlType( - TInt aControlType ) const +MEikDialogPageObserver::TFormControlTypes CLmkEditorImpl::ConvertCustomControlTypeToBaseControlType( + TInt aControlType) const { - switch( aControlType ) + switch (aControlType) { case EDistanceEditorType: { @@ -1188,14 +1116,13 @@ void CLmkEditorImpl::PreLayoutDynInitL() { CAknForm::PreLayoutDynInitL(); - // When adding fields the form must be editable: - //SetEditableL(ETrue); + SetEditableL(ETrue); if (iCalegorySelectionFlag && iCategoryNames.Count() >= 1) iEditorFieldArray->SetCategoryName(iCategoryNames[0]); iEditorFieldArray->CreateFieldsFromLmkL(); - //SetEditableL(EFalse); - //CAknForm::SetInitialCurrentLine(); + SetEditableL(EFalse); + CAknForm::SetInitialCurrentLine(); } // ----------------------------------------------------------------------------- @@ -1205,82 +1132,80 @@ void CLmkEditorImpl::PostLayoutDynInitL() { CAknForm::PostLayoutDynInitL(); - - MLmkFieldData* fields = iLmkFields->GetField( EName ); - if ( fields ) + MLmkFieldData* fields = iLmkFields->GetField(EName); + if (fields) { - TPtrC name = fields->TextData(); - + TPtrC name = fields->TextData(); //ChangeTitle HBufC* title = name.Alloc(); - CleanupStack::PushL( title ); + CleanupStack::PushL(title); iLmkUiUtils->StoreTitlePaneL(); // save old title pane - iLmkUiUtils->ChangeTitlePaneL( title ); //take ownership - CleanupStack::Pop( title ); //title + iLmkUiUtils->ChangeTitlePaneL(title); //take ownership + CleanupStack::Pop(title); //title } - SetEditableL( iEditorMode == CLmkEditorDlg::ELmkEditor ); + SetEditableL(iEditorMode == CLmkEditorDlg::ELmkEditor); CEikButtonGroupContainer* cba = CEikButtonGroupContainer::Current(); - cba->UpdateCommandObserverL(KMskCommandPos,*this); + cba->UpdateCommandObserverL(KMskCommandPos, *this); if (!IsEditable()) - { - AddMskCommandL(R_LM_MSK_EDIT,ELmkCmdEditLm); - } - else - { - //only for editor - DimmMiddleSoftKey(); - if (iFieldTypeToFocus == ECategory || iFieldTypeToFocus == ECategories) - { - AddMskCommandL(R_LM_MSK_EDIT,ELmkCmdSelectCategories); - } - } + { + AddMskCommandL(R_LM_MSK_EDIT, ELmkCmdEditLm); + } + else + { + //only for editor + DimmMiddleSoftKey(); + if (iFieldTypeToFocus == ECategory || iFieldTypeToFocus + == ECategories) + { + AddMskCommandL(R_LM_MSK_EDIT, ELmkCmdSelectCategories); + } + } } // ----------------------------------------------------------------------------- // CLmkEditorImpl::OkToExitL // ----------------------------------------------------------------------------- // -TBool CLmkEditorImpl::OkToExitL( TInt aKeyCode ) +TBool CLmkEditorImpl::OkToExitL(TInt aKeyCode) { + DEBUG( CLmkEditorImpl::OkToExitL start ); TBool ret = EFalse; - switch ( aKeyCode ) + switch (aKeyCode) { - case EAknSoftkeyDone: - { - if ( IsEditable() ) + case EAknSoftkeyDone: + { + if (IsEditable()) { - if ( iEditorFieldArray->AreAllFieldsEmptyL() ) + if (iEditorFieldArray->AreAllFieldsEmptyL()) { - - if( iLandmark && iIsHideCoordinate ) - { - TLocality locality; - iLandmark->GetPosition( locality ); - if( !Math::IsNaN( locality.Latitude() )) - { - DoNotSaveFormDataL(); - iIsEndKey = EFalse; - // Stay back in the editor mode - break; - } - } - + if (iLandmark && iIsHideCoordinate) + { + TLocality locality; + iLandmark->GetPosition(locality); + if (!Math::IsNaN(locality.Latitude())) + { + DoNotSaveFormDataL(); + iIsEndKey = EFalse; + // Stay back in the editor mode + break; + } + } TRAPD(err,CPosLandmark* landmark = iDb.ReadLandmarkLC(iLmkFields->LandmarkId());CleanupStack::PopAndDestroy( landmark )); if (err == KErrNotFound) { - // The Landmark is not in the database.Dont save the - // landmark. Just return - // Don't save when all landmark fields are empty - iLmkUiUtils->RestoreOldNaviPaneL(); - ret = ETrue; + // The Landmark is not in the database.Dont save the + // landmark. Just return + // Don't save when all landmark fields are empty + iLmkUiUtils->RestoreOldNaviPaneL(); + ret = ETrue; } else { // The landmark is in the database. Hence, confirm // from the user whether he wants to delete the // landmark - if ( LmkNotes::LandmarkConfirmationQueryL( iEikonEnv ) ) + if (LmkNotes::LandmarkConfirmationQueryL(iEikonEnv)) { iLmkFields->DeleteLandmarkL(); iLmkUiUtils->RestoreOldNaviPaneL(); @@ -1296,30 +1221,30 @@ } else { - if(!ValidateContentL()) - { - ret = EFalse; - return ret; - } - else + if (!ValidateContentL()) { + ret = EFalse; + return ret; + } + else + { /** - * Do not save landmark if disc space is not - * enough - */ + * Do not save landmark if disc space is not + * enough + */ TRAPD( err, iEditorFieldArray->SaveFieldsL() ); - if ( err == KErrDiskFull ) + if (err == KErrDiskFull) { ret = EFalse; - LmkNotes::OutOfMemoryNoteL( iEikonEnv ); + LmkNotes::OutOfMemoryNoteL(iEikonEnv); delete this; return ret; } - if ( iLandmarkItemId ) - { - *iLandmarkItemId = iLmkFields->LandmarkId(); - } + if (iLandmarkItemId) + { + *iLandmarkItemId = iLmkFields->LandmarkId(); + } iLmkUiUtils->RestoreOldNaviPaneL(); ret = ETrue; } @@ -1335,10 +1260,11 @@ default: break; } - if ( !ret ) + if (!ret) { - ret = CAknForm::OkToExitL( aKeyCode ); + ret = CAknForm::OkToExitL(aKeyCode); } + DEBUG1( CLmkEditorImpl::OkToExitL start ret=%d,ret ); return ret; } @@ -1346,78 +1272,74 @@ // CLmkEditorImpl::CreateLineL // ----------------------------------------------------------------------------- // -CCoeControl* CLmkEditorImpl::CreateLineL( - const TDesC& aCaption, - TInt aControlId, - TInt aControlType ) - { - return CreateLineByTypeL( - aCaption, aControlId, aControlType, NULL ); - } +CCoeControl* CLmkEditorImpl::CreateLineL(const TDesC& aCaption, + TInt aControlId, TInt aControlType) + { + return CreateLineByTypeL(aCaption, aControlId, aControlType, NULL); + } // ----------------------------------------------------------------------------- // CLmkEditorImpl::LineControl // ----------------------------------------------------------------------------- // -CEikCaptionedControl* CLmkEditorImpl::LineControl( TInt aControlId ) const - { - return Line( aControlId ); - } +CEikCaptionedControl* CLmkEditorImpl::LineControl(TInt aControlId) const + { + return Line(aControlId); + } // ----------------------------------------------------------------------------- // CLmkEditorImpl::DeleteControl // ----------------------------------------------------------------------------- // -void CLmkEditorImpl::DeleteControl( TInt aControlId ) - { - DeleteLine( aControlId ); - } +void CLmkEditorImpl::DeleteControl(TInt aControlId) + { + DeleteLine(aControlId); + } // ----------------------------------------------------------------------------- // CLmkEditorImpl::TryChangeFocusL // ----------------------------------------------------------------------------- // -void CLmkEditorImpl::TryChangeFocusL( TInt aControlId ) - { - if ( ControlOrNull( aControlId ) ) - { - TryChangeFocusToL( aControlId ); - } - } +void CLmkEditorImpl::TryChangeFocusL(TInt aControlId) + { + if (ControlOrNull(aControlId)) + { + TryChangeFocusToL(aControlId); + } + } // ----------------------------------------------------------------------------- // CLmkEditorImpl::SetCurrentLineCaptionL // ----------------------------------------------------------------------------- // -void CLmkEditorImpl::SetCurrentLineCaptionL( - TInt aControlId, - const TDesC& aText ) - { - CEikCaptionedControl* ctl = Line(aControlId); - if (ctl) - { - ctl->SetCaptionL(aText); - ctl->DrawDeferred(); - } - } +void CLmkEditorImpl::SetCurrentLineCaptionL(TInt aControlId, + const TDesC& aText) + { + CEikCaptionedControl* ctl = Line(aControlId); + if (ctl) + { + ctl->SetCaptionL(aText); + ctl->DrawDeferred(); + } + } // ----------------------------------------------------------------------------- // CLmkEditorImpl::Control // ----------------------------------------------------------------------------- // -CCoeControl* CLmkEditorImpl::Control( TInt aControlId ) const - { - return ControlOrNull( aControlId ); - } +CCoeControl* CLmkEditorImpl::Control(TInt aControlId) const + { + return ControlOrNull(aControlId); + } // ----------------------------------------------------------------------------- // CLmkEditorImpl::SetEditableL // ----------------------------------------------------------------------------- // -void CLmkEditorImpl::SetEditableL( TBool aState ) - { - CAknForm::SetEditableL( aState ); - } +void CLmkEditorImpl::SetEditableL(TBool aState) + { + CAknForm::SetEditableL(aState); + } // ----------------------------------------------------------------------------- // CLmkEditorImpl::Database @@ -1433,49 +1355,50 @@ // ----------------------------------------------------------------------------- // CPosLandmark* CLmkEditorImpl::GetCurrentEditedLandmarkL() - { - iEditorFieldArray->SaveFieldsToBufferL(); - CArrayPtrFlat& fieldArray = iLmkFields->Fields(); - TInt count( fieldArray.Count() ); - CPosLandmark* lmk = NULL; - if( iLandmark ) - { - HBufC8* lmBuf = PosLandmarkSerialization::PackL( *iLandmark ); - CleanupStack::PushL( lmBuf ); - lmk = PosLandmarkSerialization::UnpackL( lmBuf->Des() ); - CleanupStack::PopAndDestroy( lmBuf ); - } - else - { - lmk = CPosLandmark::NewL(); - } + { + iEditorFieldArray->SaveFieldsToBufferL(); + CArrayPtrFlat& fieldArray = iLmkFields->Fields(); + TInt count(fieldArray.Count()); + CPosLandmark* lmk = NULL; + if (iLandmark) + { + HBufC8* lmBuf = PosLandmarkSerialization::PackL(*iLandmark); + CleanupStack::PushL(lmBuf); + lmk = PosLandmarkSerialization::UnpackL(lmBuf->Des()); + CleanupStack::PopAndDestroy(lmBuf); + } + else + { + lmk = CPosLandmark::NewL(); + } - TBool isPosFieldPresent=EFalse; - - TLocationData locationData; // to store editor position data + TBool isPosFieldPresent = EFalse; + + TLocationData locationData; // to store editor position data //Position data - TLocality locality = TLocality(); // empty locality + TLocality locality = TLocality(); // empty locality - locationData.iLatitude = locality.Latitude(); - locationData.iLongitude = locality.Longitude(); - locationData.iAltitude = locality.Altitude(); - locationData.iHorizontalAccuracy = locality.HorizontalAccuracy(); - locationData.iVerticalAccuracy = locality.VerticalAccuracy(); - - for ( TInt i = 0; i < count; i++ ) + locationData.iLatitude = locality.Latitude(); + locationData.iLongitude = locality.Longitude(); + locationData.iAltitude = locality.Altitude(); + locationData.iHorizontalAccuracy = locality.HorizontalAccuracy(); + locationData.iVerticalAccuracy = locality.VerticalAccuracy(); + + for (TInt i = 0; i < count; i++) { - switch( fieldArray[i]->FieldType() ) + switch (fieldArray[i]->FieldType()) { case EName: { - lmk->SetLandmarkNameL( fieldArray[i]->TextData() ); + lmk->SetLandmarkNameL(fieldArray[i]->TextData()); HBufC* path = fieldArray[i]->IconPath(); - if ( path && path->Length() > 0 && - fieldArray[i]->IconId() != KErrNotFound ) + if (path && path->Length() > 0 && fieldArray[i]->IconId() + != KErrNotFound) { // Get the default Mask index - lmk->SetIconL( *path, fieldArray[i]->IconId() , KLmkDefaultId+1); + lmk->SetIconL(*path, fieldArray[i]->IconId(), + KLmkDefaultId + 1); } break; @@ -1485,31 +1408,30 @@ { //Add categories to landmark RArray& categories = - fieldArray[i]->Categories(); - TInt Tcount( categories.Count() ); - for ( TInt j=0; j < Tcount; j++ ) + fieldArray[i]->Categories(); + TInt Tcount(categories.Count()); + for (TInt j = 0; j < Tcount; j++) { - lmk->AddCategoryL( categories[j] ); + lmk->AddCategoryL(categories[j]); } break; } - case EDescription: - { - lmk->SetLandmarkDescriptionL( fieldArray[i]->TextData() ); - break; - } - //these all are same + case EDescription: + { + lmk->SetLandmarkDescriptionL(fieldArray[i]->TextData()); + break; + } + //these all are same case EStreet: case EPostCode: case ECity: case EStateProvince: case ECountry: - case EPhoneNumber: - case EWebAddress: + case EPhoneNumber: + case EWebAddress: { - lmk->SetPositionFieldL( - fieldArray[i]->PositionFieldId(), - fieldArray[i]->TextData() ); + lmk->SetPositionFieldL(fieldArray[i]->PositionFieldId(), + fieldArray[i]->TextData()); break; } case ELatitude: @@ -1526,8 +1448,7 @@ } case EPositionAccuracy: { - locationData.iHorizontalAccuracy = - fieldArray[i]->FloatData(); + locationData.iHorizontalAccuracy = fieldArray[i]->FloatData(); break; } case EAltitude: @@ -1547,46 +1468,44 @@ } } - if( isPosFieldPresent ) + if (isPosFieldPresent) { // remove the old values to set new values lmk->RemoveLandmarkAttributes(CPosLandmark::EPosition); - if (!Math::IsNaN(locationData.iLatitude) && - !Math::IsNaN(locationData.iLongitude)) + if (!Math::IsNaN(locationData.iLatitude) && !Math::IsNaN( + locationData.iLongitude)) { if (!Math::IsNaN(locationData.iAltitude)) { - locality.SetCoordinate( - locationData.iLatitude, - locationData.iLongitude, - locationData.iAltitude); + locality.SetCoordinate(locationData.iLatitude, + locationData.iLongitude, locationData.iAltitude); if (!Math::IsNaN(locationData.iVerticalAccuracy)) { - if( locationData.iVerticalAccuracy > 0 ) - locality.SetVerticalAccuracy(locationData.iVerticalAccuracy); + if (locationData.iVerticalAccuracy > 0) + locality.SetVerticalAccuracy( + locationData.iVerticalAccuracy); } } else { - locality.SetCoordinate( - locationData.iLatitude, - locationData.iLongitude); + locality.SetCoordinate(locationData.iLatitude, + locationData.iLongitude); } if (!Math::IsNaN(locationData.iHorizontalAccuracy)) { - if( locationData.iHorizontalAccuracy > 0 ) - locality.SetHorizontalAccuracy(locationData.iHorizontalAccuracy); + if (locationData.iHorizontalAccuracy > 0) + locality.SetHorizontalAccuracy( + locationData.iHorizontalAccuracy); } // save position if at least lat/lon are entered - lmk->SetPositionL(locality); + lmk->SetPositionL(locality); } } - return lmk; - } + } // ----------------------------------------------------------------------------- // CLmkEditorImpl::CreateLabelArrayL @@ -1595,15 +1514,15 @@ void CLmkEditorImpl::CreateLabelArrayL() { - if ( iJapaneseInputMode ) - { - // Display in Japanese order - CreateLabelArrayForJapaneseModeL(); - } - else - { // Normal mode - CreateLabelArrayForNormalModeL(); - } + if (iJapaneseInputMode) + { + // Display in Japanese order + CreateLabelArrayForJapaneseModeL(); + } + else + { // Normal mode + CreateLabelArrayForNormalModeL(); + } } // ----------------------------------------------------------------------------- @@ -1611,90 +1530,88 @@ // ----------------------------------------------------------------------------- // void CLmkEditorImpl::CreateLabelArrayForNormalModeL() - { - CreateLabelL( R_LMK_NAME_LABEL, EName ); - CreateLabelL( R_LMK_CATEGORY_LABEL, ECategory ); - CreateLabelL( R_LMK_CATEGORIES_LABEL, ECategories ); - CreateLabelL( R_LMK_DESCRIPTION_LABEL, EDescription ); - CreateLabelL( R_LMK_STREET_LABEL, EStreet ); - CreateLabelL( R_LMK_POST_CODE_LABEL, EPostCode ); - CreateLabelL( R_LMK_CITY_LABEL, ECity ); - CreateLabelL( R_LMK_STATE_PROVINCE_LABEL, EStateProvince ); - CreateLabelL( R_LMK_COUNTRY_LABEL, ECountry ); - CreateLabelL( R_LMK_PHONE_NUMBER_LABEL, EPhoneNumber ); - CreateLabelL( R_LMK_WEB_ADDRESS_LABEL, EWebAddress ); - CreateLabelL( R_LMK_LATITUDE_LABEL, ELatitude ); - CreateLabelL( R_LMK_LONGITUDE_LABEL, ELongitude ); - CreateLabelL( R_LMK_POSITION_ACCURACY_LABEL, EPositionAccuracy ); - CreateLabelL( R_LMK_ALTITUDE_LABEL, EAltitude ); - CreateLabelL( R_LMK_ALTITUDE_ACCURACY_LABEL, EAltitudeAccuracy ); - } + { + CreateLabelL(R_LMK_NAME_LABEL, EName); + CreateLabelL(R_LMK_CATEGORY_LABEL, ECategory); + CreateLabelL(R_LMK_CATEGORIES_LABEL, ECategories); + CreateLabelL(R_LMK_DESCRIPTION_LABEL, EDescription); + CreateLabelL(R_LMK_STREET_LABEL, EStreet); + CreateLabelL(R_LMK_POST_CODE_LABEL, EPostCode); + CreateLabelL(R_LMK_CITY_LABEL, ECity); + CreateLabelL(R_LMK_STATE_PROVINCE_LABEL, EStateProvince); + CreateLabelL(R_LMK_COUNTRY_LABEL, ECountry); + CreateLabelL(R_LMK_PHONE_NUMBER_LABEL, EPhoneNumber); + CreateLabelL(R_LMK_WEB_ADDRESS_LABEL, EWebAddress); + CreateLabelL(R_LMK_LATITUDE_LABEL, ELatitude); + CreateLabelL(R_LMK_LONGITUDE_LABEL, ELongitude); + CreateLabelL(R_LMK_POSITION_ACCURACY_LABEL, EPositionAccuracy); + CreateLabelL(R_LMK_ALTITUDE_LABEL, EAltitude); + CreateLabelL(R_LMK_ALTITUDE_ACCURACY_LABEL, EAltitudeAccuracy); + } // ----------------------------------------------------------------------------- // CLmkEditorImpl::CreateLabelArrayForJapaneseModeL() // ----------------------------------------------------------------------------- // void CLmkEditorImpl::CreateLabelArrayForJapaneseModeL() - { - CreateLabelL( R_LMK_NAME_LABEL, ENameJapaneseMode); - CreateLabelL( R_LMK_CATEGORY_LABEL, ECategoryJapaneseMode ); - CreateLabelL( R_LMK_CATEGORIES_LABEL, ECategoriesJapaneseMode ); - CreateLabelL( R_LMK_DESCRIPTION_LABEL, EDescriptionJapaneseMode ); - CreateLabelL( R_LMK_POST_CODE_LABEL, EPostCodeJapaneseMode ); - CreateLabelL( R_LMK_STATE_PROVINCE_LABEL, EStateProvinceJapaneseMode ); - CreateLabelL( R_LMK_CITY_LABEL, ECityJapaneseMode ); - CreateLabelL( R_LMK_STREET_LABEL, EStreetJapaneseMode ); - CreateLabelL( R_LMK_COUNTRY_LABEL, ECountryJapaneseMode ); - CreateLabelL( R_LMK_PHONE_NUMBER_LABEL, EPhoneNumberJapaneseMode ); - CreateLabelL( R_LMK_WEB_ADDRESS_LABEL, EWebAddressJapaneseMode ); - CreateLabelL( R_LMK_LATITUDE_LABEL, ELatitudeJapaneseMode ); - CreateLabelL( R_LMK_LONGITUDE_LABEL, ELongitudeJapaneseMode ); - CreateLabelL( R_LMK_POSITION_ACCURACY_LABEL, EPositionAccuracyJapaneseMode ); - CreateLabelL( R_LMK_ALTITUDE_LABEL, EAltitudeJapaneseMode ); - CreateLabelL( R_LMK_ALTITUDE_ACCURACY_LABEL, EAltitudeAccuracyJapaneseMode ); - } + { + CreateLabelL(R_LMK_NAME_LABEL, ENameJapaneseMode); + CreateLabelL(R_LMK_CATEGORY_LABEL, ECategoryJapaneseMode); + CreateLabelL(R_LMK_CATEGORIES_LABEL, ECategoriesJapaneseMode); + CreateLabelL(R_LMK_DESCRIPTION_LABEL, EDescriptionJapaneseMode); + CreateLabelL(R_LMK_POST_CODE_LABEL, EPostCodeJapaneseMode); + CreateLabelL(R_LMK_STATE_PROVINCE_LABEL, EStateProvinceJapaneseMode); + CreateLabelL(R_LMK_CITY_LABEL, ECityJapaneseMode); + CreateLabelL(R_LMK_STREET_LABEL, EStreetJapaneseMode); + CreateLabelL(R_LMK_COUNTRY_LABEL, ECountryJapaneseMode); + CreateLabelL(R_LMK_PHONE_NUMBER_LABEL, EPhoneNumberJapaneseMode); + CreateLabelL(R_LMK_WEB_ADDRESS_LABEL, EWebAddressJapaneseMode); + CreateLabelL(R_LMK_LATITUDE_LABEL, ELatitudeJapaneseMode); + CreateLabelL(R_LMK_LONGITUDE_LABEL, ELongitudeJapaneseMode); + CreateLabelL(R_LMK_POSITION_ACCURACY_LABEL, EPositionAccuracyJapaneseMode); + CreateLabelL(R_LMK_ALTITUDE_LABEL, EAltitudeJapaneseMode); + CreateLabelL(R_LMK_ALTITUDE_ACCURACY_LABEL, EAltitudeAccuracyJapaneseMode); + } // ----------------------------------------------------------------------------- // CLmkEditorImpl::CreateLabelL // ----------------------------------------------------------------------------- // -void CLmkEditorImpl::CreateLabelL( TInt iResourceId, TInt iPos ) +void CLmkEditorImpl::CreateLabelL(TInt iResourceId, TInt iPos) { - HBufC* label = iCoeEnv->AllocReadResourceL( iResourceId ); - CleanupStack::PushL( label ); - User::LeaveIfError( iLabelArray.Insert( label, iPos ) ); + HBufC* label = iCoeEnv->AllocReadResourceL(iResourceId); + CleanupStack::PushL(label); + User::LeaveIfError(iLabelArray.Insert(label, iPos)); CleanupStack::Pop(); //label } - // ----------------------------------------------------------------------------- // CLmkEditorImpl::IsNameFieldEmptyL // ----------------------------------------------------------------------------- // TBool CLmkEditorImpl::IsNameFieldEmptyL() { - const MLmkEditorField* field = &iEditorFieldArray->FieldAt( 0 ); + const MLmkEditorField* field = &iEditorFieldArray->FieldAt(0); HBufC* fieldText = field->ControlTextL(); - TBool ret( ETrue ); - if ( fieldText && fieldText->Length() > 0 ) + TBool ret(ETrue); + if (fieldText && fieldText->Length() > 0) { - //Check if any active character or not - TPtr16 ptr = fieldText->Des(); - ptr.Trim(); - if (ptr.Length() == 0) - { - ret = ETrue; - } - else - { - ret = EFalse; - } + //Check if any active character or not + TPtr16 ptr = fieldText->Des(); + ptr.Trim(); + if (ptr.Length() == 0) + { + ret = ETrue; + } + else + { + ret = EFalse; + } } delete fieldText; return ret; } - // ----------------------------------------------------------------------------- // CLmkEditorImpl::ValidateContentL() // ----------------------------------------------------------------------------- @@ -1702,49 +1619,50 @@ TBool CLmkEditorImpl::ValidateContentL() { TBool result = ETrue; - if(IsFieldEmptyL( ELatitude ) && !IsFieldEmptyL( ELongitude )) - { - LmkNotes::InformationNoteL( iEikonEnv,R_LMK_ERROR_CHECK_NOTE ); + if (IsFieldEmptyL(ELatitude) && !IsFieldEmptyL(ELongitude)) + { + LmkNotes::InformationNoteL(iEikonEnv, R_LMK_ERROR_CHECK_NOTE); DoNotSaveDataL(ELatitude); - result = EFalse; - } - else if (!IsFieldEmptyL( ELatitude ) && IsFieldEmptyL( ELongitude )) - { - LmkNotes::InformationNoteL( iEikonEnv, R_LMK_ERROR_CHECK_NOTE ); + result = EFalse; + } + else if (!IsFieldEmptyL(ELatitude) && IsFieldEmptyL(ELongitude)) + { + LmkNotes::InformationNoteL(iEikonEnv, R_LMK_ERROR_CHECK_NOTE); + DoNotSaveDataL(ELongitude); + result = EFalse; + } + else if (IsFieldEmptyL(ELatitude) && !IsFieldEmptyL(EPositionAccuracy)) + { + LmkNotes::InformationNoteL(iEikonEnv, R_LMK_ERROR_POS_ACC_CHECK_NOTE); + DoNotSaveDataL(ELatitude); + result = EFalse; + } + else if (IsFieldEmptyL(ELongitude) && !IsFieldEmptyL(EPositionAccuracy)) + { + LmkNotes::InformationNoteL(iEikonEnv, R_LMK_ERROR_POS_ACC_CHECK_NOTE); DoNotSaveDataL(ELongitude); - result = EFalse; - } - else if(IsFieldEmptyL( ELatitude ) && !IsFieldEmptyL( EPositionAccuracy )) - { - LmkNotes::InformationNoteL( iEikonEnv, R_LMK_ERROR_POS_ACC_CHECK_NOTE ); - DoNotSaveDataL(ELatitude); - result = EFalse; - } - else if (IsFieldEmptyL( ELongitude ) && !IsFieldEmptyL( EPositionAccuracy )) - { - LmkNotes::InformationNoteL( iEikonEnv, R_LMK_ERROR_POS_ACC_CHECK_NOTE ); - DoNotSaveDataL(ELongitude); - result = EFalse; - } - else if (IsFieldEmptyL( EAltitude ) && !IsFieldEmptyL( EAltitudeAccuracy )) - { - LmkNotes::InformationNoteL( iEikonEnv, R_LMK_ERROR_ALT_ACC_CHECK_NOTE ); + result = EFalse; + } + else if (IsFieldEmptyL(EAltitude) && !IsFieldEmptyL(EAltitudeAccuracy)) + { + LmkNotes::InformationNoteL(iEikonEnv, R_LMK_ERROR_ALT_ACC_CHECK_NOTE); DoNotSaveDataL(EAltitude); - result = EFalse; - } - else if ((IsFieldEmptyL( ELatitude ) || IsFieldEmptyL( ELongitude )) && !IsFieldEmptyL( EAltitude )) - { - LmkNotes::InformationNoteL( iEikonEnv, R_LMK_ERROR_ALTITUDE_CHECK_NOTE ); + result = EFalse; + } + else if ((IsFieldEmptyL(ELatitude) || IsFieldEmptyL(ELongitude)) + && !IsFieldEmptyL(EAltitude)) + { + LmkNotes::InformationNoteL(iEikonEnv, R_LMK_ERROR_ALTITUDE_CHECK_NOTE); DoNotSaveDataL(ELatitude); - result = EFalse; - } + result = EFalse; + } else if (IsInvalidUriL()) - { - LmkNotes::InformationNoteL( iEikonEnv, R_LMK_ERROR_URL_ILLEGAL_NOTE ); + { + LmkNotes::InformationNoteL(iEikonEnv, R_LMK_ERROR_URL_ILLEGAL_NOTE); DoNotSaveDataL(EWebAddress); - result = EFalse; - } - else if ( IsNameFieldEmptyL() ) + result = EFalse; + } + else if (IsNameFieldEmptyL()) { DoNotSaveFormDataL(); iIsEndKey = EFalse; @@ -1759,61 +1677,61 @@ // ----------------------------------------------------------------------------- // TBool CLmkEditorImpl::IsFieldEmptyL(const TUint16 aFieldType) - { - TInt fldId; - MLmkFieldData* field = iLmkFields->GetField(aFieldType); - if(field) - { - fldId = field->UniqueFieldIdentity(); - } + { + TInt fldId; + MLmkFieldData* field = iLmkFields->GetField(aFieldType); + if (field) + { + fldId = field->UniqueFieldIdentity(); + } else { return EFalse; } - MLmkEditorField* fld = iEditorFieldArray->Find(fldId ); - if(!fld) - { - return ETrue; - } - - TReal val; - switch(aFieldType) - { - case ELatitude: - case ELongitude: - { - val = fld->FieldValue(); - } - break; - case EPositionAccuracy: - case EAltitudeAccuracy: - case EAltitude: - { - val = fld->FieldValue(); - } - break; - } - return Math::IsNaN(val); - } + MLmkEditorField* fld = iEditorFieldArray->Find(fldId); + if (!fld) + { + return ETrue; + } + TReal val; + switch (aFieldType) + { + case ELatitude: + case ELongitude: + { + val = fld->FieldValue(); + } + break; + case EPositionAccuracy: + case EAltitudeAccuracy: + case EAltitude: + { + val = fld->FieldValue(); + } + break; + } + return Math::IsNaN(val); + } // ----------------------------------------------------------------------------- // CLmkEditorImpl::DoNotSaveDataL() // ----------------------------------------------------------------------------- // void CLmkEditorImpl::DoNotSaveDataL(const TUint16 aFieldType) - { - if( iIsEditing ) - { - MLmkFieldData* fields = iLmkFields->GetField(aFieldType); - if(fields) - { - TInt id = fields->UniqueFieldIdentity(); - TryChangeFocusL(id); - } - } + { + if (iIsEditing) + { + MLmkFieldData* fields = iLmkFields->GetField(aFieldType); + if (fields) + { + TInt id = fields->UniqueFieldIdentity(); + TryChangeFocusL(id); + } + } } + // ----------------------------------------------------------------------------- // CLmkEditorImpl::OkToExitL // ----------------------------------------------------------------------------- @@ -1821,14 +1739,13 @@ TBool CLmkEditorImpl::OkToExitL() { TBool result = ETrue; - - if ( iEditorFieldArray->AreAllFieldsEmptyL() ) + if (iEditorFieldArray->AreAllFieldsEmptyL()) { iLmkFields->DeleteLandmarkL(); } else { - if ( IsNameFieldEmptyL() ) + if (IsNameFieldEmptyL()) { DoNotSaveFormDataL(); result = EFalse; @@ -1836,20 +1753,19 @@ else { TRAPD( err, iEditorFieldArray->SaveFieldsL() ); - if ( err == KErrDiskFull ) + if (err == KErrDiskFull) { result = EFalse; - LmkNotes::OutOfMemoryNoteL( iEikonEnv ); + LmkNotes::OutOfMemoryNoteL(iEikonEnv); delete this; return result; } - if ( iLandmarkItemId ) - { - *iLandmarkItemId = iLmkFields->LandmarkId(); - } + if (iLandmarkItemId) + { + *iLandmarkItemId = iLmkFields->LandmarkId(); + } } } - return result; } @@ -1859,32 +1775,31 @@ // void CLmkEditorImpl::SelectCategoriesCmdL() { - if(iCatInfoPopupNote) - { - iCatInfoPopupNote->HideInfoPopupNote(); - } - MLmkFieldData* fields = iLmkFields->GetField( ECategory ); - if ( !fields ) + if (iCatInfoPopupNote) { - fields = iLmkFields->GetField( ECategories ); + iCatInfoPopupNote->HideInfoPopupNote(); } - - if ( fields ) + MLmkFieldData* fields = iLmkFields->GetField(ECategory); + if (!fields) + { + fields = iLmkFields->GetField(ECategories); + } + if (fields) { CLmkDlgCategorySelectorImpl* dlg = CLmkDlgCategorySelectorImpl::NewL( - iDb, ETrue ); - CleanupStack::PushL( dlg ); - dlg->SetEmptyDlgLabel(R_LMK_EMPTY_NO_CATEGORIES ,R_LMK_GUIDE_CREATE_LANDMARK); + iDb, ETrue); + CleanupStack::PushL(dlg); + dlg->SetEmptyDlgLabel(R_LMK_EMPTY_NO_CATEGORIES, + R_LMK_GUIDE_CREATE_LANDMARK); RArray& categories = fields->Categories(); - if ( dlg->ExecuteL( categories ) ) + if (dlg->ExecuteL(categories)) { - iEditorFieldArray->UpdateFieldsL( ECategory ); - iEditorFieldArray->UpdateFieldsL( ECategories ); + iEditorFieldArray->UpdateFieldsL(ECategory); + iEditorFieldArray->UpdateFieldsL(ECategories); } - CleanupStack::PopAndDestroy( dlg ); + CleanupStack::PopAndDestroy(dlg); iIsCategorySelctorOpen = EFalse; DrawNow(); - // ShowMultipleCategoriesInfoPopupL(ETrue); } } @@ -1894,25 +1809,23 @@ // void CLmkEditorImpl::CurrentLocationCmdL() { - if(ShowQueryIfLocationFieldsAlreadyFilledL()) - { - return; - } - HBufC* srvName = StringLoader::LoadLC( - R_LMK_SERVICE_RULE_NAME, - const_cast< CCoeEnv *>( iCoeEnv )); + if (ShowQueryIfLocationFieldsAlreadyFilledL()) + { + return; + } + HBufC* srvName = StringLoader::LoadLC(R_LMK_SERVICE_RULE_NAME, + const_cast (iCoeEnv)); iLocationService = CLmkLocationService::NewL(*srvName); - CleanupStack::PopAndDestroy( srvName ); //srvName - iLocationService->SetObserver( *this ); + CleanupStack::PopAndDestroy(srvName); //srvName + iLocationService->SetObserver(*this); iLocationService->LocationRequestL(); - TRAPD( error, iWaitDialogLauncher->StartWaitDialogL()); - if( error ) + if (error) { delete iLocationService; iLocationService = NULL; - User::Leave( error ); + User::Leave(error); } } @@ -1923,47 +1836,49 @@ void CLmkEditorImpl::ChangeIconCmdL() { TInt lSelectedIconIndex(0); - CLmkIconMapDialog* dialog = new(ELeave) CLmkIconMapDialog( lSelectedIconIndex ); + CLmkIconMapDialog* dialog = new (ELeave) CLmkIconMapDialog( + lSelectedIconIndex); MLmkFieldData* nameField; - if (dialog->ExecuteLD(R_LMK_ICON_TABLE_DIALOG) ) + if (dialog->ExecuteLD(R_LMK_ICON_TABLE_DIALOG)) { // icon file also contains masks, therefore 2* - TInt iconIndex = 2*lSelectedIconIndex; - RFs fs; - User::LeaveIfError(fs.Connect()); - CleanupClosePushL( fs ); + TInt iconIndex = 2 * lSelectedIconIndex; + RFs fs; + User::LeaveIfError(fs.Connect()); + CleanupClosePushL(fs); - if ( SysUtil::DiskSpaceBelowCriticalLevelL( &fs, sizeof( CPosLandmark ), EDriveC ) ) - { - CleanupStack::PopAndDestroy(); // fs - User::LeaveNoMemory(); - } - else - { - nameField = iLmkFields->GetField( EName ); + if (SysUtil::DiskSpaceBelowCriticalLevelL(&fs, sizeof(CPosLandmark), + EDriveC)) + { + CleanupStack::PopAndDestroy(); // fs + User::LeaveNoMemory(); + } + else + { + nameField = iLmkFields->GetField(EName); TFileName* iconFile = CLmkUiUtils::LmkUiIconFileLC(); - if( nameField && iconFile ) - { - nameField->SetIconId( iconIndex + EMbmLmkuiQgn_prop_lm_transport); - nameField->SetIconPathL( *iconFile ); - + if (nameField && iconFile) + { + nameField->SetIconId(iconIndex + + EMbmLmkuiQgn_prop_lm_transport); + nameField->SetIconPathL(*iconFile); + //Update context icon - CEikImage* image = new(ELeave) CEikImage(); - CleanupStack::PushL( image ); - image->CreatePictureFromFileL( *iconFile, - nameField->IconId(), - iconIndex + EMbmLmkuiQgn_prop_lm_transport_mask); - - iLmkUiUtils->UpdateContextIconL( image ); - + CEikImage* image = new (ELeave) CEikImage(); + CleanupStack::PushL(image); + image->CreatePictureFromFileL(*iconFile, nameField->IconId(), + iconIndex + EMbmLmkuiQgn_prop_lm_transport_mask); + + iLmkUiUtils->UpdateContextIconL(image); + // Added for appending Icon to Name label - CLmkUiUtils::ChangeLmNameLabelIconL (*this, *nameField); + CLmkUiUtils::ChangeLmNameLabelIconL(*this, *nameField); CleanupStack::Pop(); //image CleanupStack::PopAndDestroy();//iconFile DrawNow(); } - } - CleanupStack::PopAndDestroy(); // fs + } + CleanupStack::PopAndDestroy(); // fs } } @@ -1973,101 +1888,82 @@ // void CLmkEditorImpl::CategoriesCmdL() { - MLmkFieldData* categoryField = iLmkFields->GetField( ECategories ); - if ( !categoryField ) + MLmkFieldData* categoryField = iLmkFields->GetField(ECategories); + if (!categoryField) { - categoryField = iLmkFields->GetField( ECategory ); - if ( !categoryField ) + return; + } + RArray categories = categoryField->Categories(); + TInt count(categories.Count()); + + HBufC* catName; + // show the category list in a message query + HBufC* message = HBufC::NewLC((KPosLmMaxCategoryNameLength * count) + 1); + TPtr msgPtr = message->Des(); + CDesC16ArrayFlat* desArr = new (ELeave) CDesC16ArrayFlat(count); + CleanupStack::PushL(desArr); + // fill up the array with category´s names from the engine. + for (TInt i = 0; i < count; i++) + { + catName = CLmkDbUtils::CategoryNameL(iDb, categories[i]); + CleanupStack::PushL(catName); + desArr->AppendL(catName->Des()); + CleanupStack::PopAndDestroy(catName); //name + } + desArr->Sort(); + for (TInt i = 0; i < count; i++) + { + msgPtr.Append((*desArr)[i]); + if (i != (count - 1)) { - return; + msgPtr.Append(_L("\n")); } } - else - { - RArray categories = categoryField->Categories(); - TInt count( categories.Count() ); - - // Do not launch the popup for displaying one category name - if (count <=1 ) - { - //Launch context sensitive menu bar here - if ( iContextMenuBar ) - { - iContextMenuBar->TryDisplayMenuBarL(); - } - return; - } - - HBufC* catName; - // show the category list in a message query - HBufC* message = HBufC::NewLC( (KPosLmMaxCategoryNameLength * count) + 1); - TPtr msgPtr = message->Des(); - CDesC16ArrayFlat* desArr = new (ELeave) CDesC16ArrayFlat(count); - CleanupStack::PushL(desArr); - // fill up the array with category´s names from the engine. - for ( TInt i = 0; i < count; i++ ) - { - catName = CLmkDbUtils::CategoryNameL( iDb, categories[i] ); - CleanupStack::PushL( catName ); - desArr->AppendL(catName->Des()); - CleanupStack::PopAndDestroy( catName ); //name - } - desArr->Sort(); - for ( TInt i = 0; i < count; i++ ) - { - msgPtr.Append((*desArr)[i]); - if ( i != ( count - 1 ) ) - { - msgPtr.Append(_L("\n")); - } - } - LmkNotes::MessageQueryL( iEikonEnv, msgPtr, count ); - CleanupStack::Pop();//desArr - delete desArr; - CleanupStack::PopAndDestroy( message ); //message - } + LmkNotes::MessageQueryL(iEikonEnv, msgPtr, count); + CleanupStack::Pop();//desArr + delete desArr; + CleanupStack::PopAndDestroy(message); //message } // ----------------------------------------------------------------------------- // CLmkEditorImpl::SetCurrentLocationL // ----------------------------------------------------------------------------- // -void CLmkEditorImpl::SetCurrentLocationL( const TPosition& aPosition ) +void CLmkEditorImpl::SetCurrentLocationL(const TPosition& aPosition) { - MLmkFieldData* latitude = iLmkFields->GetField( ELatitude ); - if(latitude) - { - latitude->SetTReal( aPosition.Latitude() ); + MLmkFieldData* latitude = iLmkFields->GetField(ELatitude); + if (latitude) + { + latitude->SetTReal(aPosition.Latitude()); - MLmkFieldData* longitude = iLmkFields->GetField( ELongitude ); - if(longitude) - longitude->SetTReal( aPosition.Longitude() ); - } + MLmkFieldData* longitude = iLmkFields->GetField(ELongitude); + if (longitude) + longitude->SetTReal(aPosition.Longitude()); + } - MLmkFieldData* altitude = iLmkFields->GetField( EAltitude ); - if(altitude) - { - altitude->SetTReal( aPosition.Altitude() ); - } + MLmkFieldData* altitude = iLmkFields->GetField(EAltitude); + if (altitude) + { + altitude->SetTReal(aPosition.Altitude()); + } - MLmkFieldData* horizontalAccuracy = - iLmkFields->GetField( EPositionAccuracy ); - if(horizontalAccuracy) - { - horizontalAccuracy->SetTReal( aPosition.HorizontalAccuracy() ); - } + MLmkFieldData* horizontalAccuracy = iLmkFields->GetField( + EPositionAccuracy); + if (horizontalAccuracy) + { + horizontalAccuracy->SetTReal(aPosition.HorizontalAccuracy()); + } - MLmkFieldData* verticalAccuracy = - iLmkFields->GetField( EAltitudeAccuracy ); - if(verticalAccuracy) - { - verticalAccuracy->SetTReal( aPosition.VerticalAccuracy() ); - } - - TRAP_IGNORE(iLandmark->SetPositionL(aPosition)); - - iEditorFieldArray->UpdateFieldsL( EAllEditorItems ); - + MLmkFieldData* verticalAccuracy = iLmkFields->GetField(EAltitudeAccuracy); + if (verticalAccuracy) + { + verticalAccuracy->SetTReal(aPosition.VerticalAccuracy()); + } + + TRAP_IGNORE(iLandmark->SetPositionL(aPosition)); + + iEditorFieldArray->UpdateFieldsL(EAllEditorItems); + DrawNow(); } @@ -2077,36 +1973,35 @@ // void CLmkEditorImpl::ChangeContextImageL() { - MLmkFieldData* nameField = iLmkFields->GetField( EName ); - if( nameField ) + MLmkFieldData* nameField = iLmkFields->GetField(EName); + if (nameField) { - CEikImage* image = new(ELeave) CEikImage(); - CleanupStack::PushL( image ); + CEikImage* image = new (ELeave) CEikImage(); + CleanupStack::PushL(image); TFileName* defaultIconFile = CLmkUiUtils::LmkUiIconFileLC(); // No need to add iconFile to cleanupstack since it is a member variable from CLmkFieldData class HBufC *iconFile = nameField->IconPath(); TInt err = KErrNotFound; CFbsBitmap* bitmap; CFbsBitmap* mask; - if ( nameField->IconId() != KErrNotFound ) + if (nameField->IconId() != KErrNotFound) { TRAP(err,AknIconUtils::CreateIconL( bitmap, mask, - *iconFile, nameField->IconId(), - nameField->IconId()+1 );); + *iconFile, nameField->IconId(), + nameField->IconId()+1 );); } // If the Icon File doesn't exist the CreateIconL in the if statement above will // Leave with KErrNotFound in which case the default Icon should be loaded. // Also when the Landmarks itself doesn't have a valid Icon, the default Icon is // loaded. - if ( err != KErrNone ) + if (err != KErrNone) { - AknIconUtils::CreateIconL( bitmap, mask, - *defaultIconFile, KLmkDefaultId, - KLmkDefaultId+1 ); + AknIconUtils::CreateIconL(bitmap, mask, *defaultIconFile, + KLmkDefaultId, KLmkDefaultId + 1); } - image->SetBitmap( bitmap ); - image->SetMask( mask ); - iLmkUiUtils->SwapNewContextIconL( image ); + image->SetBitmap(bitmap); + image->SetMask(mask); + iLmkUiUtils->SwapNewContextIconL(image); CleanupStack::PopAndDestroy(); //defaultIconFile CleanupStack::Pop(); //image } @@ -2117,25 +2012,27 @@ // ---------------------------------------------------------------------------- // void CLmkEditorImpl::AttachAIWMenuInterestL() - { - if(iMapNavFeature) - { - iMapNavInterface->AttachAIWInterestL(R_LMK_EDITOR_MENU, R_LMK_EDITOR_AIW_INTEREST_SHOWONMAP); - if (iEditorMode != CLmkEditorDlg::ELmkEditor) - { - iMapNavInterface->AttachAIWInterestL(R_LMK_EDITOR_MENU, R_LMK_EDITOR_AIW_INTEREST_NAVIGATETO); - } - } - } + { + if (iMapNavFeature) + { + iMapNavInterface->AttachAIWInterestL(R_LMK_EDITOR_MENU, + R_LMK_EDITOR_AIW_INTEREST_SHOWONMAP); + if (iEditorMode != CLmkEditorDlg::ELmkEditor) + { + iMapNavInterface->AttachAIWInterestL(R_LMK_EDITOR_MENU, + R_LMK_EDITOR_AIW_INTEREST_NAVIGATETO); + } + } + } // ----------------------------------------------------------------------------- // CLmkEditorImpl::HandleResourceChange() // ----------------------------------------------------------------------------- // -void CLmkEditorImpl::HandleResourceChange (TInt aType) - { - CAknForm::HandleResourceChange(aType); - } +void CLmkEditorImpl::HandleResourceChange(TInt aType) + { + CAknForm::HandleResourceChange(aType); + } // ----------------------------------------------------------------------------- // CLmkEditorImpl::CategoriesCmdFromXmlL @@ -2144,32 +2041,33 @@ void CLmkEditorImpl::CategoriesCmdFromXmlL() { TInt count = iCategoryNames.Count(); - if ( count <= 1 ) + if (count <= 1) { return; } CDesC16ArrayFlat* desArr = new (ELeave) CDesC16ArrayFlat(count); CleanupStack::PushL(desArr); - // fill up the array with category´s names from the engine. - for ( TInt i = 0; i < count; i++ ) + // fill up the array with category´s names from the engine. + for (TInt i = 0; i < count; i++) { - desArr->AppendL(iCategoryNames[i]); - } + desArr->AppendL(iCategoryNames[i]); + } - desArr->Sort(); - // show the category list in a message query - HBufC* message = HBufC::NewLC((KPosLmMaxCategoryNameLength * iCategoryNames.Count()) + 1); - TPtr msgPtr = message->Des(); - for ( TInt i = 0; i < count; i++ ) - { + desArr->Sort(); + // show the category list in a message query + HBufC* message = HBufC::NewLC((KPosLmMaxCategoryNameLength + * iCategoryNames.Count()) + 1); + TPtr msgPtr = message->Des(); + for (TInt i = 0; i < count; i++) + { msgPtr.Append((*desArr)[i]); - if ( i != ( count - 1 )) - { - msgPtr.Append(_L("\n")); - } - } - LmkNotes::MessageQueryL( iEikonEnv, msgPtr, count ); - CleanupStack::PopAndDestroy( 2 ); //message ,desArr + if (i != (count - 1)) + { + msgPtr.Append(_L("\n")); + } + } + LmkNotes::MessageQueryL(iEikonEnv, msgPtr, count); + CleanupStack::PopAndDestroy(2); //message ,desArr } // ----------------------------------------------------------------------------- @@ -2178,432 +2076,409 @@ // void CLmkEditorImpl::ConstructContextMenuL() { - CEikMenuBar* newMenuBar = new(ELeave) CEikMenuBar(); - CleanupStack::PushL(newMenuBar); - newMenuBar->ConstructL(this, NULL, R_LMK_EDITOR_CONTEXT_MENUBAR); - iEikonEnv->EikAppUi()->AddToStackL(newMenuBar, ECoeStackPriorityMenu, ECoeStackFlagRefusesFocus); - iContextMenuBar = newMenuBar; - CleanupStack::Pop(newMenuBar); + CEikMenuBar* newMenuBar = new (ELeave) CEikMenuBar(); + CleanupStack::PushL(newMenuBar); + newMenuBar->ConstructL(this, NULL, R_LMK_EDITOR_CONTEXT_MENUBAR); + iEikonEnv->EikAppUi()->AddToStackL(newMenuBar, ECoeStackPriorityMenu, + ECoeStackFlagRefusesFocus); + iContextMenuBar = newMenuBar; + CleanupStack::Pop(newMenuBar); } // ----------------------------------------------------------------------------- // CLmkEditorImpl::GetFieldTextLengthL // ----------------------------------------------------------------------------- // -TInt CLmkEditorImpl::GetFieldTextLengthL( MLmkEditorField& afield) - { - HBufC* fieldText = afield.ControlTextL(); - TInt fieldLen (0); - if ( fieldText ) - { - if ( fieldText->Length() > 0) - {// Remove any blank spaces if any - TPtr16 ptr = fieldText->Des(); - ptr.Trim(); - fieldLen = ptr.Length(); - } - } - delete fieldText; - return fieldLen; - } +TInt CLmkEditorImpl::GetFieldTextLengthL(MLmkEditorField& afield) + { + HBufC* fieldText = afield.ControlTextL(); + TInt fieldLen(0); + if (fieldText) + { + if (fieldText->Length() > 0) + {// Remove any blank spaces if any + TPtr16 ptr = fieldText->Des(); + ptr.Trim(); + fieldLen = ptr.Length(); + } + } + delete fieldText; + return fieldLen; + } // ----------------------------------------------------------------------------- // CLmkEditorImpl::UpdateViewDlgL // ----------------------------------------------------------------------------- // void CLmkEditorImpl::UpdateViewDlgL() - { - - CPosLandmark* landmark; - TInt id = iLmkFields->LandmarkId(); - landmark = iDb.ReadLandmarkLC(id); - TLocality locality; - landmark->GetPosition(locality); + { + DEBUG( CLmkEditorImpl::UpdateViewDlgL start ) + CPosLandmark* landmark; + TInt id = iLmkFields->LandmarkId(); + landmark = iDb.ReadLandmarkLC(id); + TLocality locality; + landmark->GetPosition(locality); TRAP_IGNORE(iLandmark->SetPositionL(locality)); - CArrayPtrFlat& fieldArray = iLmkFields->Fields(); - CArrayPtrFlat& editorFieldArray = - iEditorFieldArray->GetFieldArray(); - TInt count = fieldArray.Count(); - TInt postn = KErrNotFound; - TInt ctrlid = KErrNotFound; - for (TInt i(0);iFieldType(); - MLmkEditorField* fld = iEditorFieldArray->Find(fieldArray[i]->UniqueFieldIdentity(),&postn,&ctrlid); + CArrayPtrFlat& fieldArray = iLmkFields->Fields(); + CArrayPtrFlat& editorFieldArray = + iEditorFieldArray->GetFieldArray(); + TInt count = fieldArray.Count(); + TInt postn = KErrNotFound; + TInt ctrlid = KErrNotFound; + for (TInt i(0); i < count; i++) + { + TUint fieldType = fieldArray[i]->FieldType(); + MLmkEditorField* fld = iEditorFieldArray->Find( + fieldArray[i]->UniqueFieldIdentity(), &postn, &ctrlid); - switch(fieldType) - { - case EName: - { - UpdateNameEditorControlL(fld,landmark,fieldArray[i]); - break; - } - case ECategory: - case ECategories: - { - UpdateCategoryEditorControlL( fld, fieldArray[i],ctrlid,postn,*landmark); - break; - } - case EDescription: - { - UpdateDesEditorControlL(fld,landmark,fieldArray[i],ctrlid,postn); - break; - } - //these all are same - case EStreet: - case EPostCode: - case ECity: - case EStateProvince: - case ECountry: - case EPhoneNumber: - case EWebAddress: - { - UpdateTextEditorControlL(fld,landmark,fieldArray[i], - fieldType,ctrlid,postn); - break; - } - case ELatitude: - { - UpdateCoordinateEditorControlL(fld,fieldArray[i], - locality.Latitude(), - ctrlid,postn); - break; - } - case ELongitude: - { - UpdateCoordinateEditorControlL(fld,fieldArray[i], - locality.Longitude(), - ctrlid,postn); - break; - } - case EPositionAccuracy: - { - UpdateNumberEditorControlL(fld,fieldArray[i], - locality.HorizontalAccuracy(),ctrlid,postn); - break; - } - case EAltitude: - { - UpdateNumberEditorControlL(fld,fieldArray[i], - locality.Altitude(),ctrlid,postn); - break; - } - case EAltitudeAccuracy: - { - UpdateNumberEditorControlL(fld,fieldArray[i], - locality.VerticalAccuracy(),ctrlid,postn); - break; - } - default: - { - break; - } - } - } - iEditorFieldArray->UpdateFieldsL(); - CleanupStack::PopAndDestroy( landmark ); - DrawNow(); - if(!IsEditable()) - { - //only for landmarks viewer - UpdateMskOnArrowMoveForViewerL(); - //ShowMultipleCategoriesInfoPopupL(ETrue); - } - } + switch (fieldType) + { + case EName: + { + UpdateNameEditorControlL(fld, landmark, fieldArray[i]); + break; + } + case ECategory: + case ECategories: + { + UpdateCategoryEditorControlL(fld, fieldArray[i], ctrlid, + postn, *landmark); + break; + } + case EDescription: + { + UpdateDesEditorControlL(fld, landmark, fieldArray[i], ctrlid, + postn); + break; + } + //these all are same + case EStreet: + case EPostCode: + case ECity: + case EStateProvince: + case ECountry: + case EPhoneNumber: + case EWebAddress: + { + UpdateTextEditorControlL(fld, landmark, fieldArray[i], + fieldType, ctrlid, postn); + break; + } + case ELatitude: + { + UpdateCoordinateEditorControlL(fld, fieldArray[i], + locality.Latitude(), ctrlid, postn); + break; + } + case ELongitude: + { + UpdateCoordinateEditorControlL(fld, fieldArray[i], + locality.Longitude(), ctrlid, postn); + break; + } + case EPositionAccuracy: + { + UpdateNumberEditorControlL(fld, fieldArray[i], + locality.HorizontalAccuracy(), ctrlid, postn); + break; + } + case EAltitude: + { + UpdateNumberEditorControlL(fld, fieldArray[i], + locality.Altitude(), ctrlid, postn); + break; + } + case EAltitudeAccuracy: + { + UpdateNumberEditorControlL(fld, fieldArray[i], + locality.VerticalAccuracy(), ctrlid, postn); + break; + } + default: + { + break; + } + } + } + iEditorFieldArray->UpdateFieldsL(); + CleanupStack::PopAndDestroy(landmark); + DrawNow(); + if (!IsEditable()) + { + //only for landmarks viewer + UpdateMskOnArrowMoveForViewerL(); + } + DEBUG( CLmkEditorImpl::UpdateViewDlgL End ) + } + // ----------------------------------------------------------------------------- // CLmkEditorImpl::ActivateL // ----------------------------------------------------------------------------- // void CLmkEditorImpl::ActivateL() - { - if (iEditorMode == CLmkEditorDlg::ELmkEditor - && iIsEditing) - { - MLmkFieldData* fields = iLmkFields->GetField(iFieldTypeToFocus); - if(fields) - { - TInt id = fields->UniqueFieldIdentity(); - TryChangeFocusL(id); - if (iFieldTypeToFocus == ECategories || iFieldTypeToFocus == ECategory) - { - // ShowMultipleCategoriesInfoPopupL(EFalse); - } - } - } - CCoeControl::ActivateL(); - } + { + if (iEditorMode == CLmkEditorDlg::ELmkEditor && iIsEditing) + { + MLmkFieldData* fields = iLmkFields->GetField(iFieldTypeToFocus); + if (fields) + { + TInt id = fields->UniqueFieldIdentity(); + TryChangeFocusL(id); + } + } + CCoeControl::ActivateL(); + } + // ----------------------------------------------------------------------------- // CLmkEditorImpl::UpdateTextEditorControlL // ----------------------------------------------------------------------------- // -void CLmkEditorImpl::UpdateTextEditorControlL - (MLmkEditorField* aEditorField, - CPosLandmark* aLandmark, - MLmkFieldData* fieldData, - TUint aFiledType, - TInt aPrevControlId, - TInt aPos - ) - { +void CLmkEditorImpl::UpdateTextEditorControlL(MLmkEditorField* aEditorField, + CPosLandmark* aLandmark, MLmkFieldData* fieldData, TUint aFiledType, + TInt aPrevControlId, TInt aPos) + { + TPositionFieldId fieldId = EPositionFieldNone; + switch (aFiledType) + { + case EStreet: + fieldId = EPositionFieldStreet; + break; + case EPostCode: + fieldId = EPositionFieldPostalCode; + break; + case ECity: + fieldId = EPositionFieldCity; + break; + case EStateProvince: + fieldId = EPositionFieldState; + break; + case ECountry: + fieldId = EPositionFieldCountry; + break; + case EPhoneNumber: + fieldId = ELmkPositionFieldPhoneNumber; + break; + case EWebAddress: + fieldId = ELmkPositionFieldWebAddress; + break; + } + TPtrC text; + if (aLandmark->GetPositionField(fieldId, text) == KErrNone) + { + if (IsEditable() && text.Length() == 0 && aFiledType == EWebAddress) + { + //return if web address field and field is empty and its an editor + return; + } + fieldData->SetTextL(text); + if (!IsEditable()) + { + aEditorField = AddOrDeleteLineL(aEditorField, fieldData, + aPrevControlId, fieldData->UniqueFieldIdentity(), aPos); + } + if (aEditorField) + { + //now modify the text for display + CLmkEditorTextField* field = + static_cast (aEditorField); + HBufC* buff = HBufC::NewLC(text.Length()); + TPtr dispTxt = buff->Des(); + if (!IsEditable()) + { + TPtr des1 = CLmkFields::RemoveEnterCharacter(text); + dispTxt.Copy(des1); + } + else + { + dispTxt.Copy(text); + } + if (aFiledType == EWebAddress) + { + TInt position; + if ((position = field->IsWebUrlProtocolPreFixedL(dispTxt)) + != KErrNotFound) + { + field->TrimPrefixesFromWebUrlL(dispTxt, position + 1); + } + } + TPtrC ptr; + ptr.Set(dispTxt); + field->SetControlTextL(ptr); + CleanupStack::PopAndDestroy(buff); + } + } + } - TPositionFieldId fieldId = EPositionFieldNone; - switch(aFiledType) - { - case EStreet: - fieldId = EPositionFieldStreet; - break; - case EPostCode: - fieldId = EPositionFieldPostalCode ; - break; - case ECity: - fieldId = EPositionFieldCity; - break; - case EStateProvince: - fieldId = EPositionFieldState; - break; - case ECountry: - fieldId = EPositionFieldCountry; - break; - case EPhoneNumber: - fieldId = ELmkPositionFieldPhoneNumber; - break; - case EWebAddress: - fieldId = ELmkPositionFieldWebAddress; - break; - } - TPtrC text; - if ( aLandmark->GetPositionField( - fieldId, text ) == KErrNone ) - { - if (IsEditable() && text.Length() == 0 && aFiledType == EWebAddress) - { - //return if web address field and field is empty and its an editor - return; - } - fieldData->SetTextL(text); - if(!IsEditable()) - { - aEditorField = AddOrDeleteLineL( aEditorField,fieldData,aPrevControlId, - fieldData->UniqueFieldIdentity(), aPos); - } - if(aEditorField) - { - //now modify the text for display - CLmkEditorTextField* field = static_cast(aEditorField); - HBufC* buff = HBufC::NewLC(text.Length()); - TPtr dispTxt = buff->Des(); - if(!IsEditable()) - { - TPtr des1 = CLmkFields::RemoveEnterCharacter( text ); - dispTxt.Copy(des1); - } - else - { - dispTxt.Copy(text); - } - if(aFiledType == EWebAddress) - { - TInt position; - if((position = field->IsWebUrlProtocolPreFixedL(dispTxt))!= - KErrNotFound) - { - field->TrimPrefixesFromWebUrlL( dispTxt, position +1 ); - } - } - TPtrC ptr; - ptr.Set(dispTxt); - field->SetControlTextL(ptr); - CleanupStack::PopAndDestroy( buff ); - } - - } - } // ----------------------------------------------------------------------------- // CLmkEditorImpl::UpdateDesEditorControlL // ----------------------------------------------------------------------------- // -void CLmkEditorImpl::UpdateDesEditorControlL - (MLmkEditorField* aEditorField, - CPosLandmark* aLandmark, - MLmkFieldData* fieldData, - TInt aPrevControlId, - TInt aPos - ) - { - TPtrC text; - aLandmark->GetLandmarkDescription(text); - fieldData->SetTextL(text); - TPtrC dispTxt; - if(!IsEditable()) - { - TPtr des1 = CLmkFields::RemoveEnterCharacter( text ); - dispTxt.Set(des1); - aEditorField = AddOrDeleteLineL( aEditorField,fieldData,aPrevControlId, - fieldData->UniqueFieldIdentity(), aPos); - } - else - { - dispTxt.Set(text); - } - CLmkEditorTextField* field = static_cast(aEditorField); - if(aEditorField) - { - field->Control()->SetTextL(&dispTxt); - field->Control()->DrawDeferred(); - } - } +void CLmkEditorImpl::UpdateDesEditorControlL(MLmkEditorField* aEditorField, + CPosLandmark* aLandmark, MLmkFieldData* fieldData, + TInt aPrevControlId, TInt aPos) + { + TPtrC text; + aLandmark->GetLandmarkDescription(text); + fieldData->SetTextL(text); + TPtrC dispTxt; + if (!IsEditable()) + { + TPtr des1 = CLmkFields::RemoveEnterCharacter(text); + dispTxt.Set(des1); + aEditorField = AddOrDeleteLineL(aEditorField, fieldData, + aPrevControlId, fieldData->UniqueFieldIdentity(), aPos); + } + else + { + dispTxt.Set(text); + } + CLmkEditorTextField* field = + static_cast (aEditorField); + if (aEditorField) + { + field->Control()->SetTextL(&dispTxt); + field->Control()->DrawDeferred(); + } + } + // ----------------------------------------------------------------------------- // CLmkEditorImpl::UpdateCategoryEditorControlL // ----------------------------------------------------------------------------- // -void CLmkEditorImpl::UpdateCategoryEditorControlL - ( - MLmkEditorField* aEditorField, - MLmkFieldData* fieldData, - TInt aPrevControlId, - TInt aPos, - CPosLandmark& aLandmark - ) - { - RArray& categories = fieldData->Categories(); +void CLmkEditorImpl::UpdateCategoryEditorControlL( + MLmkEditorField* aEditorField, MLmkFieldData* fieldData, + TInt aPrevControlId, TInt aPos, CPosLandmark& aLandmark) + { + RArray& categories = fieldData->Categories(); aLandmark.GetCategoriesL(categories); - TInt count( categories.Count() ); + TInt count(categories.Count()); - if ( count <= 1 ) + if (count <= 1) { - fieldData->SetFieldType( ECategory ); + fieldData->SetFieldType(ECategory); } else { - fieldData->SetFieldType( ECategories ); + fieldData->SetFieldType(ECategories); } - if(!IsEditable()) - { - aEditorField = AddOrDeleteLineL( aEditorField,fieldData,aPrevControlId, - fieldData->UniqueFieldIdentity(), aPos); - } - } + if (!IsEditable()) + { + aEditorField = AddOrDeleteLineL(aEditorField, fieldData, + aPrevControlId, fieldData->UniqueFieldIdentity(), aPos); + } + } + // ----------------------------------------------------------------------------- // CLmkEditorImpl::UpdateCoordinateEditorControlL // ----------------------------------------------------------------------------- // -void CLmkEditorImpl::UpdateCoordinateEditorControlL - ( - MLmkEditorField* aEditorField, - MLmkFieldData* fieldData, - TReal aValue, - TInt aPrevControlId, - TInt aPos - ) - { - fieldData->SetTReal( aValue ); - if(!IsEditable()) - { - aEditorField = AddOrDeleteLineL( aEditorField,fieldData,aPrevControlId, - fieldData->UniqueFieldIdentity(), aPos); - } - } +void CLmkEditorImpl::UpdateCoordinateEditorControlL( + MLmkEditorField* aEditorField, MLmkFieldData* fieldData, + TReal aValue, TInt aPrevControlId, TInt aPos) + { + fieldData->SetTReal(aValue); + if (!IsEditable()) + { + aEditorField = AddOrDeleteLineL(aEditorField, fieldData, + aPrevControlId, fieldData->UniqueFieldIdentity(), aPos); + } + } + // ----------------------------------------------------------------------------- // CLmkEditorImpl::UpdateNumberEditorControlL // ----------------------------------------------------------------------------- // -void CLmkEditorImpl::UpdateNumberEditorControlL - ( - MLmkEditorField* aEditorField, - MLmkFieldData* fieldData, - TReal32 aValue, - TInt aPrevControlId, - TInt aPos - ) - { - fieldData->SetTReal( aValue ); +void CLmkEditorImpl::UpdateNumberEditorControlL( + MLmkEditorField* aEditorField, MLmkFieldData* fieldData, + TReal32 aValue, TInt aPrevControlId, TInt aPos) + { + fieldData->SetTReal(aValue); - if(!IsEditable()) - { - aEditorField = AddOrDeleteLineL( aEditorField,fieldData,aPrevControlId, - fieldData->UniqueFieldIdentity(), aPos); - } - } + if (!IsEditable()) + { + aEditorField = AddOrDeleteLineL(aEditorField, fieldData, + aPrevControlId, fieldData->UniqueFieldIdentity(), aPos); + } + } // ----------------------------------------------------------------------------- // CLmkEditorImpl::UpdateNameEditorControl // ----------------------------------------------------------------------------- // -void CLmkEditorImpl::UpdateNameEditorControlL - ( - MLmkEditorField* aEditorField, - CPosLandmark* aLandmark, - MLmkFieldData* fieldData - ) - { - - if( aEditorField && aLandmark && fieldData ) - { - //name field icon updation - TInt iconIden = -1; - TInt iconMaskIndex = -1; - TPtrC iconFile; - CLmkEditorTextField* field = static_cast(aEditorField); - if( aLandmark->GetIcon( iconFile, iconIden, iconMaskIndex ) && field ) - { - if( iconIden > 0 ) - { - fieldData->SetIconId( iconIden ); - fieldData->SetIconPathL( iconFile ); - CEikImage* image = new( ELeave ) CEikImage(); - CleanupStack::PushL( image ); - image->CreatePictureFromFileL( iconFile, - iconIden, iconMaskIndex ); - iLmkUiUtils->UpdateContextIconL( image ); - CLmkUiUtils::ChangeLmNameLabelIconL ( *this, *fieldData ); - CleanupStack::Pop(); //image - field->CaptionedControl()->DrawDeferred(); - } - //text control updation - TPtrC text; - aLandmark->GetLandmarkName( text ); - TPtrC dispTxt; - if( !IsEditable() ) - { - TPtr des1 = CLmkFields::RemoveEnterCharacter( text ); - dispTxt.Set(des1); - } - else - { - dispTxt.Set(text); - } - field->Control()->SetTextL( &dispTxt ); - fieldData->SetTextL( text ); - HBufC* buff = dispTxt.AllocL(); - iLmkUiUtils->ChangeTitlePaneL( buff ); - field->Control()->DrawDeferred(); - } - } - } +void CLmkEditorImpl::UpdateNameEditorControlL(MLmkEditorField* aEditorField, + CPosLandmark* aLandmark, MLmkFieldData* fieldData) + { + if (aEditorField && aLandmark && fieldData) + { + //name field icon updation + TInt iconIden = -1; + TInt iconMaskIndex = -1; + TPtrC iconFile; + CLmkEditorTextField* field = + static_cast (aEditorField); + if (aLandmark->GetIcon(iconFile, iconIden, iconMaskIndex) && field) + { + if (iconIden > 0) + { + fieldData->SetIconId(iconIden); + fieldData->SetIconPathL(iconFile); + CEikImage* image = new (ELeave) CEikImage(); + CleanupStack::PushL(image); + image->CreatePictureFromFileL(iconFile, iconIden, + iconMaskIndex); + iLmkUiUtils->UpdateContextIconL(image); + CLmkUiUtils::ChangeLmNameLabelIconL(*this, *fieldData); + CleanupStack::Pop(); //image + field->CaptionedControl()->DrawDeferred(); + } + //text control updation + TPtrC text; + aLandmark->GetLandmarkName(text); + TPtrC dispTxt; + if (!IsEditable()) + { + TPtr des1 = CLmkFields::RemoveEnterCharacter(text); + dispTxt.Set(des1); + } + else + { + dispTxt.Set(text); + } + field->Control()->SetTextL(&dispTxt); + fieldData->SetTextL(text); + HBufC* buff = dispTxt.AllocL(); + iLmkUiUtils->ChangeTitlePaneL(buff); + field->Control()->DrawDeferred(); + } + } + } // ----------------------------------------------------------------------------- // CLmkEditorImpl::SetFieldTypeToFocusInEditMode // ----------------------------------------------------------------------------- // void CLmkEditorImpl::SetFieldTypeToFocusInEditMode(TUint aFieldType) - { - iFieldTypeToFocus = aFieldType; - } + { + iFieldTypeToFocus = aFieldType; + } + // ----------------------------------------------------------------------------- // CLmkEditorImpl::IsDlgEditing // ----------------------------------------------------------------------------- // TBool CLmkEditorImpl::IsDlgEditing() - { - return iIsEditing; - } + { + return iIsEditing; + } + // ----------------------------------------------------------------------------- // CLmkEditorImpl::SetDlgEditing // ----------------------------------------------------------------------------- // -void CLmkEditorImpl::SetDlgEditing(TBool aEditing) - { - iIsEditing = aEditing; - } +void CLmkEditorImpl::SetDlgEditing(TBool aEditing) + { + iIsEditing = aEditing; + } + // ----------------------------------------------------------------------------- // CLmkEditorImpl::SetDlgEditing // ----------------------------------------------------------------------------- @@ -2612,454 +2487,224 @@ { return iEditorMode; } + // ----------------------------------------------------------------------------- // CLmkEditorImpl::UpdateMskOnArrowMoveForViewerL // ----------------------------------------------------------------------------- // void CLmkEditorImpl::UpdateMskOnArrowMoveForViewerL() - { - TBool cmdAdded = EFalse; - MLmkEditorField* field = - iEditorFieldArray->Find( IdOfFocusControl() ); - TUint type = field->LandmarkItemField().FieldType(); - switch(type) - { - case ECategories: - { - AddMskCommandL(R_LM_MSK_SHOW,ELmkCmdShow); - cmdAdded = ETrue; - break; - } - case EPhoneNumber: - { - HBufC* fieldText = field->ControlTextL(); - CleanupStack::PushL( fieldText ); - if ( fieldText && fieldText->Length() > 0 ) - { - AddMskCommandL(R_LM_MSK_CALL,ELmkCmdLast); - cmdAdded = ETrue; - } - CleanupStack::PopAndDestroy( fieldText ); - break; - } - case EWebAddress: - { - HBufC* fieldText = field->ControlTextL(); - CleanupStack::PushL( fieldText ); - if ( fieldText && fieldText->Length() > 0 ) - { - AddMskCommandL(R_LM_MSK_BROWSE,ELmkCmdGoToUrl); - cmdAdded = ETrue; - } - CleanupStack::PopAndDestroy( fieldText ); - break; - } - default: - { - //nothing - break; - } - } - if (!cmdAdded) - { - AddMskCommandL(R_LM_MSK_EDIT,ELmkCmdEditLm); - } - } + { + TBool cmdAdded = EFalse; + MLmkEditorField* field = iEditorFieldArray->Find(IdOfFocusControl()); + TUint type = field->LandmarkItemField().FieldType(); + switch (type) + { + case ECategories: + { + AddMskCommandL(R_LM_MSK_SHOW, ELmkCmdShow); + cmdAdded = ETrue; + break; + } + case EPhoneNumber: + { + HBufC* fieldText = field->ControlTextL(); + CleanupStack::PushL(fieldText); + if (fieldText && fieldText->Length() > 0) + { + AddMskCommandL(R_LM_MSK_CALL, ELmkCmdLast); + cmdAdded = ETrue; + } + CleanupStack::PopAndDestroy(fieldText); + break; + } + case EWebAddress: + { + HBufC* fieldText = field->ControlTextL(); + CleanupStack::PushL(fieldText); + if (fieldText && fieldText->Length() > 0) + { + AddMskCommandL(R_LM_MSK_BROWSE, ELmkCmdGoToUrl); + cmdAdded = ETrue; + } + CleanupStack::PopAndDestroy(fieldText); + break; + } + default: + { + //nothing + break; + } + } + if (!cmdAdded) + { + AddMskCommandL(R_LM_MSK_EDIT, ELmkCmdEditLm); + } + } // ----------------------------------------------------------------------------- // CLmkEditorImpl::AddMskCommandL // ----------------------------------------------------------------------------- // -void CLmkEditorImpl::AddMskCommandL(TInt aResourceId, - TLmkAppCmdId aCommandId) - { +void CLmkEditorImpl::AddMskCommandL(TInt aResourceId, TLmkAppCmdId aCommandId) + { + HBufC* mskTxt = NULL; + mskTxt = StringLoader::LoadLC(aResourceId, iEikonEnv); + CEikButtonGroupContainer* cba = CEikButtonGroupContainer::Current(); + cba->RemoveCommandFromStack(KMskCommandPos, iMskCmdId); + iMskCmdId = aCommandId; + iCurrentResourceId = aResourceId; + cba->AddCommandToStackL(KMskCommandPos, iMskCmdId, mskTxt->Des()); + cba->MakeCommandVisible(iMskCmdId, ETrue); + CleanupStack::PopAndDestroy(mskTxt); + } - HBufC* mskTxt = NULL; - mskTxt = StringLoader::LoadLC( aResourceId, iEikonEnv ); - CEikButtonGroupContainer* cba = CEikButtonGroupContainer::Current(); - cba->RemoveCommandFromStack(KMskCommandPos,iMskCmdId); - iMskCmdId = aCommandId; - iCurrentResourceId = aResourceId; - cba->AddCommandToStackL(KMskCommandPos,iMskCmdId,mskTxt->Des()); - cba->MakeCommandVisible(iMskCmdId,ETrue); - CleanupStack::PopAndDestroy( mskTxt ); - } // ----------------------------------------------------------------------------- // CLmkEditorImpl::AddMskCommandL // ----------------------------------------------------------------------------- // void CLmkEditorImpl::DimmMiddleSoftKey() - { - /*This is required, since there was an error, - where the menu item appears if there are not items - in the lis, after pressing the middle key.Hence, if - dummy msk is added to the resource, it fixes the error, - now this dummy button needs to be disabled.Check the - dialog resource in editor.rss*/ - CEikButtonGroupContainer* cba = CEikButtonGroupContainer::Current(); - cba->MakeCommandVisible(EAknSoftkeyContextOptions,EFalse); - } - - -// ----------------------------------------------------------------------------- -// CLmkEditorImpl::ShowMultipleCategoriesInfoPopupL -// ----------------------------------------------------------------------------- -// - /*void CLmkEditorImpl::ShowMultipleCategoriesInfoPopupL(TBool aRefresh) { - if (iCatInfoPopupNote && aRefresh) - { - delete iCatInfoPopupNote; - iCatInfoPopupNote = NULL; - } - - if (!iCatInfoPopupNote) - { - - if(!IsCategoryField()) - { - return; - } - MLmkFieldData* categoryField = iLmkFields->GetField( ECategories ); - if ( !categoryField ) - { - categoryField = iLmkFields->GetField( ECategory ); - if ( !categoryField ) - { - return; - } - } - RArray categories = categoryField->Categories(); - - // This function is also called from message viewer, where the - // landmarks object is populated from xml file instead of db, - // hence the category id's will be dummy and must not be used, - // to get the category name, instead, get the category names - // from the xml file (iCategoryNames). - - TInt count( categories.Count() ); - TBool isNotFromMessageViewer(EFalse); - count = iCategoryNames.Count(); - if ( count == 0 ) // hack to determine from where the call coming. - { - //not called from message viewer - isNotFromMessageViewer = ETrue; - count = categories.Count(); - } - // Do not launch the popup for displaying one category name - if (count <=1 ) - { - return; - } - - // ==================================================================== - // Get Font for Formatting the infoPopUp strings - // ==================================================================== - - // Get parameter and table limits for popup preview text window - TAknLayoutScalableParameterLimits limits = - AknLayoutScalable_Avkon::popup_preview_text_window_ParamLimits(); - - TAknLayoutScalableTableLimits tableLimits = - AknLayoutScalable_Avkon::popup_preview_text_window_t_Limits(); - - // Get layout rects - TRect rectScreen = iAvkonAppUi->ApplicationRect(); - TInt mainPaneVariety = Layout_Meta_Data::IsLandscapeOrientation() ? 4 : 1; - - TAknWindowLineLayout lineLayout = - AknLayoutScalable_Avkon::main_pane( mainPaneVariety ).LayoutLine(); - TAknLayoutRect layoutRect; - layoutRect.LayoutRect(rectScreen, lineLayout); - TRect rectMainPane = layoutRect.Rect(); - - // Use first variety to be able to get the font for text parsing - TInt index = 0; - if ( Layout_Meta_Data::IsLandscapeOrientation() ) - { - index += 5; - } - TInt firstVariety = Min( Max( index, limits.FirstVariety() ), limits.LastVariety() ); - - TAknWindowLineLayout lineLayout2 = - AknLayoutScalable_Avkon::main_pane( mainPaneVariety ).LayoutLine(); - TAknLayoutRect layoutRect2; - layoutRect2.LayoutRect(rectScreen, lineLayout2); - TRect rectPopupWindow = layoutRect2.Rect(); - - TInt firstIndex = tableLimits.FirstIndex(); - TInt firstLineVariety = AknLayoutScalable_Avkon:: - popup_preview_text_window_t_ParamLimits( firstIndex ).FirstVariety(); - - TAknTextLineLayout popupTextLayout = - AknLayoutScalable_Avkon::popup_preview_text_window_t( - firstIndex, firstLineVariety ); - - TAknLayoutText layoutText; - layoutText.LayoutText( rectPopupWindow, popupTextLayout ); - TRect rectText = layoutText.TextRect(); - - TInt infoPopupWidth = KMaxCatSizeForInfoPopUp; - TInt infoPopupLength = KMinCatLenForInfoPopUp; - - if(rectText.Height() > 25) - { - infoPopupWidth = KMaxCatSizeForInfoPopUp + 80; - } - else if(rectText.Height() > 23) - { - infoPopupWidth = KMaxCatSizeForInfoPopUp + 55; - } - else if(rectText.Height() > 16) - { - infoPopupWidth = KMaxCatSizeForInfoPopUp + 10; - infoPopupLength++; - } - - // Prepare font to format the popupInfo string - const CFont *font = layoutText.Font(); - - // =================================================================== - // =================================================================== - - HBufC* catName = NULL; - // show the category list in a message query - HBufC* message = HBufC::NewLC( (KPosLmMaxCategoryNameLength * count) + 1); - TPtr msgPtr = message->Des(); - CDesC16ArrayFlat* desArr = new (ELeave) CDesC16ArrayFlat(count); - CleanupStack::PushL(desArr); - // fill up the array with category´s names from the engine. - for ( TInt i = 0; i < count; i++ ) - { - if ( !isNotFromMessageViewer ) - { - catName = HBufC::NewL( KPosLmMaxCategoryNameLength + 1); - catName->Des().Copy(iCategoryNames[i]); - } - else - { - catName = CLmkDbUtils::CategoryNameL( iDb, categories[i] ); - } - CleanupStack::PushL( catName ); - - TPtr des = catName->Des(); - - TInt textWidth = font->TextWidthInPixels( des ); - TInt textLength = des.Length(); - - // check the length of category name string to format for InfoPopUp. - if(textLength > infoPopupLength && textWidth > infoPopupWidth) - { - - // set the string as per KMinCatLenForInfoPopUp - if(textLength > infoPopupLength + 9) - { - textLength = infoPopupLength + 9; - des = des.Mid(0, textLength); - } - - textWidth = font->TextWidthInPixels( des ); - - for(TInt ctr=textLength; ctr >= (infoPopupLength-1);ctr--) - { - des = des.Mid(0, ctr); - textWidth = font->TextWidthInPixels( des ); - if(textWidth <= infoPopupWidth) - { - break; - } - } - - // loading the "..." string - HBufC* endString = StringLoader::LoadLC(R_LM_EDITOR_MANY_CATEGORIES); - - // appending the "..." string at end - des.Append(endString->Des()); - - // appendig formatted string into category string array - desArr->AppendL(des); - CleanupStack::PopAndDestroy(endString); // endString - } - else - { - desArr->AppendL(des); - } - CleanupStack::PopAndDestroy( catName ); //name - } - desArr->Sort(); - HBufC* catTxt = NULL; - - for ( TInt i = 0; i < desArr->Count(); i++ ) - { - if (i KMaxCatCntForInfoPopUp) - { - - catTxt = StringLoader::LoadLC( R_LM_EDITOR_MANY_CATEGORIES, iEikonEnv ); - msgPtr.Append(catTxt->Des()); - CleanupStack::PopAndDestroy(catTxt );//catTxt - } - TPoint pt1; - iCatInfoPopupNote = LmkNotes::ShowDelayedInfoPopupL(msgPtr,pt1); - UpdateCatInfoNotePosition(); - iCatInfoPopupNote->ShowInfoPopupNote(); - CleanupStack::Pop();//desArr - delete desArr; - CleanupStack::PopAndDestroy( message ); //message - } - else - { - UpdateCatInfoNotePosition(); - iCatInfoPopupNote->ShowInfoPopupNote(); - } + /*This is required, since there was an error, + where the menu item appears if there are not items + in the lis, after pressing the middle key.Hence, if + dummy msk is added to the resource, it fixes the error, + now this dummy button needs to be disabled.Check the + dialog resource in editor.rss*/ + CEikButtonGroupContainer* cba = CEikButtonGroupContainer::Current(); + cba->MakeCommandVisible(EAknSoftkeyContextOptions, EFalse); } -*/ // ----------------------------------------------------------------------------- // CLmkEditorImpl::ShowQueryIfLocationFieldsAlreadyFilledL // ----------------------------------------------------------------------------- // TBool CLmkEditorImpl::ShowQueryIfLocationFieldsAlreadyFilledL() - { - TBool result = EFalse; + { + TBool result = EFalse; TRealX lati; lati.SetNaN(); TRealX longi; longi.SetNaN(); MLmkFieldData* lat = iLmkFields->GetField(ELatitude); - if(lat) - { + if (lat) + { //get latitude control id TInt id = lat->UniqueFieldIdentity(); - MLmkEditorField* latcontrol = iEditorFieldArray->Find( id ); + MLmkEditorField* latcontrol = iEditorFieldArray->Find(id); //get latitude control current text lati = static_cast(latcontrol)->FieldValue(); MLmkFieldData* lon = iLmkFields->GetField(ELongitude); - if(lon) + if (lon) { //get longitude control id id = lon->UniqueFieldIdentity(); - MLmkEditorField* longcontrol = iEditorFieldArray->Find( id ); + MLmkEditorField* longcontrol = iEditorFieldArray->Find(id); //get longitude control current text longi = static_cast(longcontrol)->FieldValue(); } if ( (!lati.IsNaN()) && (!longi.IsNaN())) { - if ( !LmkNotes::ShowOwerriteLocationQueryL( iEikonEnv ) ) + if (!LmkNotes::ShowOwerriteLocationQueryL(iEikonEnv)) { result = ETrue; } } - } - return result; - } + } + return result; + } // ----------------------------------------------------------------------------- // CLmkEditorImpl::IsInvalidUriL // ----------------------------------------------------------------------------- // TBool CLmkEditorImpl::IsInvalidUriL() - { - TBool ret = EFalse; - MLmkFieldData* fields = iLmkFields->GetField( EWebAddress ); - if(fields) - { - MLmkEditorField* fld = iEditorFieldArray->Find(fields->UniqueFieldIdentity()); - if(fld) - { - HBufC* webaddr = HBufC::NewLC(KMaxBufferLen); - CLmkEditorTextField* field = static_cast(fld); - TPtr ptr = webaddr->Des(); - field->Control()->GetText(ptr); - ret = UriUtils::HasInvalidChars(ptr); - CleanupStack::PopAndDestroy();//webaddr - } - } - return ret; - } + { + TBool ret = EFalse; + MLmkFieldData* fields = iLmkFields->GetField(EWebAddress); + if (fields) + { + MLmkEditorField* fld = iEditorFieldArray->Find( + fields->UniqueFieldIdentity()); + if (fld) + { + HBufC* webaddr = HBufC::NewLC(KMaxBufferLen); + CLmkEditorTextField* field = + static_cast (fld); + TPtr ptr = webaddr->Des(); + field->Control()->GetText(ptr); + ret = UriUtils::HasInvalidChars(ptr); + CleanupStack::PopAndDestroy();//webaddr + } + } + return ret; + } // ----------------------------------------------------------------------------- // CLmkEditorImpl::HandleListProviderEvent // ----------------------------------------------------------------------------- // -void CLmkEditorImpl::HandleListProviderEvent(TLmkListProviderEventType /*aEvent*/ ) - { - TRAPD(err,CPosLandmark* landmark = iDb.ReadLandmarkLC(iLmkFields->LandmarkId());CleanupStack::PopAndDestroy( landmark )); +void CLmkEditorImpl::HandleListProviderEvent(TLmkListProviderEventType /*aEvent*/) + { + TRAPD(err,CPosLandmark* landmark = iDb.ReadLandmarkLC(iLmkFields->LandmarkId());CleanupStack::PopAndDestroy( landmark )); if (err == KErrNotFound) { TRAP_IGNORE(DeleteSelfL()); } - else - { - //update the landmark viewer/editor - TRAP_IGNORE(UpdateViewDlgL()); - } - } + else + { + //update the landmark viewer/editor + TRAP_IGNORE(UpdateViewDlgL()); + } + } // ----------------------------------------------------------------------------- // CLmkEditorImpl::HandleListProviderError // ----------------------------------------------------------------------------- // -void CLmkEditorImpl::HandleListProviderError( TInt /*aError*/ ) - { - //if error do nothing - } +void CLmkEditorImpl::HandleListProviderError(TInt /*aError*/) + { + //if error do nothing + } // ----------------------------------------------------------------------------- // CLmkEditorImpl::LaunchLmkEditorL // ----------------------------------------------------------------------------- // void CLmkEditorImpl::LaunchLmkEditorL() - { - CEikButtonGroupContainer* cba = CEikButtonGroupContainer::Current(); - cba->RemoveCommandFromStack( KMskCommandPos, iMskCmdId ); + { + CEikButtonGroupContainer* cba = CEikButtonGroupContainer::Current(); + cba->RemoveCommandFromStack(KMskCommandPos, iMskCmdId); // Launch editor - TLmkEditorAttributes attributeFlags( CLmkEditorDlg::ELmkAll ); - // Check if the Landmark is alreayd present in the database. Incase, - // a landmark is associated with the editor and if it is not - // added to the Database, then the viewer would be launched with - // the lanmark content - if( KPosLmNullItemId == iLmkFields->LandmarkId() && iLandmark ) + TLmkEditorAttributes attributeFlags(CLmkEditorDlg::ELmkAll); + // Check if the Landmark is alreayd present in the database. Incase, + // a landmark is associated with the editor and if it is not + // added to the Database, then the viewer would be launched with + // the lanmark content + if (KPosLmNullItemId == iLmkFields->LandmarkId() && iLandmark) { - iEditor = CLmkEditorImpl::NewL( iDb, - iSender, - attributeFlags, - CLmkEditorDlg::ELmkEditor, - iLandmark ); + iEditor = CLmkEditorImpl::NewL(iDb, iSender, attributeFlags, + CLmkEditorDlg::ELmkEditor, iLandmark); } else { - iEditor = CLmkEditorImpl::NewL( iDb, - iSender, - attributeFlags, - CLmkEditorDlg::ELmkEditor, - iLmkFields->LandmarkId() ); + iEditor = CLmkEditorImpl::NewL(iDb, iSender, attributeFlags, + CLmkEditorDlg::ELmkEditor, iLmkFields->LandmarkId()); } - - MLmkEditorField* field = iEditorFieldArray->Find( IdOfFocusControl() ); - iFieldTypeToFocus = field->LandmarkItemField().FieldType(); - iEditor->SetFieldTypeToFocusInEditMode( iFieldTypeToFocus ); - iEditor->SetDlgEditing( ETrue ); + MLmkEditorField* field = iEditorFieldArray->Find(IdOfFocusControl()); + iFieldTypeToFocus = field->LandmarkItemField().FieldType(); + iEditor->SetFieldTypeToFocusInEditMode(iFieldTypeToFocus); + iEditor->SetDlgEditing(ETrue); iIsEditing = ETrue; - if( !iMapNavFeature ) - { - iEditor->DisableMapAndNavigationMenuOptions(); - } + if (!iMapNavFeature) + { + iEditor->DisableMapAndNavigationMenuOptions(); + } iEditor->ExecuteLD(); - iEditor->SetDlgEditing( EFalse ); + iEditor->SetDlgEditing(EFalse); iIsEditing = EFalse; TInt err = KErrNone; TRAP( err, CPosLandmark* landmark = iDb.ReadLandmarkLC( iLmkFields->LandmarkId() ); CleanupStack::PopAndDestroy( landmark ) ); @@ -3069,386 +2714,118 @@ delete this; return; } - AddMskCommandL( iCurrentResourceId, iMskCmdId ); - } + AddMskCommandL(iCurrentResourceId, iMskCmdId); + } // ----------------------------------------------------------------------------- // CLmkEditorImpl::DeleteSelfL // ----------------------------------------------------------------------------- // void CLmkEditorImpl::DeleteSelfL() - { - iLmkUiUtils->RestoreOldNaviPaneL(); - if(iEditor) - { - //delete only editor,if editor instance is present, - //viewer will be deleted in ProcessCommandL, where - //editor was created. - delete iEditor; - iEditor = NULL; - } + { + iLmkUiUtils->RestoreOldNaviPaneL(); + if (iEditor) + { + //delete only editor,if editor instance is present, + //viewer will be deleted in ProcessCommandL, where + //editor was created. + delete iEditor; + iEditor = NULL; + } else - { - delete this; - } - } + { + delete this; + } + } // ----------------------------------------------------------------------------- // CLmkEditorImpl::HandleCentralRepositoryChangeL() // ----------------------------------------------------------------------------- // void CLmkEditorImpl::HandleCentralRepositoryChangeL() - { - //change unit for position accuracy - MLmkFieldData* fldData = iLmkFields->GetField( EPositionAccuracy ); - if(fldData) - { - TInt id1 = fldData->UniqueFieldIdentity(); - CLmkEditorNumberField* field = static_cast(iEditorFieldArray->Find( id1 )); - if(field) - field->HandleUnitChangeL(); - } + { + //change unit for position accuracy + MLmkFieldData* fldData = iLmkFields->GetField(EPositionAccuracy); + if (fldData) + { + TInt id1 = fldData->UniqueFieldIdentity(); + CLmkEditorNumberField* field = + static_cast (iEditorFieldArray->Find( + id1)); + if (field) + field->HandleUnitChangeL(); + } - //change altitude unit - MLmkFieldData* fldData1 = iLmkFields->GetField( EAltitude ); - if(fldData1) - { - TInt id2 = fldData1->UniqueFieldIdentity(); - CLmkEditorNumberField* field1 = static_cast(iEditorFieldArray->Find( id2 )); - if(field1) - field1->HandleUnitChangeL(); - } + //change altitude unit + MLmkFieldData* fldData1 = iLmkFields->GetField(EAltitude); + if (fldData1) + { + TInt id2 = fldData1->UniqueFieldIdentity(); + CLmkEditorNumberField* field1 = + static_cast (iEditorFieldArray->Find( + id2)); + if (field1) + field1->HandleUnitChangeL(); + } - //change altitude accuracy unit - MLmkFieldData* fldData2 = iLmkFields->GetField( EAltitudeAccuracy ); - if(fldData2) - { - TInt id3 = fldData2->UniqueFieldIdentity(); - CLmkEditorNumberField* field2 = static_cast(iEditorFieldArray->Find( id3 )); - if(field2) - field2->HandleUnitChangeL(); - } - } + //change altitude accuracy unit + MLmkFieldData* fldData2 = iLmkFields->GetField(EAltitudeAccuracy); + if (fldData2) + { + TInt id3 = fldData2->UniqueFieldIdentity(); + CLmkEditorNumberField* field2 = + static_cast (iEditorFieldArray->Find( + id3)); + if (field2) + field2->HandleUnitChangeL(); + } + } // ----------------------------------------------------------------------------- // CLmkEditorImpl::UpdateCatInfoNotePosition() // ----------------------------------------------------------------------------- // void CLmkEditorImpl::UpdateCatInfoNotePosition() - { - //this is only to set the position of the - //cat info note. - if(iCatInfoPopupNote && IsCategoryField()) - { - CEikCaptionedControl* tmpline = CurrentLine(); - TPoint pt1 = tmpline->PositionRelativeToScreen(); - pt1.iX+=KHOffsetCatInfoPopup; - pt1.iY+=KVOffsetCatInfoPopup; - iCatInfoPopupNote->SetPositionAndAlignment(pt1,EHLeftVTop); - } - } + { + //this is only to set the position of the + //cat info note. + if (iCatInfoPopupNote && IsCategoryField()) + { + CEikCaptionedControl* tmpline = CurrentLine(); + TPoint pt1 = tmpline->PositionRelativeToScreen(); + pt1.iX += KHOffsetCatInfoPopup; + pt1.iY += KVOffsetCatInfoPopup; + iCatInfoPopupNote->SetPositionAndAlignment(pt1, EHLeftVTop); + } + } // ----------------------------------------------------------------------------- // CLmkEditorImpl::IsCategoryField() // ----------------------------------------------------------------------------- // TBool CLmkEditorImpl::IsCategoryField() - { - //to check whether the current focussed field is a - //category field. - TBool result = ETrue; - MLmkEditorField* field = - iEditorFieldArray->Find( IdOfFocusControl() ); - TUint type = field->LandmarkItemField().FieldType(); - if(type != ECategories && type != ECategory) - { - result = EFalse; - } - return result; - } - + { + //to check whether the current focussed field is a + //category field. + TBool result = ETrue; + MLmkEditorField* field = iEditorFieldArray->Find(IdOfFocusControl()); + TUint type = field->LandmarkItemField().FieldType(); + if (type != ECategories && type != ECategory) + { + result = EFalse; + } + return result; + } #ifdef RD_SCALABLE_UI_V2 // ----------------------------------------------------------------------------- // CLmkEditorImpl::HandleDialogPageEventL // ----------------------------------------------------------------------------- // - -void CLmkEditorImpl::HandleDialogPageEventL(TInt /*aEventID*/) - { - /* - if(IsEditable()) - { - //editor - HandleEditorCommandL(); - } - */ - } - -#endif //RD_SCALABLE_UI_V2 - -// ----------------------------------------------------------------------------- -// CLmkEditorImpl::LineChangedL -// ----------------------------------------------------------------------------- -// - -void CLmkEditorImpl::LineChangedL(TInt /*aControlId*/) - { - - //hide the category info pop-up if active - if(iCatInfoPopupNote) - { - iCatInfoPopupNote->HideInfoPopupNote(); - } - MLmkEditorField* field = iEditorFieldArray->Find( IdOfFocusControl() ); - __ASSERT_DEBUG( field, Panic( KLmkPanicNullMember ) ); - TUint type = field->LandmarkItemField().FieldType(); - if (IsEditable()) - { - //editor - if ( type == ECategory || type == ECategories ) - { - AddMskCommandL(R_LM_MSK_EDIT,ELmkCmdSelectCategories); - } - else - { - CEikButtonGroupContainer* cba = CEikButtonGroupContainer::Current(); - cba->MakeCommandVisible(iMskCmdId,EFalse); - } - } - else - { - //viewer - UpdateMskOnArrowMoveForViewerL(); - } - if ( type == ECategory || type == ECategories ) - { - // ShowMultipleCategoriesInfoPopupL(IdOfFocusControl()); - } - - } - -// ----------------------------------------------------------------------------- -// CLmkEditorImpl::ClearPositionInfoL() -// ----------------------------------------------------------------------------- -// -void CLmkEditorImpl::ClearPositionInfoL() - { - //clear latitude - MLmkFieldData* lat = iLmkFields->GetField(ELatitude); - if(lat) - { - TInt id = lat->UniqueFieldIdentity(); - MLmkEditorField* latcontrol = iEditorFieldArray->Find( id ); - if(latcontrol) - { - latcontrol->ResetL(); - } - } - //clear longitude - MLmkFieldData* lon = iLmkFields->GetField(ELongitude); - if(lon) - { - TInt id = lon->UniqueFieldIdentity(); - MLmkEditorField* longcontrol = iEditorFieldArray->Find( id ); - if(longcontrol) - { - longcontrol->ResetL(); - } - } - //clear position accuracy - MLmkFieldData* fldData = iLmkFields->GetField( EPositionAccuracy ); - if(fldData) - { - TInt id1 = fldData->UniqueFieldIdentity(); - CLmkEditorNumberField* field = static_cast(iEditorFieldArray->Find( id1 )); - if(field) - { - field->ResetL(); - } - } - //clear altitude - MLmkFieldData* fldData1 = iLmkFields->GetField( EAltitude ); - if(fldData1) - { - TInt id2 = fldData1->UniqueFieldIdentity(); - CLmkEditorNumberField* field1 = static_cast(iEditorFieldArray->Find( id2 )); - if(field1) - { - field1->ResetL(); - } - } - //clear altitude accuracy - MLmkFieldData* fldData2 = iLmkFields->GetField( EAltitudeAccuracy ); - if(fldData2) - { - TInt id3 = fldData2->UniqueFieldIdentity(); - CLmkEditorNumberField* field2 = static_cast(iEditorFieldArray->Find( id3 )); - if(field2) - { - field2->ResetL(); - } - } - - DrawNow(); - - } - -// ----------------------------------------------------------------------------- -// CLmkEditorImpl::ArePositionFieldEmptyL() -// ----------------------------------------------------------------------------- -// -TBool CLmkEditorImpl::ArePositionFieldEmptyL() - { - return (IsFieldEmptyL( ELatitude ) && IsFieldEmptyL( ELongitude ) && IsFieldEmptyL( EAltitude ) - && IsFieldEmptyL( EAltitudeAccuracy ) && IsFieldEmptyL( EPositionAccuracy)) ? ETrue : EFalse; - } - -#ifdef RD_SCALABLE_UI_V2 -// ----------------------------------------------------------------------------- -// CLmkEditorImpl::HandleEditorCommandL() -// ----------------------------------------------------------------------------- -// -void CLmkEditorImpl::HandleEditorCommandL() - { - MLmkEditorField* field = iEditorFieldArray->Find( IdOfFocusControl() ); - __ASSERT_DEBUG( field, Panic( KLmkPanicNullMember ) ); - - TUint type = field->LandmarkItemField().FieldType(); - switch(type) - { - case ECategories: - case ECategory: - { - ProcessCommandL( ELmkCmdSelectCategories ); - break; - } - } - } -#endif //RD_SCALABLE_UI_V2 - -// ----------------------------------------------------------------------------- -// CLmkAppLmItemSelectorImpl::HandleDialogDismissed -// ----------------------------------------------------------------------------- -// -void CLmkEditorImpl::HandleDialogDismissed( TInt aButtonId ) - { - if( EEikBidCancel == aButtonId ) - { - delete iLocationService; - iLocationService = NULL; - } - } -// ----------------------------------------------------------------------------- -// CLmkEditorImpl::InsertLineL() -// ----------------------------------------------------------------------------- -// -MLmkEditorField* CLmkEditorImpl::InsertLineL( MLmkFieldData* aFieldData, - TInt aPrevControlId) - { - MLmkEditorField* editorField = NULL; - //data present, but control not present - TryChangeFocusL(aPrevControlId); - editorField = LmkEditorFieldFactory::CreateFieldL( - *aFieldData, *this ); - CleanupStack::PushL( editorField ); - if ( editorField ) - { - editorField->SetEditableL(EFalse); - iEditorFieldArray->GetFieldArray().AppendL( editorField ); - editorField->ActivateL(); - } - CleanupStack::Pop(); //editorField - return editorField; - } - -// ----------------------------------------------------------------------------- -// CLmkEditorImpl::DeleteLineL() -// ----------------------------------------------------------------------------- -// -void CLmkEditorImpl::DeleteLineL( MLmkEditorField* aEditorField, - TInt aCtrlId , TInt aPos) - { - //data not present but control present - //iEditorFieldArray->GetFieldArray().Delete( aPos-1 ); - iEditorFieldArray->GetFieldArray().Delete( aPos ); - delete aEditorField; - aEditorField=NULL; - DeleteLine(aCtrlId); - } - -// ----------------------------------------------------------------------------- -// CLmkEditorImpl::AddOrDeleteLineL() -// ----------------------------------------------------------------------------- -// -MLmkEditorField* CLmkEditorImpl::AddOrDeleteLineL( MLmkEditorField* aEditorField, - MLmkFieldData* aFieldData , - TInt aPrevControlId, - TInt aCtrlId , TInt aPos) - { - TBool valPresent = iEditorFieldArray->CheckIfFieldIsEmpty(*aFieldData); - - if(valPresent && !aEditorField) - { - aEditorField = InsertLineL( aFieldData, aPrevControlId); - } - else if(!valPresent && aEditorField) - { - DeleteLineL(aEditorField, aCtrlId,aPos); - aEditorField = NULL; - } - return aEditorField; - } - -// ----------------------------------------------------------------------------- -// CLmkEditorImpl::MessageQueryCallBack() -// ----------------------------------------------------------------------------- -// -TInt CLmkEditorImpl::MessageQueryCallBack( TAny* /*aPtr*/ ) - { - TInt result = KErrNone; - CEikonEnv* env = CEikonEnv::Static(); - TRAP_IGNORE(result = LmkNotes::GenericMessageQueryL(env,R_LMK_REQUEST_FAIL_INFO_TEXT, - R_LMK_MSG_QUERY_HEADING_PANE_TEXT)); - return result; - } - -// --------------------------------------------------------- -// CLmkEditorImpl::CheckHideCoordinateL() -// --------------------------------------------------------- -// -void CLmkEditorImpl::CheckHideCoordinateL() - { - TInt coordinateSettingValue = ELocCoordinatesNotHidden; - TInt helpSettingValue = ELocHelpNotHidden; - CRepository* repository = CRepository::NewL( TUid::Uid( KCRUidLocLocalVariation) ); - CleanupStack::PushL( repository ); - User::LeaveIfError( repository->Get( KLocHideCoordinates, - coordinateSettingValue )); - User::LeaveIfError( repository->Get( KLocHideHelp, - helpSettingValue )); - CleanupStack::PopAndDestroy( repository ); - - if( ELocCoordinatesHidden == coordinateSettingValue ) - iIsHideCoordinate = ETrue; - else - iIsHideCoordinate = EFalse; - - if( ELocHelpHidden == helpSettingValue ) - iIsHideHelp = ETrue; - else - iIsHideHelp = EFalse; - - } - -// --------------------------------------------------------- -// CLmkEditorImpl::HandlePointerEventL() -// --------------------------------------------------------- -// -void CLmkEditorImpl::HandlePointerEventL(const TPointerEvent& aPointerEvent) +void CLmkEditorImpl::HandleDialogPageEventL(TInt aEventID) { - if (aPointerEvent.iType == TPointerEvent::EButton1Up && iIsDragging - == EFalse) + CAknForm::HandleDialogPageEventL(aEventID); + if (aEventID == MEikDialogPageObserver::EDialogPageTapped) { MLmkEditorField* field = iEditorFieldArray->Find(IdOfFocusControl()); TUint type = field->LandmarkItemField().FieldType(); @@ -3467,7 +2844,7 @@ } else {// view or receive mode - if (type == ECategory || type == ECategories) + if (type == ECategories) { if (iCalegorySelectionFlag) // Receive mode { @@ -3490,21 +2867,258 @@ } } } + } + +#endif //RD_SCALABLE_UI_V2 +// ----------------------------------------------------------------------------- +// CLmkEditorImpl::LineChangedL +// ----------------------------------------------------------------------------- +// + +void CLmkEditorImpl::LineChangedL(TInt /*aControlId*/) + { + //hide the category info pop-up if active + if (iCatInfoPopupNote) + { + iCatInfoPopupNote->HideInfoPopupNote(); + } + MLmkEditorField* field = iEditorFieldArray->Find(IdOfFocusControl()); + __ASSERT_DEBUG( field, Panic( KLmkPanicNullMember ) ); + TUint type = field->LandmarkItemField().FieldType(); + if (IsEditable()) + { + //editor + if (type == ECategory || type == ECategories) + { + AddMskCommandL(R_LM_MSK_EDIT, ELmkCmdSelectCategories); + } + else + { + CEikButtonGroupContainer* cba = + CEikButtonGroupContainer::Current(); + cba->MakeCommandVisible(iMskCmdId, EFalse); + } + } else { - CAknForm::HandlePointerEventL(aPointerEvent); + //viewer + UpdateMskOnArrowMoveForViewerL(); + } + } - if (aPointerEvent.iType == TPointerEvent::EButton1Down) +// ----------------------------------------------------------------------------- +// CLmkEditorImpl::ClearPositionInfoL() +// ----------------------------------------------------------------------------- +// +void CLmkEditorImpl::ClearPositionInfoL() + { + //clear latitude + MLmkFieldData* lat = iLmkFields->GetField(ELatitude); + if (lat) + { + TInt id = lat->UniqueFieldIdentity(); + MLmkEditorField* latcontrol = iEditorFieldArray->Find(id); + if (latcontrol) + { + latcontrol->ResetL(); + } + } + //clear longitude + MLmkFieldData* lon = iLmkFields->GetField(ELongitude); + if (lon) + { + TInt id = lon->UniqueFieldIdentity(); + MLmkEditorField* longcontrol = iEditorFieldArray->Find(id); + if (longcontrol) + { + longcontrol->ResetL(); + } + } + //clear position accuracy + MLmkFieldData* fldData = iLmkFields->GetField(EPositionAccuracy); + if (fldData) + { + TInt id1 = fldData->UniqueFieldIdentity(); + CLmkEditorNumberField* field = + static_cast (iEditorFieldArray->Find( + id1)); + if (field) { - iIsDragging = EFalse; + field->ResetL(); + } + } + //clear altitude + MLmkFieldData* fldData1 = iLmkFields->GetField(EAltitude); + if (fldData1) + { + TInt id2 = fldData1->UniqueFieldIdentity(); + CLmkEditorNumberField* field1 = + static_cast (iEditorFieldArray->Find( + id2)); + if (field1) + { + field1->ResetL(); } + } + //clear altitude accuracy + MLmkFieldData* fldData2 = iLmkFields->GetField(EAltitudeAccuracy); + if (fldData2) + { + TInt id3 = fldData2->UniqueFieldIdentity(); + CLmkEditorNumberField* field2 = + static_cast (iEditorFieldArray->Find( + id3)); + if (field2) + { + field2->ResetL(); + } + } + DrawNow(); + } - if (aPointerEvent.iType == TPointerEvent::EDrag) +// ----------------------------------------------------------------------------- +// CLmkEditorImpl::ArePositionFieldEmptyL() +// ----------------------------------------------------------------------------- +// +TBool CLmkEditorImpl::ArePositionFieldEmptyL() + { + return (IsFieldEmptyL(ELatitude) && IsFieldEmptyL(ELongitude) + && IsFieldEmptyL(EAltitude) && IsFieldEmptyL(EAltitudeAccuracy) + && IsFieldEmptyL(EPositionAccuracy)) ? ETrue : EFalse; + } + +#ifdef RD_SCALABLE_UI_V2 +// ----------------------------------------------------------------------------- +// CLmkEditorImpl::HandleEditorCommandL() +// ----------------------------------------------------------------------------- +// +void CLmkEditorImpl::HandleEditorCommandL() + { + MLmkEditorField* field = iEditorFieldArray->Find(IdOfFocusControl()); + __ASSERT_DEBUG( field, Panic( KLmkPanicNullMember ) ); + + TUint type = field->LandmarkItemField().FieldType(); + switch (type) + { + case ECategories: + case ECategory: { - iIsDragging = ETrue; + ProcessCommandL(ELmkCmdSelectCategories); + break; } } } +#endif //RD_SCALABLE_UI_V2 +// ----------------------------------------------------------------------------- +// CLmkAppLmItemSelectorImpl::HandleDialogDismissed +// ----------------------------------------------------------------------------- +// +void CLmkEditorImpl::HandleDialogDismissed(TInt aButtonId) + { + if (EEikBidCancel == aButtonId) + { + delete iLocationService; + iLocationService = NULL; + } + } + +// ----------------------------------------------------------------------------- +// CLmkEditorImpl::InsertLineL() +// ----------------------------------------------------------------------------- +// +MLmkEditorField* CLmkEditorImpl::InsertLineL(MLmkFieldData* aFieldData, + TInt aPrevControlId) + { + MLmkEditorField* editorField = NULL; + //data present, but control not present + TryChangeFocusL(aPrevControlId); + editorField = LmkEditorFieldFactory::CreateFieldL(*aFieldData, *this); + CleanupStack::PushL(editorField); + if (editorField) + { + editorField->SetEditableL(EFalse); + iEditorFieldArray->GetFieldArray().AppendL(editorField); + editorField->ActivateL(); + } + CleanupStack::Pop(); //editorField + return editorField; + } + +// ----------------------------------------------------------------------------- +// CLmkEditorImpl::DeleteLineL() +// ----------------------------------------------------------------------------- +// +void CLmkEditorImpl::DeleteLineL(MLmkEditorField* aEditorField, TInt aCtrlId, + TInt aPos) + { + //data not present but control present + //iEditorFieldArray->GetFieldArray().Delete( aPos-1 ); + iEditorFieldArray->GetFieldArray().Delete(aPos); + delete aEditorField; + aEditorField = NULL; + DeleteLine(aCtrlId); + } + +// ----------------------------------------------------------------------------- +// CLmkEditorImpl::AddOrDeleteLineL() +// ----------------------------------------------------------------------------- +// +MLmkEditorField* CLmkEditorImpl::AddOrDeleteLineL( + MLmkEditorField* aEditorField, MLmkFieldData* aFieldData, + TInt aPrevControlId, TInt aCtrlId, TInt aPos) + { + TBool valPresent = iEditorFieldArray->CheckIfFieldIsEmpty(*aFieldData); + if (valPresent && !aEditorField) + { + aEditorField = InsertLineL(aFieldData, aPrevControlId); + } + else if (!valPresent && aEditorField) + { + DeleteLineL(aEditorField, aCtrlId, aPos); + aEditorField = NULL; + } + return aEditorField; + } + +// ----------------------------------------------------------------------------- +// CLmkEditorImpl::MessageQueryCallBack() +// ----------------------------------------------------------------------------- +// +TInt CLmkEditorImpl::MessageQueryCallBack(TAny* /*aPtr*/) + { + TInt result = KErrNone; + CEikonEnv* env = CEikonEnv::Static(); + TRAP_IGNORE(result = LmkNotes::GenericMessageQueryL(env,R_LMK_REQUEST_FAIL_INFO_TEXT, + R_LMK_MSG_QUERY_HEADING_PANE_TEXT)); + return result; + } + +// --------------------------------------------------------- +// CLmkEditorImpl::CheckHideCoordinateL() +// --------------------------------------------------------- +// +void CLmkEditorImpl::CheckHideCoordinateL() + { + TInt coordinateSettingValue = ELocCoordinatesNotHidden; + TInt helpSettingValue = ELocHelpNotHidden; + CRepository* repository = CRepository::NewL(TUid::Uid( + KCRUidLocLocalVariation)); + CleanupStack::PushL(repository); + User::LeaveIfError(repository->Get(KLocHideCoordinates, + coordinateSettingValue)); + User::LeaveIfError(repository->Get(KLocHideHelp, helpSettingValue)); + CleanupStack::PopAndDestroy(repository); + + if (ELocCoordinatesHidden == coordinateSettingValue) + iIsHideCoordinate = ETrue; + else + iIsHideCoordinate = EFalse; + + if (ELocHelpHidden == helpSettingValue) + iIsHideHelp = ETrue; + else + iIsHideHelp = EFalse; + } // End of File