|
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: Virtual Phonebook Filtered contact view. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef CVPBKFILTEREDCONTACTVIEW_H |
|
20 #define CVPBKFILTEREDCONTACTVIEW_H |
|
21 |
|
22 // INCLUDES |
|
23 #include <e32base.h> |
|
24 #include <MVPbkContactViewBase.h> |
|
25 #include <MVPbkContactViewObserver.h> |
|
26 #include <MVPbkContactViewFiltering.h> |
|
27 |
|
28 // FORWARD DECLARATIONS |
|
29 namespace VPbkEngUtils { class CVPbkAsyncOperation; } |
|
30 class MVPbkContactSelector; |
|
31 |
|
32 /** |
|
33 * Virtual Phonebook filtered contact view. |
|
34 * This class can be used for filtering an existing view. A client |
|
35 * gives the view for filtering and also a contact selector that |
|
36 * is used to select contacts from the given view. |
|
37 */ |
|
38 class CVPbkFilteredContactView : |
|
39 public CBase, |
|
40 public MVPbkContactViewBase, |
|
41 public MVPbkContactViewObserver, |
|
42 public MVPbkContactViewFiltering |
|
43 { |
|
44 public: |
|
45 /** |
|
46 * Two-phase constructor. |
|
47 * NOTE: Does not support find functionality. |
|
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 aContactSelector A contact selector for selecting |
|
53 * contacts to the view. |
|
54 * @return A new instance of this class |
|
55 */ |
|
56 IMPORT_C static CVPbkFilteredContactView* NewL( |
|
57 MVPbkContactViewBase& aBaseView, |
|
58 MVPbkContactViewObserver& aObserver, |
|
59 MVPbkContactSelector& aContactSelector); |
|
60 |
|
61 /** |
|
62 * Two-phase constructor. |
|
63 * Note: Supports find functionality. |
|
64 * |
|
65 * @param aBaseView The view to filter. |
|
66 * @param aObserver an observer that is notified when this |
|
67 * view is ready for use. |
|
68 * @param aContactSelector A contact selector for selecting |
|
69 * contacts to the view. |
|
70 * @param aMasterFieldTypeList Field type list |
|
71 * @return A new instance of this class |
|
72 */ |
|
73 IMPORT_C static CVPbkFilteredContactView* NewL( |
|
74 MVPbkContactViewBase& aBaseView, |
|
75 MVPbkContactViewObserver& aObserver, |
|
76 MVPbkContactSelector& aContactSelector, |
|
77 const MVPbkFieldTypeList& aMasterFieldTypeList ); |
|
78 |
|
79 /** |
|
80 * Destructor. |
|
81 */ |
|
82 ~CVPbkFilteredContactView(); |
|
83 |
|
84 protected: // From MVPbkContactViewBase |
|
85 TVPbkContactViewType Type() const; |
|
86 void ChangeSortOrderL(const MVPbkFieldTypeList& aSortOrder); |
|
87 const MVPbkFieldTypeList& SortOrder() const; |
|
88 void RefreshL(); |
|
89 TInt ContactCountL() const; |
|
90 const MVPbkViewContact& ContactAtL(TInt aIndex) const; |
|
91 MVPbkContactLink* CreateLinkLC(TInt aIndex) const; |
|
92 TInt IndexOfLinkL(const MVPbkContactLink& aContactLink) const; |
|
93 void AddObserverL(MVPbkContactViewObserver& aObserver); |
|
94 void RemoveObserver(MVPbkContactViewObserver& aObserver); |
|
95 TBool MatchContactStore(const TDesC& aContactStoreUri) const; |
|
96 TBool MatchContactStoreDomain(const TDesC& aContactStoreDomain) const; |
|
97 MVPbkContactBookmark* CreateBookmarkLC(TInt aIndex) const; |
|
98 TInt IndexOfBookmarkL( |
|
99 const MVPbkContactBookmark& aContactBookmark) const; |
|
100 MVPbkContactViewFiltering* ViewFiltering(); |
|
101 |
|
102 private: // From MVPbkContactViewFiltering |
|
103 MVPbkContactViewBase* CreateFilteredViewLC( |
|
104 MVPbkContactViewObserver& aObserver, |
|
105 const MDesCArray& aFindWords, |
|
106 const MVPbkContactBookmarkCollection* aAlwaysIncludedContacts ); |
|
107 |
|
108 void UpdateFilterL( |
|
109 const MDesCArray& aFindWords, |
|
110 const MVPbkContactBookmarkCollection* aAlwaysIncludedContacts ); |
|
111 |
|
112 private: // From MVPbkContactViewObserver |
|
113 void ContactViewReady(MVPbkContactViewBase& aView); |
|
114 void ContactViewUnavailable(MVPbkContactViewBase& aView); |
|
115 void ContactAddedToView( |
|
116 MVPbkContactViewBase& aView, |
|
117 TInt aIndex, const |
|
118 MVPbkContactLink& aContactLink ); |
|
119 void ContactRemovedFromView( |
|
120 MVPbkContactViewBase& aView, |
|
121 TInt aIndex, |
|
122 const MVPbkContactLink& aContactLink ); |
|
123 void ContactViewError( |
|
124 MVPbkContactViewBase& aView, |
|
125 TInt aError, |
|
126 TBool aErrorNotified ); |
|
127 |
|
128 private: // Implementation |
|
129 CVPbkFilteredContactView( |
|
130 MVPbkContactViewBase& aBaseView, |
|
131 MVPbkContactSelector& aContactSelector, |
|
132 const MVPbkFieldTypeList* aMasterFieldTypeList ); |
|
133 void ConstructL( MVPbkContactViewObserver& aObserver ); |
|
134 void BuildViewMappingL(); |
|
135 void HandleBuildViewMapping(); |
|
136 void DoAddObserverL(MVPbkContactViewObserver& aObserver); |
|
137 void AddObserverError(MVPbkContactViewObserver& aObserver, TInt aError); |
|
138 |
|
139 TInt UpdateViewMappingAfterAddingL( TInt aBaseIndex ); |
|
140 TInt UpdateViewMappingAfterDeleting( TInt aBaseIndex ); |
|
141 |
|
142 private: // Data |
|
143 ///Own: Indicated whether view is ready |
|
144 TBool iIsReady; |
|
145 ///Ref: Contact base view |
|
146 MVPbkContactViewBase& iBaseView; |
|
147 ///Ref: Contact view selection criteria |
|
148 MVPbkContactSelector& iContactSelector; |
|
149 ///Ref: Master field type list |
|
150 const MVPbkFieldTypeList* iMasterFieldTypeList; |
|
151 ///Own: Asynchronous operation |
|
152 VPbkEngUtils::CVPbkAsyncOperation* iAsyncOperation; |
|
153 ///Own: Mapping between base view and filtered view |
|
154 RArray<TInt> iContactMapping; |
|
155 ///Ref: Array to view observers |
|
156 RPointerArray<MVPbkContactViewObserver> iObservers; |
|
157 }; |
|
158 |
|
159 #endif // CVPBKFILTEREDCONTACTVIEW_H |
|
160 |
|
161 //End of file |
|
162 |
|
163 |