1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/epoc32/include/app/CVPbkFilteredContactView.h Wed Mar 31 12:33:34 2010 +0100
1.3 @@ -0,0 +1,163 @@
1.4 +/*
1.5 +* Copyright (c) 2004-2007 Nokia Corporation and/or its subsidiary(-ies).
1.6 +* All rights reserved.
1.7 +* This component and the accompanying materials are made available
1.8 +* under the terms of "Eclipse Public License v1.0"
1.9 +* which accompanies this distribution, and is available
1.10 +* at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.11 +*
1.12 +* Initial Contributors:
1.13 +* Nokia Corporation - initial contribution.
1.14 +*
1.15 +* Contributors:
1.16 +*
1.17 +* Description: Virtual Phonebook Filtered contact view.
1.18 +*
1.19 +*/
1.20 +
1.21 +
1.22 +#ifndef CVPBKFILTEREDCONTACTVIEW_H
1.23 +#define CVPBKFILTEREDCONTACTVIEW_H
1.24 +
1.25 +// INCLUDES
1.26 +#include <e32base.h>
1.27 +#include <mvpbkcontactviewbase.h>
1.28 +#include <mvpbkcontactviewobserver.h>
1.29 +#include <mvpbkcontactviewfiltering.h>
1.30 +
1.31 +// FORWARD DECLARATIONS
1.32 +namespace VPbkEngUtils { class CVPbkAsyncOperation; }
1.33 +class MVPbkContactSelector;
1.34 +
1.35 +/**
1.36 + * Virtual Phonebook filtered contact view.
1.37 + * This class can be used for filtering an existing view. A client
1.38 + * gives the view for filtering and also a contact selector that
1.39 + * is used to select contacts from the given view.
1.40 + */
1.41 +class CVPbkFilteredContactView :
1.42 + public CBase,
1.43 + public MVPbkContactViewBase,
1.44 + public MVPbkContactViewObserver,
1.45 + public MVPbkContactViewFiltering
1.46 + {
1.47 + public:
1.48 + /**
1.49 + * Two-phase constructor.
1.50 + * NOTE: Does not support find functionality.
1.51 + *
1.52 + * @param aBaseView The view to filter.
1.53 + * @param aObserver an observer that is notified when this
1.54 + * view is ready for use.
1.55 + * @param aContactSelector A contact selector for selecting
1.56 + * contacts to the view.
1.57 + * @return A new instance of this class
1.58 + */
1.59 + IMPORT_C static CVPbkFilteredContactView* NewL(
1.60 + MVPbkContactViewBase& aBaseView,
1.61 + MVPbkContactViewObserver& aObserver,
1.62 + MVPbkContactSelector& aContactSelector);
1.63 +
1.64 + /**
1.65 + * Two-phase constructor.
1.66 + * Note: Supports find functionality.
1.67 + *
1.68 + * @param aBaseView The view to filter.
1.69 + * @param aObserver an observer that is notified when this
1.70 + * view is ready for use.
1.71 + * @param aContactSelector A contact selector for selecting
1.72 + * contacts to the view.
1.73 + * @param aMasterFieldTypeList Field type list
1.74 + * @return A new instance of this class
1.75 + */
1.76 + IMPORT_C static CVPbkFilteredContactView* NewL(
1.77 + MVPbkContactViewBase& aBaseView,
1.78 + MVPbkContactViewObserver& aObserver,
1.79 + MVPbkContactSelector& aContactSelector,
1.80 + const MVPbkFieldTypeList& aMasterFieldTypeList );
1.81 +
1.82 + /**
1.83 + * Destructor.
1.84 + */
1.85 + ~CVPbkFilteredContactView();
1.86 +
1.87 + protected: // From MVPbkContactViewBase
1.88 + TVPbkContactViewType Type() const;
1.89 + void ChangeSortOrderL(const MVPbkFieldTypeList& aSortOrder);
1.90 + const MVPbkFieldTypeList& SortOrder() const;
1.91 + void RefreshL();
1.92 + TInt ContactCountL() const;
1.93 + const MVPbkViewContact& ContactAtL(TInt aIndex) const;
1.94 + MVPbkContactLink* CreateLinkLC(TInt aIndex) const;
1.95 + TInt IndexOfLinkL(const MVPbkContactLink& aContactLink) const;
1.96 + void AddObserverL(MVPbkContactViewObserver& aObserver);
1.97 + void RemoveObserver(MVPbkContactViewObserver& aObserver);
1.98 + TBool MatchContactStore(const TDesC& aContactStoreUri) const;
1.99 + TBool MatchContactStoreDomain(const TDesC& aContactStoreDomain) const;
1.100 + MVPbkContactBookmark* CreateBookmarkLC(TInt aIndex) const;
1.101 + TInt IndexOfBookmarkL(
1.102 + const MVPbkContactBookmark& aContactBookmark) const;
1.103 + MVPbkContactViewFiltering* ViewFiltering();
1.104 +
1.105 + private: // From MVPbkContactViewFiltering
1.106 + MVPbkContactViewBase* CreateFilteredViewLC(
1.107 + MVPbkContactViewObserver& aObserver,
1.108 + const MDesCArray& aFindWords,
1.109 + const MVPbkContactBookmarkCollection* aAlwaysIncludedContacts );
1.110 +
1.111 + void UpdateFilterL(
1.112 + const MDesCArray& aFindWords,
1.113 + const MVPbkContactBookmarkCollection* aAlwaysIncludedContacts );
1.114 +
1.115 + private: // From MVPbkContactViewObserver
1.116 + void ContactViewReady(MVPbkContactViewBase& aView);
1.117 + void ContactViewUnavailable(MVPbkContactViewBase& aView);
1.118 + void ContactAddedToView(
1.119 + MVPbkContactViewBase& aView,
1.120 + TInt aIndex, const
1.121 + MVPbkContactLink& aContactLink );
1.122 + void ContactRemovedFromView(
1.123 + MVPbkContactViewBase& aView,
1.124 + TInt aIndex,
1.125 + const MVPbkContactLink& aContactLink );
1.126 + void ContactViewError(
1.127 + MVPbkContactViewBase& aView,
1.128 + TInt aError,
1.129 + TBool aErrorNotified );
1.130 +
1.131 + private: // Implementation
1.132 + CVPbkFilteredContactView(
1.133 + MVPbkContactViewBase& aBaseView,
1.134 + MVPbkContactSelector& aContactSelector,
1.135 + const MVPbkFieldTypeList* aMasterFieldTypeList );
1.136 + void ConstructL( MVPbkContactViewObserver& aObserver );
1.137 + void BuildViewMappingL();
1.138 + void HandleBuildViewMapping();
1.139 + void DoAddObserverL(MVPbkContactViewObserver& aObserver);
1.140 + void AddObserverError(MVPbkContactViewObserver& aObserver, TInt aError);
1.141 +
1.142 + TInt UpdateViewMappingAfterAddingL( TInt aBaseIndex );
1.143 + TInt UpdateViewMappingAfterDeleting( TInt aBaseIndex );
1.144 +
1.145 + private: // Data
1.146 + ///Own: Indicated whether view is ready
1.147 + TBool iIsReady;
1.148 + ///Ref: Contact base view
1.149 + MVPbkContactViewBase& iBaseView;
1.150 + ///Ref: Contact view selection criteria
1.151 + MVPbkContactSelector& iContactSelector;
1.152 + ///Ref: Master field type list
1.153 + const MVPbkFieldTypeList* iMasterFieldTypeList;
1.154 + ///Own: Asynchronous operation
1.155 + VPbkEngUtils::CVPbkAsyncOperation* iAsyncOperation;
1.156 + ///Own: Mapping between base view and filtered view
1.157 + RArray<TInt> iContactMapping;
1.158 + ///Ref: Array to view observers
1.159 + RPointerArray<MVPbkContactViewObserver> iObservers;
1.160 + };
1.161 +
1.162 +#endif // CVPBKFILTEREDCONTACTVIEW_H
1.163 +
1.164 +//End of file
1.165 +
1.166 +