landmarksui/uicontrols/src/CLmkDlgCombiSelectorImpl.cpp
branchRCL_3
changeset 17 1fc85118c3ae
parent 16 8173571d354e
child 18 870918037e16
equal deleted inserted replaced
16:8173571d354e 17:1fc85118c3ae
     1 /*
       
     2 * Copyright (c) 2002-2005 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:    LandmarksUi Content File -    This contains methods implementing a combined dialog for Landmarks
       
    15 *                by name view and categories view
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 
       
    21 
       
    22 
       
    23 
       
    24 
       
    25 // INCLUDE FILES
       
    26 
       
    27 #include <eikapp.h>
       
    28 #include <eikenv.h>
       
    29 #include <StringLoader.h>
       
    30 #include <AknsUtils.h>
       
    31 #include <akntabgrp.h>
       
    32 #include <eikspane.h>
       
    33 #include <aknnavide.h>
       
    34 #include <aknnavi.h>
       
    35 #include <barsread.h>
       
    36 #include <lmkui.rsg>
       
    37 #include <EPos_CPosLmCategoryCriteria.h>
       
    38 #include "LmkConsts.h"
       
    39 #include "landmarks.hrh"
       
    40 #include "CLmkDbUtils.h"
       
    41 #include "CLmkLmItemListProvider.h"
       
    42 #include "CLmkUiUtils.h"
       
    43 #include "CLmkSelectorDialog.h"
       
    44 #include "CLmkEmptyDialog.h"
       
    45 #include "CLmkDlgLmSelectorImpl.h"
       
    46 #include "CLmkDlgCategorySelectorImpl.h"
       
    47 #include "CLmkDlgCombiSelectorImpl.h"
       
    48 #include "CLmkLmItemListMemento.h"
       
    49 #include <lmkerrors.h>
       
    50 
       
    51 
       
    52 // CONSTANTS
       
    53 /// Unnamed namespace for local definitions
       
    54 namespace {
       
    55 
       
    56 const TInt KLmkNumberOfSelectors = 3;
       
    57 
       
    58 #if defined(_DEBUG)
       
    59 _LIT( KPanicMsg, "CLmkDlgCombiSelectorImpl" );
       
    60 void Panic( TPanicCode aReason )
       
    61     {
       
    62     User::Panic( KPanicMsg, aReason );
       
    63     }
       
    64 #endif
       
    65 }  // namespace
       
    66 // ============================ MEMBER FUNCTIONS ===============================
       
    67 
       
    68 // -----------------------------------------------------------------------------
       
    69 // CLmkDlgCombiSelectorImpl::CLmkDlgCombiSelectorImpl
       
    70 // C++ default constructor can NOT contain any code, that
       
    71 // might leave.
       
    72 // -----------------------------------------------------------------------------
       
    73 //
       
    74 CLmkDlgCombiSelectorImpl::CLmkDlgCombiSelectorImpl( CPosLandmarkDatabase& aDb )
       
    75     : CLmkDlgSelectorImplBase( aDb ),
       
    76       iSelectorState( ELmkInitialState ),
       
    77       iSelectors( KLmkNumberOfSelectors ),
       
    78       iMementos( KLmkNumberOfSelectors ),
       
    79       iNavigating( EFalse ),
       
    80       iAlwaysModify( EFalse ),
       
    81       iCustomLandmarksTitle(0)
       
    82     {
       
    83     }
       
    84 
       
    85 // -----------------------------------------------------------------------------
       
    86 // CLmkDlgCombiSelectorImpl::ConstructL
       
    87 // Symbian 2nd phase constructor can leave.
       
    88 // -----------------------------------------------------------------------------
       
    89 //
       
    90 void CLmkDlgCombiSelectorImpl::ConstructL()
       
    91     {
       
    92     BaseConstructL();
       
    93 
       
    94     // Default status pane:
       
    95     CEikStatusPane* sp = iEnv->AppUiFactory()->StatusPane();
       
    96 
       
    97     // Fetch pointer to the default navi pane control:
       
    98     iNaviPane = static_cast<CAknNavigationControlContainer*>(
       
    99                         sp->ControlL( TUid::Uid( EEikStatusPaneUidNavi ) ) );
       
   100     __ASSERT_DEBUG( iNaviPane, Panic( KLmkPanicNullMember ) );
       
   101     iNaviDeco = iNaviPane->CreateTabGroupL();
       
   102    	iNaviDeco->SetControlType( CAknNavigationDecorator::ETabGroup );
       
   103     iTabGroup = static_cast<CAknTabGroup*>( iNaviDeco->DecoratedControl() );
       
   104     __ASSERT_DEBUG( iTabGroup, Panic( KLmkPanicNullMember ) );
       
   105 
       
   106     // Add Tab Icons
       
   107     AddTabsL( *iTabGroup );
       
   108 
       
   109     // Set observer for CAknTabGroup
       
   110     iTabGroup->SetObserver( this );
       
   111 
       
   112     // Create mementos and initialize selector array with NULL pointers:
       
   113     MLmkListMemento* memento = NULL;
       
   114     for ( TInt i( 0 ); i < KLmkNumberOfSelectors; ++i )
       
   115         {
       
   116         memento = MementoL();
       
   117         User::LeaveIfError( iMementos.Append( memento ) );
       
   118         User::LeaveIfError( iSelectors.Append( NULL ) );
       
   119         }
       
   120     }
       
   121 
       
   122 // -----------------------------------------------------------------------------
       
   123 // CLmkDlgCombiSelectorImpl::NewL
       
   124 // Two-phased constructor.
       
   125 // -----------------------------------------------------------------------------
       
   126 //
       
   127 EXPORT_C CLmkDlgCombiSelectorImpl* CLmkDlgCombiSelectorImpl::NewL(
       
   128     CPosLandmarkDatabase& aDb )
       
   129     {
       
   130     CLmkDlgCombiSelectorImpl* self =
       
   131         new( ELeave ) CLmkDlgCombiSelectorImpl( aDb );
       
   132     CleanupStack::PushL( self );
       
   133     self->ConstructL();
       
   134     CleanupStack::Pop();
       
   135     return self;
       
   136     }
       
   137 
       
   138 // ----------------------------------------------------
       
   139 // CLmkDlgCombiSelectorImpl::~CLmkDlgCombiSelectorImpl
       
   140 // ----------------------------------------------------
       
   141 //
       
   142 CLmkDlgCombiSelectorImpl::~CLmkDlgCombiSelectorImpl()
       
   143     {
       
   144     iSelectors.ResetAndDestroy();
       
   145     iMementos.ResetAndDestroy();
       
   146     delete iNaviDeco;
       
   147     if( iCustomLandmarksTitle )
       
   148     	delete iCustomLandmarksTitle;
       
   149     }
       
   150 
       
   151 // ----------------------------------------------------
       
   152 // CLmkDlgCombiSelectorImpl::StopExecutionL
       
   153 // ----------------------------------------------------
       
   154 //
       
   155 void CLmkDlgCombiSelectorImpl::StopExecutionL()
       
   156     {
       
   157     __ASSERT_DEBUG( iSelectors.Count() == KLmkNumberOfSelectors,
       
   158                     Panic( KLmkPanicSelectorArrayIndex ) );
       
   159 
       
   160     for ( TInt i( 0 ); i < KLmkNumberOfSelectors; ++i )
       
   161         {
       
   162         if ( iSelectors[i] )
       
   163             {
       
   164             iSelectors[i]->StopExecutionL();
       
   165             }
       
   166         }
       
   167     iNaviPane->Pop( iNaviDeco );
       
   168     // Dialog ExecuteL returns and we must consider it in final state
       
   169     iSelectorState = ELmkFinalState;
       
   170     }
       
   171 
       
   172 // -----------------------------------------------------------------------------
       
   173 // CLmkDlgCombiSelectorImpl::ExecuteL
       
   174 //
       
   175 // (other items were commented in a header).
       
   176 // -----------------------------------------------------------------------------
       
   177 //
       
   178 TInt CLmkDlgCombiSelectorImpl::ExecuteL(
       
   179     TPosLmItemId& aOpenedItem,
       
   180     TBool aAlwaysModifyOpened )
       
   181     {
       
   182     // Ensure that ExecuteL is not already running:
       
   183     __ASSERT_DEBUG( iSelectorState == ELmkFinalState ||
       
   184                     iSelectorState == ELmkInitialState,
       
   185                     Panic( KLmkPanicIllegalMethodCall ) );
       
   186 
       
   187     iSelectorState = ELmkInitialState;
       
   188     iOpenedItem = &aOpenedItem;
       
   189     iAlwaysModify = aAlwaysModifyOpened;
       
   190     CLmkEmptyDialog * lDlg = new(ELeave)CLmkEmptyDialog();
       
   191     lDlg->SetMopParent(iMopParent);
       
   192 	lDlg->ExecuteLD(R_EMPTY_DIALOG);
       
   193 
       
   194     TLmkSelectorStateEvent nextEvent( ELmkSelectorStart );
       
   195     do
       
   196         {
       
   197         nextEvent = HandleAnyStateEventL( nextEvent );
       
   198 
       
   199         } while ( nextEvent != ELmkSelectorNoEvent );
       
   200 
       
   201     lDlg->EmptyDialogExitL();
       
   202     return iDlgRetVal;
       
   203     }
       
   204 
       
   205 // -----------------------------------------------------------------------------
       
   206 // CLmkDlgCombiSelectorImpl::ExecuteL
       
   207 //
       
   208 // (other items were commented in a header).
       
   209 // -----------------------------------------------------------------------------
       
   210 //
       
   211 TInt CLmkDlgCombiSelectorImpl::ExecuteL(
       
   212      RArray<TPosLmItemId>& aSelectedItems,
       
   213      TBool aAlwaysModifySelected )
       
   214     {
       
   215     // Ensure that ExecuteL is not already running:
       
   216     __ASSERT_DEBUG( iSelectorState == ELmkFinalState ||
       
   217                     iSelectorState == ELmkInitialState,
       
   218                     Panic( KLmkPanicIllegalMethodCall ) );
       
   219 
       
   220     iSelectorState = ELmkInitialState;
       
   221     iSelectedItems = &aSelectedItems;
       
   222     iAlwaysModify = aAlwaysModifySelected;
       
   223 
       
   224 
       
   225     TLmkSelectorStateEvent nextEvent( ELmkSelectorStart );
       
   226     do
       
   227         {
       
   228         nextEvent = HandleAnyStateEventL( nextEvent );
       
   229 
       
   230         } while ( nextEvent != ELmkSelectorNoEvent );
       
   231 
       
   232     return iDlgRetVal;
       
   233     }
       
   234 
       
   235 // ----------------------------------------------------
       
   236 // CLmkDlgCombiSelectorImpl::HandleAnyStateEventL
       
   237 // ----------------------------------------------------
       
   238 //
       
   239 CLmkDlgCombiSelectorImpl::TLmkSelectorStateEvent
       
   240 CLmkDlgCombiSelectorImpl::HandleAnyStateEventL(
       
   241     TLmkSelectorStateEvent aEvent )
       
   242     {
       
   243     TLmkSelectorStateEvent nextEvent( ELmkSelectorNoEvent );
       
   244 
       
   245     switch ( iSelectorState )
       
   246         {
       
   247         case ELmkInitialState:
       
   248             {
       
   249             nextEvent = HandleInitialStateEventL( aEvent );
       
   250             break;
       
   251             }
       
   252         case ELmkLandmarkSelector:
       
   253             {
       
   254             nextEvent = HandleLandmarkSelectorStateEventL( aEvent );
       
   255             break;
       
   256             }
       
   257         case ELmkCategorySelector:
       
   258             {
       
   259             nextEvent = HandleCategorySelectorStateEventL( aEvent );
       
   260             break;
       
   261             }
       
   262         case ELmkFilteredLmSelector:
       
   263             {
       
   264             nextEvent = HandleFilteredLmSelectorStateEventL( aEvent );
       
   265             break;
       
   266             }
       
   267         default: // ELmkFinalState
       
   268             {
       
   269             nextEvent = HandleDefaultStateStateEventL( aEvent );
       
   270             }
       
   271         }
       
   272     if ( iNavigating )
       
   273         { // navigation variable overrides dialog return value
       
   274         iNavigating = EFalse;
       
   275         nextEvent = ELmkSelectorNavigating;
       
   276         }
       
   277 
       
   278     return nextEvent;
       
   279     }
       
   280 
       
   281 // ----------------------------------------------------
       
   282 // CLmkDlgCombiSelectorImpl::HandleInitialStateEventL
       
   283 // ----------------------------------------------------
       
   284 //
       
   285 CLmkDlgCombiSelectorImpl::TLmkSelectorStateEvent
       
   286 CLmkDlgCombiSelectorImpl::HandleInitialStateEventL(
       
   287     TLmkSelectorStateEvent /*aEvent*/ )
       
   288     {
       
   289 
       
   290     iTabGroup->SetActiveTabById( ETabLandmarkList );
       
   291     iNaviPane->PushL( *iNaviDeco );
       
   292     iSelectorState = ELmkLandmarkSelector;
       
   293     CLmkDlgSelectorImplBase& selector = CurrentStateSelectorL();
       
   294 
       
   295     if ( iSelectedItems )
       
   296         { // multi selector mode
       
   297         iDlgRetVal = selector.ExecuteL( *iSelectedItems, iAlwaysModify );
       
   298         }
       
   299     else
       
   300         { // single selector mode
       
   301         iDlgRetVal = selector.ExecuteL( *iOpenedItem, iAlwaysModify );
       
   302         }
       
   303     return ELmkSelectorStop;
       
   304     }
       
   305 
       
   306 // ----------------------------------------------------
       
   307 // CLmkDlgCombiSelectorImpl::HandleAnyStateEventL
       
   308 // ----------------------------------------------------
       
   309 //
       
   310 CLmkDlgCombiSelectorImpl::TLmkSelectorStateEvent
       
   311 CLmkDlgCombiSelectorImpl::HandleLandmarkSelectorStateEventL(
       
   312     TLmkSelectorStateEvent aEvent )
       
   313     {
       
   314     __ASSERT_DEBUG( aEvent == ELmkSelectorNavigating ||
       
   315                     aEvent == ELmkSelectorStop,
       
   316                     Panic( KLmkPanicUnexpectedEvent ) );
       
   317 
       
   318     if ( aEvent == ELmkSelectorNavigating )
       
   319         {
       
   320         iSelectorState = ELmkCategorySelector;
       
   321         CLmkDlgSelectorImplBase& selector = CurrentStateSelectorL();
       
   322         iDlgRetVal = selector.ExecuteL( iCategoryIndex );
       
   323         return ELmkSelectorStop;
       
   324         }
       
   325     else
       
   326         { // aEvent == ELmkSelectorStop
       
   327         iSelectorState = ELmkFinalState;
       
   328         return ELmkSelectorNoEvent;
       
   329         }
       
   330     }
       
   331 
       
   332 // ----------------------------------------------------
       
   333 // CLmkDlgCombiSelectorImpl::HandleCategorySelectorStateEventL
       
   334 // ----------------------------------------------------
       
   335 //
       
   336 CLmkDlgCombiSelectorImpl::TLmkSelectorStateEvent
       
   337 CLmkDlgCombiSelectorImpl::HandleCategorySelectorStateEventL(
       
   338     TLmkSelectorStateEvent aEvent )
       
   339     {
       
   340     __ASSERT_DEBUG( aEvent == ELmkSelectorNavigating ||
       
   341                     aEvent == ELmkSelectorStop,
       
   342                     Panic( KLmkPanicUnexpectedEvent ) );
       
   343 
       
   344     if ( aEvent == ELmkSelectorNavigating )
       
   345         {
       
   346         iSelectorState = ELmkLandmarkSelector;
       
   347         CLmkDlgSelectorImplBase& selector = CurrentStateSelectorL();
       
   348 
       
   349         if ( iSelectedItems )
       
   350             { // multi selector mode
       
   351             iDlgRetVal = selector.ExecuteL( *iSelectedItems, iAlwaysModify );
       
   352             }
       
   353         else
       
   354             { // single selector mode
       
   355             iDlgRetVal = selector.ExecuteL( *iOpenedItem, iAlwaysModify );
       
   356             }
       
   357         return ELmkSelectorStop;
       
   358         }
       
   359     else if ( aEvent == ELmkSelectorStop && iDlgRetVal != 0 )
       
   360         { // -> open category contents
       
   361         TPosLmItemId categoryId( KPosLmNullItemId );
       
   362         static_cast<const CLmkLmItemListProvider&>( ListProvider() ).
       
   363             GetSelectedItemId( categoryId, iCategoryIndex );
       
   364 
       
   365 		HBufC* catName = NULL;
       
   366 
       
   367         if (categoryId == KPosLmNullItemId) // 'uncategorised' category
       
   368         {
       
   369 	        // 'uncategorised' category
       
   370 	        // set criteria for searchnig 'Uncategorised' landmarks
       
   371 			catName = StringLoader::LoadL(
       
   372 			        R_LMK_LM_LIST_UNCATEGORISED,
       
   373 			        const_cast<CEikonEnv *>( iEnv ));
       
   374         }
       
   375         else
       
   376         {
       
   377            //HBufC* catName = CLmkDbUtils::CategoryNameL( iDb, categoryId );
       
   378            catName = CLmkDbUtils::CategoryNameL( iDb, categoryId );
       
   379         }
       
   380 
       
   381         CleanupStack::PushL( catName );
       
   382         //Store old and create new navi pane
       
   383         iLmkUiUtils->StoreNaviPaneL();
       
   384         iLmkUiUtils->CreateNaviLabelL( *catName );
       
   385         CleanupStack::PopAndDestroy(); //catName
       
   386 
       
   387         iSelectorState = ELmkFilteredLmSelector;
       
   388         CLmkDlgSelectorImplBase& selector = CurrentStateSelectorL( categoryId );
       
   389 		if(iMementos[iSelectorState])
       
   390 	    	{
       
   391 	    	CLmkLmItemListMemento* memento =
       
   392 				 static_cast<CLmkLmItemListMemento*>(iMementos[iSelectorState]);
       
   393 	    	memento->UpdateModelAvailability(EFalse);
       
   394 	    	}
       
   395         if ( iSelectedItems )
       
   396             { // Return value is stored even if "Back" was pressed:
       
   397             iDlgRetVal = selector.ExecuteL( *iSelectedItems, ETrue );
       
   398             }
       
   399         else
       
   400             { // Return value is not stored if "Back" was pressed:
       
   401             iDlgRetVal = selector.ExecuteL( *iOpenedItem, EFalse );
       
   402             }
       
   403         return ELmkSelectorStop;
       
   404         }
       
   405     else // aEvent == ELmkSelectorStop && dialog canceled
       
   406         {
       
   407         iSelectorState = ELmkFinalState;
       
   408         return ELmkSelectorNoEvent;
       
   409         }
       
   410     }
       
   411 
       
   412 // ----------------------------------------------------
       
   413 // CLmkDlgCombiSelectorImpl::HandleFilteredLmSelectorStateEventL
       
   414 // ----------------------------------------------------
       
   415 //
       
   416 CLmkDlgCombiSelectorImpl::TLmkSelectorStateEvent
       
   417 CLmkDlgCombiSelectorImpl::HandleFilteredLmSelectorStateEventL(
       
   418     TLmkSelectorStateEvent aEvent )
       
   419     {
       
   420     __ASSERT_DEBUG( aEvent == ELmkSelectorStop,
       
   421                     Panic( KLmkPanicUnexpectedEvent ) );
       
   422 
       
   423     // filtered lm selector shouldn't be removed earlier
       
   424     CLmkDlgSelectorImplBase*& selector = iSelectors[ELmkFilteredLmSelector];
       
   425     delete selector;
       
   426     selector = NULL; // iSelector's pointer points to NULL now!
       
   427 
       
   428     //Restore navi panel
       
   429     iLmkUiUtils->RestoreOldNaviPaneL();
       
   430 
       
   431     if ( aEvent == ELmkSelectorStop && iDlgRetVal != 0 )
       
   432         {
       
   433         iSelectorState = ELmkFinalState;
       
   434         return ELmkSelectorNoEvent;
       
   435         }
       
   436     else // aEvent == ELmkSelectorStop & dialog canceled
       
   437         {
       
   438         iSelectorState = ELmkCategorySelector;
       
   439         CLmkDlgSelectorImplBase& dlgselector = CurrentStateSelectorL();
       
   440         TInt categoryIndex( -1 );
       
   441         iDlgRetVal = dlgselector.ExecuteL( categoryIndex );
       
   442         iCategoryIndex = categoryIndex;
       
   443         return ELmkSelectorStop;
       
   444         }
       
   445     }
       
   446 
       
   447 // ----------------------------------------------------
       
   448 // CLmkDlgCombiSelectorImpl::HandleDefaultStateStateEventL
       
   449 // ----------------------------------------------------
       
   450 //
       
   451 CLmkDlgCombiSelectorImpl::TLmkSelectorStateEvent
       
   452 CLmkDlgCombiSelectorImpl::HandleDefaultStateStateEventL(
       
   453     TLmkSelectorStateEvent /*aEvent*/ )
       
   454     {
       
   455     return ELmkSelectorNoEvent;
       
   456     }
       
   457 
       
   458 // ----------------------------------------------------
       
   459 // CLmkDlgCombiSelectorImpl::SetupListProviderL
       
   460 // ----------------------------------------------------
       
   461 //
       
   462 void CLmkDlgCombiSelectorImpl::SetupListProviderL()
       
   463     {
       
   464     // This class does not create own provider
       
   465     }
       
   466 
       
   467 // ----------------------------------------------------
       
   468 // CLmkDlgCombiSelectorImpl::ListProvider
       
   469 // ----------------------------------------------------
       
   470 //
       
   471 const CLmkListProviderBase& CLmkDlgCombiSelectorImpl::ListProvider() const
       
   472     {
       
   473     if ( iSelectorState ==  ELmkCategorySelector )
       
   474         {
       
   475         return iSelectors[ELmkCategorySelector]->ListProvider();
       
   476         }
       
   477     else if ( iSelectorState ==  ELmkFilteredLmSelector )
       
   478         {
       
   479         return iSelectors[ELmkFilteredLmSelector]->ListProvider();
       
   480         }
       
   481     else // ELmkLandmarkSelector
       
   482         {
       
   483         return iSelectors[ELmkLandmarkSelector]->ListProvider();
       
   484         }
       
   485     }
       
   486 
       
   487 // ----------------------------------------------------
       
   488 // CLmkDlgCombiSelectorImpl::GetDlgResources
       
   489 // ----------------------------------------------------
       
   490 //
       
   491 void CLmkDlgCombiSelectorImpl::GetDlgResources(
       
   492     TBool /*aIsSingleSelector*/,
       
   493     TInt& aTitlePaneResource,
       
   494     TInt& aMenuBarResource,
       
   495     TInt& aDialogResource ) const
       
   496     {
       
   497     // This class does not define resources
       
   498     aTitlePaneResource = NULL;
       
   499     aMenuBarResource = NULL;
       
   500     aDialogResource = NULL;
       
   501     }
       
   502 
       
   503 // ----------------------------------------------------
       
   504 // CLmkDlgCombiSelectorImpl::StoreMemento
       
   505 // ----------------------------------------------------
       
   506 //
       
   507 void CLmkDlgCombiSelectorImpl::StoreMemento()
       
   508     {
       
   509     // This class does not store
       
   510     }
       
   511 
       
   512 // ----------------------------------------------------
       
   513 // CLmkDlgCombiSelectorImpl::RestoreMemento
       
   514 // ----------------------------------------------------
       
   515 //
       
   516 void CLmkDlgCombiSelectorImpl::RestoreMemento()
       
   517     {
       
   518     // This class does not restore
       
   519     }
       
   520 
       
   521 // ----------------------------------------------------
       
   522 // CLmkDlgCombiSelectorImpl::ProcessCommandL
       
   523 // ----------------------------------------------------
       
   524 //
       
   525 void CLmkDlgCombiSelectorImpl::ProcessCommandL( TInt /*aCommandId*/ )
       
   526     {
       
   527     // This class does not process cmds
       
   528     }
       
   529 
       
   530 // ----------------------------------------------------
       
   531 // CLmkDlgCombiSelectorImpl::HandleNavigationEventL
       
   532 // ----------------------------------------------------
       
   533 //
       
   534 TKeyResponse CLmkDlgCombiSelectorImpl::HandleNavigationEventL(
       
   535     const TKeyEvent& aKeyEvent )
       
   536     {
       
   537     __ASSERT_DEBUG( iTabGroup, Panic( KLmkPanicNullMember ) );
       
   538     // tab scroll key event handling is not needed 'Landmark Contents' view
       
   539     if ( iSelectorState ==  ELmkFilteredLmSelector)
       
   540 	    {
       
   541 	    return EKeyWasNotConsumed;
       
   542 	    }
       
   543 
       
   544     TInt active = iTabGroup->ActiveTabId();
       
   545     TBool shift = EFalse;
       
   546 
       
   547     if ( active == ETabCategoryList )
       
   548         {
       
   549         if(AknLayoutUtils::LayoutMirrored())
       
   550         	{
       
   551         	if(aKeyEvent.iCode == EKeyRightArrow)
       
   552         		{
       
   553         		shift = ETrue;
       
   554         		}
       
   555         	else
       
   556 	        	{//aKeyEvent.iCode == EKeyLeftArrow
       
   557 	        	shift = EFalse;
       
   558 	        	}
       
   559         	}
       
   560         else
       
   561         	{
       
   562         	if(aKeyEvent.iCode == EKeyLeftArrow)
       
   563         		{
       
   564         		shift = ETrue;
       
   565         		}
       
   566         	else
       
   567 	        	{//aKeyEvent.iCode == EKeyRightArrow
       
   568 	        	shift = EFalse;
       
   569 	        	}
       
   570         	}
       
   571 
       
   572         if(shift)
       
   573         	{
       
   574         	iTabGroup->SetActiveTabById( ETabLandmarkList );
       
   575 	        iNaviPane->PushL(*iNaviDeco);
       
   576 	        iNavigating = ETrue;
       
   577         	}
       
   578         else
       
   579 	        {// no need to set the tab id
       
   580 	        return EKeyWasNotConsumed;
       
   581 	        }
       
   582         }
       
   583     else if ( active == ETabLandmarkList )
       
   584         {
       
   585         TBool shift = EFalse;
       
   586         if(AknLayoutUtils::LayoutMirrored())
       
   587         	{
       
   588         	if(aKeyEvent.iCode == EKeyLeftArrow)
       
   589         		{
       
   590         		shift = ETrue;
       
   591         		}
       
   592         	else //aKeyEvent.iCode == EKeyRightArrow
       
   593 	        	{
       
   594 	        	shift = EFalse;
       
   595 	        	}
       
   596         	}
       
   597         else
       
   598         	{
       
   599         	if(aKeyEvent.iCode == EKeyRightArrow)
       
   600         		{
       
   601         		shift = ETrue;
       
   602         		}
       
   603         	else //aKeyEvent.iCode == EKeyLeftArrow
       
   604 	        	{
       
   605 	        	shift = EFalse;
       
   606 	        	}
       
   607         	}
       
   608 
       
   609         if(shift)
       
   610         	{
       
   611         	iTabGroup->SetActiveTabById( ETabCategoryList );
       
   612 	        iNaviPane->PushL(*iNaviDeco);
       
   613 	        iNavigating = ETrue;
       
   614         	}
       
   615         else // no need to set the tab id
       
   616 	        {
       
   617 	        return EKeyWasNotConsumed;
       
   618 	        }
       
   619         }
       
   620     else
       
   621         {
       
   622         return EKeyWasNotConsumed;
       
   623         }
       
   624     return EKeyWasConsumed;
       
   625     }
       
   626 
       
   627 // ----------------------------------------------------
       
   628 // CLmkDlgCombiSelectorImpl::HandleLaunchingEventL
       
   629 // ----------------------------------------------------
       
   630 //
       
   631 void CLmkDlgCombiSelectorImpl::HandleLaunchingEventL()
       
   632     {
       
   633     // This class does not do anything with this event
       
   634     }
       
   635 
       
   636 // ----------------------------------------------------
       
   637 // CLmkDlgCombiSelectorImpl::HandleClosingEventL
       
   638 // ----------------------------------------------------
       
   639 //
       
   640 void CLmkDlgCombiSelectorImpl::HandleClosingEventL()
       
   641     {
       
   642     // This class does not do anything with this event
       
   643     }
       
   644 
       
   645 CLmkDlgSelectorImplBase& CLmkDlgCombiSelectorImpl::CurrentStateSelectorL(
       
   646     TPosLmItemId aCategoryId )
       
   647     {
       
   648     __ASSERT_DEBUG( iSelectors.Count() == KLmkNumberOfSelectors,
       
   649                     Panic( KLmkPanicSelectorArrayIndex ) );
       
   650 
       
   651     CLmkDlgSelectorImplBase*& selector = iSelectors[iSelectorState];
       
   652     if ( selector == NULL )
       
   653         { // iSelector's pointer will be modified!
       
   654         if ( iSelectorState == ELmkLandmarkSelector )
       
   655             {
       
   656             selector = CLmkDlgLmSelectorImpl::NewL( iDb );
       
   657             if (iCustomLandmarksTitle) 
       
   658             		{
       
   659             		selector->CLmkDlgSelectorImplBase::SetDialogTitleL(*iCustomLandmarksTitle);
       
   660             		}
       
   661             }
       
   662         else if ( iSelectorState == ELmkCategorySelector )
       
   663             {
       
   664             // Don't show empty categories -> 2nd parameter EFalse
       
   665             selector = CLmkDlgCategorySelectorImpl::NewL( iDb, EFalse );
       
   666             }
       
   667         else //ELmkFilteredLmSelector
       
   668             {
       
   669             __ASSERT_DEBUG( iSelectorState == ELmkFilteredLmSelector,
       
   670                             Panic( KLmkPanicWrongSelector ) );
       
   671             CPosLmCategoryCriteria* criteria = CPosLmCategoryCriteria::NewLC();
       
   672             criteria->SetCategoryItemId( aCategoryId );
       
   673             selector = CLmkDlgLmSelectorImpl::NewL( iDb, criteria );
       
   674             if (iCustomLandmarksTitle) 
       
   675             		{
       
   676             		selector->CLmkDlgSelectorImplBase::SetDialogTitleL(*iCustomLandmarksTitle);	
       
   677             		}
       
   678             CleanupStack::Pop(); // criteria, ownership was transferred
       
   679             }
       
   680 
       
   681         selector->SetMopParent(iMopParent);
       
   682         selector->SetSelectorImplParent( this );
       
   683         selector->SetMemento( *( iMementos[iSelectorState] ) );
       
   684         selector->SetEmptyDlgLabel(iCurrentLabelPrimResource , iCurrentLabelSecResource);
       
   685         }
       
   686 
       
   687     return *selector;
       
   688     }
       
   689 
       
   690 // ----------------------------------------------------
       
   691 // CLmkDlgCombiSelectorImpl::AddTabsL
       
   692 // ----------------------------------------------------
       
   693 //
       
   694 void CLmkDlgCombiSelectorImpl::AddTabsL(CAknTabGroup& aTabGroup)
       
   695     {
       
   696     aTabGroup.SetTabFixedWidthL(EAknTabWidthWithTwoTabs);
       
   697 
       
   698     MAknsSkinInstance* skin = AknsUtils::SkinInstance();
       
   699 
       
   700     TFileName filename( KLmkSystemMbmPath );
       
   701     filename.Append(KLandmarksIconFileName);
       
   702 	CLmkUiUtils::GetFileWithCorrectDriveL( filename );
       
   703 
       
   704     //Add tab icon 1
       
   705     CFbsBitmap* lmkListBitmap = NULL;
       
   706     CFbsBitmap* lmkBitmapMask = NULL;
       
   707     
       
   708     AknsUtils::CreateIconLC( skin,
       
   709                             KAknsIIDQgnPropLmNamesTab2,
       
   710                             lmkListBitmap,
       
   711                             lmkBitmapMask,
       
   712                             /**filename*/filename,
       
   713                             EMbmLandmarksQgn_prop_lm_names_tab2,
       
   714                             EMbmLandmarksQgn_prop_lm_names_tab2_mask );
       
   715 
       
   716     CleanupStack::Pop(2); //lmkListBitmap, lmkBitmapMask
       
   717 
       
   718     //Add tab icon 2
       
   719     CFbsBitmap* lmkCatBitmap = NULL;
       
   720     CFbsBitmap* lmkCatBitmapMask = NULL;
       
   721 
       
   722     AknsUtils::CreateIconLC( skin,
       
   723                             KAknsIIDQgnPropLmCategoriesTab2,
       
   724                             lmkCatBitmap,
       
   725                             lmkCatBitmapMask,
       
   726                             /* *filename */filename,
       
   727                             EMbmLandmarksQgn_prop_lm_categories_tab2,
       
   728                             EMbmLandmarksQgn_prop_lm_categories_tab2_mask );
       
   729 
       
   730     CleanupStack::Pop(2); //lmkCatBitmap, lmkCatBitmapMask
       
   731 
       
   732     if(AknLayoutUtils::LayoutMirrored())
       
   733     	{
       
   734     	aTabGroup.AddTabL(ETabCategoryList, lmkCatBitmap, lmkCatBitmapMask); // ELmkByCategoryView
       
   735     	aTabGroup.AddTabL( ETabLandmarkList, lmkListBitmap, lmkBitmapMask ); //ELmkByLmView
       
   736     	}
       
   737     else
       
   738     	{
       
   739     	aTabGroup.AddTabL( ETabLandmarkList, lmkListBitmap, lmkBitmapMask ); //ELmkByLmView
       
   740     	aTabGroup.AddTabL(ETabCategoryList, lmkCatBitmap, lmkCatBitmapMask); // ELmkByCategoryView
       
   741     	}
       
   742     }
       
   743 
       
   744 // ----------------------------------------------------------------------------
       
   745 // CLmkDlgCombiSelectorImpl::GetBitmapFilenameL
       
   746 // ----------------------------------------------------------------------------
       
   747 //
       
   748 HBufC* CLmkDlgCombiSelectorImpl::GetBitmapFilenameLC()
       
   749 	{
       
   750 	// Path and file name:
       
   751 	HBufC* filename = HBufC::NewLC( KMaxFileName);
       
   752 	TPtr fileNamePtr = 	filename->Des();
       
   753 	fileNamePtr.Append(KLmkSystemMbmPath);
       
   754 	fileNamePtr.Append(KLandmarksIconFileName);
       
   755 
       
   756 	TBuf<20> aApp; // Holds drive name where the file is stored
       
   757 	CEikAppUi *appUi = (CEikAppUi *)(iEnv->AppUi());
       
   758 	HBufC* fullPath = HBufC::NewLC( KMaxFileName);
       
   759 	*fullPath = appUi->Application()->AppFullName();
       
   760 	TPtr fullPathPtr =  fullPath->Des();
       
   761 	TParsePtr ptr(fullPathPtr);
       
   762 	aApp.Copy(ptr.Drive());
       
   763 
       
   764 	// Add drive to path & file name:
       
   765 	TParse parse;
       
   766 	User::LeaveIfError( parse.Set( fileNamePtr, &aApp, NULL ) );
       
   767 	CleanupStack::PopAndDestroy(2); // fullPath, filename
       
   768 	return parse.FullName().AllocLC();
       
   769 	}
       
   770 
       
   771 // ----------------------------------------------------------------------------
       
   772 // CLmkDlgCombiSelectorImpl::TabChangedL
       
   773 // ----------------------------------------------------------------------------
       
   774 //
       
   775 void CLmkDlgCombiSelectorImpl::TabChangedL( TInt /*aIndex*/ )
       
   776 	{
       
   777 	iNaviPane->PushL(*iNaviDeco);
       
   778 	iNavigating = ETrue;
       
   779 
       
   780 	TInt active = iTabGroup->ActiveTabId();
       
   781 
       
   782 	if ( active == ETabCategoryList ) // After tab change, ETabCategoryList tab is active
       
   783 		{
       
   784 		iSelectors[ETabLandmarkList]->StopExecutionL();
       
   785 		iSelectorState = ELmkLandmarkSelector;
       
   786 		}
       
   787 	else if( active == ETabLandmarkList ) // After tab change, ETabLandmarkList tab is active
       
   788 		{
       
   789 		iSelectors[ETabCategoryList]->StopExecutionL();
       
   790 		iSelectorState = ELmkCategorySelector;
       
   791 		}
       
   792 	}
       
   793 	
       
   794 // ----------------------------------------------------------------------------
       
   795 // CLmkDlgCombiSelectorImpl::SetDialogTitleL
       
   796 // ----------------------------------------------------------------------------
       
   797 //
       
   798 void CLmkDlgCombiSelectorImpl::SetDialogTitleL(const TDesC& aTitle)
       
   799     {
       
   800     delete iCustomLandmarksTitle;
       
   801     iCustomLandmarksTitle = NULL;
       
   802     iCustomLandmarksTitle = aTitle.AllocL();
       
   803     }
       
   804 
       
   805 		
       
   806 //  End of File