phonebookui/Phonebook/inc/CPbkContactFindView.h
changeset 0 e686773b3f54
equal deleted inserted replaced
-1:000000000000 0:e686773b3f54
       
     1 /*
       
     2 * Copyright (c) 2002 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: 
       
    15 *     Sub view to a CContactViewBase.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 #ifndef __CPbkContactFindView_H__
       
    21 #define __CPbkContactFindView_H__
       
    22 
       
    23 // INCLUDES
       
    24 #include <cntviewbase.h>
       
    25 #include "MPbkFindPrimitives.h"
       
    26 
       
    27 
       
    28 // FORWARD DECLARATIONS
       
    29 class CPbkContactEngine;
       
    30 class MPbkContactNameFormat;
       
    31 /// For testing only
       
    32 class CPbkContactFindView_TestAccess;
       
    33 
       
    34 
       
    35 // CLASS DECLARATION
       
    36 
       
    37 /**
       
    38  * @internal Only Phonebook internal use supported.
       
    39  *
       
    40  * Specialized Contact Find View for Phonebook. Implements features needed
       
    41  * by the Find UI.
       
    42  */
       
    43 class CPbkContactFindView :
       
    44         public CContactViewBase, 
       
    45         private MContactViewObserver
       
    46 	{
       
    47     public:  // Constructors and destructors
       
    48         /**
       
    49          * Creates a new instance of this class.
       
    50          *
       
    51          * @param aEngine   Phonebook engine.
       
    52          * @param aBaseView the view this view is based on.
       
    53          * @param aObserver observer for this contact view.
       
    54          * @param aNameFormat   contact name formatting interface. Used by
       
    55          *                      find to filter contacts by name.
       
    56          * @param aFindPrimitives   find matching primitives to use
       
    57          * @return a new instance of this class.
       
    58          */
       
    59 	    IMPORT_C static CPbkContactFindView* NewL
       
    60             (CPbkContactEngine& aEngine,
       
    61             CContactViewBase& aBaseView,
       
    62             MContactViewObserver& aObserver,
       
    63             MPbkFindPrimitives& aFindPrimitives);
       
    64 
       
    65     public:  // New functions
       
    66         /**
       
    67          * Filters this view to contain only entries which match a find text.
       
    68          *
       
    69          * @param aFindText         text to match.
       
    70          * @param aIncludeAlways    contacts to include always in this view
       
    71          *                          even if they don't match aFindText.
       
    72          * @return ETrue if this view's contents changed.
       
    73          */
       
    74         IMPORT_C TBool SetFindTextL
       
    75             (const TDesC& aFindText,
       
    76 			const CContactIdArray* aIncludeAlways = NULL);
       
    77 
       
    78         /**
       
    79          * Returns the current find text.
       
    80          */
       
    81         IMPORT_C const TDesC& FindText() const;
       
    82 
       
    83         /**
       
    84          * Stops find filtering of this view.
       
    85          * @return ETrue if this view's contents changed.
       
    86          */
       
    87         IMPORT_C TBool ResetFind();
       
    88 
       
    89         /**
       
    90          * Returns the index of first contact in this view matching FindText().
       
    91          * Returns -1 if there are no matches or FindText() is empty.
       
    92          */
       
    93         IMPORT_C TInt IndexOfFirstFindMatchL() const;
       
    94             
       
    95         /**
       
    96          * Pointer to a find matching function.
       
    97          * @param aTargetText   text to search for aFindText
       
    98          * @param aFindText     text to search from aTargetText
       
    99          * @return ETrue if aFindText matches aTargetText, EFalse otherwise.
       
   100          */
       
   101         typedef TBool (*TFindMatcher)(const TDesC& aTargetText,
       
   102 			const TDesC& aFindText);
       
   103 
       
   104     public: // From CContactViewBase.
       
   105 	    TContactItemId AtL(TInt aIndex) const;
       
   106 	    const CViewContact& ContactAtL(TInt aIndex) const;
       
   107 	    TInt CountL() const;
       
   108 	    TInt FindL(TContactItemId aId) const;
       
   109 	    HBufC* AllFieldsLC(TInt aIndex,const TDesC& aSeparator) const;
       
   110 	    TContactViewPreferences ContactViewPreferences();
       
   111 	    const RContactViewSortOrder& SortOrderL() const;
       
   112         TAny* CContactViewBase_Reserved_1(TFunction aFunction,TAny* aParams);
       
   113 
       
   114     protected:  // Constructors and destructor
       
   115 	    CPbkContactFindView
       
   116             (CPbkContactEngine& aEngine, 
       
   117             CContactViewBase& aBaseView, 
       
   118             MPbkFindPrimitives& aFindPrimitives);
       
   119 	    void ConstructL(MContactViewObserver& aObserver);
       
   120 	    ~CPbkContactFindView();
       
   121 
       
   122     private: // From MContactViewObserver.
       
   123 	    void HandleContactViewEvent
       
   124             (const CContactViewBase& aView, const TContactViewEvent& aEvent);
       
   125 
       
   126    private:  // Implementation
       
   127 	    void HandleContactViewEventL(const TContactViewEvent& aEvent);
       
   128         class MState;
       
   129         friend class MState;
       
   130         class CStateBase;
       
   131         friend class CStateBase;
       
   132         class CNotReadyState;
       
   133         friend class CNotReadyState;
       
   134         class CReadyState;
       
   135         friend class CReadyState;
       
   136         class CFindState;
       
   137         friend class CFindState;
       
   138         inline void SetStateReady();
       
   139         inline void SetStateNotReady();
       
   140         /// For testing only
       
   141         friend class CPbkContactFindView_TestAccess;
       
   142 
       
   143     private:  // Data
       
   144         /// Own: current state
       
   145         MState* iCurrentState;
       
   146         /// Ref: the contact view this view is based on
       
   147 	    CContactViewBase& iBaseView;
       
   148         /// Ref: contact name formatter
       
   149         MPbkContactNameFormat& iNameFormatter;
       
   150         /// Ref: find matching primitives
       
   151         MPbkFindPrimitives* iFindPrimitives;
       
   152 	};
       
   153 
       
   154 
       
   155 #endif // __CPbkContactFindView_H__
       
   156 
       
   157 // End of File