22 #include <e32base.h> |
22 #include <e32base.h> |
23 #include <MVPbkSingleContactOperationObserver.h> |
23 #include <MVPbkSingleContactOperationObserver.h> |
24 #include <MPbk2ImageOperationObservers.h> |
24 #include <MPbk2ImageOperationObservers.h> |
25 #include <MVPbkContactViewObserver.h> |
25 #include <MVPbkContactViewObserver.h> |
26 #include <TPbk2IconId.h> |
26 #include <TPbk2IconId.h> |
27 |
27 #include "MPbk2FilteredViewStack.h" |
28 |
28 |
29 //FORWARD declaration |
29 //FORWARD declaration |
30 class CPbk2ImageManager; |
30 class CPbk2ImageManager; |
31 class CVPbkContactManager; |
31 class CVPbkContactManager; |
32 class MVPbkContactOperationBase; |
32 class MVPbkContactOperationBase; |
83 * Class for loading contact thumbnails |
83 * Class for loading contact thumbnails |
84 */ |
84 */ |
85 NONSHARABLE_CLASS( CPbk2ThumbnailManager ) : public CBase, |
85 NONSHARABLE_CLASS( CPbk2ThumbnailManager ) : public CBase, |
86 public MVPbkSingleContactOperationObserver, |
86 public MVPbkSingleContactOperationObserver, |
87 public MPbk2ImageGetObserver, |
87 public MPbk2ImageGetObserver, |
88 public MVPbkContactViewObserver |
88 public MVPbkContactViewObserver, |
|
89 public MPbk2FilteredViewStackObserver |
89 { |
90 { |
90 public: // constructor & destructor |
91 public: // constructor & destructor |
91 |
92 |
92 IMPORT_C static CPbk2ThumbnailManager* NewL( CVPbkContactManager& aContactManager ); |
93 IMPORT_C static CPbk2ThumbnailManager* NewL( CVPbkContactManager& aContactManager ); |
93 virtual ~CPbk2ThumbnailManager(); |
94 virtual ~CPbk2ThumbnailManager(); |
108 |
109 |
109 /* |
110 /* |
110 * Returns icon index from Pbk2IconArray for double listbox index. |
111 * Returns icon index from Pbk2IconArray for double listbox index. |
111 * If icon is not set, default icon index is returned |
112 * If icon is not set, default icon index is returned |
112 */ |
113 */ |
113 TInt GetPbkIconIndex( TInt aListboxIndex, const MVPbkBaseContact& aContactLink ); |
114 TInt GetPbkIconIndexL( TInt aListboxIndex, const MVPbkBaseContact& aContactLink ); |
114 |
115 |
115 /* |
116 /* |
116 * Setter for default icon ID |
117 * Setter for default icon ID |
117 */ |
118 */ |
118 void SetDefaultIconId( TPbk2IconId aDefaultIconId ); |
119 void SetDefaultIconId( TPbk2IconId aDefaultIconId ); |
134 |
135 |
135 /* |
136 /* |
136 * Returns number of loaded thumbnails |
137 * Returns number of loaded thumbnails |
137 */ |
138 */ |
138 TInt ThumbnailCount(); |
139 TInt ThumbnailCount(); |
139 |
140 |
140 /* |
|
141 * Adds contact to the array and starts loading the thumbnail for it. |
|
142 * If loading is already in progress, contact is added to queue. |
|
143 * |
|
144 */ |
|
145 void LoadThumbnailL( const MVPbkContactLink& aContactLink, TInt aListboxIndex ); |
|
146 |
|
147 /* |
|
148 * Removes contact from loader's array and deletes the thumbnail. |
|
149 * Returns KErrNone or KErrNotFound. |
|
150 */ |
|
151 TInt RemoveThumbnail( const MVPbkContactLink& aContactLink, TInt aListboxIndex ); |
|
152 |
|
153 /** |
141 /** |
154 * Reset thumbnail manager. Clear cache and cancel all ongoing operations. |
142 * Reset thumbnail manager. Clear cache and cancel all ongoing operations. |
155 */ |
143 */ |
156 void Reset(); |
144 void Reset(); |
157 |
145 |
163 /* |
151 /* |
164 * Getter for thumbnail icon size |
152 * Getter for thumbnail icon size |
165 */ |
153 */ |
166 const TSize& GetThumbnailIconSize(); |
154 const TSize& GetThumbnailIconSize(); |
167 |
155 |
|
156 /** |
|
157 * Set view for thumbnail manager. Thumbnail manager will start observing the |
|
158 * view and update it's internal state accordingly. Remove view by setting it |
|
159 * to NULL. |
|
160 */ |
|
161 void SetContactViewL( MPbk2FilteredViewStack* aView ); |
|
162 |
168 private: // new functions |
163 private: // new functions |
169 |
164 |
170 /* |
165 /** |
171 * If contact is added to middle of the list, increase indexes that are added after the given index |
166 * Removes contact from loader's array and deletes the thumbnail. |
172 */ |
167 */ |
173 void IncreaseIndexes( TInt aListboxIndex ); |
168 void RemoveThumbnail( const MVPbkContactLink& aContactLink, TInt aListboxIndex ); |
174 |
169 |
175 /* |
170 /* |
176 * If contact is removed from middle of the list, decrease indexes that are added after the given index |
171 * reset listbox indexes to match the array order |
177 */ |
172 */ |
178 void DecreaseIndexes( TInt aListboxIndex ); |
173 void ResetIndexes(); |
179 |
174 |
180 /* |
175 /* |
181 * Removes allready loaded thumbnail from the last position of the priorization array. |
176 * Removes allready loaded thumbnail from the last position of the priorization array. |
182 * Removes also image from Pbk2IconArray and iContactThumbnails. |
177 * Removes also image from Pbk2IconArray and iContactThumbnails. |
183 */ |
178 */ |
184 void MakeRoomForNextThumbnail(); |
179 void MakeRoomForNextThumbnail(); |
185 |
180 |
186 /* |
181 /* |
187 * Finds correct item from the iContactThumbnails based on the base contact |
|
188 */ |
|
189 CPbk2TmItem* FindItem( const MVPbkBaseContact& aContactLink ); |
|
190 /* |
|
191 * Starts loading of the contact thumbnails. |
182 * Starts loading of the contact thumbnails. |
192 */ |
183 */ |
193 void StartLoading(); |
184 void StartLoading(); |
194 |
185 |
195 /* |
186 /* |
219 |
210 |
220 /** |
211 /** |
221 * Handle view ready events |
212 * Handle view ready events |
222 */ |
213 */ |
223 void DoContactViewReadyL( MVPbkContactViewBase& aView ); |
214 void DoContactViewReadyL( MVPbkContactViewBase& aView ); |
|
215 |
|
216 /** |
|
217 * Create empty thumbnail item array reflecting the aView. |
|
218 */ |
|
219 void PreCreateThumbnailArrayL( MVPbkContactViewBase& aView ); |
224 |
220 |
225 private: // From MVPbkSingleContactOperationObserver |
221 private: // From MVPbkSingleContactOperationObserver |
226 void VPbkSingleContactOperationComplete( |
222 void VPbkSingleContactOperationComplete( |
227 MVPbkContactOperationBase& aOperation, |
223 MVPbkContactOperationBase& aOperation, |
228 MVPbkStoreContact* aContact ); |
224 MVPbkStoreContact* aContact ); |
253 void ContactViewError( |
249 void ContactViewError( |
254 MVPbkContactViewBase& aView, |
250 MVPbkContactViewBase& aView, |
255 TInt aError, |
251 TInt aError, |
256 TBool aErrorNotified ); |
252 TBool aErrorNotified ); |
257 |
253 |
258 |
254 private: // From MPbk2FilteredViewStackObserver |
|
255 void TopViewChangedL( MVPbkContactViewBase& aOldView ); |
|
256 void TopViewUpdatedL(); |
|
257 void BaseViewChangedL(); |
|
258 void ViewStackError( TInt aError ); |
|
259 void ContactAddedToBaseView( |
|
260 MVPbkContactViewBase& aBaseView, |
|
261 TInt aIndex, |
|
262 const MVPbkContactLink& aContactLink ); |
|
263 |
|
264 |
259 private: //constructors |
265 private: //constructors |
260 CPbk2ThumbnailManager( CVPbkContactManager& aContactManager ); |
266 CPbk2ThumbnailManager( CVPbkContactManager& aContactManager ); |
261 void ConstructL(); |
267 void ConstructL(); |
262 |
268 |
263 private: //data |
269 private: //data |
306 // loading priority. |
312 // loading priority. |
307 RArray<MVPbkContactLink*> iPriorityArray; |
313 RArray<MVPbkContactLink*> iPriorityArray; |
308 /// Own: Holds the item whose thumbnail load is in progress |
314 /// Own: Holds the item whose thumbnail load is in progress |
309 /// This item needs to be removed when its safe |
315 /// This item needs to be removed when its safe |
310 CPbk2TmItem* iInProgressItemToBeRemoved; |
316 CPbk2TmItem* iInProgressItemToBeRemoved; |
|
317 /// Not own. Filtered view of contacts. |
|
318 MPbk2FilteredViewStack* iView; |
311 }; |
319 }; |
312 |
320 |
313 #endif /* CPBK2THUMBNAILMANAGER_H_ */ |
321 #endif /* CPBK2THUMBNAILMANAGER_H_ */ |