phonebookui/Phonebook2/UIControls/inc/CPbk2NamesListReadyState.h
branchRCL_3
changeset 20 f4a778e096c2
parent 0 e686773b3f54
equal deleted inserted replaced
19:5b6f26637ad3 20:f4a778e096c2
       
     1 /*
       
     2 * Copyright (c) 2005-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 names list ready state.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef CPBK2NAMESLISTREADYSTATE_H
       
    20 #define CPBK2NAMESLISTREADYSTATE_H
       
    21 
       
    22 //  INCLUDES
       
    23 #include <e32base.h>
       
    24 #include <coecntrl.h>
       
    25 #include <aknsfld.h>
       
    26 #include "MPbk2NamesListState.h"
       
    27 #include "MPbk2FindDelayObserver.h"
       
    28 #include "RPbk2ContactBookmarkCollection.h"
       
    29 #include <MPbk2UiControlCmdItem.h>
       
    30 #include <MPbk2CmdItemVisibilityObserver.h>
       
    31 
       
    32 // FORWARD DECLARATIONS
       
    33 class CPbk2ContactViewListBox;
       
    34 class MVPbkContactViewBase;
       
    35 class MVPbkContactLinkArray;
       
    36 class MVPbkContactBookmark;
       
    37 class CAknSearchField;
       
    38 class CPbk2ThumbnailLoader;
       
    39 class MPbk2UiControlEventSender;
       
    40 class TPointerEvent;
       
    41 class CPbk2FindDelay;
       
    42 class MPbk2Command;
       
    43 class MPbk2ContactNameFormatter;
       
    44 class CPbk2FindStringSplitter;
       
    45 class CVPbkContactFindPolicy;
       
    46 class CPbk2AdaptiveSearchGridFiller;
       
    47 class CPbk2PredictiveSearchFilter;
       
    48 class CVPbkContactLinkArray;
       
    49 // CLASS DECLARATION
       
    50 
       
    51 /**
       
    52  * Phonebook 2 names list ready state.
       
    53  * Responsible for:
       
    54  * - Implements names list control's ready state
       
    55  */
       
    56 NONSHARABLE_CLASS(CPbk2NamesListReadyState) :
       
    57         public CBase,
       
    58         public MPbk2NamesListState,
       
    59         public MPbk2FindDelayObserver,
       
    60         public MAdaptiveSearchTextObserver,
       
    61         public MPbk2CmdItemVisibilityObserver
       
    62     {
       
    63     public:  // Constructors and destructor
       
    64 
       
    65         /**
       
    66          * Creates a new instance of this class.
       
    67          *
       
    68          * @param aParent               Parent control.
       
    69          * @param aListBox              Reference to the list box.
       
    70          * @param aViewStack            A view stack for findbox filtering
       
    71          * @param aView                 The contact view.
       
    72          * @param aFindBox              Reference to find box.
       
    73          * @param aThumbnailLoader      Thumbnail loader.
       
    74          * @param aEventSender          UI control event sender.
       
    75          * @param aNameFormatter        Phonebook 2 contact name formatter interface
       
    76          * @param aCommandItems         Array of UI control Command item interface
       
    77          * @param aSearchFilter         PBk2 Search Filter
       
    78          * @return  A new instance of this class.
       
    79          */
       
    80         static CPbk2NamesListReadyState* NewLC(
       
    81                 const CCoeControl* aParent,
       
    82                 CPbk2ContactViewListBox& aListBox,
       
    83                 MPbk2FilteredViewStack& aViewStack,
       
    84                 CAknSearchField* aFindBox,
       
    85                 CPbk2ThumbnailLoader& aThumbnailLoader,
       
    86                 MPbk2UiControlEventSender& aEventSender,
       
    87                 MPbk2ContactNameFormatter& aNameFormatter,
       
    88                 RPointerArray<MPbk2UiControlCmdItem>& aCommandItems,
       
    89                 CPbk2PredictiveSearchFilter& aSearchFilter );
       
    90 
       
    91         /**
       
    92          * Destructor.
       
    93          */
       
    94         ~CPbk2NamesListReadyState();
       
    95 
       
    96     public: // From MPbk2NamesListState
       
    97         void ActivateStateL();
       
    98         void DeactivateState();
       
    99         TInt CountComponentControls() const;
       
   100         CCoeControl* ComponentControl(
       
   101                 TInt aIndex ) const;
       
   102         void SizeChanged();
       
   103         void MakeComponentsVisible(
       
   104                 TBool aVisible );
       
   105         void ActivateL();
       
   106         void Draw(
       
   107                 const TRect& aRect,
       
   108                 CWindowGc& aGc ) const;
       
   109         TKeyResponse OfferKeyEventL(
       
   110                 const TKeyEvent& aKeyEvent,
       
   111                 TEventCode aType );
       
   112         void HandlePointerEventL(
       
   113                 const TPointerEvent& aPointerEvent );
       
   114         TInt NamesListState() const;
       
   115         void HandleContactViewEventL(
       
   116                 TInt aEvent,
       
   117                 TInt aIndex );
       
   118         void HandleCommandEventL(TInt aEvent, TInt aCmdIndex);
       
   119         void HandleCommandItemEventL(TInt aEvent, TInt aListboxIndex);        
       
   120         CCoeControl& CoeControl();
       
   121         void HandleControlEventL(
       
   122                 CCoeControl* aControl,
       
   123                 MCoeControlObserver::TCoeEvent aEventType, TInt aParam );
       
   124         const MVPbkViewContact* TopContactL();
       
   125 
       
   126     public: // From MPbk2ContactUiControl
       
   127         MPbk2ContactUiControl* ParentControl() const;
       
   128         TInt NumberOfContacts() const;
       
   129         const MVPbkBaseContact* FocusedContactL() const;
       
   130         const MVPbkViewContact* FocusedViewContactL() const;
       
   131         const MVPbkStoreContact* FocusedStoreContact() const;
       
   132         void SetFocusedContactL(
       
   133                 const MVPbkBaseContact& aContact );
       
   134         void SetFocusedContactL(
       
   135                 const MVPbkContactBookmark& aContactBookmark );
       
   136         void SetFocusedContactL(
       
   137                 const MVPbkContactLink& aContactLink );
       
   138         TInt FocusedContactIndex() const;
       
   139         void SetFocusedContactIndexL(
       
   140                 TInt aIndex );
       
   141         TInt NumberOfContactFields() const;
       
   142         const MVPbkBaseContactField* FocusedField() const;
       
   143         TInt FocusedFieldIndex() const;
       
   144         void SetFocusedFieldIndex(
       
   145                 TInt aIndex );
       
   146         TBool ContactsMarked() const;
       
   147         MVPbkContactLinkArray* SelectedContactsL() const;
       
   148         MVPbkContactLinkArray* SelectedContactsOrFocusedContactL() const;
       
   149         MPbk2ContactLinkIterator* SelectedContactsIteratorL() const;
       
   150         CArrayPtr<MVPbkContactStore>* SelectedContactStoresL() const;
       
   151         void ClearMarks();
       
   152         void SetSelectedContactL(
       
   153                 TInt aIndex,
       
   154                 TBool aSelected );
       
   155         void SetSelectedContactL(
       
   156                 const MVPbkContactBookmark& aContactBookmark,
       
   157                 TBool aSelected );
       
   158         void SetSelectedContactL(
       
   159                 const MVPbkContactLink& aContactLink,
       
   160                 TBool aSelected );
       
   161         void DynInitMenuPaneL(
       
   162                 TInt aResourceId,
       
   163                 CEikMenuPane* aMenuPane ) const;
       
   164         void ProcessCommandL(
       
   165                 TInt aCommandId ) const;
       
   166         void UpdateAfterCommandExecution();
       
   167         TInt GetMenuFilteringFlagsL() const;
       
   168         CPbk2ViewState* ControlStateL() const;
       
   169         void RestoreControlStateL(
       
   170                 CPbk2ViewState* aState );
       
   171         const TDesC& FindTextL();
       
   172         void ResetFindL();
       
   173         void HideThumbnail();
       
   174         void ShowThumbnail();
       
   175         void SetBlank(
       
   176                 TBool aBlank );
       
   177         void RegisterCommand(
       
   178                 MPbk2Command* aCommand );
       
   179         void SetTextL(
       
   180                 const TDesC& aText );
       
   181         TAny* ContactUiControlExtension(TUid aExtensionUid );        
       
   182     
       
   183     public: // From MPbk2ContactUiControl2
       
   184         TInt CommandItemCount() const;
       
   185         const MPbk2UiControlCmdItem& CommandItemAt( TInt aIndex ) const;
       
   186         const MPbk2UiControlCmdItem* FocusedCommandItem() const;
       
   187         void DeleteCommandItemL( TInt aIndex );
       
   188         void AddCommandItemL(MPbk2UiControlCmdItem* aCommand, TInt aIndex);
       
   189     
       
   190     public: // From MPbk2PointerEventInspector
       
   191         TBool FocusedItemPointed();
       
   192         TBool FocusableItemPointed();
       
   193         TBool SearchFieldPointed();
       
   194 
       
   195     public: // From MPbk2FilteredViewStackObserver
       
   196         void TopViewChangedL( MVPbkContactViewBase& aOldView );
       
   197         void TopViewUpdatedL();
       
   198         void BaseViewChangedL();
       
   199         void ViewStackError( TInt aError );
       
   200         void ContactAddedToBaseView(
       
   201                 MVPbkContactViewBase& aBaseView, TInt aIndex,
       
   202                 const MVPbkContactLink& aContactLink );
       
   203 
       
   204     public: // From MPbk2FindDelayObserver
       
   205         void FindDelayComplete();
       
   206         
       
   207     public: // From MAdaptiveSearchTextObserver
       
   208         void AdaptiveSearchTextChanged( CAknSearchField* aSearchField ); 
       
   209 
       
   210 
       
   211     private: // From MPbk2AddFavoritesVisibilityObserver
       
   212         void CmdItemVisibilityChanged( TInt aCmdItemId, TBool aVisible );
       
   213 
       
   214     private: // Implementation
       
   215         CPbk2NamesListReadyState(const CCoeControl& aParent,
       
   216                 CPbk2ContactViewListBox& aListBox,
       
   217                 MPbk2FilteredViewStack& aViewStack,
       
   218                 CAknSearchField* aFindBox,
       
   219                 CPbk2ThumbnailLoader& aThumbnailLoader,
       
   220                 MPbk2UiControlEventSender& aEventSender,
       
   221                 MPbk2ContactNameFormatter& aNameFormatter,
       
   222                 RPointerArray<MPbk2UiControlCmdItem>& aCommandItems,
       
   223                 CPbk2PredictiveSearchFilter& aSearchFilter );
       
   224         void ConstructL();
       
   225         void SetFocusedContactL( TInt aIndex,
       
   226                 const MVPbkBaseContact* aContact  );
       
   227         TBool RestoreMarkedContactsL(
       
   228                 const MVPbkContactLinkArray* aMarkedContacts );
       
   229         void RestoreMarkedItemsL(
       
   230             const MVPbkContactBookmarkCollection& aMarkedItems );
       
   231         void DisableRedrawEnablePushL();
       
   232         void HandleFocusChangeL();
       
   233         void UpdateFindResultL();
       
   234         void UpdateFindBoxL();
       
   235         MVPbkContactBookmarkCollection& SelectedItemsL(
       
   236             MVPbkContactViewBase& aCurrentView );
       
   237         TBool HasSelectedItemsChangedL();
       
   238         void SetCurrentItemIndexAndDrawL();
       
   239         void UpdateAdaptiveSearchGridL( TBool aClearCache );
       
   240         TBool IsContactAtListboxIndex( TInt aListboxIndex ) const;
       
   241         void AllowCommandsToShowThemselves( TBool aVisible );  
       
   242         void UpdateCommandEnabled(TInt aCommandId, TBool aEnabled);
       
   243         void UnmarkCommands() const;
       
   244         TBool IsCommandEnabled( TInt aCommandId) const;
       
   245         TInt FindCommand(TInt aCommandId) const;
       
   246         TInt CalculateListboxIndex(TInt aCommandIndex) const;                
       
   247         void UnsubscribeCmdItemsVisibility() const;
       
   248         void SubscribeCmdItemsVisibility();
       
   249         void HandleListboxEventL(TInt aEvent, TInt aListboxIndex, TBool aMantainFocus);
       
   250         TInt EnabledCommandCount() const; 
       
   251 
       
   252         /*
       
   253          * If wanted contact link is my card, function checks command item extension
       
   254          * and fetches my card link. If the link exist, it is appended to the array
       
   255          */
       
   256         void AppendMyCardLinkIfExistL( CVPbkContactLinkArray& aArray ) const;
       
   257         
       
   258         CEikMenuBar* DialogMenuBar(CAknAppUi* aAppUi);
       
   259         CEikMenuBar* ViewMenuBar(CAknAppUi* aAppUi);
       
   260         CEikMenuBar* MenuBar(CAknAppUi* aAppUi);
       
   261         
       
   262     private: // Data
       
   263         /// Own: Buffer for text retrieved from iFindBox
       
   264         HBufC* iFindTextBuf;
       
   265         /// Own: find start typing delay
       
   266         CPbk2FindDelay* iFindDelay;
       
   267         /// Ref: Parent coecontrol
       
   268         const CCoeControl& iParent;
       
   269         /// Ref: The list box
       
   270         CPbk2ContactViewListBox& iListBox;
       
   271         /// Ref: The control view stack that also the contact view.
       
   272         MPbk2FilteredViewStack& iViewStack;
       
   273         /// Ref: Find box control
       
   274         CAknSearchField* iFindBox;
       
   275         /// Ref: Thumbnail loader
       
   276         CPbk2ThumbnailLoader& iThumbnailLoader;
       
   277         /// Own: Is this state visible
       
   278         TBool iVisible;
       
   279         /// Ref: UI control event sender
       
   280         MPbk2UiControlEventSender& iEventSender;
       
   281         /// Own: Search field indicator
       
   282         TBool iSearchFieldPointed;
       
   283         /// Own: Collection of selected/marked items
       
   284         RPbk2ContactBookmarkCollection iSelectedItems;
       
   285         /// Ref: Name formatter
       
   286         MPbk2ContactNameFormatter& iNameFormatter;
       
   287         /// Own: Array of search strings
       
   288         MDesCArray* iStringArray;
       
   289         /// Own: String splitter
       
   290         CPbk2FindStringSplitter* iStringSplitter;
       
   291         /// Own: Contact find policy
       
   292         CVPbkContactFindPolicy* iFindPolicy;
       
   293         /// Own: User to create keymaps for adaptive search grid.
       
   294         CPbk2AdaptiveSearchGridFiller *iAdaptiveSearchGridFiller;
       
   295         /// Ref: Command items
       
   296         RPointerArray<MPbk2UiControlCmdItem>& iCommandItems;
       
   297         /// Iterator indexes.
       
   298         mutable RArray<TInt> iIteratorIndexes;
       
   299         /// Ref :Search Pane Filter
       
   300         CPbk2PredictiveSearchFilter& iSearchFilter;
       
   301     };
       
   302 
       
   303 #endif // CPBK2NAMESLISTREADYSTATE_H
       
   304 
       
   305 // End of File