phonebookui/Phonebook2/GroupExtension/src/CPguGroupMembersView.cpp
branchRCL_3
changeset 63 f4a778e096c2
child 64 c1e8ba0c2b16
child 68 9da50d567e3c
equal deleted inserted replaced
62:5b6f26637ad3 63:f4a778e096c2
       
     1 /*
       
     2 * Copyright (c) 2006-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:  Phonebook 2 group members view.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include "CPguGroupMembersView.h"
       
    20 
       
    21 // Phonebook 2
       
    22 #include "CPguAddMembersCmd.h"
       
    23 #include "CPguRemoveFromGroupCmd.h"
       
    24 #include "Pbk2GroupUi.hrh"
       
    25 #include <Pbk2GroupUIRes.rsg>
       
    26 #include <CPbk2AppUiBase.h>
       
    27 #include <Pbk2Commands.rsg>
       
    28 #include <CPbk2UIExtensionView.h>
       
    29 #include <CPbk2DocumentBase.h>
       
    30 #include <CPbk2NamesListControl.h>
       
    31 #include <CPbk2ViewState.h>
       
    32 #include <CPbk2ControlContainer.h>
       
    33 #include <MPbk2ViewActivationTransaction.h>
       
    34 #include <MPbk2ViewExplorer.h>
       
    35 #include <MPbk2CommandHandler.h>
       
    36 #include <CPbk2SortOrderManager.h>
       
    37 #include <MPbk2ContactNavigation.h>
       
    38 #include <MPbk2ContactNavigationLoader.h>
       
    39 #include <Pbk2NavigatorFactory.h>
       
    40 #include <Pbk2Commands.hrh>
       
    41 #include <MPbk2ContactNameFormatter.h>
       
    42 #include <CPbk2ViewStateTransformer.h>
       
    43 #include <csxhelp/phob.hlp.hrh>
       
    44 #include <Pbk2UID.h>
       
    45 #include <MPbk2StartupMonitor.h>
       
    46 #include <MVPbkContactViewObserver.h>
       
    47 #include <CPbk2ContactUiControlSubstitute.h>
       
    48 #include <MPbk2StoreConfigurationObserver.h>
       
    49 #include <MPbk2ControlObserver.h>
       
    50 #include <MPbk2NavigationObserver.h>
       
    51 #include <MPbk2MenuCommandObserver.h>
       
    52 #include <Pbk2CommonUi.rsg>
       
    53 #include <Pbk2UIControls.rsg>
       
    54 #include <MPbk2PointerEventInspector.h>
       
    55 #include <MPbk2ApplicationServices.h>
       
    56 #include <MPbk2ContactViewSupplier.h>
       
    57 #include <CPbk2StoreConfiguration.h>
       
    58 #include <MPbk2AppUi.h>
       
    59 #include <Pbk2MenuFilteringFlags.hrh>
       
    60 
       
    61 // Virtual Phonebook
       
    62 #include <MVPbkContactViewBase.h>
       
    63 #include <MVPbkViewContact.h>
       
    64 #include <MVPbkExpandable.h>
       
    65 #include <MVPbkContactLink.h>
       
    66 #include <CVPbkContactStoreUriArray.h>
       
    67 #include <CVPbkContactManager.h>
       
    68 #include <MVPbkContactStoreList.h>
       
    69 #include <MVPbkContactStore.h>
       
    70 #include <MVPbkContactStoreProperties.h>
       
    71 
       
    72 // System includes
       
    73 #include <akntitle.h>
       
    74 #include <eikbtgpc.h>
       
    75 #include <avkon.rsg>
       
    76 #include <aknnavide.h>
       
    77 #include <akntabgrp.h>
       
    78 #include <StringLoader.h>
       
    79 #include <AknUtils.h>
       
    80 #include <eiklbx.h>
       
    81 #include <eiklbo.h>
       
    82 #include <touchfeedback.h>
       
    83 
       
    84 
       
    85 /// Unnamed namespace for local definitions
       
    86 namespace {
       
    87 
       
    88 const TInt KFirstItem = 0; // First item index
       
    89 
       
    90 /**
       
    91  * Returns ETrue if shift is depressed in aKeyEvent.
       
    92  *
       
    93  * @param aKeyEvent     Key event.
       
    94  * @return  ETrue if shift is depressed.
       
    95  */
       
    96 inline TBool ShiftDown( const TKeyEvent& aKeyEvent )
       
    97     {
       
    98     return ( ( aKeyEvent.iModifiers ) &
       
    99              ( EModifierShift|EModifierLeftShift|EModifierRightShift )
       
   100                 ) != 0;
       
   101     }
       
   102 
       
   103 /**
       
   104  * Returns ETrue if either Shift or Control key is depressed.
       
   105  *
       
   106  * @param aKeyEvent Key event.
       
   107  * @return  ETrue if shift or control is down.
       
   108  */
       
   109 inline TBool IsShiftOrControlDown( const TKeyEvent& aKeyEvent )
       
   110     {
       
   111     return ( aKeyEvent.iModifiers &
       
   112         ( EModifierShift | EModifierLeftShift | EModifierRightShift |
       
   113           EModifierCtrl | EModifierLeftCtrl | EModifierRightCtrl ) ) != 0;
       
   114     }
       
   115 
       
   116 /**
       
   117  * Phonebook 2 group members transaction.
       
   118  * Encapsulates the information that is needed
       
   119  * to switch from group to group viewing.
       
   120  */
       
   121 class CGroupMembersViewTransaction : public CBase
       
   122     {
       
   123     public: // Construction and destruction
       
   124 
       
   125         /**
       
   126          * Creates new instance of this class.
       
   127          *
       
   128          * @return  A new instace of this class.
       
   129          */
       
   130         static CGroupMembersViewTransaction* NewLC();
       
   131 
       
   132         /**
       
   133          * Destructor
       
   134          */
       
   135         ~CGroupMembersViewTransaction();
       
   136 
       
   137     public: // Interface
       
   138 
       
   139         /**
       
   140          * Sets group members view.
       
   141          *
       
   142          * @param aGroupMembersView     Group members view to set.
       
   143          */
       
   144         void SetGroupMembersView(
       
   145                 MVPbkContactViewBase* aGroupMembersView );
       
   146 
       
   147         /**
       
   148          * Set group's name.
       
   149          *
       
   150          * @param aGroupName        Group name to set.
       
   151          */
       
   152         void SetGroupName(
       
   153                 HBufC* aGroupName );
       
   154 
       
   155         /**
       
   156          * Sets group link.
       
   157          *
       
   158          * @param aGroupLink Group link to set.
       
   159          */
       
   160         void SetGroupLink(
       
   161                 MVPbkContactLink* aGroupLink );
       
   162 
       
   163         /**
       
   164          * Returns group link.
       
   165          *
       
   166          * @return  Group link.
       
   167          */
       
   168         MVPbkContactLink* GroupLink() const;
       
   169 
       
   170         /**
       
   171          * Returns group link, ownership is transferred.
       
   172          *
       
   173          * @return  Group link.
       
   174          */
       
   175         MVPbkContactLink* GetGroupLink();
       
   176 
       
   177         /**
       
   178          * Returns group name.
       
   179          *
       
   180          * @return  Group name.
       
   181          */
       
   182         HBufC* GetGroupName();
       
   183 
       
   184         /**
       
   185          * Returns group members view.
       
   186          *
       
   187          * @return  Group members view.
       
   188          */
       
   189         MVPbkContactViewBase* GroupMembersView() const;
       
   190 
       
   191         /**
       
   192          * Returns group members view, ownership is transferred.
       
   193          *
       
   194          * @return  Group members view.
       
   195          */
       
   196         MVPbkContactViewBase* GetGroupMembersView();
       
   197 
       
   198     private: // Implementation
       
   199         CGroupMembersViewTransaction();
       
   200 
       
   201     private: // Data
       
   202         /// Own: Group members view
       
   203         MVPbkContactViewBase* iGroupMembersView;
       
   204         /// Own: Group name
       
   205         HBufC* iGroupName;
       
   206         /// Own: Group link
       
   207         MVPbkContactLink* iGroupLink;
       
   208     };
       
   209 
       
   210 // --------------------------------------------------------------------------
       
   211 // CGroupMembersViewTransaction::CGroupMembersViewTransaction
       
   212 // --------------------------------------------------------------------------
       
   213 //
       
   214 CGroupMembersViewTransaction::CGroupMembersViewTransaction()
       
   215     {
       
   216     }
       
   217 
       
   218 // --------------------------------------------------------------------------
       
   219 // CGroupMembersViewTransaction::~CGroupMembersViewTransaction
       
   220 // --------------------------------------------------------------------------
       
   221 //
       
   222 CGroupMembersViewTransaction::~CGroupMembersViewTransaction()
       
   223     {
       
   224     delete iGroupMembersView;
       
   225     delete iGroupName;
       
   226     delete iGroupLink;
       
   227     }
       
   228 
       
   229 // --------------------------------------------------------------------------
       
   230 // CGroupMembersViewTransaction::NewLC
       
   231 // --------------------------------------------------------------------------
       
   232 //
       
   233 CGroupMembersViewTransaction* CGroupMembersViewTransaction::NewLC()
       
   234     {
       
   235     CGroupMembersViewTransaction* self =
       
   236         new ( ELeave ) CGroupMembersViewTransaction;
       
   237     CleanupStack::PushL( self );
       
   238     return self;
       
   239     }
       
   240 
       
   241 // --------------------------------------------------------------------------
       
   242 // CGroupMembersViewTransaction::SetGroupMembersView
       
   243 // --------------------------------------------------------------------------
       
   244 //
       
   245 void CGroupMembersViewTransaction::SetGroupMembersView
       
   246         ( MVPbkContactViewBase* aGroupMembersView )
       
   247     {
       
   248     delete iGroupMembersView;
       
   249     iGroupMembersView = aGroupMembersView;
       
   250     }
       
   251 
       
   252 // --------------------------------------------------------------------------
       
   253 // CGroupMembersViewTransaction::SetGroupName
       
   254 // --------------------------------------------------------------------------
       
   255 //
       
   256 void CGroupMembersViewTransaction::SetGroupName
       
   257         ( HBufC* aGroupName )
       
   258     {
       
   259     delete iGroupName;
       
   260     iGroupName = aGroupName;
       
   261     }
       
   262 
       
   263 // --------------------------------------------------------------------------
       
   264 // CGroupMembersViewTransaction::SetGroupLink
       
   265 // --------------------------------------------------------------------------
       
   266 //
       
   267 void CGroupMembersViewTransaction::SetGroupLink
       
   268         ( MVPbkContactLink* aGroupLink )
       
   269     {
       
   270     delete iGroupLink;
       
   271     iGroupLink = aGroupLink;
       
   272     }
       
   273 
       
   274 // --------------------------------------------------------------------------
       
   275 // CGroupMembersViewTransaction::GroupLink
       
   276 // --------------------------------------------------------------------------
       
   277 //
       
   278 MVPbkContactLink* CGroupMembersViewTransaction::GroupLink() const
       
   279     {
       
   280     return iGroupLink;
       
   281     }
       
   282 
       
   283 // --------------------------------------------------------------------------
       
   284 // CGroupMembersViewTransaction::GetGroupLink
       
   285 // --------------------------------------------------------------------------
       
   286 //
       
   287 MVPbkContactLink* CGroupMembersViewTransaction::GetGroupLink()
       
   288     {
       
   289     MVPbkContactLink* groupLink = iGroupLink;
       
   290     iGroupLink = NULL;
       
   291     return groupLink;
       
   292     }
       
   293 
       
   294 // --------------------------------------------------------------------------
       
   295 // CGroupMembersViewTransaction::GetGroupName
       
   296 // --------------------------------------------------------------------------
       
   297 //
       
   298 HBufC* CGroupMembersViewTransaction::GetGroupName()
       
   299     {
       
   300     HBufC* groupName = iGroupName;
       
   301     iGroupName = NULL;
       
   302     return groupName;
       
   303     }
       
   304 
       
   305 // --------------------------------------------------------------------------
       
   306 // CGroupMembersViewTransaction::GroupMembersView
       
   307 // --------------------------------------------------------------------------
       
   308 //
       
   309 MVPbkContactViewBase* CGroupMembersViewTransaction::GroupMembersView() const
       
   310     {
       
   311     return iGroupMembersView;
       
   312     }
       
   313 
       
   314 // --------------------------------------------------------------------------
       
   315 // CGroupMembersViewTransaction::GetGroupMembersView
       
   316 // --------------------------------------------------------------------------
       
   317 //
       
   318 MVPbkContactViewBase* CGroupMembersViewTransaction::GetGroupMembersView()
       
   319     {
       
   320     MVPbkContactViewBase* groupMembersView = iGroupMembersView;
       
   321     iGroupMembersView = NULL;
       
   322     return groupMembersView;
       
   323     }
       
   324 
       
   325 } /// namespace
       
   326 
       
   327 /**
       
   328  * Phonebook 2 group members view implementation base class.
       
   329  */
       
   330 class CPguGroupMembersView::CGroupMembersViewImpl :
       
   331         public CBase,
       
   332         protected MVPbkContactViewObserver
       
   333     {
       
   334     public: // Interface
       
   335 
       
   336         /**
       
   337          * Creates control.
       
   338          *
       
   339          * @param aClientRect   Client's rect.
       
   340          */
       
   341         virtual void CreateControlL(
       
   342                 const TRect& aClientRect ) = 0;
       
   343 
       
   344         /**
       
   345          * Returns the control.
       
   346          *
       
   347          * @return  Control.
       
   348          */
       
   349         virtual MPbk2ContactUiControl* Control() = 0;
       
   350 
       
   351         /**
       
   352          * Return view's state.
       
   353          *
       
   354          * @return  View state.
       
   355          */
       
   356         virtual CPbk2ViewState* ViewStateLC() const = 0;
       
   357 
       
   358         /**
       
   359          * Handles command key
       
   360          *
       
   361          * @param aKeyEvent     Key event.
       
   362          * @param aType         Command type.
       
   363          * @return  ETrue if command handled in function, else EFalse.
       
   364          */
       
   365         virtual TBool HandleCommandKeyL(
       
   366                 const TKeyEvent& aKeyEvent,
       
   367                 TEventCode aType ) = 0;
       
   368 
       
   369         /**
       
   370          * Returns menu filtering flags.
       
   371          *
       
   372          * @return  The flags.
       
   373          */
       
   374         virtual TInt GetViewSpecificMenuFilteringFlagsL() const = 0;
       
   375 
       
   376         /**
       
   377          * Dynamically initialises a menu pane.
       
   378          *
       
   379          * @param aResourceId   Resource id of the menu.
       
   380          * @param aMenuPane     The in-memory representation of
       
   381          *                      the menu pane.
       
   382          */
       
   383         virtual void DynInitMenuPaneL(
       
   384                 TInt aResourceId,
       
   385                 CEikMenuPane* aMenuPane ) = 0;
       
   386 
       
   387         /**
       
   388          * Restores view's state.
       
   389          *
       
   390          * @param aState    The state to restore.
       
   391          */
       
   392         virtual void RestoreControlStateL(
       
   393                 CPbk2ViewState* aState ) = 0;
       
   394 
       
   395         /**
       
   396          * Handles command,
       
   397          *
       
   398          * @param aCommand  Id of the command to respond to.
       
   399          */
       
   400         virtual void HandleCommandL(
       
   401                 TInt aCommand ) = 0;
       
   402 
       
   403         /**
       
   404          * Handles a change in the position or size
       
   405          * of the screen area occupied by the status pane.
       
   406          */
       
   407         virtual void HandleStatusPaneSizeChange() = 0;
       
   408 
       
   409 
       
   410         /**
       
   411          * Handles listbox events in derived classes
       
   412          * Note that this is not derived from MEikListBoxObserver but defined here
       
   413          */
       
   414         virtual void HandleListBoxEventL( CEikListBox* aListBox, TListBoxEvent aEventType ) = 0;
       
   415 
       
   416 
       
   417         /**
       
   418          * Handles listbox events in derived classes
       
   419          * Note that this is not derived from MEikListBoxObserver but defined here
       
   420          */
       
   421         virtual void ShowContextMenuL() = 0;
       
   422 
       
   423 
       
   424 
       
   425         /**
       
   426          * Handles pointer events.
       
   427          *
       
   428          * @param aPointerEvent     The pointer event.
       
   429          */
       
   430         virtual void HandlePointerEventL(
       
   431                 const TPointerEvent& aPointerEvent) = 0;
       
   432 
       
   433         /**
       
   434          * Updates Cba buttons.
       
   435          */
       
   436         virtual void UpdateCbasL() = 0;
       
   437 
       
   438         /**
       
   439          * Handles long tap event.
       
   440          *
       
   441          * @param aPenEventLocation         Pen location
       
   442          * @param aPenEventScreenLocation   Pen screen location.
       
   443          */
       
   444         virtual void HandleLongTapEventL(
       
   445                 const TPoint& aPenEventLocation,
       
   446                 const TPoint& aPenEventScreenLocation ) = 0;
       
   447 
       
   448     public: // From MVPbkContactViewObserver
       
   449         void ContactViewUnavailable(
       
   450                 MVPbkContactViewBase& aView );
       
   451         void ContactAddedToView(
       
   452                 MVPbkContactViewBase& aView,
       
   453                 TInt aIndex,
       
   454                 const MVPbkContactLink& aContactLink );
       
   455         void ContactRemovedFromView(
       
   456                 MVPbkContactViewBase& aView,
       
   457                 TInt aIndex,
       
   458                 const MVPbkContactLink& aContactLink );
       
   459         void ContactViewError(
       
   460                 MVPbkContactViewBase& aView,
       
   461                 TInt aError,
       
   462                 TBool aErrorNotified );
       
   463 
       
   464     public: // Base class interface
       
   465 
       
   466         /**
       
   467          * Destructor.
       
   468          */
       
   469         virtual ~CGroupMembersViewImpl()
       
   470             {}
       
   471         
       
   472     public:
       
   473         
       
   474         void SetMarkingModeOn( TBool aMarkingModeOn )
       
   475             {
       
   476             iMarkingModeOn = aMarkingModeOn;
       
   477             }
       
   478         
       
   479         TBool IsMarkingModeOn()
       
   480             {
       
   481             return iMarkingModeOn;
       
   482             }
       
   483 
       
   484     protected: // Implementation
       
   485         CGroupMembersViewImpl() : iMarkingModeOn( EFalse )
       
   486             {}
       
   487         
       
   488     protected:
       
   489         // Flag to indicate whether Marking mode is active
       
   490         TBool iMarkingModeOn;
       
   491     };
       
   492 
       
   493 
       
   494 /**
       
   495  * Group members view implementation class. This class encapsulates
       
   496  * the view implementation when the group members view isnt ready, so
       
   497  * all the nesessary information needed to create the group members view
       
   498  * isnt ready. This class iniates the all groups view loading and waits
       
   499  * for its completion. Up on completion it switches to the next state.
       
   500  */
       
   501 class CPguGroupMembersView::CGroupMembersAllGroupsNotReady :
       
   502         public CPguGroupMembersView::CGroupMembersViewImpl
       
   503     {
       
   504     public: // interface
       
   505         /**
       
   506          * Creates a new instance of this class.
       
   507          *
       
   508          * @param aViewParent           Parent view.
       
   509          * @param aView                 UI extension view.
       
   510          * @param aFocusedGroupLink     Focused groups.
       
   511          * @return  A new instance of this class.
       
   512          */
       
   513         static CGroupMembersAllGroupsNotReady* NewL(
       
   514                 MPbk2GroupMembersViewActivationCallback& aViewParent,
       
   515                 CPbk2UIExtensionView& aView,
       
   516                 const MVPbkContactLink* aFocusedGroupLink );
       
   517 
       
   518         /**
       
   519          * Destructor.
       
   520          */
       
   521         ~CGroupMembersAllGroupsNotReady();
       
   522 
       
   523     public: // From CGroupMembersViewImpl
       
   524         void CreateControlL(
       
   525                 const TRect& aClientRect );
       
   526         MPbk2ContactUiControl* Control();
       
   527         CPbk2ViewState* ViewStateLC() const;
       
   528         TBool HandleCommandKeyL(
       
   529                 const TKeyEvent& aKeyEvent,
       
   530                 TEventCode aType );
       
   531         TInt GetViewSpecificMenuFilteringFlagsL() const;
       
   532         void DynInitMenuPaneL(
       
   533                 TInt aResourceId,
       
   534                 CEikMenuPane* aMenuPane );
       
   535         void RestoreControlStateL(
       
   536                 CPbk2ViewState* aState );
       
   537         void HandleCommandL(
       
   538                 TInt aCommand );
       
   539         void HandleStatusPaneSizeChange();
       
   540 
       
   541         /**
       
   542          * Handles listbox events.
       
   543          * Note that this is not derived from MEikListBoxObserver but defined here
       
   544          */
       
   545         void HandleListBoxEventL( CEikListBox* aListBox, TListBoxEvent aEventType );
       
   546 
       
   547         void ShowContextMenuL();
       
   548 
       
   549         void HandlePointerEventL(
       
   550                 const TPointerEvent& aPointerEvent );
       
   551         void UpdateCbasL();
       
   552         void HandleLongTapEventL(
       
   553                 const TPoint& aPenEventLocation,
       
   554                 const TPoint& aPenEventScreenLocation );
       
   555 
       
   556     public: // From MVPbkContactViewObserver
       
   557         void ContactViewReady(
       
   558                 MVPbkContactViewBase& aView );
       
   559 
       
   560     private: // Implementation
       
   561         CGroupMembersAllGroupsNotReady(
       
   562                 MPbk2GroupMembersViewActivationCallback& aViewParent,
       
   563                 CPbk2UIExtensionView& aView,
       
   564                 const MVPbkContactLink* aFocusedGroupLink );
       
   565         void ConstructL();
       
   566 
       
   567     private: // Data
       
   568         /// Ref: Parent view
       
   569         MPbk2GroupMembersViewActivationCallback& iViewParent;
       
   570         /// Ref: UI extension view
       
   571         CPbk2UIExtensionView& iView;
       
   572         /// Ref: Focused group link
       
   573         const MVPbkContactLink* iFocusedGroupLink;
       
   574         /// RefO observed all groups view
       
   575         MVPbkContactViewBase* iAllGroupsView;
       
   576         /// This view's control container type
       
   577         typedef CPbk2ControlContainer<
       
   578             CPbk2ContactUiControlSubstitute> CContainer;
       
   579         /// Own: This view's control container
       
   580         CContainer* iContainer;
       
   581         /// Ref: Empty control
       
   582         CPbk2ContactUiControlSubstitute* iControl;
       
   583         
       
   584     };
       
   585 
       
   586 
       
   587 /**
       
   588  * Group members view implementation class. This class encapsulates
       
   589  * the situation when all nesessary information to show the group
       
   590  * members data is present and it can be shown to the user. The navigation
       
   591  * from group to group and user commands are handled in this state.
       
   592  */
       
   593 class CPguGroupMembersView::CGroupMembersAllGroupsReady :
       
   594         public CPguGroupMembersView::CGroupMembersViewImpl,
       
   595         private MPbk2StoreConfigurationObserver,
       
   596         private MPbk2ContactNavigationLoader,
       
   597         private MPbk2MenuCommandObserver,
       
   598         private MPbk2ControlObserver,
       
   599         private MPbk2NavigationObserver
       
   600     {
       
   601     public: // Construction and destruction
       
   602 
       
   603         /**
       
   604          * Creates a new instance of this class.
       
   605          *
       
   606          * @param aViewParent           Parent view.
       
   607          * @param aView                 UI extension view.
       
   608          * @param aContactManager       Contact manager.
       
   609          * @param aContactNameFormatter Name formatter
       
   610          * @param aStorePropertyArray   Store property array.
       
   611          * @param aCommandHandler       Command handler.
       
   612          * @param aSortOrderManager     Sort order manager.
       
   613          * @param aFocusedGroupIndex    Focused group index.
       
   614          * @return  A new instance of this class
       
   615          */
       
   616         static CGroupMembersAllGroupsReady* NewL(
       
   617                 MPbk2GroupMembersViewActivationCallback& aViewParent,
       
   618                 CPbk2UIExtensionView& aView,
       
   619                 CVPbkContactManager& aContactManager,
       
   620                 MPbk2ContactNameFormatter& aContactNameFormatter,
       
   621                 CPbk2StorePropertyArray& aStorePropertyArray,
       
   622                 MPbk2CommandHandler& aCommandHandler,
       
   623                 CPbk2SortOrderManager& aSortOrderManager,
       
   624                 const TInt aFocusedGroupIndex );
       
   625 
       
   626         /**
       
   627          * Destructor
       
   628          */
       
   629         ~CGroupMembersAllGroupsReady();
       
   630 
       
   631     public: // From CGroupMembersViewImpl
       
   632         void CreateControlL(
       
   633                 const TRect& aClientRect );
       
   634         MPbk2ContactUiControl* Control();
       
   635         CPbk2ViewState* ViewStateLC() const;
       
   636         TBool HandleCommandKeyL(
       
   637                 const TKeyEvent& aKeyEvent,
       
   638                 TEventCode aType );
       
   639         TInt GetViewSpecificMenuFilteringFlagsL() const;
       
   640         void DynInitMenuPaneL(
       
   641                 TInt aResourceId,
       
   642                 CEikMenuPane* aMenuPane );
       
   643         void RestoreControlStateL(
       
   644                 CPbk2ViewState* aState );
       
   645         void HandleCommandL(
       
   646                 TInt aCommand );
       
   647         void HandleStatusPaneSizeChange();
       
   648         /**
       
   649          * Handles listbox events.
       
   650          * Note that this is not derived from MEikListBoxObserver but defined here
       
   651          */
       
   652         void HandleListBoxEventL( CEikListBox* aListBox, TListBoxEvent aEventType );
       
   653         void ShowContextMenuL();
       
   654 
       
   655         void HandlePointerEventL(
       
   656                 const TPointerEvent& aPointerEvent );
       
   657         void UpdateCbasL();
       
   658         void HandleLongTapEventL(
       
   659                 const TPoint& aPenEventLocation,
       
   660                 const TPoint& aPenEventScreenLocation );
       
   661 
       
   662     private: // From MPbk2ControlObserver
       
   663         void HandleControlEventL(
       
   664                 MPbk2ContactUiControl& aControl,
       
   665                 const TPbk2ControlEvent& aEvent );
       
   666 
       
   667     private: // From MPbk2StoreConfigurationObserver
       
   668         void ConfigurationChanged();
       
   669         void ConfigurationChangedComplete();
       
   670 
       
   671     private: // From MPbk2ContactNavigationLoader
       
   672         void ChangeContactL(
       
   673                 const MVPbkContactLink& aContactLink );
       
   674         MVPbkContactLink* ContactLinkLC() const;
       
   675 
       
   676     private: // From MPbk2MenuCommandObserver
       
   677         void PreCommandExecutionL(
       
   678                 const MPbk2Command& aCommand );
       
   679         void PostCommandExecutionL(
       
   680                 const MPbk2Command& aCommand );
       
   681 
       
   682     private: // From MVPbkContactViewObserver
       
   683         void ContactViewReady(
       
   684                 MVPbkContactViewBase& aView );
       
   685 
       
   686     private: // From MPbk2NavigationObserver
       
   687         void HandleNavigationEvent(
       
   688                 const TEventType& aEventType );
       
   689 
       
   690     private: // Implementation
       
   691         CGroupMembersAllGroupsReady(
       
   692                 MPbk2GroupMembersViewActivationCallback& aViewParent,
       
   693                 CPbk2UIExtensionView& aView,
       
   694                 CVPbkContactManager& aContactManager,
       
   695                 MPbk2ContactNameFormatter& aContactNameFormatter,
       
   696                 CPbk2StorePropertyArray& aStorePropertyArray,
       
   697                 MPbk2CommandHandler& aCommandHandler,
       
   698                 CPbk2SortOrderManager& aSortOrderManager );
       
   699         void ConstructL(
       
   700                 const TInt aFocusedGroupIndex );
       
   701         void DoCommitTransActionL(
       
   702                 MVPbkContactViewBase& aView );
       
   703         static void ChangeTitlePaneL(
       
   704                 HBufC* aTitleText );
       
   705         void UpdateListEmptyTextL(
       
   706                 TInt aListState );
       
   707 
       
   708     private: // Data
       
   709         /// Ref: Parent view
       
   710         MPbk2GroupMembersViewActivationCallback& iViewParent;
       
   711         /// Ref: UI extension view
       
   712         CPbk2UIExtensionView& iView;
       
   713         /// Ref: Contact manager
       
   714         CVPbkContactManager& iContactManager;
       
   715         /// Ref: Contact name formatter
       
   716         MPbk2ContactNameFormatter& iContactNameFormatter;
       
   717         /// Ref: Store properties
       
   718         CPbk2StorePropertyArray& iStoreProperties;
       
   719         /// Ref: Command handler
       
   720         MPbk2CommandHandler& iCommandHandler;
       
   721         /// Ref: Sort order
       
   722         CPbk2SortOrderManager& iSortOrderManager;
       
   723         /// This view's control container type
       
   724         typedef CPbk2ControlContainer<CPbk2NamesListControl> CContainer;
       
   725         /// Own: This view's control container
       
   726         CContainer* iContainer;
       
   727         /// Ref: This view's control
       
   728         MPbk2ContactUiControl* iControl;
       
   729         /// Ref: Focus movement observer
       
   730         MPbk2PointerEventInspector* iPointerEventInspector;
       
   731         /// Own: Navigation strategy
       
   732         MPbk2ContactNavigation* iNavigation;
       
   733         /// Own: Group members view
       
   734         MVPbkContactViewBase* iGroupMembersView;
       
   735         /// Own: View transition transaction
       
   736         CGroupMembersViewTransaction* iViewTransitionTransaction;
       
   737         /// Own: List of stores used
       
   738         RPointerArray<MVPbkContactStore> iStoreList;
       
   739         /// Own: ETrue, if any selection modifier key is depressed
       
   740         TBool iSelectionModifierUsed;
       
   741         /// Own: Stylus popup menu state indicator
       
   742         TBool iStylusPopupMenuLaunched;
       
   743         // Ref: Store management ptr
       
   744         CPbk2StoreConfiguration* iStoreConf;
       
   745     };
       
   746 
       
   747 // --------------------------------------------------------------------------
       
   748 // CPguGroupMembersView::CGroupMembersViewImpl:::ContactViewUnavailable
       
   749 // --------------------------------------------------------------------------
       
   750 //
       
   751 void CPguGroupMembersView::CGroupMembersViewImpl::ContactViewUnavailable
       
   752         ( MVPbkContactViewBase& /*aView*/ )
       
   753     {
       
   754     TRAP_IGNORE( UpdateCbasL() );
       
   755     }
       
   756 
       
   757 // --------------------------------------------------------------------------
       
   758 // CPguGroupMembersView::CGroupMembersViewImpl:::ContactAddedToView
       
   759 // --------------------------------------------------------------------------
       
   760 //
       
   761 void CPguGroupMembersView::CGroupMembersViewImpl::ContactAddedToView
       
   762         ( MVPbkContactViewBase& /*aView*/, TInt /*aIndex*/,
       
   763           const MVPbkContactLink& /*aContactLink*/ )
       
   764     {
       
   765     TRAP_IGNORE( UpdateCbasL() );
       
   766     }
       
   767 
       
   768 // --------------------------------------------------------------------------
       
   769 // CPguGroupMembersView::CGroupMembersViewImpl:::ContactRemovedFromView
       
   770 // --------------------------------------------------------------------------
       
   771 //
       
   772 void CPguGroupMembersView::CGroupMembersViewImpl::ContactRemovedFromView
       
   773         ( MVPbkContactViewBase& /*aView*/, TInt /*aIndex*/,
       
   774           const MVPbkContactLink& /*aContactLink*/ )
       
   775     {
       
   776     TRAP_IGNORE( UpdateCbasL() );
       
   777     }
       
   778 
       
   779 // --------------------------------------------------------------------------
       
   780 // CPguGroupMembersView::CGroupMembersViewImpl:::ContactViewError
       
   781 // --------------------------------------------------------------------------
       
   782 //
       
   783 void CPguGroupMembersView::CGroupMembersViewImpl::ContactViewError
       
   784         ( MVPbkContactViewBase& /*aView*/, TInt /*aError*/,
       
   785           TBool /*aErrorNotified*/ )
       
   786     {
       
   787     // Do nothing
       
   788     }
       
   789 
       
   790 // --------------------------------------------------------------------------
       
   791 // CPguGroupMembersView::CGroupMembersAllGroupsNotReady::CGroupMembersAllGrou
       
   792 // --------------------------------------------------------------------------
       
   793 //
       
   794 CPguGroupMembersView::CGroupMembersAllGroupsNotReady::
       
   795     CGroupMembersAllGroupsNotReady
       
   796             ( MPbk2GroupMembersViewActivationCallback& aViewParent,
       
   797               CPbk2UIExtensionView& aView,
       
   798               const MVPbkContactLink* aFocusedGroupLink ) :
       
   799                 iViewParent(aViewParent),
       
   800                 iView(aView),
       
   801                 iFocusedGroupLink(aFocusedGroupLink)
       
   802     {
       
   803     }
       
   804 
       
   805 // --------------------------------------------------------------------------
       
   806 // CPguGroupMembersView::CGroupMembersAllGroupsNotReady::~CGroupMembersAllGro
       
   807 // --------------------------------------------------------------------------
       
   808 //
       
   809 CPguGroupMembersView::CGroupMembersAllGroupsNotReady::
       
   810         ~CGroupMembersAllGroupsNotReady()
       
   811     {
       
   812     iAllGroupsView->RemoveObserver( *this );
       
   813 
       
   814     // Remove control from stack
       
   815     if (iContainer)
       
   816         {
       
   817         CCoeEnv::Static()->AppUi()->RemoveFromStack(iContainer);
       
   818         delete iContainer;
       
   819         }
       
   820     }
       
   821 
       
   822 // --------------------------------------------------------------------------
       
   823 // CPguGroupMembersView::CGroupMembersAllGroupsNotReady::ConstructL
       
   824 // --------------------------------------------------------------------------
       
   825 //
       
   826 void CPguGroupMembersView::CGroupMembersAllGroupsNotReady::ConstructL()
       
   827     {
       
   828     // The all groups view isnt ready, observe it then expand
       
   829     Phonebook2::Pbk2AppUi()->ApplicationServices().
       
   830         ViewSupplier().AllGroupsViewL()->AddObserverL( *this );
       
   831 
       
   832     iViewParent.SetFocusedContact( iFocusedGroupLink->CloneLC() );
       
   833     CleanupStack::Pop();
       
   834     }
       
   835 
       
   836 // --------------------------------------------------------------------------
       
   837 // CPguGroupMembersView::CGroupMembersAllGroupsNotReady::NewL
       
   838 // --------------------------------------------------------------------------
       
   839 //
       
   840 CPguGroupMembersView::CGroupMembersAllGroupsNotReady*
       
   841     CPguGroupMembersView::CGroupMembersAllGroupsNotReady::NewL
       
   842         ( MPbk2GroupMembersViewActivationCallback& aViewParent,
       
   843           CPbk2UIExtensionView& aView,
       
   844           const MVPbkContactLink* aFocusedGroupLink )
       
   845     {
       
   846     CGroupMembersAllGroupsNotReady* self =
       
   847         new ( ELeave ) CGroupMembersAllGroupsNotReady
       
   848             ( aViewParent, aView, aFocusedGroupLink );
       
   849     CleanupStack::PushL( self );
       
   850     self->ConstructL();
       
   851     CleanupStack::Pop( self );
       
   852     return self;
       
   853     }
       
   854 
       
   855 // --------------------------------------------------------------------------
       
   856 // CPguGroupMembersView::CGroupMembersAllGroupsNotReady::CreateControlL
       
   857 // --------------------------------------------------------------------------
       
   858 //
       
   859 void CPguGroupMembersView::CGroupMembersAllGroupsNotReady::CreateControlL
       
   860         ( const TRect& aClientRect )
       
   861     {
       
   862     // Create the container and control
       
   863     CContainer* container = CContainer::NewLC( &iView, &iView, iView );
       
   864     container->SetHelpContext(
       
   865             TCoeHelpContext(iView.ApplicationUid(),
       
   866             KPHOB_HLP_GROUP_MEMBER_LIST));
       
   867 
       
   868     // create empty control
       
   869     CPbk2ContactUiControlSubstitute* control =
       
   870             CPbk2ContactUiControlSubstitute::NewL();
       
   871 
       
   872     // Takes ownership
       
   873     container->SetControl(control, aClientRect);
       
   874 
       
   875     control->SetContainerWindowL(*container);
       
   876     HBufC* emptyText = StringLoader::LoadLC( R_QTN_PHOB_NO_ENTRIES_IN_GRP );
       
   877     control->SetTextL( *emptyText );
       
   878     CleanupStack::PopAndDestroy( emptyText );
       
   879 
       
   880     CCoeEnv::Static()->AppUi()->AddToStackL(iView, container);
       
   881     CleanupStack::Pop(container);
       
   882     iContainer = container;
       
   883     iControl = control;
       
   884 
       
   885     iContainer->ActivateL();
       
   886     iContainer->Control()->MakeVisible(ETrue);
       
   887 
       
   888     // set CBA
       
   889     iView.Cba()->SetCommandSetL(R_AVKON_SOFTKEYS_BACK);
       
   890     iView.Cba()->DrawDeferred();
       
   891     }
       
   892 
       
   893 // --------------------------------------------------------------------------
       
   894 // CPguGroupMembersView::CGroupMembersAllGroupsNotReady::Control
       
   895 // --------------------------------------------------------------------------
       
   896 //
       
   897 MPbk2ContactUiControl* CPguGroupMembersView::
       
   898         CGroupMembersAllGroupsNotReady::Control()
       
   899     {
       
   900     return iControl;
       
   901     }
       
   902 
       
   903 // --------------------------------------------------------------------------
       
   904 // CPguGroupMembersView::CGroupMembersAllGroupsNotReady::ContactViewReady
       
   905 // --------------------------------------------------------------------------
       
   906 //
       
   907 void CPguGroupMembersView::CGroupMembersAllGroupsNotReady::ContactViewReady
       
   908         ( MVPbkContactViewBase& aView )
       
   909     {
       
   910     // If we have a new view, lets change it
       
   911     if (&aView == iAllGroupsView)
       
   912         {
       
   913         TInt groupIndex = KErrNotFound;
       
   914         TRAPD(leaveCode,
       
   915             {
       
   916             groupIndex = iAllGroupsView->IndexOfLinkL(*iFocusedGroupLink);
       
   917             // switch to ready state
       
   918             iViewParent.TransformViewActivationStateToReadyL(groupIndex);
       
   919             });
       
   920         if (leaveCode != KErrNone)
       
   921             {
       
   922             // notify user
       
   923             CCoeEnv::Static()->HandleError(leaveCode);
       
   924             }
       
   925         }
       
   926     else
       
   927         {
       
   928         // When ContactViewReady() is called, the program needs to check whether 
       
   929         // the namelist control in the container is visible or not. 
       
   930         // If visible, call DrawDeferred() to refresh the container, 
       
   931         // and if not, the container needs not to be refreshed to avoid flicker on the background.
       
   932         if ( iContainer->Control() && iContainer->Control()->IsVisible() )
       
   933             {
       
   934             iContainer->DrawDeferred();
       
   935             }
       
   936         }
       
   937     }
       
   938 
       
   939 // --------------------------------------------------------------------------
       
   940 // CPguGroupMembersView::CGroupMembersAllGroupsNotReady::ViewStateLC
       
   941 // --------------------------------------------------------------------------
       
   942 //
       
   943 CPbk2ViewState* CPguGroupMembersView::
       
   944         CGroupMembersAllGroupsNotReady::ViewStateLC() const
       
   945     {
       
   946     CPbk2ViewState* state = CPbk2ViewState::NewLC();
       
   947     MVPbkContactLink* parentContactLink =
       
   948         iViewParent.FocusedContact()->CloneLC();
       
   949     state->SetParentContact( parentContactLink );
       
   950     CleanupStack::Pop(); // parentContactLink
       
   951     return state;
       
   952     }
       
   953 
       
   954 // --------------------------------------------------------------------------
       
   955 // CPguGroupMembersView::CGroupMembersAllGroupsNotReady::HandleCommandKeyL
       
   956 // --------------------------------------------------------------------------
       
   957 //
       
   958 TBool CPguGroupMembersView::CGroupMembersAllGroupsNotReady::HandleCommandKeyL
       
   959         ( const TKeyEvent& /*aKeyEvent*/, TEventCode /*aType*/ )
       
   960     {
       
   961     // No handling in this state
       
   962     return EFalse;
       
   963     }
       
   964 
       
   965 // --------------------------------------------------------------------------
       
   966 // CPguGroupMembersView::CGroupMembersAllGroupsNotReady::HandleStatusPaneSize
       
   967 // --------------------------------------------------------------------------
       
   968 //
       
   969 void CPguGroupMembersView::CGroupMembersAllGroupsNotReady::
       
   970         HandleStatusPaneSizeChange()
       
   971     {
       
   972     // Resize the container to fill the client rectangle
       
   973     if(iContainer)
       
   974         {
       
   975         iContainer->SetRect(iView.ClientRect());
       
   976         }
       
   977     }
       
   978 
       
   979 
       
   980 // ----------------------------------------------------------------------------
       
   981 // CPguGroupMembersView::CGroupMembersAllGroupsNotReady::HandleListBoxEventL
       
   982 // ----------------------------------------------------------------------------
       
   983 //
       
   984 void CPguGroupMembersView::CGroupMembersAllGroupsNotReady::HandleListBoxEventL(CEikListBox* /*aListBox*/ ,TListBoxEvent /*aEventType*/ )
       
   985     {
       
   986     }
       
   987 
       
   988 
       
   989 
       
   990 // --------------------------------------------------------------------------
       
   991 // CPguGroupMembersView::CGroupMembersAllGroupsNotReady::HandlePointerEventL
       
   992 // --------------------------------------------------------------------------
       
   993 //
       
   994 void CPguGroupMembersView::CGroupMembersAllGroupsNotReady::HandlePointerEventL
       
   995         ( const TPointerEvent& /*aPointerEvent*/ )
       
   996     {
       
   997     }
       
   998 
       
   999 
       
  1000 // --------------------------------------------------------------------------
       
  1001 // CPguGroupMembersView::CGroupMembersAllGroupsNotReady::ShowContextMenuL
       
  1002 // --------------------------------------------------------------------------
       
  1003 //
       
  1004 void CPguGroupMembersView::CGroupMembersAllGroupsNotReady::ShowContextMenuL()
       
  1005     {
       
  1006     }
       
  1007    
       
  1008 
       
  1009 
       
  1010 
       
  1011 // --------------------------------------------------------------------------
       
  1012 // CPguGroupMembersView::CGroupMembersAllGroupsNotReady::UpdateCbasL
       
  1013 // --------------------------------------------------------------------------
       
  1014 //
       
  1015 void CPguGroupMembersView::CGroupMembersAllGroupsNotReady::UpdateCbasL()
       
  1016     {
       
  1017     }
       
  1018 
       
  1019 // --------------------------------------------------------------------------
       
  1020 // CPguGroupMembersView::CGroupMembersAllGroupsNotReady::HandleLongTapEventL
       
  1021 // --------------------------------------------------------------------------
       
  1022 //
       
  1023 void CPguGroupMembersView::CGroupMembersAllGroupsNotReady::HandleLongTapEventL
       
  1024         ( const TPoint& /*aPenEventLocation*/,
       
  1025           const TPoint& /*aPenEventScreenLocation*/ )
       
  1026     {
       
  1027     }
       
  1028 
       
  1029 // --------------------------------------------------------------------------
       
  1030 // CPguGroupMembersView::CGroupMembersAllGroupsNotReady::GetViewSpecificMenu
       
  1031 // --------------------------------------------------------------------------
       
  1032 //
       
  1033 TInt CPguGroupMembersView::CGroupMembersAllGroupsNotReady::
       
  1034         GetViewSpecificMenuFilteringFlagsL() const
       
  1035     {
       
  1036     return iControl->GetMenuFilteringFlagsL();
       
  1037     }
       
  1038 
       
  1039 // --------------------------------------------------------------------------
       
  1040 // CPguGroupMembersView::CGroupMembersAllGroupsNotReady::DynInitMenuPaneL
       
  1041 // --------------------------------------------------------------------------
       
  1042 //
       
  1043 void CPguGroupMembersView::CGroupMembersAllGroupsNotReady::DynInitMenuPaneL
       
  1044         ( TInt /*aResourceId*/, CEikMenuPane* /*aMenuPane*/ )
       
  1045     {
       
  1046     // Do nothing
       
  1047     }
       
  1048 
       
  1049 // --------------------------------------------------------------------------
       
  1050 // CPguGroupMembersView::CGroupMembersAllGroupsNotReady::RestoreControlStateL
       
  1051 // --------------------------------------------------------------------------
       
  1052 //
       
  1053 void CPguGroupMembersView::CGroupMembersAllGroupsNotReady::
       
  1054         RestoreControlStateL( CPbk2ViewState* /*aState*/ )
       
  1055     {
       
  1056     // Nothing to restore
       
  1057     }
       
  1058 
       
  1059 // --------------------------------------------------------------------------
       
  1060 // CPguGroupMembersView::CGroupMembersAllGroupsNotReady::HandleCommandL
       
  1061 // --------------------------------------------------------------------------
       
  1062 //
       
  1063 void CPguGroupMembersView::CGroupMembersAllGroupsNotReady::HandleCommandL
       
  1064         ( TInt /*aCommand*/ )
       
  1065     {
       
  1066     // Do nothing
       
  1067     }
       
  1068 
       
  1069 // --------------------------------------------------------------------------
       
  1070 // CPguGroupMembersView::CGroupMembersAllGroupsReady::CGroupMembersAllGroups
       
  1071 // --------------------------------------------------------------------------
       
  1072 //
       
  1073 CPguGroupMembersView::CGroupMembersAllGroupsReady::CGroupMembersAllGroupsReady
       
  1074         ( MPbk2GroupMembersViewActivationCallback& aViewParent,
       
  1075           CPbk2UIExtensionView& aView,
       
  1076           CVPbkContactManager& aContactManager,
       
  1077           MPbk2ContactNameFormatter& aContactNameFormatter,
       
  1078           CPbk2StorePropertyArray& aStorePropertyArray,
       
  1079           MPbk2CommandHandler& aCommandHandler,
       
  1080           CPbk2SortOrderManager& aSortOrderManager ) :
       
  1081             iViewParent(aViewParent),
       
  1082             iView(aView),
       
  1083             iContactManager(aContactManager),
       
  1084             iContactNameFormatter(aContactNameFormatter),
       
  1085             iStoreProperties(aStorePropertyArray),
       
  1086             iCommandHandler(aCommandHandler),
       
  1087             iSortOrderManager(aSortOrderManager)
       
  1088     {
       
  1089     }
       
  1090 
       
  1091 // --------------------------------------------------------------------------
       
  1092 // CPguGroupMembersView::CGroupMembersAllGroupsReady::~CGroupMembersAllGroups
       
  1093 // --------------------------------------------------------------------------
       
  1094 //
       
  1095 CPguGroupMembersView::CGroupMembersAllGroupsReady::
       
  1096         ~CGroupMembersAllGroupsReady()
       
  1097     {    
       
  1098     iCommandHandler.RemoveMenuCommandObserver( *this );
       
  1099 
       
  1100     if ( iStoreConf )
       
  1101         {
       
  1102         iStoreConf->RemoveObserver( *this );
       
  1103         }
       
  1104 
       
  1105     delete iViewTransitionTransaction;
       
  1106 
       
  1107     // remove control from stack
       
  1108     if (iContainer)
       
  1109         {
       
  1110         iContainer->Control()->HideThumbnail();
       
  1111         iContainer->Control()->MakeVisible(EFalse);
       
  1112         CCoeEnv::Static()->AppUi()->RemoveFromStack(iContainer);
       
  1113         delete iContainer;
       
  1114         }
       
  1115 
       
  1116     // Stop observing group members view
       
  1117     if (iGroupMembersView)
       
  1118         {
       
  1119         iGroupMembersView->RemoveObserver( *this );
       
  1120         }
       
  1121     delete iGroupMembersView;
       
  1122     delete iNavigation;
       
  1123     iStoreList.Reset();
       
  1124     iStoreList.Close();
       
  1125     }
       
  1126 
       
  1127 // --------------------------------------------------------------------------
       
  1128 // CPguGroupMembersView::CGroupMembersAllGroupsReady::ConstructL
       
  1129 // --------------------------------------------------------------------------
       
  1130 //
       
  1131 void CPguGroupMembersView::CGroupMembersAllGroupsReady::ConstructL
       
  1132         ( const TInt aFocusedGroupIndex )
       
  1133     {
       
  1134     // Add this view to observe command events
       
  1135     iCommandHandler.AddMenuCommandObserver(*this);
       
  1136 
       
  1137     iStoreConf = &( Phonebook2::Pbk2AppUi()->ApplicationServices().
       
  1138         StoreConfiguration() );
       
  1139     iStoreConf->AddObserverL( *this );
       
  1140 
       
  1141     // Expand the group members view from the all groups view
       
  1142     const MVPbkViewContact& group =
       
  1143         Phonebook2::Pbk2AppUi()->ApplicationServices().
       
  1144             ViewSupplier().AllGroupsViewL()->ContactAtL
       
  1145                 ( aFocusedGroupIndex );
       
  1146     iGroupMembersView = group.Expandable()->ExpandLC(*this,
       
  1147                 iSortOrderManager.SortOrder());
       
  1148     CleanupStack::Pop(); // ExpandLC
       
  1149 
       
  1150     // create a store list that contains all the stores
       
  1151     MVPbkContactStoreList& storeList = iContactManager.ContactStoresL();
       
  1152     for (TInt i = 0; i < storeList.Count(); ++i)
       
  1153         {
       
  1154         MVPbkContactStore& store = storeList.At(i);
       
  1155         iStoreList.Append(&store);
       
  1156         }
       
  1157 
       
  1158     // Create a navigation object which can navigate all the available groups
       
  1159     iNavigation = Pbk2NavigatorFactory::CreateContactNavigatorL
       
  1160         ( iView.Id(), *this, *this, iStoreList.Array(),
       
  1161           R_QTN_PHOB_NAVI_POS_INDICATOR_GROUP_MEMBERS_VIEW );
       
  1162 
       
  1163     // Navigation view remains the same
       
  1164     iNavigation->SetScrollViewL
       
  1165         ( Phonebook2::Pbk2AppUi()->ApplicationServices().
       
  1166           ViewSupplier().AllGroupsViewL(), EFalse );
       
  1167 
       
  1168     // Set the group title to the title pane
       
  1169     HBufC* titleText = iContactNameFormatter.GetContactTitleL(group.Fields(),
       
  1170             MPbk2ContactNameFormatter::EPreserveLeadingSpaces );
       
  1171     CleanupStack::PushL( titleText );
       
  1172     ChangeTitlePaneL(titleText);
       
  1173     CleanupStack::Pop( titleText );
       
  1174     }
       
  1175 
       
  1176 // --------------------------------------------------------------------------
       
  1177 // CPguGroupMembersView::CGroupMembersAllGroupsReady::NewL
       
  1178 // --------------------------------------------------------------------------
       
  1179 //
       
  1180 CPguGroupMembersView::CGroupMembersAllGroupsReady*
       
  1181     CPguGroupMembersView::CGroupMembersAllGroupsReady::NewL
       
  1182             ( MPbk2GroupMembersViewActivationCallback& aViewParent,
       
  1183               CPbk2UIExtensionView& aView,
       
  1184               CVPbkContactManager& aContactManager,
       
  1185               MPbk2ContactNameFormatter& aContactNameFormatter,
       
  1186               CPbk2StorePropertyArray& aStorePropertyArray,
       
  1187               MPbk2CommandHandler& aCommandHandler,
       
  1188               CPbk2SortOrderManager& aSortOrderManager,
       
  1189               const TInt aFocusedGroupIndex )
       
  1190     {
       
  1191     CGroupMembersAllGroupsReady* self =
       
  1192         new ( ELeave ) CGroupMembersAllGroupsReady
       
  1193             ( aViewParent, aView, aContactManager,
       
  1194               aContactNameFormatter, aStorePropertyArray, aCommandHandler,
       
  1195               aSortOrderManager );
       
  1196     CleanupStack::PushL (self );
       
  1197     self->ConstructL( aFocusedGroupIndex );
       
  1198     CleanupStack::Pop( self );
       
  1199     return self;
       
  1200     }
       
  1201 
       
  1202 // --------------------------------------------------------------------------
       
  1203 // CPguGroupMembersView::CGroupMembersAllGroupsReady::CreateControlL
       
  1204 // --------------------------------------------------------------------------
       
  1205 //
       
  1206 void CPguGroupMembersView::CGroupMembersAllGroupsReady::CreateControlL
       
  1207         ( const TRect& aClientRect )
       
  1208     {
       
  1209     // Create the container and control
       
  1210     CContainer* container = CContainer::NewLC( &iView, &iView, iView );
       
  1211     container->SetHelpContext(
       
  1212             TCoeHelpContext(iView.ApplicationUid(),
       
  1213             KPHOB_HLP_GROUP_MEMBER_LIST));
       
  1214 
       
  1215     CPbk2NamesListControl* control = CPbk2NamesListControl::NewL(
       
  1216             R_PBK2_GROUPMEMBERS_CONTROL,
       
  1217             container, iContactManager, *iGroupMembersView,
       
  1218             iContactNameFormatter, iStoreProperties);
       
  1219 
       
  1220     // Takes ownership
       
  1221     container->SetControl(control, aClientRect);
       
  1222     control->SetTextL( KNullDesC );
       
  1223     control->AddObserverL(*this);
       
  1224 
       
  1225     iNavigation->UpdateNaviIndicatorsL(*iViewParent.FocusedContact());
       
  1226     //Set the current group link to Nameslist control
       
  1227     control->SetCurrentGroupLinkL(iViewParent.FocusedContact());
       
  1228 
       
  1229     CCoeEnv::Static()->AppUi()->AddToStackL(iView, container);
       
  1230     CleanupStack::Pop(container);
       
  1231     iContainer = container;
       
  1232     iControl = control;
       
  1233     iPointerEventInspector = control;
       
  1234 
       
  1235     iContainer->ActivateL();
       
  1236     iContainer->Control()->MakeVisible( ETrue );
       
  1237     }
       
  1238 
       
  1239 // --------------------------------------------------------------------------
       
  1240 // CPguGroupMembersView::CGroupMembersAllGroupsReady::Control
       
  1241 // --------------------------------------------------------------------------
       
  1242 //
       
  1243 MPbk2ContactUiControl* CPguGroupMembersView::CGroupMembersAllGroupsReady::
       
  1244         Control()
       
  1245     {
       
  1246     return iControl;
       
  1247     }
       
  1248 
       
  1249 // --------------------------------------------------------------------------
       
  1250 // CPguGroupMembersView::CGroupMembersAllGroupsReady::HandleControlEventL
       
  1251 // --------------------------------------------------------------------------
       
  1252 //
       
  1253 void CPguGroupMembersView::CGroupMembersAllGroupsReady::HandleControlEventL
       
  1254         ( MPbk2ContactUiControl& /*aControl*/,
       
  1255           const TPbk2ControlEvent& aEvent )
       
  1256     {
       
  1257     switch(aEvent.iEventType)
       
  1258         {
       
  1259         case TPbk2ControlEvent::EReady:
       
  1260             {
       
  1261             UpdateCbasL();
       
  1262 
       
  1263             // Restore control state
       
  1264             iViewParent.RestoreStateL();
       
  1265             if (iControl)
       
  1266                 {
       
  1267                 iControl->ShowThumbnail();
       
  1268                 }
       
  1269             break;
       
  1270             }
       
  1271         case TPbk2ControlEvent::EControlLeavesSelectionMode: // FALLTHROUGH
       
  1272         case TPbk2ControlEvent::EItemRemoved:                // FALLTHROUGH
       
  1273         case TPbk2ControlEvent::EContactSelected:            // FALLTHROUGH
       
  1274         case TPbk2ControlEvent::EContactUnselected:          // FALLTHROUGH
       
  1275         case TPbk2ControlEvent::EContactUnselectedAll:       
       
  1276             {
       
  1277             UpdateCbasL();
       
  1278             break;
       
  1279             }
       
  1280         case TPbk2ControlEvent::EControlStateChanged:
       
  1281             {
       
  1282             UpdateCbasL();
       
  1283             UpdateListEmptyTextL( aEvent.iInt );
       
  1284             iContainer->Control()->DrawDeferred();
       
  1285             break;
       
  1286             }
       
  1287         default:
       
  1288             {
       
  1289             // Do nothing
       
  1290             break;
       
  1291             }
       
  1292         }
       
  1293     }
       
  1294 
       
  1295 // --------------------------------------------------------------------------
       
  1296 // CPguGroupMembersView::CGroupMembersAllGroupsReady::ConfigurationChanged
       
  1297 // --------------------------------------------------------------------------
       
  1298 //
       
  1299 void CPguGroupMembersView::CGroupMembersAllGroupsReady::ConfigurationChanged()
       
  1300     {
       
  1301     // Update navigations scroll view
       
  1302     TRAPD( error,
       
  1303         iNavigation->SetScrollViewL
       
  1304             ( Phonebook2::Pbk2AppUi()->ApplicationServices().
       
  1305               ViewSupplier().AllGroupsViewL(), EFalse ) );
       
  1306     if ( error != KErrNone )
       
  1307         {
       
  1308         CCoeEnv::Static()->HandleError( error );
       
  1309         }
       
  1310     }
       
  1311 
       
  1312 // --------------------------------------------------------------------------
       
  1313 // CPguGroupMembersView::CGroupMembersAllGroupsReady::ConfigurationChangedCo
       
  1314 // --------------------------------------------------------------------------
       
  1315 //
       
  1316 void CPguGroupMembersView::CGroupMembersAllGroupsReady::
       
  1317         ConfigurationChangedComplete()
       
  1318     {
       
  1319     // Do nothing
       
  1320     }
       
  1321 
       
  1322 // --------------------------------------------------------------------------
       
  1323 // CPguGroupMembersView::CGroupMembersAllGroupsReady::ChangeContactL
       
  1324 // Called through MPbk2ContactNavigationCallback to change the
       
  1325 // group that is viewed.
       
  1326 // --------------------------------------------------------------------------
       
  1327 //
       
  1328 void CPguGroupMembersView::CGroupMembersAllGroupsReady::ChangeContactL
       
  1329         ( const MVPbkContactLink& aContactLink )
       
  1330     {
       
  1331     if (iViewTransitionTransaction)
       
  1332         {
       
  1333         // remove observer from view
       
  1334         iViewTransitionTransaction->GroupMembersView()->RemoveObserver( *this );
       
  1335 
       
  1336         // destroy tranaction
       
  1337         delete iViewTransitionTransaction;
       
  1338         iViewTransitionTransaction = NULL;
       
  1339         }
       
  1340 
       
  1341     CGroupMembersViewTransaction* transaction =
       
  1342         CGroupMembersViewTransaction::NewLC();
       
  1343     // create a copy of the group link
       
  1344     MVPbkContactLink* groupLink = aContactLink.CloneLC();
       
  1345 
       
  1346     // Get the index of the group to view from the all groups view
       
  1347     const TInt groupIndex = Phonebook2::Pbk2AppUi()->ApplicationServices().
       
  1348         ViewSupplier().AllGroupsViewL()->IndexOfLinkL( *groupLink );
       
  1349     if (groupIndex != KErrNotFound)
       
  1350         {
       
  1351         // Get the group at position from the all groups view
       
  1352         const MVPbkViewContact& group = Phonebook2::Pbk2AppUi()->ApplicationServices().
       
  1353         ViewSupplier().AllGroupsViewL()->ContactAtL( groupIndex );
       
  1354 
       
  1355         // retrieve group name, which is later shown on the title pane
       
  1356         HBufC* groupName = iContactNameFormatter.GetContactTitleL(group.Fields(),
       
  1357                 MPbk2ContactNameFormatter::EPreserveLeadingSpaces);
       
  1358         CleanupStack::PushL(groupName);
       
  1359 
       
  1360         // initiate the next group members view loading
       
  1361         MVPbkContactViewBase* groupMembersView = group.Expandable()->ExpandLC(*this,
       
  1362                 iSortOrderManager.SortOrder());
       
  1363 
       
  1364         // the group members view loading has initiated, transfer ownership of these
       
  1365         // items to the transaction. Transaction will be committed when the view
       
  1366         // reaches the ready state
       
  1367         transaction->SetGroupMembersView(groupMembersView);
       
  1368         CleanupStack::Pop(); // ExpandLC
       
  1369         transaction->SetGroupName(groupName);
       
  1370         CleanupStack::Pop(groupName);
       
  1371         transaction->SetGroupLink(groupLink);
       
  1372         CleanupStack::Pop(); // CloneLC
       
  1373 
       
  1374         // now assign the transaction and wait for the view to become ready
       
  1375         iViewTransitionTransaction = transaction;
       
  1376         CleanupStack::Pop(transaction);
       
  1377         }
       
  1378     else
       
  1379         {
       
  1380         // the all groups view isnt ready, so contact change isnt possible
       
  1381         // cleanup
       
  1382         CleanupStack::PopAndDestroy(2, transaction); // groupLink, transaction
       
  1383         User::Leave(KErrNotReady);
       
  1384         }
       
  1385     }
       
  1386 
       
  1387 // --------------------------------------------------------------------------
       
  1388 // CPguGroupMembersView::CGroupMembersAllGroupsReady::ViewStateLC
       
  1389 // --------------------------------------------------------------------------
       
  1390 //
       
  1391 MVPbkContactLink* CPguGroupMembersView::CGroupMembersAllGroupsReady::
       
  1392         ContactLinkLC() const
       
  1393     {
       
  1394     return iViewParent.FocusedContact()->CloneLC();
       
  1395     }
       
  1396 
       
  1397 // --------------------------------------------------------------------------
       
  1398 // CPguGroupMembersView::CGroupMembersAllGroupsReady::ViewStateLC
       
  1399 // --------------------------------------------------------------------------
       
  1400 //
       
  1401 CPbk2ViewState* CPguGroupMembersView::CGroupMembersAllGroupsReady::
       
  1402         ViewStateLC() const
       
  1403     {
       
  1404     CPbk2ViewState* state = iControl->ControlStateL();
       
  1405     CleanupStack::PushL( state );
       
  1406     MVPbkContactLink* parentContactLink =
       
  1407         iViewParent.FocusedContact()->CloneLC();
       
  1408     state->SetParentContact( parentContactLink );
       
  1409     CleanupStack::Pop(); // parentContactLink
       
  1410     return state;
       
  1411     }
       
  1412 
       
  1413 // --------------------------------------------------------------------------
       
  1414 // CPguGroupMembersView::CGroupMembersAllGroupsReady::HandleCommandKeyL
       
  1415 // --------------------------------------------------------------------------
       
  1416 //
       
  1417 TBool CPguGroupMembersView::CGroupMembersAllGroupsReady::HandleCommandKeyL
       
  1418         ( const TKeyEvent& aKeyEvent, TEventCode aType )
       
  1419     {
       
  1420     TBool itemSpecEnabled = 
       
  1421         Phonebook2::Pbk2AppUi()->ActiveView()->MenuBar()->ItemSpecificCommandsEnabled();
       
  1422     TBool result = iNavigation->HandleCommandKeyL( aKeyEvent, aType );
       
  1423 
       
  1424     if(!result && aType == EEventKey)
       
  1425         {
       
  1426         switch (aKeyEvent.iCode)
       
  1427             {
       
  1428             case EKeyBackspace:
       
  1429                 {
       
  1430                 if ( (itemSpecEnabled && (iControl->NumberOfContacts() > 0) )
       
  1431                         || iControl->ContactsMarked() )
       
  1432                     {
       
  1433                     if ( iControl->FindTextL() == KNullDesC )
       
  1434                         {
       
  1435                         HandleCommandL( EPbk2CmdRemoveFromGroup );
       
  1436                         result = ETrue;
       
  1437                         }
       
  1438                     }
       
  1439                 break;
       
  1440                 }
       
  1441             case EKeyEnter: // FALLTHROUGH
       
  1442             case EKeyOK:
       
  1443                 {
       
  1444                 if ( !ShiftDown(aKeyEvent) ) // pure OK or ENTER key
       
  1445                     {
       
  1446                     if ( iControl->ContactsMarked() && itemSpecEnabled )
       
  1447                         {
       
  1448                         result = ETrue;
       
  1449                         }
       
  1450                     else if ( iControl->NumberOfContacts() == 0 )
       
  1451                         {
       
  1452                         result = ETrue;
       
  1453                         }
       
  1454                     }
       
  1455                 break;
       
  1456                 }
       
  1457 
       
  1458             case EKeyPhoneSend:
       
  1459                 {
       
  1460                 // Use the EPbk2CmdCall id to identify that
       
  1461                 // call is being launched with send key
       
  1462                 if ( itemSpecEnabled && (iControl->NumberOfContacts() > 0) &&
       
  1463                      !iControl->ContactsMarked() )
       
  1464                     {
       
  1465                     // If there is a dialog display on the top of screen, don't make call.
       
  1466                     if ( !(CEikonEnv::Static()->EikAppUi()->IsDisplayingDialog()) )
       
  1467                         {
       
  1468                         // Use the EPbk2CmdCall id to identify that
       
  1469                         // call is being launched with send key
       
  1470                         HandleCommandL( EPbk2CmdCall );
       
  1471                         }
       
  1472                     result = ETrue;
       
  1473                     }
       
  1474                 break;
       
  1475                 }
       
  1476 
       
  1477             case EKeyPoC:
       
  1478                 {
       
  1479                 // Use the EPbk2CmdPoC id to identify that
       
  1480                 // call is being launched with PoC key
       
  1481                 HandleCommandL( EPbk2CmdPoC );
       
  1482                 result = ETrue;
       
  1483                 break;
       
  1484                 }
       
  1485 
       
  1486             default:
       
  1487                 {
       
  1488                 break;
       
  1489                 }
       
  1490             }
       
  1491         }
       
  1492 
       
  1493     // Update selection modifier key state
       
  1494     iSelectionModifierUsed = IsShiftOrControlDown( aKeyEvent ) ||
       
  1495         ( (aType == EEventKeyDown) && (aKeyEvent.iCode == EStdKeyHash) );
       
  1496 
       
  1497     return result;
       
  1498     }
       
  1499 
       
  1500 // --------------------------------------------------------------------------
       
  1501 // CPguGroupMembersView::CGroupMembersAllGroupsReady::GetViewSpecificMenuFi
       
  1502 // --------------------------------------------------------------------------
       
  1503 //
       
  1504 TInt CPguGroupMembersView::CGroupMembersAllGroupsReady::
       
  1505         GetViewSpecificMenuFilteringFlagsL() const
       
  1506     {
       
  1507     return iControl->GetMenuFilteringFlagsL();
       
  1508     }
       
  1509 
       
  1510 // --------------------------------------------------------------------------
       
  1511 // CPguGroupMembersView::CGroupMembersAllGroupsReady::DynInitMenuPaneL
       
  1512 // --------------------------------------------------------------------------
       
  1513 //
       
  1514 void CPguGroupMembersView::CGroupMembersAllGroupsReady::DynInitMenuPaneL
       
  1515         ( TInt aResourceId, CEikMenuPane* aMenuPane )
       
  1516     {
       
  1517     // Ask the control do control specific filtering
       
  1518     // (for example call HandleMarkableListDynInitMenuPane if needed)
       
  1519     iControl->DynInitMenuPaneL(aResourceId, aMenuPane);
       
  1520     
       
  1521     switch ( aResourceId )
       
  1522         {
       
  1523         case R_PHONEBOOK2_OPEN_ME_MENU:
       
  1524             {
       
  1525             // Weed out commands not meant to be used with empty list
       
  1526             // Weed out commands not meant to be used with marked items
       
  1527             if ( iControl->NumberOfContacts() == 0 ||
       
  1528                     iControl->ContactsMarked() )
       
  1529                 {
       
  1530                 aMenuPane->SetItemDimmed( EPbk2CmdOpenCca, ETrue );
       
  1531                 }
       
  1532             break;
       
  1533             }
       
  1534 
       
  1535         case R_PHONEBOOK2_GROUPMEMBERS_MENU:
       
  1536             {
       
  1537             // Weed out commands not meant to be used with empty list
       
  1538             if ( iControl->NumberOfContacts() == 0 )
       
  1539                 {
       
  1540                 aMenuPane->SetItemDimmed( EPbk2CmdRemoveFromGroup, ETrue );
       
  1541                 aMenuPane->SetItemDimmed( EPbk2CmdBelongsToGroups, ETrue );
       
  1542                 }
       
  1543 
       
  1544             if ( iControl->ContactsMarked() )
       
  1545                 {
       
  1546                 aMenuPane->SetItemDimmed( EPbk2CmdBelongsToGroups, ETrue );
       
  1547                 aMenuPane->SetItemDimmed( EPbk2CmdAddMembers, ETrue );
       
  1548                 }
       
  1549             // Weed out commands not meant to be if names list is empty
       
  1550             if ( Phonebook2::Pbk2AppUi()->ApplicationServices().
       
  1551                     ViewSupplier().AllContactsViewL()->ContactCountL() == 0 )
       
  1552                 {
       
  1553                 aMenuPane->SetItemDimmed( EPbk2CmdAddMembers, ETrue );
       
  1554                 }
       
  1555             break;
       
  1556             }
       
  1557 
       
  1558         case R_PHONEBOOK2_BCARD_SEND_MENU:
       
  1559             {
       
  1560             // Weed out commands not meant to be used with empty list
       
  1561             if ( iControl->NumberOfContacts() == 0 )
       
  1562                 {
       
  1563                 aMenuPane->SetItemDimmed( EPbk2CmdSend, ETrue );
       
  1564                 }
       
  1565                 
       
  1566             // When Marking mode is active,
       
  1567             // Send as business card item should be shown in pop up menu.
       
  1568             if( iMarkingModeOn )
       
  1569                 {
       
  1570                 aMenuPane->SetItemSpecific( EPbk2CmdSend, ETrue );
       
  1571                 }
       
  1572             break;
       
  1573             }
       
  1574 
       
  1575         case R_PHONEBOOK2_GROUPMEMBERS_CONTEXT_MENU:
       
  1576             {
       
  1577             // Weed out commands not meant to be used with empty list
       
  1578             if ( iControl->NumberOfContacts() == 0 )
       
  1579                 {
       
  1580                 aMenuPane->SetItemDimmed( EPbk2CmdRemoveFromGroup, ETrue );
       
  1581                 }
       
  1582 
       
  1583             // Weed out commands not meant to be used with marked items
       
  1584             if ( iControl->ContactsMarked() )
       
  1585                 {
       
  1586                 aMenuPane->SetItemDimmed( EPbk2CmdAddMembers, ETrue );
       
  1587                 }
       
  1588 
       
  1589             // Weed out commands not meant to be if names list is empty
       
  1590             if ( Phonebook2::Pbk2AppUi()->ApplicationServices().
       
  1591                     ViewSupplier().AllContactsViewL()->ContactCountL() == 0 )
       
  1592                 {
       
  1593                 aMenuPane->SetItemDimmed( EPbk2CmdAddMembers, ETrue );
       
  1594                 }
       
  1595             break;
       
  1596             }
       
  1597 
       
  1598         default:
       
  1599             {
       
  1600             
       
  1601             // Phonebook 2 menu filtering happens in Commands
       
  1602             iCommandHandler.DynInitMenuPaneL(aResourceId,
       
  1603                     aMenuPane, iView, *iControl );
       
  1604             }
       
  1605       
       
  1606         };
       
  1607     }
       
  1608 
       
  1609 // --------------------------------------------------------------------------
       
  1610 // CPguGroupMembersView::CGroupMembersAllGroupsReady::ContactViewReady
       
  1611 // --------------------------------------------------------------------------
       
  1612 //
       
  1613 void CPguGroupMembersView::CGroupMembersAllGroupsReady::ContactViewReady
       
  1614         ( MVPbkContactViewBase& aView )
       
  1615     {
       
  1616     // If we have a new view, lets change it
       
  1617     if ((&aView != iGroupMembersView) &&
       
  1618         (&aView == iViewTransitionTransaction->GroupMembersView()))
       
  1619         {
       
  1620         TRAP_IGNORE(DoCommitTransActionL(aView));
       
  1621         }
       
  1622     else
       
  1623         {
       
  1624         // When ContactViewReady() is called, the program needs to check whether 
       
  1625         // the namelist control in the container is visible or not. 
       
  1626         // If visible, call DrawDeferred() to refresh the container, 
       
  1627         // and if not, the container needs not to be refreshed to avoid flicker on the background.
       
  1628         if ( iContainer->Control() && iContainer->Control()->IsVisible() )
       
  1629             {
       
  1630             iContainer->DrawDeferred();
       
  1631             }
       
  1632         }
       
  1633     }
       
  1634 
       
  1635 // --------------------------------------------------------------------------
       
  1636 // CPguGroupMembersView::CGroupMembersAllGroupsReady::HandleNavigationEvent
       
  1637 // --------------------------------------------------------------------------
       
  1638 //
       
  1639 void CPguGroupMembersView::CGroupMembersAllGroupsReady::HandleNavigationEvent
       
  1640         ( const TEventType& aEventType )
       
  1641     {
       
  1642     if (aEventType == MPbk2NavigationObserver::EContactDeleted)
       
  1643         {
       
  1644         // Return to the previous view
       
  1645         TRAPD( err,
       
  1646             {
       
  1647             CPbk2ViewState* state = ViewStateLC();
       
  1648             if ( iViewParent.FocusedContact() )
       
  1649                 {
       
  1650                 // change focused contact to current focused contact
       
  1651                 state->SetFocusedContact(
       
  1652                     iViewParent.FocusedContact()->CloneLC() );
       
  1653                 CleanupStack::Pop(); // currentGroup
       
  1654                 }
       
  1655             Phonebook2::Pbk2AppUi()->Pbk2ViewExplorer()->
       
  1656                 ActivatePreviousViewL( state );
       
  1657             CleanupStack::PopAndDestroy(state);
       
  1658             } ); // TRAPD
       
  1659 
       
  1660         if ( err != KErrNone )
       
  1661             {
       
  1662             CCoeEnv::Static()->HandleError( err );
       
  1663             }
       
  1664         }
       
  1665     }
       
  1666 
       
  1667 // --------------------------------------------------------------------------
       
  1668 // CPguGroupMembersView::CGroupMembersAllGroupsReady::DoCommitTransActionL
       
  1669 // --------------------------------------------------------------------------
       
  1670 //
       
  1671 void CPguGroupMembersView::CGroupMembersAllGroupsReady::DoCommitTransActionL
       
  1672         ( MVPbkContactViewBase& aView )
       
  1673     {
       
  1674     MVPbkContactLink* groupLink = iViewTransitionTransaction->GroupLink();
       
  1675     HBufC* titleText = iViewTransitionTransaction->GetGroupName();
       
  1676     CleanupStack::PushL( titleText );
       
  1677 
       
  1678     // Update navi indicators in the navi pane
       
  1679     iNavigation->UpdateNaviIndicatorsL( *groupLink );
       
  1680 
       
  1681     // Change title pane text
       
  1682     ChangeTitlePaneL(titleText);
       
  1683     CleanupStack::Pop(titleText);
       
  1684 
       
  1685     // Reset old view before changing
       
  1686     iContainer->Control()->Reset();
       
  1687 
       
  1688     // Set control's active view next
       
  1689     iContainer->Control()->SetViewL( aView );
       
  1690 
       
  1691     // Trash old view
       
  1692     if (iGroupMembersView)
       
  1693         {
       
  1694         iGroupMembersView->RemoveObserver( *this );
       
  1695         delete iGroupMembersView;
       
  1696         iGroupMembersView = NULL;
       
  1697         }
       
  1698 
       
  1699     // Set correct focused index (First item)
       
  1700     iContainer->Control()->SetFocusedContactIndexL(KFirstItem);
       
  1701 
       
  1702     //Set the current group link to Nameslist control
       
  1703    iContainer->Control()->SetCurrentGroupLinkL(groupLink);
       
  1704     // The new base view is already being observed by this class
       
  1705     // (observer set in ExpandLC call in ChangeContactL method)
       
  1706 
       
  1707     // commit the transaction
       
  1708     MVPbkContactViewBase* groupMembersView =
       
  1709         iViewTransitionTransaction->GetGroupMembersView();
       
  1710     groupLink = iViewTransitionTransaction->GetGroupLink();
       
  1711     iGroupMembersView = groupMembersView;
       
  1712     iViewParent.SetFocusedContact(groupLink);
       
  1713 
       
  1714     // delete the transaction
       
  1715     delete iViewTransitionTransaction;
       
  1716     iViewTransitionTransaction = NULL;
       
  1717     }
       
  1718 
       
  1719 // --------------------------------------------------------------------------
       
  1720 // CPguGroupMembersView::CGroupMembersAllGroupsReady::ChangeTitlePaneL
       
  1721 // --------------------------------------------------------------------------
       
  1722 //
       
  1723 void CPguGroupMembersView::CGroupMembersAllGroupsReady::ChangeTitlePaneL
       
  1724         ( HBufC* aTitleText )
       
  1725     {
       
  1726     CEikStatusPane* statusPane =
       
  1727         CEikonEnv::Static()->AppUiFactory()->StatusPane();
       
  1728 
       
  1729     if (statusPane && statusPane->PaneCapabilities(
       
  1730             TUid::Uid(EEikStatusPaneUidTitle)).IsPresent())
       
  1731         {
       
  1732         CAknTitlePane* titlePane = static_cast<CAknTitlePane*>(statusPane->
       
  1733                             ControlL(TUid::Uid(EEikStatusPaneUidTitle)));
       
  1734         titlePane->SetText(aTitleText); // Takes ownership of aTitle
       
  1735         }
       
  1736     }
       
  1737 
       
  1738 // --------------------------------------------------------------------------
       
  1739 // CPguGroupMembersView::CGroupMembersAllGroupsReady::UpdateListEmptyTextL
       
  1740 // --------------------------------------------------------------------------
       
  1741 //
       
  1742 void CPguGroupMembersView::CGroupMembersAllGroupsReady::UpdateListEmptyTextL
       
  1743         ( TInt aListState )
       
  1744     {
       
  1745     HBufC* text = NULL;
       
  1746 
       
  1747     switch ( aListState )
       
  1748         {
       
  1749         case CPbk2NamesListControl::EStateEmpty:
       
  1750             {
       
  1751             text = StringLoader::LoadLC( R_QTN_PHOB_NO_ENTRIES_IN_GRP );
       
  1752             break;
       
  1753             }
       
  1754         case CPbk2NamesListControl::EStateFiltered:
       
  1755             {
       
  1756             text = StringLoader::LoadLC( R_PBK2_FIND_NO_MATCHES );
       
  1757             break;
       
  1758             }
       
  1759         default:
       
  1760             {
       
  1761             text = KNullDesC().AllocLC();
       
  1762             break;
       
  1763             }
       
  1764         }
       
  1765 
       
  1766     if ( text )
       
  1767         {
       
  1768         iControl->SetTextL( *text );
       
  1769         CleanupStack::PopAndDestroy(); // text
       
  1770         }
       
  1771     }
       
  1772 
       
  1773 // --------------------------------------------------------------------------
       
  1774 // CPguGroupMembersView::CGroupMembersAllGroupsReady::UpdateCbasL
       
  1775 // --------------------------------------------------------------------------
       
  1776 //
       
  1777 void CPguGroupMembersView::CGroupMembersAllGroupsReady::UpdateCbasL()
       
  1778     {
       
  1779     if ( iControl )
       
  1780         {
       
  1781         if ( iControl->NumberOfContacts() > 0
       
  1782             && !iControl->ContactsMarked() )
       
  1783             {
       
  1784             // Set middle softkey as Open.
       
  1785             iView.Cba()->SetCommandSetL(R_PGU_SOFTKEYS_OPTIONS_BACK_OPEN);
       
  1786             iView.Cba()->DrawDeferred();
       
  1787             }
       
  1788         else
       
  1789             {
       
  1790             // If names list is empty, MSK should be empty
       
  1791             if ( Phonebook2::Pbk2AppUi()->ApplicationServices().
       
  1792                     ViewSupplier().AllContactsViewL()->ContactCountL() == 0 )
       
  1793                 {
       
  1794                 // Set middle softkey as Context menu.
       
  1795                 iView.Cba()->SetCommandSetL(
       
  1796                     R_PBK2_SOFTKEYS_OPTIONS_BACK_EMPTY);
       
  1797                 }
       
  1798             else
       
  1799                 {
       
  1800                 // Set middle softkey as Context menu.
       
  1801                 iView.Cba()->SetCommandSetL(
       
  1802                     R_PBK2_SOFTKEYS_OPTIONS_BACK_CONTEXT);
       
  1803                 }
       
  1804             iView.Cba()->DrawDeferred();
       
  1805             }
       
  1806         }
       
  1807     }
       
  1808 
       
  1809 // --------------------------------------------------------------------------
       
  1810 // CPguGroupMembersView::CGroupMembersAllGroupsReady::RestoreControlStateL
       
  1811 // --------------------------------------------------------------------------
       
  1812 //
       
  1813 void CPguGroupMembersView::CGroupMembersAllGroupsReady::RestoreControlStateL
       
  1814         ( CPbk2ViewState* aState )
       
  1815     {
       
  1816     if ( iControl )
       
  1817         {
       
  1818         iControl->RestoreControlStateL(aState);
       
  1819         }
       
  1820     }
       
  1821 
       
  1822 // --------------------------------------------------------------------------
       
  1823 // CPguGroupMembersView::CGroupMembersAllGroupsReady::HandleCommandL
       
  1824 // --------------------------------------------------------------------------
       
  1825 //
       
  1826 void CPguGroupMembersView::CGroupMembersAllGroupsReady::HandleCommandL
       
  1827         ( TInt aCommand )
       
  1828     { 
       
  1829         switch(aCommand)
       
  1830             {
       
  1831             case EPbk2CmdRemoveFromGroup:
       
  1832                 {
       
  1833                 if ( iControl && ( iControl->FocusedContactIndex() != KErrNotFound ) )
       
  1834                     {
       
  1835                     CPguRemoveFromGroupCmd* cmd =
       
  1836                             CPguRemoveFromGroupCmd::NewLC(
       
  1837                                 *iViewParent.FocusedContact(),
       
  1838                                 *iControl);
       
  1839                     iCommandHandler.AddAndExecuteCommandL(cmd);
       
  1840                     
       
  1841                     CleanupStack::Pop(cmd);  // command handler takes the ownership
       
  1842                     }
       
  1843                 break;
       
  1844                 }
       
  1845     
       
  1846             case EPbk2CmdAddMembers:
       
  1847                 {
       
  1848                 CPguAddMembersCmd* cmd =
       
  1849                         CPguAddMembersCmd::NewLC(*iViewParent.FocusedContact(),
       
  1850                             *iControl);
       
  1851                 iCommandHandler.AddAndExecuteCommandL(cmd);
       
  1852                 CleanupStack::Pop(cmd); // command handler takes the ownership
       
  1853                 break;
       
  1854                 }
       
  1855     
       
  1856             default:
       
  1857                 {
       
  1858                 // Do nothing
       
  1859                 break;
       
  1860                 }
       
  1861             }
       
  1862         
       
  1863     if ( iControl && !iCommandHandler.HandleCommandL( aCommand, *iControl,
       
  1864         &iView ) )
       
  1865             {
       
  1866             iControl->ProcessCommandL( aCommand );
       
  1867             Phonebook2::Pbk2AppUi()->HandleCommandL( aCommand );
       
  1868             }
       
  1869         
       
  1870     UpdateCbasL();
       
  1871     }
       
  1872 
       
  1873 // --------------------------------------------------------------------------
       
  1874 // CPguGroupMembersView::CGroupMembersAllGroupsReady::HandleStatusPaneSizeCh
       
  1875 // --------------------------------------------------------------------------
       
  1876 //
       
  1877 void CPguGroupMembersView::CGroupMembersAllGroupsReady::
       
  1878     HandleStatusPaneSizeChange()
       
  1879     {
       
  1880     // Resize the container to fill the client rectangle
       
  1881     if( iContainer )
       
  1882         {
       
  1883         iContainer->SetRect(iView.ClientRect());
       
  1884         }
       
  1885     }
       
  1886 
       
  1887 
       
  1888 // ----------------------------------------------------------------------------
       
  1889 // CPguGroupMembersView::CGroupMembersAllGroupsReady::HandleListBoxEventL
       
  1890 // ----------------------------------------------------------------------------
       
  1891 //
       
  1892 void CPguGroupMembersView::CGroupMembersAllGroupsReady::HandleListBoxEventL(CEikListBox* /*aListBox*/,TListBoxEvent aEventType)
       
  1893     { 
       
  1894 
       
  1895     if( AknLayoutUtils::PenEnabled() )  
       
  1896         {
       
  1897         switch ( aEventType )
       
  1898             {
       
  1899             case EEventItemDoubleClicked:
       
  1900             case EEventItemSingleClicked:
       
  1901                 {
       
  1902 
       
  1903                 ShowContextMenuL();
       
  1904                 break;
       
  1905                 }
       
  1906             case EEventItemClicked: //Happens after focus changed
       
  1907             break;
       
  1908             case EEventEnterKeyPressed:
       
  1909                 {
       
  1910                 if (iControl->NumberOfContacts() > 0 &&
       
  1911                     !iControl->ContactsMarked())
       
  1912                     {
       
  1913                     // Select key is mapped to "Open Contact" command
       
  1914                     HandleCommandL( EPbk2CmdOpenCca );
       
  1915                     }
       
  1916                 break;
       
  1917                 }
       
  1918             default:
       
  1919                break;
       
  1920             }
       
  1921         }
       
  1922 
       
  1923 
       
  1924     }
       
  1925 
       
  1926 
       
  1927 
       
  1928 
       
  1929 // --------------------------------------------------------------------------
       
  1930 // CPguGroupMembersView::CGroupMembersAllGroupsReady::HandlePointerEventL
       
  1931 // --------------------------------------------------------------------------
       
  1932 //
       
  1933 void CPguGroupMembersView::CGroupMembersAllGroupsReady::HandlePointerEventL
       
  1934         ( const TPointerEvent& aPointerEvent )
       
  1935     {
       
  1936     if ( AknLayoutUtils::PenEnabled() )
       
  1937         {
       
  1938         if ( iPointerEventInspector->FocusableItemPointed() && iContainer && !(iControl->ContactsMarked()))
       
  1939             {
       
  1940             iContainer->LongTapDetectorL().PointerEventL( aPointerEvent );
       
  1941             }
       
  1942         }
       
  1943     }
       
  1944     
       
  1945     
       
  1946 // --------------------------------------------------------------------------
       
  1947 // CPguGroupMembersView::CGroupMembersAllGroupsReady::ShowContextMenuL
       
  1948 // --------------------------------------------------------------------------
       
  1949 //
       
  1950 void CPguGroupMembersView::CGroupMembersAllGroupsReady::ShowContextMenuL()
       
  1951     {
       
  1952     if ( iStylusPopupMenuLaunched )
       
  1953         {
       
  1954         // Absorb EButton1Up event if we already launched the
       
  1955         // stylus popup menu
       
  1956         iStylusPopupMenuLaunched = EFalse;
       
  1957         }
       
  1958     else if ( !iPointerEventInspector->SearchFieldPointed() &&
       
  1959               !iSelectionModifierUsed )
       
  1960         {
       
  1961         if ( iControl->NumberOfContacts() > 0 && 
       
  1962                 iPointerEventInspector->FocusedItemPointed() )
       
  1963             {
       
  1964             if ( !iControl->ContactsMarked() )
       
  1965                 {
       
  1966                 // Open contact
       
  1967                 HandleCommandL(EPbk2CmdOpenCca);
       
  1968                 }
       
  1969             }
       
  1970         }
       
  1971     }
       
  1972    
       
  1973     
       
  1974     
       
  1975 
       
  1976 // --------------------------------------------------------------------------
       
  1977 // CPguGroupMembersView::CGroupMembersAllGroupsReady::HandleLongTapEventL
       
  1978 // --------------------------------------------------------------------------
       
  1979 //
       
  1980 void CPguGroupMembersView::CGroupMembersAllGroupsReady::HandleLongTapEventL
       
  1981         ( const TPoint& /*aPenEventLocation*/,
       
  1982           const TPoint& aPenEventScreenLocation )
       
  1983     {
       
  1984     if( iControl->ContactsMarked() )
       
  1985         {
       
  1986         //if there are marked contacts, context menu should not open
       
  1987         return;
       
  1988         }
       
  1989     }
       
  1990 
       
  1991 // --------------------------------------------------------------------------
       
  1992 // CPguGroupMembersView::CGroupMembersAllGroupsReady::PreCommandExecutionL
       
  1993 // --------------------------------------------------------------------------
       
  1994 //
       
  1995 void CPguGroupMembersView::CGroupMembersAllGroupsReady::PreCommandExecutionL
       
  1996         ( const MPbk2Command& /*aCommand*/ )
       
  1997     {    
       
  1998     if (iContainer && iContainer->Control())
       
  1999         {
       
  2000         iContainer->Control()->HideThumbnail();
       
  2001         }
       
  2002     }
       
  2003 
       
  2004 // --------------------------------------------------------------------------
       
  2005 // CPguGroupMembersView::CGroupMembersAllGroupsReady::PostCommandExecutionL
       
  2006 // --------------------------------------------------------------------------
       
  2007 //
       
  2008 void CPguGroupMembersView::CGroupMembersAllGroupsReady::PostCommandExecutionL
       
  2009         ( const MPbk2Command& /*aCommand*/ )
       
  2010     {    
       
  2011     if ( iContainer && iContainer->Control() )
       
  2012         {
       
  2013         iContainer->Control()->ShowThumbnail();
       
  2014         }
       
  2015 
       
  2016     UpdateCbasL();
       
  2017     }
       
  2018 
       
  2019 // --------------------------------------------------------------------------
       
  2020 // CPguGroupMembersView::CPguGroupMembersView
       
  2021 // --------------------------------------------------------------------------
       
  2022 //
       
  2023 CPguGroupMembersView::CPguGroupMembersView( CPbk2UIExtensionView& aView ) :
       
  2024             iView( aView )
       
  2025     {
       
  2026     }
       
  2027 
       
  2028 // --------------------------------------------------------------------------
       
  2029 // CPguGroupMembersView::~CPguGroupMembersView
       
  2030 // --------------------------------------------------------------------------
       
  2031 //
       
  2032 CPguGroupMembersView::~CPguGroupMembersView()
       
  2033     {
       
  2034     delete iFocusedGroup;
       
  2035     delete iControlState;
       
  2036     delete iViewImpl;
       
  2037     }
       
  2038 
       
  2039 // --------------------------------------------------------------------------
       
  2040 // CPguGroupMembersView::NewL
       
  2041 // --------------------------------------------------------------------------
       
  2042 //
       
  2043 CPguGroupMembersView* CPguGroupMembersView::NewL
       
  2044         ( CPbk2UIExtensionView& aView )
       
  2045     {
       
  2046     CPguGroupMembersView* self =
       
  2047         new(ELeave) CPguGroupMembersView( aView );
       
  2048     return self;
       
  2049     }
       
  2050 
       
  2051 // --------------------------------------------------------------------------
       
  2052 // CPguGroupMembersView::HandleStatusPaneSizeChange
       
  2053 // --------------------------------------------------------------------------
       
  2054 //
       
  2055 void CPguGroupMembersView::HandleStatusPaneSizeChange()
       
  2056     {
       
  2057     if ( iViewImpl )
       
  2058         {
       
  2059         iViewImpl->HandleStatusPaneSizeChange();
       
  2060         }
       
  2061     }
       
  2062 
       
  2063 // --------------------------------------------------------------------------
       
  2064 // CPguGroupMembersView::ViewStateLC
       
  2065 // --------------------------------------------------------------------------
       
  2066 //
       
  2067 CPbk2ViewState* CPguGroupMembersView::ViewStateLC() const
       
  2068     {
       
  2069     CPbk2ViewState* ret = NULL;
       
  2070     if ( iViewImpl )
       
  2071         {
       
  2072         ret = iViewImpl->ViewStateLC();
       
  2073         }
       
  2074     else
       
  2075         {
       
  2076         CleanupStack::PushL( ret ); // LC function semantics
       
  2077         }
       
  2078 
       
  2079     return ret;
       
  2080     }
       
  2081 
       
  2082 // --------------------------------------------------------------------------
       
  2083 // CPguGroupMembersView::HandleCommandKeyL
       
  2084 // --------------------------------------------------------------------------
       
  2085 //
       
  2086 TBool CPguGroupMembersView::HandleCommandKeyL(
       
  2087         const TKeyEvent& aKeyEvent,
       
  2088         TEventCode aType )
       
  2089     {
       
  2090     // Pass the key event to the strategy
       
  2091     return iViewImpl->HandleCommandKeyL(aKeyEvent, aType);
       
  2092     }
       
  2093 
       
  2094 // --------------------------------------------------------------------------
       
  2095 // CPguGroupMembersView::GetViewSpecificMenuFilteringFlagsL
       
  2096 // --------------------------------------------------------------------------
       
  2097 //
       
  2098 TInt CPguGroupMembersView::GetViewSpecificMenuFilteringFlagsL() const
       
  2099     {
       
  2100     TInt flags = iViewImpl->GetViewSpecificMenuFilteringFlagsL();
       
  2101     MPbk2ContactUiControl* ctrl = iViewImpl->Control();
       
  2102     if( ctrl )
       
  2103         {
       
  2104         const MVPbkViewContact* contact = ctrl->FocusedViewContactL();
       
  2105         if( contact && contact->Expandable() )
       
  2106             {
       
  2107             flags |= KPbk2FocusedItemIsExpandable;
       
  2108             }
       
  2109         }
       
  2110     return flags;
       
  2111     }
       
  2112 
       
  2113 // --------------------------------------------------------------------------
       
  2114 // CPguGroupMembersView::DoActivateL
       
  2115 // --------------------------------------------------------------------------
       
  2116 //
       
  2117 void CPguGroupMembersView::DoActivateL
       
  2118         ( const TVwsViewId& aPrevViewId, TUid aCustomMessageId,
       
  2119           const TDesC8& aCustomMessage )
       
  2120     {
       
  2121     UpdateViewStateL(aCustomMessageId, aCustomMessage);
       
  2122 
       
  2123     MPbk2ApplicationServices& appServices =
       
  2124         Phonebook2::Pbk2AppUi()->ApplicationServices();
       
  2125 
       
  2126     // Focus setting cannot be done here as the group view might not be ready
       
  2127     // when using view launch
       
  2128 
       
  2129     MVPbkContactViewBase* allGroupsView =
       
  2130         appServices.ViewSupplier().AllGroupsViewL();
       
  2131 
       
  2132     // get the focused group from the view parameters
       
  2133     const MVPbkContactLink* focusedGroupLink = iControlState->FocusedContact();
       
  2134     // find the group's index from the group view
       
  2135     TInt groupIndex = allGroupsView->IndexOfLinkL(*focusedGroupLink);
       
  2136     if (groupIndex == KErrNotFound)
       
  2137         {
       
  2138         // if the parameter is correct check whether the focused group is set
       
  2139         groupIndex = allGroupsView->IndexOfLinkL(*iFocusedGroup);
       
  2140         }
       
  2141     else
       
  2142         {
       
  2143         delete iFocusedGroup;
       
  2144         iFocusedGroup = iControlState->TakeFocusedContact();
       
  2145         }
       
  2146 
       
  2147     MPbk2ViewActivationTransaction* viewActivationTransaction = NULL;
       
  2148     if (groupIndex == KErrNotFound)
       
  2149         {
       
  2150         // if the group view isnt ready, thus the index cannot be retrieved,
       
  2151         // do a alternative view and refresh later, when the view is ready
       
  2152         viewActivationTransaction =
       
  2153             Phonebook2::Pbk2AppUi()->Pbk2ViewExplorer()->HandleViewActivationLC
       
  2154                 ( iView.Id(), aPrevViewId, NULL, NULL,
       
  2155                   Phonebook2::EUpdateNaviPane | Phonebook2::EUpdateTitlePane |
       
  2156                   Phonebook2::EUpdateContextPane );
       
  2157 
       
  2158         iViewImpl = CPguGroupMembersView::CGroupMembersAllGroupsNotReady::NewL
       
  2159             ( *this, iView, focusedGroupLink );
       
  2160         }
       
  2161     else
       
  2162         {
       
  2163         // standard phonebook view activation
       
  2164         const MVPbkViewContact& contact = allGroupsView->ContactAtL(groupIndex);
       
  2165         HBufC* title = appServices.NameFormatter().GetContactTitleL
       
  2166                 ( contact.Fields(),
       
  2167                   MPbk2ContactNameFormatter::EPreserveLeadingSpaces );
       
  2168         CleanupStack::PushL( title );
       
  2169 
       
  2170         viewActivationTransaction =
       
  2171             Phonebook2::Pbk2AppUi()->Pbk2ViewExplorer()->HandleViewActivationLC
       
  2172                 ( iView.Id(), aPrevViewId, title, NULL,
       
  2173                   Phonebook2::EUpdateNaviPane | Phonebook2::EUpdateTitlePane |
       
  2174                   Phonebook2::EUpdateContextPane );
       
  2175 
       
  2176 
       
  2177 
       
  2178         iViewImpl = CGroupMembersAllGroupsReady::NewL
       
  2179             ( *this, iView, appServices.ContactManager(),
       
  2180                 appServices.NameFormatter(), appServices.StoreProperties(),
       
  2181                 *appServices.CommandHandlerL(), appServices.SortOrderManager(),
       
  2182                 groupIndex );
       
  2183         }
       
  2184 
       
  2185     // notifies startup monitor of view activation
       
  2186     if (Phonebook2::Pbk2AppUi()->Pbk2StartupMonitor())
       
  2187         {
       
  2188         Phonebook2::Pbk2AppUi()->Pbk2StartupMonitor()->
       
  2189             NotifyViewActivationL( iView.Id() );
       
  2190         }
       
  2191 
       
  2192     iViewImpl->CreateControlL(iView.ClientRect());
       
  2193 
       
  2194     CPbk2NamesListControl* nlctrl=static_cast <CPbk2NamesListControl*> (iViewImpl->Control());
       
  2195 
       
  2196     // It will return the listbox by calling nlctrl->ComponentControl(0),
       
  2197     // which is defined in CPbk2NamesListControl::ComponentControl(TInt aIndex).
       
  2198     CCoeControl* ctrl=nlctrl->ComponentControl(0);
       
  2199     CEikListBox* listbox=static_cast <CEikListBox*> (ctrl);
       
  2200     listbox->SetListBoxObserver( this );
       
  2201     listbox->SetMarkingModeObserver( this );
       
  2202 
       
  2203     iPreviousViewId = aPrevViewId;
       
  2204 
       
  2205     viewActivationTransaction->Commit();
       
  2206     CleanupStack::PopAndDestroy(); // viewActivationTransaction
       
  2207     if (groupIndex != KErrNotFound)
       
  2208         {
       
  2209         CleanupStack::PopAndDestroy(); // title
       
  2210         }
       
  2211     }
       
  2212 
       
  2213 // --------------------------------------------------------------------------
       
  2214 // CPguGroupMembersView::DoDeactivate
       
  2215 // --------------------------------------------------------------------------
       
  2216 //
       
  2217 void CPguGroupMembersView::DoDeactivate()
       
  2218     {
       
  2219     // Trash the old states
       
  2220     delete iControlState;
       
  2221     iControlState = NULL;
       
  2222 
       
  2223     // Store current state, safe to ignore. There's no real harm,
       
  2224     // if theres no stored state when activating this view again
       
  2225     TRAP_IGNORE( StoreStateL() );
       
  2226 
       
  2227     delete iViewImpl;
       
  2228     iViewImpl = NULL;
       
  2229     }
       
  2230 
       
  2231 // --------------------------------------------------------------------------
       
  2232 // CPguGroupMembersView::HandleCommandL
       
  2233 // --------------------------------------------------------------------------
       
  2234 //
       
  2235 void CPguGroupMembersView::HandleCommandL( TInt aCommand )
       
  2236     {
       
  2237     switch ( aCommand )
       
  2238         {
       
  2239         case EAknSoftkeyBack:       // FALLTHROUGH
       
  2240         case EPbk2CmdOpenPreviousView:
       
  2241             {
       
  2242             ReturnToPreviousViewL();
       
  2243             break;
       
  2244             }
       
  2245         default:
       
  2246             {
       
  2247             if ( iViewImpl )
       
  2248                 {
       
  2249                 // route handle command to view implementation
       
  2250                 iViewImpl->HandleCommandL(aCommand);
       
  2251                 }
       
  2252             break;
       
  2253             }
       
  2254         }
       
  2255     }
       
  2256 
       
  2257 // --------------------------------------------------------------------------
       
  2258 // CPguGroupMembersView::DynInitMenuPaneL
       
  2259 // --------------------------------------------------------------------------
       
  2260 //
       
  2261 void CPguGroupMembersView::DynInitMenuPaneL(
       
  2262         TInt aResourceId, CEikMenuPane* aMenuPane )
       
  2263     {
       
  2264     if ( iViewImpl )
       
  2265         {
       
  2266         // Ask the control do control specific filtering
       
  2267         // (for example call HandleMarkableListDynInitMenuPane if needed)
       
  2268         iViewImpl->DynInitMenuPaneL(aResourceId, aMenuPane);
       
  2269         }
       
  2270     }
       
  2271 
       
  2272 // ----------------------------------------------------------------------------
       
  2273 // CPguGroupMembersView::HandleListBoxEventL
       
  2274 // ----------------------------------------------------------------------------
       
  2275 //
       
  2276 void CPguGroupMembersView::HandleListBoxEventL(CEikListBox* aListBox,TListBoxEvent aEventType)
       
  2277     {
       
  2278     
       
  2279     
       
  2280     
       
  2281     if( AknLayoutUtils::PenEnabled() )  
       
  2282         {
       
  2283         switch ( aEventType )
       
  2284             {
       
  2285             case EEventItemDoubleClicked:
       
  2286             case EEventItemSingleClicked:
       
  2287             case EEventEnterKeyPressed:
       
  2288                 {
       
  2289 
       
  2290                 if ( iViewImpl )
       
  2291                     {
       
  2292                     // route the events to the view implementing the application
       
  2293                     // view currently
       
  2294                     iViewImpl->HandleListBoxEventL(aListBox,aEventType);
       
  2295                     }
       
  2296                 break;
       
  2297                 }
       
  2298             case EEventItemClicked: //Happens after focus changed
       
  2299             break;
       
  2300             default:
       
  2301                break;
       
  2302             }
       
  2303         }
       
  2304      
       
  2305     }
       
  2306 
       
  2307 
       
  2308 
       
  2309 // --------------------------------------------------------------------------
       
  2310 // CPguGroupMembersView::HandlePointerEventL
       
  2311 // --------------------------------------------------------------------------
       
  2312 //
       
  2313 void CPguGroupMembersView::HandlePointerEventL(
       
  2314         const TPointerEvent& aPointerEvent)
       
  2315     {
       
  2316     if ( iViewImpl && !iViewImpl->IsMarkingModeOn() )
       
  2317         {
       
  2318         // Route the pointer events to the view implementing the application
       
  2319         // view currently except the Marking mode is active, 
       
  2320         // because the event is handled by avkon when marking mode is active.
       
  2321         iViewImpl->HandlePointerEventL(aPointerEvent);
       
  2322         }
       
  2323     }
       
  2324 
       
  2325 // --------------------------------------------------------------------------
       
  2326 // CPguGroupMembersView::HandleLongTapEventL
       
  2327 // --------------------------------------------------------------------------
       
  2328 //
       
  2329 void CPguGroupMembersView::HandleLongTapEventL(
       
  2330         const TPoint& aPenEventLocation,
       
  2331         const TPoint& aPenEventScreenLocation )
       
  2332     {
       
  2333     if ( iViewImpl )
       
  2334         {
       
  2335         // route the long tap event to the view implementing the application
       
  2336         // view currently
       
  2337         iViewImpl->HandleLongTapEventL(
       
  2338             aPenEventLocation, aPenEventScreenLocation );
       
  2339         }
       
  2340     }
       
  2341 
       
  2342 // -----------------------------------------------------------------------------
       
  2343 // CPguGroupMembersView::MarkingModeStatusChanged
       
  2344 // -----------------------------------------------------------------------------
       
  2345 //
       
  2346 void CPguGroupMembersView::MarkingModeStatusChanged( TBool aActivated )
       
  2347     {
       
  2348     if( iViewImpl )
       
  2349         {
       
  2350         iViewImpl->SetMarkingModeOn( aActivated );
       
  2351         CPbk2NamesListControl* nlctrl = 
       
  2352             static_cast <CPbk2NamesListControl*> (iViewImpl->Control());
       
  2353         if( !aActivated )
       
  2354             {
       
  2355             // It will return the findbox by calling 
       
  2356             // nlctrl->ComponentControl(1), which is defined in 
       
  2357             // CPbk2NamesListControl::ComponentControl(TInt aIndex).
       
  2358             CCoeControl* ctrl=nlctrl->ComponentControl(1);
       
  2359             if( ctrl->IsVisible() )
       
  2360                 {
       
  2361                 // Clear the text of the FindBox
       
  2362                 // when canceling from Marking mode.
       
  2363                 TRAP_IGNORE( nlctrl->ResetFindL() );
       
  2364                 }
       
  2365             }
       
  2366         nlctrl->SetMarkingMode( aActivated );
       
  2367         }
       
  2368     }
       
  2369 
       
  2370 // -----------------------------------------------------------------------------
       
  2371 // CPguGroupMembersView::ExitMarkingMode
       
  2372 // Called by avkon, if the return value is ETrue, 
       
  2373 // the Marking mode will be canceled after any operation,
       
  2374 // otherwise the Marking mode keep active.
       
  2375 // -----------------------------------------------------------------------------
       
  2376 //
       
  2377 TBool CPguGroupMembersView::ExitMarkingMode() const
       
  2378     {
       
  2379     return EFalse; 
       
  2380     }
       
  2381 
       
  2382 // --------------------------------------------------------------------------
       
  2383 // CPguGroupMembersView::TransformViewActivationStateToReady
       
  2384 // --------------------------------------------------------------------------
       
  2385 //
       
  2386 void CPguGroupMembersView::TransformViewActivationStateToReadyL(
       
  2387         const TInt aGroupIndex)
       
  2388     {
       
  2389     if ( aGroupIndex == KErrNotFound )
       
  2390         {
       
  2391         ReturnToPreviousViewL();
       
  2392         }
       
  2393     else
       
  2394         {
       
  2395         // Pops the control from the control stack
       
  2396         delete iViewImpl;
       
  2397         iViewImpl = NULL;
       
  2398 
       
  2399         // Switch view control states
       
  2400         MPbk2ApplicationServices& appServices =
       
  2401             Phonebook2::Pbk2AppUi()->ApplicationServices();
       
  2402         iViewImpl = CPguGroupMembersView::CGroupMembersAllGroupsReady::NewL
       
  2403             ( *this, iView, appServices.ContactManager(),
       
  2404               appServices.NameFormatter(), appServices.StoreProperties(),
       
  2405               *appServices.CommandHandlerL(), appServices.SortOrderManager(),
       
  2406               aGroupIndex );
       
  2407 
       
  2408         // Creates and activates the control
       
  2409         iViewImpl->CreateControlL(iView.ClientRect());
       
  2410         }
       
  2411     }
       
  2412 
       
  2413 // --------------------------------------------------------------------------
       
  2414 // CPguGroupMembersView::FocusedContact
       
  2415 // --------------------------------------------------------------------------
       
  2416 //
       
  2417 MVPbkContactLink* CPguGroupMembersView::FocusedContact() const
       
  2418     {
       
  2419     return iFocusedGroup;
       
  2420     }
       
  2421 
       
  2422 // --------------------------------------------------------------------------
       
  2423 // CPguGroupMembersView::SetFocusedContact
       
  2424 // --------------------------------------------------------------------------
       
  2425 //
       
  2426 void CPguGroupMembersView::SetFocusedContact(MVPbkContactLink* aGroupLink)
       
  2427     {
       
  2428     delete iFocusedGroup;
       
  2429     iFocusedGroup = aGroupLink;
       
  2430     }
       
  2431 
       
  2432 // --------------------------------------------------------------------------
       
  2433 // CPguGroupMembersView::StoreStateL
       
  2434 // --------------------------------------------------------------------------
       
  2435 //
       
  2436 void CPguGroupMembersView::StoreStateL()
       
  2437     {
       
  2438     // retrieves the views state from the implementation
       
  2439     CPbk2ViewState* state = ViewStateLC();
       
  2440     CleanupStack::Pop(state);
       
  2441     if ( state )
       
  2442         {
       
  2443         // and stores it as member data
       
  2444         delete iControlState;
       
  2445         iControlState = state;
       
  2446         }
       
  2447     }
       
  2448 
       
  2449 // --------------------------------------------------------------------------
       
  2450 // CPguGroupMembersView::RestoreStateL
       
  2451 // --------------------------------------------------------------------------
       
  2452 //
       
  2453 void CPguGroupMembersView::RestoreStateL()
       
  2454     {
       
  2455     iViewImpl->RestoreControlStateL(iControlState);
       
  2456     delete iControlState;
       
  2457     iControlState = NULL;
       
  2458     }
       
  2459 
       
  2460 // --------------------------------------------------------------------------
       
  2461 // CPguGroupMembersView::UpdateViewStateL
       
  2462 // --------------------------------------------------------------------------
       
  2463 //
       
  2464 void CPguGroupMembersView::UpdateViewStateL(
       
  2465         const TUid aCustomMessageId,
       
  2466         const TDesC8& aCustomMessage)
       
  2467     {
       
  2468     CPbk2ViewState* viewState = NULL;
       
  2469     // Read the desired UI state from aCustomMessage
       
  2470     if (aCustomMessageId == TUid::Uid(KPbkViewStateUid))
       
  2471         {
       
  2472         // Handle lecagy view state message
       
  2473         CPbk2ViewStateTransformer* transformer =
       
  2474             CPbk2ViewStateTransformer::NewLC
       
  2475                 ( Phonebook2::Pbk2AppUi()->ApplicationServices().
       
  2476                     ContactManager() );
       
  2477         viewState = transformer->TransformLegacyViewStateToPbk2ViewStateLC
       
  2478             ( aCustomMessage );
       
  2479         CleanupStack::Pop(); // viewState
       
  2480         CleanupStack::PopAndDestroy(transformer);
       
  2481         }
       
  2482     else if (aCustomMessageId == CPbk2ViewState::Uid())
       
  2483         {
       
  2484         // Read the desired UI state from aCustomMessage
       
  2485         viewState = CPbk2ViewState::NewL(aCustomMessage);
       
  2486         }
       
  2487     else
       
  2488         {
       
  2489         User::Leave(KErrNotSupported);
       
  2490         }
       
  2491 
       
  2492     if ( iControlState )
       
  2493         {
       
  2494         // Merge parameter view state with the stored state
       
  2495         if ( viewState->FocusedContact() &&
       
  2496              viewState->FocusedContact() != iControlState->FocusedContact() )
       
  2497             {
       
  2498             iControlState->SetFocusedContact(
       
  2499                             viewState->TakeFocusedContact() );
       
  2500             iControlState->SetFocusedFieldIndex( KErrNotFound );
       
  2501             iControlState->SetTopFieldIndex( KErrNotFound );
       
  2502             }
       
  2503         if ( viewState->FocusedFieldIndex() >= 0 )
       
  2504             {
       
  2505             iControlState->SetFocusedFieldIndex(
       
  2506                     viewState->FocusedFieldIndex() );
       
  2507             }
       
  2508         if ( viewState->TopFieldIndex() >= 0 )
       
  2509             {
       
  2510             iControlState->SetTopFieldIndex(
       
  2511                     viewState->TopFieldIndex() );
       
  2512             }
       
  2513         if ( viewState->ParentContact() &&
       
  2514              viewState->ParentContact() != iControlState->ParentContact() )
       
  2515             {
       
  2516             iControlState->SetParentContact(
       
  2517                 viewState->TakeParentContact() );
       
  2518             }
       
  2519 
       
  2520         // Input state overwrites the saved state. When the view is deactivated
       
  2521         // and then again activated marks are not set if the input state
       
  2522         /// doesn't say otherwise.
       
  2523         iControlState->SetMarkedContacts( viewState->TakeMarkedContacts() );
       
  2524 
       
  2525         // Delete parameter view state
       
  2526         delete viewState;
       
  2527         }
       
  2528     else
       
  2529         {
       
  2530         // No stored state, use the parameter supplied one
       
  2531         iControlState = viewState;
       
  2532         }
       
  2533     }
       
  2534 
       
  2535 // --------------------------------------------------------------------------
       
  2536 // CPguGroupMembersView::ReturnToPreviousViewL
       
  2537 // --------------------------------------------------------------------------
       
  2538 //
       
  2539 void CPguGroupMembersView::ReturnToPreviousViewL() const
       
  2540     {
       
  2541     CPbk2ViewState* state = ViewStateLC();
       
  2542     if ( iFocusedGroup )
       
  2543         {
       
  2544         // Change focused contact to current focused contact
       
  2545         state->SetFocusedContact( iFocusedGroup->CloneLC() );
       
  2546         CleanupStack::Pop(); // currentGroup
       
  2547         }
       
  2548     Phonebook2::Pbk2AppUi()->Pbk2ViewExplorer()->
       
  2549         ActivatePreviousViewL( state );
       
  2550     CleanupStack::PopAndDestroy(state);
       
  2551     }
       
  2552 
       
  2553 // End of File