phonebookui/Phonebook2/USIMExtension/src/CPsu2NameListViewBase.cpp
changeset 0 e686773b3f54
child 35 4ae315f230bc
equal deleted inserted replaced
-1:000000000000 0:e686773b3f54
       
     1 /*
       
     2 * Copyright (c) 2002-2007 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:  A base class for sim name list views
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include "CPsu2NameListViewBase.h"
       
    20 
       
    21 // Phonebook2
       
    22 #include "CPsu2ViewManager.h"
       
    23 #include <CPbk2AppUiBase.h>
       
    24 #include <CPbk2ControlContainer.h>
       
    25 #include <CPbk2NamesListControl.h>
       
    26 #include <CPbk2UIExtensionView.h>
       
    27 #include <MPbk2CommandHandler.h>
       
    28 #include <CPbk2ViewState.h>
       
    29 #include <CPbk2IconInfoContainer.h>
       
    30 #include <CPbk2IconFactory.h>
       
    31 #include <Pbk2USimUIRes.rsg>
       
    32 #include <Pbk2CommonUi.rsg>
       
    33 #include <Pbk2UIControls.rsg>
       
    34 #include <MPbk2ViewExplorer.h>
       
    35 #include <csxhelp/phob.hlp.hrh>
       
    36 #include <CPbk2SortOrderManager.h>
       
    37 #include <Pbk2ContactNameFormatterFactory.h>
       
    38 #include <MPbk2ContactNameFormatter.h>
       
    39 #include <MPbk2PointerEventInspector.h>
       
    40 #include <MPbk2ApplicationServices.h>
       
    41 
       
    42 
       
    43 // Virtual Phonebook
       
    44 #include <MVPbkContactViewBase.h>
       
    45 #include <CVPbkContactManager.h>
       
    46 
       
    47 // System includes
       
    48 #include <avkon.rsg>
       
    49 #include <eikbtgpc.h>
       
    50 #include <AknsUtils.h>
       
    51 #include <AknUtils.h>
       
    52 #include <AknIconUtils.h>
       
    53 #include <aknlayout.cdl.h>
       
    54 #include <StringLoader.h>
       
    55 #include <barsread.h>
       
    56 
       
    57 
       
    58 /// Unnamed namespace for local definitions
       
    59 namespace {
       
    60 
       
    61 /**
       
    62  * Returns ETrue if either Shift or Control key is depressed.
       
    63  *
       
    64  * @param aKeyEvent Key event.
       
    65  * @return  ETrue if shift or control is down.
       
    66  */
       
    67 inline TBool IsShiftOrControlDown( const TKeyEvent& aKeyEvent )
       
    68     {
       
    69     return ( aKeyEvent.iModifiers &
       
    70         ( EModifierShift | EModifierLeftShift | EModifierRightShift |
       
    71           EModifierCtrl | EModifierLeftCtrl | EModifierRightCtrl ) ) != 0;
       
    72     }
       
    73 
       
    74 }  /// namespace
       
    75 
       
    76 
       
    77 // ============================ MEMBER FUNCTIONS ===============================
       
    78 
       
    79 // -----------------------------------------------------------------------------
       
    80 // CPsu2NameListViewBase::TContextPaneIcon::TContextPaneIcon
       
    81 // C++ default constructor can NOT contain any code, that
       
    82 // might leave.
       
    83 // -----------------------------------------------------------------------------
       
    84 //
       
    85 CPsu2NameListViewBase::TContextPaneIcon::TContextPaneIcon(TPsu2SimIconId aIconId)
       
    86 :   iIconId( aIconId )
       
    87     {
       
    88     }
       
    89 
       
    90 // -----------------------------------------------------------------------------
       
    91 // CPsu2NameListViewBase::TContextPaneIcon::CreateLC
       
    92 // -----------------------------------------------------------------------------
       
    93 //
       
    94 CEikImage* CPsu2NameListViewBase::TContextPaneIcon::CreateLC()
       
    95     {
       
    96     CEikImage* image = new(ELeave) CEikImage;
       
    97     CleanupStack::PushL( image );
       
    98 
       
    99     CPbk2IconInfoContainer* iconInfoContainer =
       
   100         CPbk2IconInfoContainer::NewL( R_PSU2_ICON_INFO_ARRAY );
       
   101     CleanupStack::PushL( iconInfoContainer );
       
   102     CPbk2IconFactory* factory = CPbk2IconFactory::NewLC( *iconInfoContainer );
       
   103 
       
   104     CFbsBitmap* bitmap = NULL;
       
   105     CFbsBitmap* mask = NULL;
       
   106     factory->CreateIconL( iIconId, *AknsUtils::SkinInstance(), bitmap, mask );
       
   107     SetSize( *bitmap, *mask );
       
   108     image->SetNewBitmaps( bitmap, mask );
       
   109 
       
   110     CleanupStack::PopAndDestroy(2); // factory, iconInfoContainer
       
   111     return image;
       
   112     }
       
   113 
       
   114 // -----------------------------------------------------------------------------
       
   115 // CPsu2NameListViewBase::TContextPaneIcon::SetSize
       
   116 // -----------------------------------------------------------------------------
       
   117 //
       
   118 void CPsu2NameListViewBase::TContextPaneIcon::SetSize(CFbsBitmap& aBitmap,
       
   119     CFbsBitmap& aMask )
       
   120     {
       
   121     TAknLayoutRect statuspane;
       
   122     statuspane.LayoutRect(iAvkonAppUi->ApplicationRect(),
       
   123         AknLayout::status_pane(iAvkonAppUi->ApplicationRect(),0));
       
   124 
       
   125     // context pane
       
   126     TAknWindowLineLayout contextPaneLayout =
       
   127         AknLayout::context_pane(statuspane.Rect(), 0);
       
   128     TAknLayoutRect contextPaneLayoutRect;
       
   129     contextPaneLayoutRect.LayoutRect(statuspane.Rect(), contextPaneLayout);
       
   130     TRect contextPaneRect = contextPaneLayoutRect.Rect();
       
   131 
       
   132     AknIconUtils::SetSize( &aBitmap, contextPaneRect.Size() );
       
   133     AknIconUtils::SetSize( &aMask, contextPaneRect.Size() );
       
   134     }
       
   135 
       
   136 // -----------------------------------------------------------------------------
       
   137 // CPsu2NameListViewBase::CPsu2NameListViewBase
       
   138 // C++ default constructor can NOT contain any code, that
       
   139 // might leave.
       
   140 // -----------------------------------------------------------------------------
       
   141 //
       
   142 CPsu2NameListViewBase::CPsu2NameListViewBase
       
   143         ( CPbk2UIExtensionView& aExtensionView,
       
   144           CPsu2ViewManager& aViewManager) :
       
   145             iExtensionView( aExtensionView ),
       
   146             iViewManager( aViewManager ),
       
   147             iFocusIndex( KErrNotFound )
       
   148     {
       
   149     }
       
   150 
       
   151 // -----------------------------------------------------------------------------
       
   152 // CPsu2NameListViewBase::~CPsu2NameListViewBase
       
   153 // -----------------------------------------------------------------------------
       
   154 //
       
   155 CPsu2NameListViewBase::~CPsu2NameListViewBase()
       
   156     {
       
   157     delete iControlState;
       
   158 
       
   159     if (iContainer)
       
   160         {
       
   161         CCoeEnv::Static()->AppUi()->RemoveFromStack( iContainer );
       
   162         delete iContainer;
       
   163         }
       
   164     delete iNameFormatter;
       
   165     delete iSortOrderManager;
       
   166     }
       
   167 
       
   168 
       
   169 // -----------------------------------------------------------------------------
       
   170 // CPsu2NameListViewBase::UpdateListEmptyTextL
       
   171 // -----------------------------------------------------------------------------
       
   172 //
       
   173 void CPsu2NameListViewBase::UpdateListEmptyTextL( TInt aListState )
       
   174     {    
       
   175     switch ( aListState )
       
   176         {            
       
   177         case CPbk2NamesListControl::EStateEmpty:                
       
   178             {
       
   179             HBufC* text = StringLoader::LoadLC( R_QTN_SELEC_EMPTY_LIST );
       
   180             if ( iControl )
       
   181                 {
       
   182                 iControl->SetTextL( *text );                
       
   183                 }
       
   184             CleanupStack::PopAndDestroy( text );
       
   185             break;
       
   186             }
       
   187         case CPbk2NamesListControl::EStateReady: // FALLTHROUGH                    
       
   188         case CPbk2NamesListControl::EStateFiltered:
       
   189             {
       
   190             HBufC* text = StringLoader::LoadLC( R_PBK2_FIND_NO_MATCHES );
       
   191             if ( iControl )
       
   192                 {
       
   193                 iControl->SetTextL( *text );                
       
   194                 }
       
   195             CleanupStack::PopAndDestroy( text );
       
   196             break;
       
   197             }
       
   198         case CPbk2NamesListControl::EStateNotReady: // FALLTHROUGH
       
   199         default:
       
   200             {            
       
   201             if ( iControl )
       
   202                 {
       
   203                 iControl->SetTextL( KNullDesC );                
       
   204                 }
       
   205             break;
       
   206             }
       
   207         }
       
   208     }
       
   209 
       
   210 // -----------------------------------------------------------------------------
       
   211 // CPsu2NameListViewBase::HandleStatusPaneSizeChange
       
   212 // -----------------------------------------------------------------------------
       
   213 //
       
   214 void CPsu2NameListViewBase::HandleStatusPaneSizeChange()
       
   215     {
       
   216     // Resize the container to fill the client rectangle
       
   217     if (iContainer)
       
   218         {
       
   219         iContainer->SetRect(iExtensionView.ClientRect());
       
   220         }
       
   221     }
       
   222 
       
   223 // -----------------------------------------------------------------------------
       
   224 // CPsu2NameListViewBase::ViewStateLC
       
   225 // -----------------------------------------------------------------------------
       
   226 //
       
   227 CPbk2ViewState* CPsu2NameListViewBase::ViewStateLC() const
       
   228     {
       
   229     CPbk2ViewState* state = NULL;
       
   230     if (iControl)
       
   231         {
       
   232         state = iControl->ControlStateL();
       
   233         }
       
   234 
       
   235     CleanupStack::PushL(state);
       
   236     return state;
       
   237     }
       
   238 
       
   239 // -----------------------------------------------------------------------------
       
   240 // CPsu2NameListViewBase::HandleCommandKeyL
       
   241 // -----------------------------------------------------------------------------
       
   242 //
       
   243 TBool CPsu2NameListViewBase::HandleCommandKeyL(const TKeyEvent& aKeyEvent,
       
   244         TEventCode aType)
       
   245     {
       
   246     // Update selection modifier key state
       
   247     iSelectionModifierUsed = IsShiftOrControlDown( aKeyEvent ) ||
       
   248         ( (aType == EEventKeyDown) && (aKeyEvent.iCode == EStdKeyHash) );
       
   249 
       
   250     return EFalse;
       
   251     }
       
   252 
       
   253 // -----------------------------------------------------------------------------
       
   254 // CPsu2NameListViewBase::HandlePointerEventL
       
   255 // -----------------------------------------------------------------------------
       
   256 //
       
   257 void CPsu2NameListViewBase::HandlePointerEventL(
       
   258         const TPointerEvent& /*aPointerEvent*/ )
       
   259     {
       
   260     // Do nothing
       
   261     }
       
   262 
       
   263 // -----------------------------------------------------------------------------
       
   264 // CPsu2NameListViewBase::GetViewSpecificMenuFilteringFlagsL
       
   265 // -----------------------------------------------------------------------------
       
   266 //
       
   267 TInt CPsu2NameListViewBase::GetViewSpecificMenuFilteringFlagsL() const
       
   268     {
       
   269     TInt flags = 0;
       
   270     if ( iControl )
       
   271         {
       
   272         flags = iControl->GetMenuFilteringFlagsL();
       
   273         }
       
   274         
       
   275     return flags;
       
   276     }
       
   277 
       
   278 // -----------------------------------------------------------------------------
       
   279 // CPsu2NameListViewBase::DoActivateL
       
   280 // -----------------------------------------------------------------------------
       
   281 //
       
   282 void CPsu2NameListViewBase::DoActivateL(const TVwsViewId& aPrevViewId,
       
   283             TUid /*aCustomMessageId*/, const TDesC8& /*aCustomMessage*/)
       
   284     {
       
   285     MPbk2ApplicationServices& appServices =
       
   286         Phonebook2::Pbk2AppUi()->ApplicationServices();
       
   287 
       
   288     iSortOrderManager = CPbk2SortOrderManager::NewL
       
   289         ( appServices.ContactManager().FieldTypes() );
       
   290 
       
   291     HBufC* unnamedBuf = StringLoader::LoadLC( R_QTN_PHOB_UNNAMED );
       
   292 
       
   293     TResourceReader reader;
       
   294     CCoeEnv::Static()->CreateResourceReaderLC( reader,
       
   295         R_PSU2_FDN_TITLE_FIELD_SELECTOR);
       
   296     iNameFormatter = Pbk2ContactNameFormatterFactory::CreateL
       
   297         ( appServices.ContactManager().FieldTypes(),
       
   298           *iSortOrderManager,
       
   299           reader,
       
   300           unnamedBuf,
       
   301           &appServices.ContactManager().FsSession() );
       
   302     CleanupStack::PopAndDestroy(); // reader
       
   303     CleanupStack::PopAndDestroy( unnamedBuf );
       
   304     iSortOrderManager->SetContactViewL( iViewManager.CurrentSimView() );
       
   305 
       
   306     // Add this view to observe command events
       
   307     appServices.CommandHandlerL()->AddMenuCommandObserver(*this);
       
   308 
       
   309     CreateControlsL();
       
   310     iContainer->ActivateL();
       
   311     UpdateListEmptyTextL( CPbk2NamesListControl::EStateNotReady );
       
   312     if( aPrevViewId.iViewUid != TUid::Uid( EPsu2FixedDialingInfoViewId ) )
       
   313       	{
       
   314         // Clean up the old view control state 
       
   315         // so that it will be a brand new control 
       
   316       	// when the FD view is activated from non-fix dialling area
       
   317         delete iControlState;
       
   318         iControlState  = NULL;
       
   319         iFocusIndex = KErrNotFound;   	
       
   320         }
       
   321     iViewManager.CurrentSimView().AddObserverL(*iControl);
       
   322     iViewManager.RegisterStoreAndView();
       
   323     }
       
   324 
       
   325 // -----------------------------------------------------------------------------
       
   326 // CPsu2NameListViewBase::DoDeactivate
       
   327 // -----------------------------------------------------------------------------
       
   328 //
       
   329 void CPsu2NameListViewBase::DoDeactivate()
       
   330     {
       
   331     delete iNameFormatter;
       
   332     iNameFormatter = NULL;
       
   333     delete iSortOrderManager;
       
   334     iSortOrderManager = NULL;
       
   335 
       
   336     TRAP_IGNORE(
       
   337         Phonebook2::Pbk2AppUi()->ApplicationServices().CommandHandlerL()->
       
   338             RemoveMenuCommandObserver(*this) );
       
   339 
       
   340     delete iControlState;
       
   341     iControlState = NULL;
       
   342 
       
   343     if (iContainer)
       
   344         {
       
   345         iViewManager.CurrentSimView().RemoveObserver(*iControl);
       
   346         CCoeEnv::Static()->AppUi()->RemoveFromStack(iContainer);
       
   347         // Store current state, safe to ignore. There's no real harm,
       
   348         // if theres no stored state when activating this view again
       
   349         TRAP_IGNORE(StoreStateL());
       
   350         delete iContainer;
       
   351         iContainer = NULL;
       
   352         // iControl is owned by iContainer it is deleted with container
       
   353         iControl = NULL;
       
   354         }
       
   355 
       
   356     iViewManager.DeregisterStoreAndView();
       
   357     }
       
   358 
       
   359 // -----------------------------------------------------------------------------
       
   360 // CPsu2NameListViewBase::HandleCommandL
       
   361 // -----------------------------------------------------------------------------
       
   362 //
       
   363 void CPsu2NameListViewBase::HandleCommandL(TInt aCommand)
       
   364     {
       
   365     if ( aCommand == EPbk2CmdExit || aCommand == EAknSoftkeyBack
       
   366          || aCommand == EPbk2CmdOpenPreviousView || aCommand == EAknCmdHideInBackground )
       
   367         {
       
   368         // Initialize this view control state
       
   369         delete iControlState;
       
   370         iControlState  = NULL;
       
   371         iControlState = CPbk2ViewState::NewL();
       
   372         iControlState->SetFlags( CPbk2ViewState::EInitialized );
       
   373         iFocusIndex = KErrNotFound;
       
   374         RestoreStateL();
       
   375         }
       
   376         
       
   377     if ( iControl )
       
   378         {
       
   379         // No command handling in this class, forward to Commands
       
   380         if ( !Phonebook2::Pbk2AppUi()->ApplicationServices().
       
   381               CommandHandlerL()->HandleCommandL
       
   382                 (aCommand, *iControl, &iExtensionView))
       
   383             {
       
   384             iControl->ProcessCommandL(aCommand);
       
   385             Phonebook2::Pbk2AppUi()->HandleCommandL(aCommand);
       
   386             // Update cbas, if command handler is consuming the command
       
   387             // postcommandexecution is updating cbas
       
   388             UpdateCbasL();
       
   389             }        
       
   390         }
       
   391     }
       
   392 
       
   393 // -----------------------------------------------------------------------------
       
   394 // CPsu2NameListViewBase::DynInitMenuPaneL
       
   395 // -----------------------------------------------------------------------------
       
   396 //
       
   397 void CPsu2NameListViewBase::DynInitMenuPaneL(TInt aResourceId,
       
   398         CEikMenuPane* aMenuPane)
       
   399     {
       
   400     if ( iControl )
       
   401         {
       
   402         // Ask the control do control specific filtering
       
   403         // (for example call HandleMarkableListDynInitMenuPane if needed)
       
   404         iControl->DynInitMenuPaneL(aResourceId, aMenuPane);
       
   405 
       
   406         // Phonebook 2 menu filtering happens in Commands
       
   407         Phonebook2::Pbk2AppUi()->ApplicationServices().
       
   408             CommandHandlerL()->DynInitMenuPaneL
       
   409                 ( aResourceId, aMenuPane, iExtensionView, *iControl );        
       
   410         }
       
   411     }
       
   412 
       
   413 // -----------------------------------------------------------------------------
       
   414 // CPsu2NameListViewBase::HandleLongTapEventL
       
   415 // -----------------------------------------------------------------------------
       
   416 //
       
   417 void CPsu2NameListViewBase::HandleLongTapEventL(
       
   418         const TPoint& /*aPenEventLocation*/,
       
   419         const TPoint& /*aPenEventScreenLocation*/)
       
   420     {
       
   421     // Do nothing
       
   422     }
       
   423 
       
   424 // -----------------------------------------------------------------------------
       
   425 // CPsu2NameListViewBase::HandleControlEventL
       
   426 // -----------------------------------------------------------------------------
       
   427 //
       
   428 void CPsu2NameListViewBase::HandleControlEventL(
       
   429         MPbk2ContactUiControl& /*aControl*/,
       
   430         const TPbk2ControlEvent& aEvent)
       
   431     {
       
   432     switch (aEvent.iEventType)
       
   433         {
       
   434         case TPbk2ControlEvent::EReady:
       
   435             {
       
   436             UpdateCbasL();
       
   437             UpdateListEmptyTextL( aEvent.iInt );
       
   438             // Restore control state
       
   439             RestoreStateL();
       
   440             break;
       
   441             }
       
   442 
       
   443         case TPbk2ControlEvent::EContactSetChanged:
       
   444             {
       
   445             if ( iControl )
       
   446                 {
       
   447                 iControl->DrawNow();
       
   448                 }            
       
   449             break;
       
   450             }
       
   451 
       
   452         case TPbk2ControlEvent::EControlStateChanged:   // FALLTHROUGH
       
   453         case TPbk2ControlEvent::EContactSelected:   // FALLTHROUGH
       
   454         case TPbk2ControlEvent::EContactUnselected: // FALLTHROUGH
       
   455         case TPbk2ControlEvent::EContactUnselectedAll:  // FALLTHROUGH
       
   456         case TPbk2ControlEvent::EItemRemoved:
       
   457             {
       
   458             UpdateCbasL();
       
   459             UpdateListEmptyTextL( aEvent.iInt );
       
   460             if ( iControl )
       
   461                 {
       
   462                 iControl->DrawDeferred();
       
   463                 }            
       
   464             break;
       
   465             }
       
   466 
       
   467         default:
       
   468             {
       
   469             // Do nothing
       
   470             break;
       
   471             }
       
   472         }
       
   473     }
       
   474 
       
   475 // --------------------------------------------------------------------------
       
   476 // CPsu2NameListViewBase::PreCommandExecutionL
       
   477 // --------------------------------------------------------------------------
       
   478 //
       
   479 void CPsu2NameListViewBase::PreCommandExecutionL
       
   480         ( const MPbk2Command& /*aCommand*/ )
       
   481     {
       
   482     iCommandBetweenPreAndPostExecution = ETrue;
       
   483     }
       
   484 
       
   485 // --------------------------------------------------------------------------
       
   486 // CPsu2NameListViewBase::PostCommandExecutionL
       
   487 // --------------------------------------------------------------------------
       
   488 //
       
   489 void CPsu2NameListViewBase::PostCommandExecutionL
       
   490         ( const MPbk2Command& /*aCommand*/ )
       
   491     {
       
   492     iCommandBetweenPreAndPostExecution = EFalse;
       
   493     UpdateCbasL();
       
   494     }
       
   495 
       
   496 // -----------------------------------------------------------------------------
       
   497 // CPsu2NameListViewBase::CreateControlsL
       
   498 // -----------------------------------------------------------------------------
       
   499 //
       
   500 void CPsu2NameListViewBase::CreateControlsL()
       
   501     {
       
   502     if (!iContainer)
       
   503         {
       
   504         // Create the container and control
       
   505         CContainer* container = CContainer::NewLC(
       
   506             &iExtensionView,
       
   507             &iExtensionView,
       
   508             iExtensionView);
       
   509 
       
   510         container->SetHelpContext(
       
   511             TCoeHelpContext( iExtensionView.ApplicationUid(),
       
   512                              KPHOB_HLP_NAME_LIST ));
       
   513 
       
   514         CPbk2NamesListControl* control = CPbk2NamesListControl::NewL(
       
   515                 NameListControlResourceId(), container,
       
   516                 Phonebook2::Pbk2AppUi()->ApplicationServices().
       
   517                     ContactManager(),
       
   518                 iViewManager.CurrentSimView(),
       
   519                 *iNameFormatter,
       
   520                 Phonebook2::Pbk2AppUi()->ApplicationServices().
       
   521                     StoreProperties() );
       
   522         CleanupStack::PushL(control);
       
   523         control->AddObserverL(*this);
       
   524 
       
   525         // takes ownership of the control
       
   526         container->SetControl(control, iExtensionView.ClientRect());
       
   527         CleanupStack::Pop(control);
       
   528 
       
   529         CCoeEnv::Static()->AppUi()->AddToStackL(iExtensionView, container);
       
   530         CleanupStack::Pop(container);
       
   531         iContainer = container;
       
   532         iControl = control;
       
   533         iPointerEventInspector = control;
       
   534         }
       
   535     }
       
   536 
       
   537 // -----------------------------------------------------------------------------
       
   538 // CPsu2NameListViewBase::StoreStateL
       
   539 // -----------------------------------------------------------------------------
       
   540 //
       
   541 void CPsu2NameListViewBase::StoreStateL()
       
   542     {
       
   543     CPbk2ViewState* state = NULL;
       
   544     if ( iControl )
       
   545         {
       
   546         state = iControl->ControlStateL();        
       
   547         }
       
   548         
       
   549     if ( state )
       
   550         {
       
   551         delete iControlState;
       
   552         iControlState = state;
       
   553         }
       
   554     if ( iControl )
       
   555         {
       
   556         // If contact is deleted in other view
       
   557         // this will keep focus correct
       
   558         iFocusIndex = iControl->FocusedContactIndex();
       
   559         }
       
   560     }
       
   561 
       
   562 // -----------------------------------------------------------------------------
       
   563 // CPsu2NameListViewBase::RestoreStateL
       
   564 // -----------------------------------------------------------------------------
       
   565 //
       
   566 void CPsu2NameListViewBase::RestoreStateL()
       
   567     {
       
   568     if ( iControl )
       
   569         {
       
   570         iControl->RestoreControlStateL(iControlState);        
       
   571         }
       
   572         
       
   573     if ( iFocusIndex != KErrNotFound && iControlState )
       
   574         {
       
   575         // If contact has been deleted in other view
       
   576         // this will keep focus correct
       
   577         if ( iControlState->FocusedContact() )
       
   578             {
       
   579             TInt indexOfContact(
       
   580                 iViewManager.CurrentSimView().IndexOfLinkL(
       
   581                     *iControlState->FocusedContact() ) );
       
   582             if ( iControl && indexOfContact == KErrNotFound )
       
   583                 {
       
   584                 iControl->SetFocusedContactIndexL( iFocusIndex );                
       
   585                 }
       
   586             }
       
   587         }
       
   588     delete iControlState;
       
   589     iControlState = NULL;
       
   590     }
       
   591 
       
   592 //  End of File