landmarksui/uicontrols/inc/CLmkSelectorImplBase.h
branchRCL_3
changeset 17 1fc85118c3ae
parent 16 8173571d354e
child 18 870918037e16
equal deleted inserted replaced
16:8173571d354e 17:1fc85118c3ae
     1 /*
       
     2 * Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:    LandmarksUi Content File -    Selector functionality common to both application (view-based) and
       
    15                  common ui components (dialog-based).
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 
       
    21 
       
    22 
       
    23 
       
    24 
       
    25 #ifndef CLMKSELECTORIMPLBASE_H
       
    26 #define CLMKSELECTORIMPLBASE_H
       
    27 
       
    28 //  INCLUDES
       
    29 #include "MLmkListProviderObserver.h"
       
    30 #include <EPos_Landmarks.h> // Lm typedefs, constants etc.
       
    31 
       
    32 // FORWARD DECLARATIONS
       
    33 class CPosLandmarkDatabase;
       
    34 class CLmkListProviderBase;
       
    35 class CLmkSelectorIconMgr;
       
    36 class CAknIconArray;
       
    37 class CLmkUiUtils;
       
    38 class MLmkListMemento;
       
    39 class CEikListBox;
       
    40 class CEikonEnv;
       
    41 
       
    42 // CLASS DECLARATION
       
    43 
       
    44 /**
       
    45 *  Selector functionality common to both application (view-based) and
       
    46 *  common ui components (dialog-based).
       
    47 *
       
    48 */
       
    49 class CLmkSelectorImplBase
       
    50 : public CBase,
       
    51   public MLmkListProviderObserver
       
    52     {
       
    53     public:  // Constructors and destructor
       
    54         /**
       
    55         * Destructor.
       
    56         */
       
    57         ~CLmkSelectorImplBase();
       
    58 
       
    59     public: // New functions
       
    60         /**
       
    61         * Sets memento to be used by this class. Memento's
       
    62         * lifetime must be at least as long as this class's lifetime.
       
    63         * @param aMemento
       
    64         */
       
    65         IMPORT_C void SetMemento( MLmkListMemento& aMemento );
       
    66 
       
    67         /**
       
    68         * Creates a memento (but does not set it with SetMemento()).
       
    69         * @return created memento, ownership is transferred
       
    70         */
       
    71         virtual MLmkListMemento* MementoL() = 0;
       
    72 
       
    73         /**
       
    74         * Template method implemented by the subclass and called by
       
    75         * the base class.
       
    76         */
       
    77         virtual void SetupListProviderL() = 0;
       
    78 
       
    79         /**
       
    80         * Template method implemented by the subclass and called by
       
    81         * the base class. Needed since composite selector doesn't
       
    82         * have own list provider but it utilizes other providers.
       
    83         * @return CLmkListProviderBase reference
       
    84         */
       
    85         virtual const CLmkListProviderBase& ListProvider() const = 0;
       
    86 
       
    87         /**
       
    88         * Return number of visible items
       
    89         * @return TInt
       
    90         */
       
    91         virtual TInt ListVisibleItemCount() = 0;
       
    92 
       
    93         /**
       
    94         * Return number of marked items
       
    95         * @return TInt
       
    96         */
       
    97         virtual TInt ListMarkedItemCountL() = 0;
       
    98 
       
    99     protected: // New functions
       
   100         /**
       
   101         * Helper method which creates icon array and icon manager, sets
       
   102         * default icons and gives icon manager reference to list provider.
       
   103         * @return created icon array, left in the cleanup stack
       
   104         */
       
   105         CAknIconArray* SetupIconMgrLC();
       
   106 
       
   107         /**
       
   108         * Helper method for storing listbox state.
       
   109         * @param aListbox
       
   110         * @param aProvider
       
   111         * @param aFiltered
       
   112         */
       
   113         void Store( const CEikListBox& aListBox,
       
   114                     const CLmkListProviderBase& aProvider,
       
   115                     TBool aFiltered );
       
   116 
       
   117         /**
       
   118         * Helper method for restoring listbox state
       
   119         * @param aListbox
       
   120         * @param aProvider
       
   121         * @param aFiltered
       
   122         */
       
   123         void Restore( const CEikListBox& aListBox,
       
   124                       const CLmkListProviderBase& aProvider,
       
   125                       TBool aFiltered );
       
   126 
       
   127     protected: // From MLmkListProviderObserver
       
   128         void HandleListProviderEvent( TLmkListProviderEventType aEvent );
       
   129 
       
   130     protected: // Constructors and destructor
       
   131         /**
       
   132         * C++ default constructor.
       
   133         * @param aDb
       
   134         * @return newly instantiated object
       
   135         */
       
   136         CLmkSelectorImplBase( CPosLandmarkDatabase& aDb );
       
   137 
       
   138         /**
       
   139         * By default Symbian 2nd phase constructor is private.
       
   140         */
       
   141         void BaseConstructL();
       
   142 
       
   143     protected: // Data
       
   144 
       
   145         ///Ref:
       
   146         CPosLandmarkDatabase& iDb;
       
   147 
       
   148         ///Ref:
       
   149         MLmkListMemento* iMemento;
       
   150 
       
   151         ///Own:
       
   152         CLmkListProviderBase* iListProvider;
       
   153 
       
   154         ///Own:
       
   155         CLmkSelectorIconMgr* iIconMgr;
       
   156 
       
   157         ///Own:
       
   158         CLmkUiUtils* iLmkUiUtils;
       
   159 
       
   160     private: // Internal classes
       
   161 
       
   162         // This struct-like class is used for postponing memento.
       
   163         // It does not own any heap data.
       
   164         class TLmkRestoreData
       
   165             {
       
   166             public: // Constructor:
       
   167                 TLmkRestoreData();
       
   168 
       
   169             public: // Public data:
       
   170                 TBool iRestoreRequested;
       
   171                 const CEikListBox* iListBox;
       
   172                 const CLmkListProviderBase* iProvider;
       
   173                 TBool iFiltered;
       
   174             };
       
   175 
       
   176     private: // Data
       
   177         // These should not be used by subclasses, their content is
       
   178         // guaranteed to be correct only within this class.
       
   179 
       
   180         ///Latest provider event recorded by this class
       
   181         TLmkListProviderEventType iSelectorImplBaseLatestListEvent;
       
   182 
       
   183         ///Contains information for possible postponed memento operation
       
   184         TLmkRestoreData iRestoreData;
       
   185 
       
   186     protected:
       
   187         // Ref
       
   188         CEikonEnv*      iEnv;
       
   189     };
       
   190 
       
   191 #endif      // CLMKSELECTORIMPLBASE_H
       
   192 
       
   193 // End of File