|
1 /* |
|
2 * Copyright (c) 2005-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: Phonebook 2 names list control. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef CPBK2NAMESLISTCONTROL_H |
|
20 #define CPBK2NAMESLISTCONTROL_H |
|
21 |
|
22 // INCLUDES |
|
23 #include <coecntrl.h> |
|
24 #include <MPbk2ContactUiControl.h> |
|
25 #include <MPbk2ContactUiControl2.h> |
|
26 #include <MVPbkContactViewObserver.h> |
|
27 #include <MPbk2PointerEventInspector.h> |
|
28 #include <MPbk2ContactUiControlUpdate.h> |
|
29 #include <MPbk2UiControlCmdItem.h> |
|
30 #include <mpbk2commanditemupdater.h> |
|
31 #include <eiksbobs.h> |
|
32 #include <aknsfld.h> |
|
33 #include <eiklbo.h> |
|
34 #include "CPbk2ControlContainer.h" |
|
35 #include "CPbk2ThumbnailManager.h" |
|
36 |
|
37 // FORWARD DECLARATIONS |
|
38 class MPbk2NamesListState; |
|
39 class CPbk2ContactViewListBox; |
|
40 class CPbk2NamesListStateFactory; |
|
41 class CVPbkContactManager; |
|
42 class MPbk2ContactNameFormatter; |
|
43 class MPbk2ControlObserver; |
|
44 class CPbk2StorePropertyArray; |
|
45 class CAknSearchField; |
|
46 class CPbk2ThumbnailLoader; |
|
47 class MPbk2FilteredViewStack; |
|
48 class CPbk2UiControlEventSender; |
|
49 class CPbk2FilteredViewStackObserver; |
|
50 class CPbk2ListBoxSelectionObserver; |
|
51 class MPbk2ContactUiControlExtension; |
|
52 class CPbk2PredictiveSearchFilter; |
|
53 class CPbk2ContactViewDoubleListBox; |
|
54 |
|
55 // CLASS DECLARATION |
|
56 |
|
57 /** |
|
58 * Phonebook 2 names list control. |
|
59 * Responsible for delegating control calls to control state objects, |
|
60 * selecting correct state object based on events etc. indications, |
|
61 * and notifying observers about control events. In other words |
|
62 * this class manages the names list control framework and performs |
|
63 * the high level operations itself but delegates the detailed operations |
|
64 * to names list state classes. |
|
65 */ |
|
66 class CPbk2NamesListControl : public CCoeControl, |
|
67 public MPbk2ContactUiControl, |
|
68 public MPbk2ContactUiControl2, |
|
69 public MVPbkContactViewObserver, |
|
70 public MPbk2PointerEventInspector, |
|
71 public MCoeControlObserver, |
|
72 public MPbk2ContactUiControlUpdate, |
|
73 public MEikScrollBarObserver, |
|
74 public MAdaptiveSearchTextObserver, |
|
75 public MEikListBoxObserver, |
|
76 public MPbk2ControlContainerForegroundEventObserver, |
|
77 public MPbk2CommandItemUpdater |
|
78 { |
|
79 public: // Enumerations |
|
80 |
|
81 /// The names list states |
|
82 enum TPbk2NamesListState |
|
83 { |
|
84 /// Startup state |
|
85 EStateStartup = 0, |
|
86 /// Not ready state |
|
87 EStateNotReady, |
|
88 EStateEmpty, |
|
89 EStateReady, |
|
90 EStateFiltered, |
|
91 EStateHidden |
|
92 }; |
|
93 |
|
94 public: // Constructors and destructor |
|
95 |
|
96 /** |
|
97 * Creates a new instance of this class. |
|
98 * |
|
99 * @param aResourceId Id of the resource where the control |
|
100 * is defined in. |
|
101 * @param aContainer This control's container. |
|
102 * @param aManager Virtual Phonebook contact manager. |
|
103 * @param aView The contact view. |
|
104 * @param aNameFormatter Name formatter. |
|
105 * @param aStoreProperties An array containg properties |
|
106 * for the stores that are shown. |
|
107 * @return A new instance of this class. |
|
108 */ |
|
109 IMPORT_C static CPbk2NamesListControl* NewL( |
|
110 TInt aResourceId, |
|
111 const CCoeControl* aContainer, |
|
112 CVPbkContactManager& aManager, |
|
113 MVPbkContactViewBase& aView, |
|
114 MPbk2ContactNameFormatter& aNameFormatter, |
|
115 CPbk2StorePropertyArray& aStoreProperties ); |
|
116 |
|
117 /** |
|
118 * Creates a new instance of this class. |
|
119 * |
|
120 * @param aResourceId Id of the resource where the control |
|
121 * is defined in. |
|
122 * @param aContainer This control's container. |
|
123 * @param aManager Virtual Phonebook contact manager. |
|
124 * @param aView The contact view. |
|
125 * @param aNameFormatter Name formatter. |
|
126 * @param aStoreProperties An array containg properties |
|
127 * for the stores that are shown. |
|
128 * @param aThumbManager Thumbnail manager for social phonebook //TODO |
|
129 * @return A new instance of this class. |
|
130 */ |
|
131 IMPORT_C static CPbk2NamesListControl* NewL( |
|
132 TInt aResourceId, |
|
133 const CCoeControl* aContainer, |
|
134 CVPbkContactManager& aManager, |
|
135 MVPbkContactViewBase& aView, |
|
136 MPbk2ContactNameFormatter& aNameFormatter, |
|
137 CPbk2StorePropertyArray& aStoreProperties, |
|
138 CPbk2ThumbnailManager* aThumbManager ); |
|
139 |
|
140 /** |
|
141 * Constructor. Defined as public for custom control needs. |
|
142 * |
|
143 * @param aContainer This control's container. |
|
144 * @param aManager Virtual Phonebook contact manager. |
|
145 * @param aView The contact view. |
|
146 * @param aNameFormatter Name formatter. |
|
147 * @param aStoreProperties An array containg properties |
|
148 * for the stores that are shown. |
|
149 */ |
|
150 IMPORT_C CPbk2NamesListControl( |
|
151 const CCoeControl* aContainer, |
|
152 CVPbkContactManager& aManager, |
|
153 MVPbkContactViewBase& aView, |
|
154 MPbk2ContactNameFormatter& aNameFormatter, |
|
155 CPbk2StorePropertyArray& aStoreProperties ); |
|
156 |
|
157 /** |
|
158 * Destructor. |
|
159 */ |
|
160 ~CPbk2NamesListControl(); |
|
161 |
|
162 public: // Interface |
|
163 |
|
164 /** |
|
165 * Adds an observer to this control. |
|
166 * |
|
167 * @param aObserver The observer to add. |
|
168 */ |
|
169 IMPORT_C void AddObserverL( |
|
170 MPbk2ControlObserver& aObserver ); |
|
171 |
|
172 /** |
|
173 * Removes an observer from this control. |
|
174 * |
|
175 * @param aObserver The observer to remove. |
|
176 */ |
|
177 IMPORT_C void RemoveObserver( |
|
178 MPbk2ControlObserver& aObserver ); |
|
179 |
|
180 /** |
|
181 * Resets the control. |
|
182 * -Clears marks |
|
183 * -Resets the find box |
|
184 * -Sets focus to the first contact |
|
185 * -Removes the thumbnail |
|
186 * -Updates the state of the control asynchronously according to |
|
187 * the Virtual Phonebook view state |
|
188 */ |
|
189 IMPORT_C void Reset(); |
|
190 |
|
191 /** |
|
192 * Sets the new view for the control. This will cause |
|
193 * the control to reset its state according to state of aView |
|
194 * asynchronously. |
|
195 */ |
|
196 IMPORT_C void SetViewL( MVPbkContactViewBase& aView ); |
|
197 |
|
198 /** |
|
199 * Sets the new view for the control. This will cause |
|
200 * the control to reset its state according to state of aView |
|
201 * asynchronously. Control takes given view's ownership. |
|
202 */ |
|
203 IMPORT_C void GiveViewL( MVPbkContactViewBase* aView ); |
|
204 |
|
205 /** |
|
206 * Use this method to block pointer events from this control. |
|
207 */ |
|
208 IMPORT_C void AllowPointerEvents( TBool aAllow ); |
|
209 |
|
210 /** |
|
211 * Set the group contact link for curently open group. |
|
212 * |
|
213 * @param aGroupLinktoSet The input group contact link |
|
214 */ |
|
215 IMPORT_C void SetCurrentGroupLinkL( MVPbkContactLink* aGroupLinktoSet); |
|
216 /** |
|
217 * Fetches the current view |
|
218 * |
|
219 * @return Current view. |
|
220 */ |
|
221 MVPbkContactViewBase& View(); |
|
222 |
|
223 |
|
224 |
|
225 public: // From CCoeControl |
|
226 void MakeVisible( |
|
227 TBool aVisible ); |
|
228 TKeyResponse OfferKeyEventL( |
|
229 const TKeyEvent& aKeyEvent, |
|
230 TEventCode aType ); |
|
231 void ConstructFromResourceL( |
|
232 TResourceReader& aReader ); |
|
233 void ActivateL(); |
|
234 TInt CountComponentControls() const; |
|
235 CCoeControl* ComponentControl( |
|
236 TInt aIndex ) const; |
|
237 void FocusChanged( |
|
238 TDrawNow aDrawNow ); |
|
239 void SizeChanged(); |
|
240 void Draw( |
|
241 const TRect& aRect ) const; |
|
242 void HandleResourceChange( |
|
243 TInt aType ); |
|
244 void HandlePointerEventL( |
|
245 const TPointerEvent& aPointerEvent ); |
|
246 |
|
247 public: // From MPbk2ContactUiControl |
|
248 MPbk2ContactUiControl* ParentControl() const; |
|
249 TInt NumberOfContacts() const; |
|
250 const MVPbkBaseContact* FocusedContactL() const; |
|
251 const MVPbkViewContact* FocusedViewContactL() const; |
|
252 const MVPbkStoreContact* FocusedStoreContact() const; |
|
253 void SetFocusedContactL( |
|
254 const MVPbkBaseContact& aContact ); |
|
255 void SetFocusedContactL( |
|
256 const MVPbkContactBookmark& aContactBookmark ); |
|
257 void SetFocusedContactL( |
|
258 const MVPbkContactLink& aContactLink ); |
|
259 TInt FocusedContactIndex() const; |
|
260 void SetFocusedContactIndexL( |
|
261 TInt aIndex ); |
|
262 TInt NumberOfContactFields() const; |
|
263 const MVPbkBaseContactField* FocusedField() const; |
|
264 TInt FocusedFieldIndex() const; |
|
265 void SetFocusedFieldIndex( |
|
266 TInt aIndex ); |
|
267 TBool ContactsMarked() const; |
|
268 MVPbkContactLinkArray* SelectedContactsL() const; |
|
269 MVPbkContactLinkArray* SelectedContactsOrFocusedContactL() const; |
|
270 MPbk2ContactLinkIterator* SelectedContactsIteratorL() const; |
|
271 CArrayPtr<MVPbkContactStore>* SelectedContactStoresL() const; |
|
272 void ClearMarks(); |
|
273 void SetSelectedContactL( |
|
274 TInt aIndex, |
|
275 TBool aSelected ); |
|
276 void SetSelectedContactL( |
|
277 const MVPbkContactBookmark& aContactBookmark, |
|
278 TBool aSelected ); |
|
279 void SetSelectedContactL( |
|
280 const MVPbkContactLink& aContactLink, |
|
281 TBool aSelected ); |
|
282 |
|
283 void DynInitMenuPaneL( |
|
284 TInt aResourceId, |
|
285 CEikMenuPane* aMenuPane ) const; |
|
286 void ProcessCommandL ( |
|
287 TInt aCommandId ) const; |
|
288 void UpdateAfterCommandExecution(); |
|
289 TInt GetMenuFilteringFlagsL() const; |
|
290 CPbk2ViewState* ControlStateL() const; |
|
291 void RestoreControlStateL( |
|
292 CPbk2ViewState* aState ); |
|
293 const TDesC& FindTextL(); |
|
294 void ResetFindL(); |
|
295 void ShowThumbnail(); |
|
296 void HideThumbnail(); |
|
297 void SetBlank( |
|
298 TBool aBlank ); |
|
299 void RegisterCommand( |
|
300 MPbk2Command* aCommand ); |
|
301 void SetTextL( |
|
302 const TDesC& aText ); |
|
303 TAny* ContactUiControlExtension(TUid aExtensionUid ); |
|
304 |
|
305 public: // From MPbk2ContactUiControl2 |
|
306 TInt CommandItemCount() const; |
|
307 const MPbk2UiControlCmdItem& CommandItemAt( TInt aIndex ) const; |
|
308 const MPbk2UiControlCmdItem* FocusedCommandItem() const; |
|
309 void DeleteCommandItemL( TInt aIndex ); |
|
310 void AddCommandItemL(MPbk2UiControlCmdItem* aCommand, TInt aIndex); |
|
311 |
|
312 public: // From MVPbkContactViewObserver |
|
313 void ContactViewReady( |
|
314 MVPbkContactViewBase& aView ); |
|
315 void ContactViewUnavailable( |
|
316 MVPbkContactViewBase& aView ); |
|
317 void ContactAddedToView( |
|
318 MVPbkContactViewBase& aView, |
|
319 TInt aIndex, |
|
320 const MVPbkContactLink& aContactLink ); |
|
321 void ContactRemovedFromView( |
|
322 MVPbkContactViewBase& aView, |
|
323 TInt aIndex, |
|
324 const MVPbkContactLink& aContactLink ); |
|
325 void ContactViewError( |
|
326 MVPbkContactViewBase& aView, |
|
327 TInt aError, |
|
328 TBool aErrorNotified ); |
|
329 |
|
330 public: // From MPbk2PointerEventInspector |
|
331 TBool FocusedItemPointed(); |
|
332 TBool FocusableItemPointed(); |
|
333 TBool SearchFieldPointed(); |
|
334 |
|
335 public: // From MCoeControlObserver |
|
336 void HandleControlEventL( |
|
337 CCoeControl* aControl, |
|
338 TCoeEvent aEventType ); |
|
339 |
|
340 public: // From MPbk2ContactUiControlUpdate |
|
341 void UpdateContact( |
|
342 const MVPbkContactLink& aContactLink ); |
|
343 |
|
344 public: // From MPbk2CommandItemUpdater |
|
345 void UpdateCommandItem( TInt aCommandId ); |
|
346 |
|
347 public: // from MEikScrollBarObserver |
|
348 void HandleScrollEventL(CEikScrollBar* aScrollBar, TEikScrollEvent aEventType); |
|
349 public: // from MEikListBoxObserver |
|
350 void HandleListBoxEventL( CEikListBox* aListBox, TListBoxEvent aEventType ); |
|
351 public: // from MAdaptiveSearchTextObserver |
|
352 |
|
353 void AdaptiveSearchTextChanged( CAknSearchField* aSearchField ); |
|
354 private: // Implementation |
|
355 |
|
356 /** |
|
357 * Constructor. |
|
358 * |
|
359 * @param aContainer This control's container. |
|
360 * @param aManager Virtual Phonebook contact manager. |
|
361 * @param aView The contact view. |
|
362 * @param aNameFormatter Name formatter. |
|
363 * @param aStoreProperties An array containg properties |
|
364 * for the stores that are shown. |
|
365 * @param aThumbManager Thumbnail manager for social phonebook |
|
366 */ |
|
367 CPbk2NamesListControl( |
|
368 const CCoeControl* aContainer, |
|
369 CVPbkContactManager& aManager, |
|
370 MVPbkContactViewBase& aView, |
|
371 MPbk2ContactNameFormatter& aNameFormatter, |
|
372 CPbk2StorePropertyArray& aStoreProperties, |
|
373 CPbk2ThumbnailManager* aThumbManager ); |
|
374 |
|
375 void ConstructL( |
|
376 TInt aResourceId); |
|
377 void Redraw(); |
|
378 void DoHandleContactViewReadyL( |
|
379 MVPbkContactViewBase& aView ); |
|
380 void DoHandleContactAdditionL( |
|
381 TInt aIndex ); |
|
382 void DoHandleContactRemovalL( |
|
383 TInt aIndex ); |
|
384 void SelectAndChangeReadyStateL(); |
|
385 void RelayoutControls(); |
|
386 void HandleTopViewChangedL( |
|
387 MVPbkContactViewBase& aOldView ); |
|
388 void HandleTopViewUpdatedL(); |
|
389 void HandleBaseViewChangedL(); |
|
390 void HandleViewStackError( |
|
391 TInt aError ); |
|
392 void HandleContactAddedToBaseView( |
|
393 MVPbkContactViewBase& aBaseView, |
|
394 TInt aIndex, |
|
395 const MVPbkContactLink& aContactLink ); |
|
396 void DeleteIfAlreadyAdded(const MPbk2UiControlCmdItem* aCommand); // Fix ETKI-7NADZC |
|
397 |
|
398 |
|
399 private: //from MPbk2ControlContainerForegroundEventObserver |
|
400 void HandleForegroundEventL( TBool aForeground ); |
|
401 |
|
402 private: // Data |
|
403 /// Ref: Current state |
|
404 MPbk2NamesListState* iCurrentState; |
|
405 /// Own: State factory |
|
406 CPbk2NamesListStateFactory* iStateFactory; |
|
407 /// Own: List box |
|
408 CPbk2ContactViewListBox* iListBox; |
|
409 /// Own: Observers of this object |
|
410 RPointerArray<MPbk2ControlObserver> iObservers; |
|
411 /// Own: Previous view count |
|
412 TInt iPrevCount; |
|
413 /// Own: Find box |
|
414 CAknSearchField* iFindBox; |
|
415 /// Ref: Virtual Phonebook contact manager |
|
416 CVPbkContactManager& iContactManager; |
|
417 /// Ref: All contacts view |
|
418 MVPbkContactViewBase* iBaseView; |
|
419 /// Ref: The view that is used by the control |
|
420 MPbk2FilteredViewStack* iViewStack; |
|
421 /// Ref: Control container |
|
422 const CCoeControl* iContainer; |
|
423 /// Ref: Name formatter |
|
424 MPbk2ContactNameFormatter& iNameFormatter; |
|
425 /// Ref: The store's UI properties |
|
426 CPbk2StorePropertyArray& iStoreProperties; |
|
427 /// Own: Thumbnail loader |
|
428 CPbk2ThumbnailLoader* iThumbnailLoader; |
|
429 /// Ref: Command in Execution |
|
430 MPbk2Command* iCommand; |
|
431 /// Own: A control event sender |
|
432 CPbk2UiControlEventSender* iEventSender; |
|
433 /// Own: An observer for the filtered view stack |
|
434 CPbk2FilteredViewStackObserver* iStackObserver; |
|
435 /// Own: An observer for listbox selection mode changes |
|
436 CPbk2ListBoxSelectionObserver* iListBoxSelectionObserver; |
|
437 /// Own: Flag for owning the base view |
|
438 TBool iOwnBaseView; |
|
439 /// Own: UI extension |
|
440 MPbk2ContactUiControlExtension* iUiExtension; |
|
441 /// flag whether pointer moved or not for the thumbnail |
|
442 TBool iDidMove; |
|
443 /// Defines whether this control handles pointer events or not. |
|
444 TBool iAllowPointerEvents; |
|
445 /// Command items. Owns the array members. |
|
446 RPointerArray<MPbk2UiControlCmdItem> iCommandItems; |
|
447 /// Own: Search filter |
|
448 CPbk2PredictiveSearchFilter* iSearchFilter; |
|
449 //Flag to indicate Feature manager initilization |
|
450 TBool iFeatureManagerInitilized; |
|
451 |
|
452 //REF: Thumbnail manager //TODO |
|
453 CPbk2ThumbnailManager* iThumbManager; |
|
454 //OWN: double list box "handle" |
|
455 CPbk2ContactViewDoubleListBox* iDoubleListBox; |
|
456 |
|
457 }; |
|
458 |
|
459 #endif // CPBK2NAMESLISTCONTROL_H |
|
460 |
|
461 // End of File |