phonebookengines/VirtualPhonebook/VPbkEng/inc/CVPbkFindView.h
changeset 0 e686773b3f54
child 35 4ae315f230bc
equal deleted inserted replaced
-1:000000000000 0:e686773b3f54
       
     1 /*
       
     2 * Copyright (c) 2004-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:  Find contact view
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef CVPBKFINDVIEW_H
       
    20 #define CVPBKFINDVIEW_H
       
    21 
       
    22 #include <e32base.h>
       
    23 #include <MVPbkContactViewBase.h>
       
    24 #include <MVPbkContactViewObserver.h>
       
    25 #include <MVPbkContactViewFiltering.h>
       
    26 #include <badesca.h>
       
    27 
       
    28 namespace VPbkEngUtils { class CVPbkAsyncOperation; }
       
    29 
       
    30 class CVPbkFieldTypeRefsList;
       
    31 class CVPbkContactNameConstructionPolicy;
       
    32 class CVPbkContactFindPolicy;
       
    33 
       
    34 /**
       
    35  * Virtual Phonebook Find view
       
    36  *
       
    37  * This class can be used for find from an existing view. A client
       
    38  * gives the view for find.
       
    39  */
       
    40 NONSHARABLE_CLASS( CVPbkFindView ): public CBase,
       
    41                                     public MVPbkContactViewBase,
       
    42                                     public MVPbkContactViewObserver,
       
    43                                     public MVPbkContactViewFiltering
       
    44 	{
       
    45     public:
       
    46         /**
       
    47          * Two-phase constructor.
       
    48          *
       
    49          * @param aBaseView The view to filter.
       
    50          * @param aObserver an observer that is notified when this
       
    51          *                  view is ready for use.
       
    52          * @param aFindWords an array words that must match to the contact.
       
    53          * @param aAlwaysIncludedContacts contacts that must be in the view
       
    54          *                                even they don't match to aFindWords.
       
    55          *                                This an optional parameter. Give
       
    56          *                                NULL if not needed.
       
    57          * @param aMasterFieldTypeList Field type list
       
    58          * @return a new instance of this class         
       
    59          */
       
    60         static CVPbkFindView* NewLC(
       
    61                 MVPbkContactViewBase& aBaseView,
       
    62                 MVPbkContactViewObserver& aObserver,
       
    63                 const MDesCArray& aFindWords,
       
    64                 const MVPbkContactBookmarkCollection* aAlwaysIncludedContacts,
       
    65                 const MVPbkFieldTypeList& aMasterFieldTypeList );
       
    66         ~CVPbkFindView();
       
    67 
       
    68     protected: // From MVPbkContactViewBase
       
    69         TVPbkContactViewType Type() const;
       
    70         void ChangeSortOrderL(const MVPbkFieldTypeList& aSortOrder);
       
    71         const MVPbkFieldTypeList& SortOrder() const;
       
    72         void RefreshL();
       
    73         TInt ContactCountL() const;
       
    74         const MVPbkViewContact& ContactAtL(TInt aIndex) const;
       
    75         MVPbkContactLink* CreateLinkLC(TInt aIndex) const;
       
    76         TInt IndexOfLinkL(const MVPbkContactLink& aContactLink) const;
       
    77         void AddObserverL(MVPbkContactViewObserver& aObserver);
       
    78         void RemoveObserver(MVPbkContactViewObserver& aObserver);
       
    79         TBool MatchContactStore(const TDesC& aContactStoreUri) const;
       
    80         TBool MatchContactStoreDomain(const TDesC& aContactStoreDomain) const;
       
    81         MVPbkContactBookmark* CreateBookmarkLC(TInt aIndex) const;
       
    82         TInt IndexOfBookmarkL(
       
    83             const MVPbkContactBookmark& aContactBookmark) const;
       
    84         MVPbkContactViewFiltering* ViewFiltering();
       
    85     
       
    86     private: // From MVPbkContactViewFiltering    
       
    87         MVPbkContactViewBase* CreateFilteredViewLC( 
       
    88                 MVPbkContactViewObserver& aObserver,
       
    89                 const MDesCArray& aFindWords,
       
    90                 const MVPbkContactBookmarkCollection* aAlwaysIncludedContacts );
       
    91             
       
    92         void UpdateFilterL( 
       
    93                 const MDesCArray& aFindWords,
       
    94                 const MVPbkContactBookmarkCollection* aAlwaysIncludedContacts );
       
    95         
       
    96     private: // From MVPbkContactViewObserver
       
    97         void ContactViewReady(MVPbkContactViewBase& aView);
       
    98         void ContactViewUnavailable(MVPbkContactViewBase& aView);
       
    99         void ContactAddedToView(
       
   100                 MVPbkContactViewBase& aView, 
       
   101                 TInt aIndex, 
       
   102                 const MVPbkContactLink& aContactLink );
       
   103         void ContactRemovedFromView(
       
   104                 MVPbkContactViewBase& aView, 
       
   105                 TInt aIndex, 
       
   106                 const MVPbkContactLink& aContactLink );
       
   107         void ContactViewError(
       
   108                 MVPbkContactViewBase& aView, 
       
   109                 TInt aError, 
       
   110                 TBool aErrorNotified );
       
   111 
       
   112     private: // Implementation
       
   113         CVPbkFindView(
       
   114                 MVPbkContactViewBase& aBaseView,                
       
   115                 const MVPbkFieldTypeList* aMasterFieldTypeList );
       
   116         void ConstructL(
       
   117                 const MDesCArray& aFindWords,
       
   118                 const MVPbkContactBookmarkCollection* aAlwaysIncludedContacts );
       
   119         void BuildViewMappingL();
       
   120         void HandleBuildViewMapping();
       
   121         void DoAddObserverL(MVPbkContactViewObserver& aObserver);
       
   122         void AddObserverError(MVPbkContactViewObserver& aObserver, TInt aError);
       
   123         TBool ContactMatchRefineL(         
       
   124                 const MVPbkViewContact& aViewContact,
       
   125                 TPtrC aFindWord );
       
   126         void SetFindStringsL( const MDesCArray& aFindWords );
       
   127         void SetAlwaysIncludedContactsL( 
       
   128                 const MVPbkContactBookmarkCollection* aAlwaysIncludedContacts );
       
   129         void SendViewEventToObservers( 
       
   130             void( MVPbkContactViewObserver::* aObserverFunc)
       
   131             ( MVPbkContactViewBase& ) );
       
   132         void SendViewErrorEventToObservers( TInt aError, TBool 
       
   133             aErrorNotified );
       
   134 
       
   135     private: // Data
       
   136         ///Own: indicated whether view is ready
       
   137         TBool iIsReady;
       
   138         ///Ref: contact base view
       
   139         MVPbkContactViewBase& iBaseView;
       
   140         ///Ref: Master field type list
       
   141         const MVPbkFieldTypeList* iMasterFieldTypeList;
       
   142         ///Own: Asynchronous operation
       
   143         VPbkEngUtils::CVPbkAsyncOperation* iAsyncOperation;
       
   144         ///Own: mapping between base view and filtered view
       
   145         RArray<TInt> iContactMapping;
       
   146         ///Ref: array to view observers
       
   147         RPointerArray<MVPbkContactViewObserver> iObservers;
       
   148         /// Own: find words for filtering
       
   149         CDesCArrayFlat* iFindStrings;
       
   150         /// Own: a field type list for name construction policy
       
   151         CVPbkFieldTypeRefsList* iFieldTypeRefsList;
       
   152         /// Own: a policy for name formatting
       
   153         CVPbkContactNameConstructionPolicy* iNameConstructionPolicy;
       
   154         /// Own: a policy for match
       
   155         CVPbkContactFindPolicy* iContactFindPolicy;
       
   156         /// Own: always included contacts
       
   157         const MVPbkContactBookmarkCollection* iAlwaysIncludedContacts;
       
   158     };
       
   159 
       
   160 #endif // CVPBKFINDVIEW_H
       
   161 
       
   162 //End of file
       
   163 
       
   164