|
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 // INCLUDE FILES |
|
20 #include "CPbk2NamesListControl.h" |
|
21 |
|
22 // Phonebook 2 |
|
23 #include "CPbk2NamesListStateFactory.h" |
|
24 #include "CPbk2ContactViewListBox.h" |
|
25 #include "CPbk2ThumbnailLoader.h" |
|
26 #include "cpbk2filteredviewstack.h" |
|
27 #include "MPbk2NamesListState.h" |
|
28 #include "MPbk2ControlObserver.h" |
|
29 #include "MPbk2UiControlEventSender.h" |
|
30 #include <CPbk2ControlContainer.h> |
|
31 #include <CPbk2ViewState.h> |
|
32 #include <Pbk2UIControls.hrh> |
|
33 #include <MPbk2Command.h> |
|
34 #include <MPbk2ContactUiControlExtension.h> |
|
35 #include <pbk2contactuicontroldoublelistboxextension.h> |
|
36 #include <MPbk2UIExtensionFactory.h> |
|
37 #include <CPbk2UIExtensionManager.h> |
|
38 #include "MPbk2FilteredViewStack.h" |
|
39 #include "cpbk2predictiveviewstack.h" |
|
40 #include <Pbk2Commands.hrh> |
|
41 #include <Pbk2InternalUID.h> |
|
42 #include "CPbk2PredictiveSearchFilter.h" |
|
43 #include "cpbk2contactviewdoublelistbox.h" |
|
44 |
|
45 // Virtual Phonebook |
|
46 #include <MVPbkContactViewBase.h> |
|
47 #include <MVPbkViewContact.h> |
|
48 #include <MVPbkContactLink.h> |
|
49 |
|
50 // System includes |
|
51 #include <barsread.h> |
|
52 #include <aknsfld.h> |
|
53 #include <AknPriv.hrh> |
|
54 #include <featmgr.h> |
|
55 |
|
56 // Debugging headers |
|
57 #include <Pbk2Debug.h> |
|
58 |
|
59 |
|
60 /// Unnamed namespace for local definitions |
|
61 namespace { |
|
62 |
|
63 /** |
|
64 * Handles errors. |
|
65 * |
|
66 * @param aErrorCode Error code. |
|
67 */ |
|
68 void HandleError( TInt aErrorCode ) |
|
69 { |
|
70 if ( aErrorCode != KErrNone ) |
|
71 { |
|
72 // Display standard error message |
|
73 CEikonEnv::Static()->HandleError( aErrorCode ); |
|
74 } |
|
75 } |
|
76 |
|
77 #ifdef _DEBUG |
|
78 enum TPanicCode |
|
79 { |
|
80 EPanicLogic_ComponentControl = 1, |
|
81 }; |
|
82 |
|
83 void Panic(TPanicCode aReason) |
|
84 { |
|
85 _LIT(KPanicText, "CPbk2NamesListControl"); |
|
86 User::Panic(KPanicText, aReason); |
|
87 } |
|
88 #endif // _DEBUG |
|
89 |
|
90 } /// namespace |
|
91 |
|
92 /** |
|
93 * A helper class for sending control events. |
|
94 */ |
|
95 NONSHARABLE_CLASS( CPbk2UiControlEventSender ) : public CBase, |
|
96 public MPbk2UiControlEventSender |
|
97 { |
|
98 public: // Construction and destruction |
|
99 |
|
100 /** |
|
101 * Creates a new instance of this class. |
|
102 * |
|
103 * @param aControl Control. |
|
104 * @param aObservers Observers. |
|
105 * @return A new instance of this class. |
|
106 */ |
|
107 static CPbk2UiControlEventSender* NewL( |
|
108 CPbk2NamesListControl& aControl, |
|
109 RPointerArray<MPbk2ControlObserver>& aObservers ); |
|
110 |
|
111 /** |
|
112 * Destructor. |
|
113 */ |
|
114 ~CPbk2UiControlEventSender(); |
|
115 |
|
116 public: /// From MPbk2UiControlEventSender |
|
117 TBool SendEventToObserversL( |
|
118 const TPbk2ControlEvent& aEvent ); |
|
119 void Reset(); |
|
120 |
|
121 private: // Implementation |
|
122 CPbk2UiControlEventSender( |
|
123 CPbk2NamesListControl& aControl, |
|
124 RPointerArray<MPbk2ControlObserver>& aObservers ); |
|
125 void ConstructL(); |
|
126 TBool SendEvent( |
|
127 const TPbk2ControlEvent& aEvent ); |
|
128 |
|
129 private: // Data |
|
130 /// Ref: Control |
|
131 CPbk2NamesListControl& iControl; |
|
132 /// Ref: Observers |
|
133 RPointerArray<MPbk2ControlObserver>& iObservers; |
|
134 /// Own: Indicates has the ready event been sent |
|
135 TBool iReadyEventSend; |
|
136 }; |
|
137 |
|
138 /** |
|
139 * A helper class for hiding inheritance of MPbk2FilteredViewStackObserver |
|
140 * from CPbk2NamesListControl. |
|
141 */ |
|
142 class CPbk2FilteredViewStackObserver : public CBase, |
|
143 public MPbk2FilteredViewStackObserver |
|
144 { |
|
145 public: /// Typedefs |
|
146 typedef void( CPbk2NamesListControl::* TopViewChangedFuncPtr ) |
|
147 ( MVPbkContactViewBase& aOldView ); |
|
148 typedef void( CPbk2NamesListControl::* ViewStackErrorFuncPtr ) |
|
149 ( TInt aError ); |
|
150 typedef void( CPbk2NamesListControl::* ContactAddedToBaseViewFuncPtr ) |
|
151 ( MVPbkContactViewBase& aBaseView, |
|
152 TInt aIndex, const MVPbkContactLink& aContactLink ); |
|
153 typedef void( CPbk2NamesListControl::* TopViewUpdatedFuncPtr )(); |
|
154 typedef void( CPbk2NamesListControl::* BaseViewChangedFuncPtr )(); |
|
155 |
|
156 public: // Construction and destruction |
|
157 |
|
158 /** |
|
159 * Creates a new instance of this class. |
|
160 * |
|
161 * @param aControl Control. |
|
162 * @param aViewStack View stack. |
|
163 * @param aTopViewChangedFuncPtr Top view changed function pointer. |
|
164 * @param aTopViewUpdatedFuncPtr Top view updated function pointer. |
|
165 * @param aBaseViewChangedFuncPtr Base view changed function pointer. |
|
166 * @param aViewStackErrorFuncPtr View stack error function pointer. |
|
167 * @param aContactAddedToBaseViewFuncPtr Contact added to base view function pointer. |
|
168 * @return A new instance of this class. |
|
169 */ |
|
170 static CPbk2FilteredViewStackObserver* NewL( |
|
171 CPbk2NamesListControl& aControl, |
|
172 TopViewChangedFuncPtr aTopViewChangedFuncPtr, |
|
173 TopViewUpdatedFuncPtr aTopViewUpdatedFuncPtr, |
|
174 BaseViewChangedFuncPtr aBaseViewChangedFuncPtr, |
|
175 ViewStackErrorFuncPtr aViewStackErrorFuncPtr, |
|
176 ContactAddedToBaseViewFuncPtr aContactAddedToBaseViewFuncPtr ); |
|
177 |
|
178 /** |
|
179 * Destructor. |
|
180 */ |
|
181 ~CPbk2FilteredViewStackObserver(); |
|
182 |
|
183 private: // From MPbk2FilteredViewStackObserver |
|
184 void TopViewChangedL( |
|
185 MVPbkContactViewBase& aOldView ); |
|
186 void TopViewUpdatedL(); |
|
187 void BaseViewChangedL(); |
|
188 void ViewStackError( |
|
189 TInt aError ); |
|
190 void ContactAddedToBaseView( |
|
191 MVPbkContactViewBase& aBaseView, |
|
192 TInt aIndex, |
|
193 const MVPbkContactLink& aContactLink ); |
|
194 |
|
195 private: // Implementation |
|
196 CPbk2FilteredViewStackObserver( |
|
197 CPbk2NamesListControl& aControl, |
|
198 TopViewChangedFuncPtr aTopViewChangedFuncPtr, |
|
199 TopViewUpdatedFuncPtr aTopViewUpdatedFuncPtr, |
|
200 BaseViewChangedFuncPtr aBaseViewChangedFuncPtr, |
|
201 ViewStackErrorFuncPtr aViewStackErrorFuncPtr, |
|
202 ContactAddedToBaseViewFuncPtr aContactAddedToBaseViewFuncPtr ); |
|
203 void ConstructL(); |
|
204 |
|
205 private: // Data |
|
206 /// Ref: Control |
|
207 CPbk2NamesListControl& iControl; |
|
208 /// Ref: Top view changed function pointer |
|
209 TopViewChangedFuncPtr iTopViewChangedFuncPtr; |
|
210 /// Ref: Top view updated function pointer |
|
211 TopViewUpdatedFuncPtr iTopViewUpdatedFuncPtr; |
|
212 /// Ref: Base view changed function pointer |
|
213 BaseViewChangedFuncPtr iBaseViewChangedFuncPtr; |
|
214 /// Ref: View stack error function pointer |
|
215 ViewStackErrorFuncPtr iViewStackErrorFuncPtr; |
|
216 /// Ref: Contact added to base view function pointer |
|
217 ContactAddedToBaseViewFuncPtr iContactAddedToBaseViewFuncPtr; |
|
218 }; |
|
219 |
|
220 /** |
|
221 * An observer for list box selections. Sends control events |
|
222 * when the list box enters to or from the selection mode. |
|
223 */ |
|
224 NONSHARABLE_CLASS( CPbk2ListBoxSelectionObserver ) : public CBase, |
|
225 private MListBoxSelectionObserver |
|
226 { |
|
227 public: // Interface |
|
228 |
|
229 /** |
|
230 * Creates a new instance of this class. |
|
231 * |
|
232 * @param aListBox The list box that is observed. |
|
233 * @param aEventSender An event sender for sending control |
|
234 * events. |
|
235 * @return A new instance of this class. |
|
236 */ |
|
237 static CPbk2ListBoxSelectionObserver* NewL( |
|
238 CPbk2NamesListControl& aControl, |
|
239 CEikListBox& aListBox, |
|
240 MPbk2UiControlEventSender& aEventSender ); |
|
241 |
|
242 /** |
|
243 * Destructor |
|
244 */ |
|
245 ~CPbk2ListBoxSelectionObserver(); |
|
246 |
|
247 private: /// From MListBoxSelectionObserver |
|
248 void SelectionModeChanged( |
|
249 CEikListBox* aListBox, |
|
250 TBool aSelectionModeEnabled ); |
|
251 |
|
252 private: // Implementation |
|
253 CPbk2ListBoxSelectionObserver( |
|
254 CPbk2NamesListControl& aControl, |
|
255 CEikListBox& aListBox, |
|
256 MPbk2UiControlEventSender& aEventSender ); |
|
257 void ConstructL(); |
|
258 |
|
259 private: // Data |
|
260 /// Ref: Control |
|
261 CPbk2NamesListControl& iControl; |
|
262 /// Ref: List box |
|
263 CEikListBox& iListBox; |
|
264 /// Ref: Event sender |
|
265 MPbk2UiControlEventSender& iEventSender; |
|
266 }; |
|
267 |
|
268 // -------------------------------------------------------------------------- |
|
269 // CPbk2UiControlEventSender::CPbk2UiControlEventSender |
|
270 // -------------------------------------------------------------------------- |
|
271 // |
|
272 CPbk2UiControlEventSender::CPbk2UiControlEventSender |
|
273 ( CPbk2NamesListControl& aControl, |
|
274 RPointerArray<MPbk2ControlObserver>& aObservers ) : |
|
275 iControl( aControl ), |
|
276 iObservers( aObservers ) |
|
277 { |
|
278 } |
|
279 |
|
280 // -------------------------------------------------------------------------- |
|
281 // CPbk2UiControlEventSender::NewL |
|
282 // -------------------------------------------------------------------------- |
|
283 // |
|
284 CPbk2UiControlEventSender* CPbk2UiControlEventSender::NewL( |
|
285 CPbk2NamesListControl& aControl, |
|
286 RPointerArray<MPbk2ControlObserver>& aObservers ) |
|
287 { |
|
288 CPbk2UiControlEventSender* self = |
|
289 new ( ELeave ) CPbk2UiControlEventSender( aControl, aObservers ); |
|
290 return self; |
|
291 } |
|
292 |
|
293 // -------------------------------------------------------------------------- |
|
294 // CPbk2UiControlEventSender::~CPbk2UiControlEventSender |
|
295 // -------------------------------------------------------------------------- |
|
296 // |
|
297 CPbk2UiControlEventSender::~CPbk2UiControlEventSender() |
|
298 { |
|
299 } |
|
300 |
|
301 // -------------------------------------------------------------------------- |
|
302 // CPbk2UiControlEventSender::SendEventToObserversL |
|
303 // Sends control observer events in reverse order to disable the possibility |
|
304 // of crash if aObserver is changed during the loop. |
|
305 // -------------------------------------------------------------------------- |
|
306 // |
|
307 TBool CPbk2UiControlEventSender::SendEventToObserversL( |
|
308 const TPbk2ControlEvent& aEvent ) |
|
309 { |
|
310 // Loop backwards in case some observer destroys itself in the |
|
311 // event handler |
|
312 TBool okToSendEvent( SendEvent( aEvent ) ); |
|
313 for ( TInt i = iObservers.Count() - 1; i >= 0 && okToSendEvent; --i ) |
|
314 { |
|
315 iObservers[i]->HandleControlEventL( iControl, aEvent ); |
|
316 } |
|
317 |
|
318 return okToSendEvent; |
|
319 } |
|
320 |
|
321 // -------------------------------------------------------------------------- |
|
322 // CPbk2UiControlEventSender::Reset |
|
323 // Resets event sender |
|
324 // -------------------------------------------------------------------------- |
|
325 // |
|
326 void CPbk2UiControlEventSender::Reset() |
|
327 { |
|
328 iReadyEventSend = EFalse; |
|
329 } |
|
330 |
|
331 // -------------------------------------------------------------------------- |
|
332 // CPbk2UiControlEventSender::SendEvent |
|
333 // Makes sure that ready event is send only ones and reset the status |
|
334 // if control goes unavailable |
|
335 // -------------------------------------------------------------------------- |
|
336 // |
|
337 TBool CPbk2UiControlEventSender::SendEvent |
|
338 ( const TPbk2ControlEvent& aEvent ) |
|
339 { |
|
340 TBool ret( ETrue ); |
|
341 if ( aEvent.iEventType == TPbk2ControlEvent::EUnavailable ) |
|
342 { |
|
343 iReadyEventSend = EFalse; |
|
344 } |
|
345 else if ( aEvent.iEventType == TPbk2ControlEvent::EReady ) |
|
346 { |
|
347 if ( iReadyEventSend ) |
|
348 { |
|
349 ret = EFalse; |
|
350 } |
|
351 else |
|
352 { |
|
353 iReadyEventSend = ETrue; |
|
354 } |
|
355 } |
|
356 return ret; |
|
357 } |
|
358 |
|
359 // -------------------------------------------------------------------------- |
|
360 // CPbk2FilteredViewStackObserver::CPbk2FilteredViewStackObserver |
|
361 // -------------------------------------------------------------------------- |
|
362 // |
|
363 CPbk2FilteredViewStackObserver::CPbk2FilteredViewStackObserver( |
|
364 CPbk2NamesListControl& aControl, |
|
365 TopViewChangedFuncPtr aTopViewChangedFuncPtr, |
|
366 TopViewUpdatedFuncPtr aTopViewUpdatedFuncPtr, |
|
367 BaseViewChangedFuncPtr aBaseViewChangedFuncPtr, |
|
368 ViewStackErrorFuncPtr aViewStackErrorFuncPtr, |
|
369 ContactAddedToBaseViewFuncPtr aContactAddedToBaseViewFuncPtr ) : |
|
370 iControl( aControl ), |
|
371 iTopViewChangedFuncPtr( aTopViewChangedFuncPtr ), |
|
372 iTopViewUpdatedFuncPtr( aTopViewUpdatedFuncPtr ), |
|
373 iBaseViewChangedFuncPtr( aBaseViewChangedFuncPtr ), |
|
374 iViewStackErrorFuncPtr( aViewStackErrorFuncPtr ), |
|
375 iContactAddedToBaseViewFuncPtr( aContactAddedToBaseViewFuncPtr ) |
|
376 { |
|
377 } |
|
378 |
|
379 // -------------------------------------------------------------------------- |
|
380 // CPbk2FilteredViewStackObserver::NewL |
|
381 // -------------------------------------------------------------------------- |
|
382 // |
|
383 CPbk2FilteredViewStackObserver* CPbk2FilteredViewStackObserver::NewL( |
|
384 CPbk2NamesListControl& aControl, |
|
385 TopViewChangedFuncPtr aTopViewChangedFuncPtr, |
|
386 TopViewUpdatedFuncPtr aTopViewUpdatedFuncPtr, |
|
387 BaseViewChangedFuncPtr aBaseViewChangedFuncPtr, |
|
388 ViewStackErrorFuncPtr aViewStackErrorFuncPtr, |
|
389 ContactAddedToBaseViewFuncPtr aContactAddedToBaseViewFuncPtr ) |
|
390 { |
|
391 CPbk2FilteredViewStackObserver* self = |
|
392 new ( ELeave ) CPbk2FilteredViewStackObserver( aControl, |
|
393 aTopViewChangedFuncPtr, |
|
394 aTopViewUpdatedFuncPtr, |
|
395 aBaseViewChangedFuncPtr, |
|
396 aViewStackErrorFuncPtr, |
|
397 aContactAddedToBaseViewFuncPtr ); |
|
398 CleanupStack::PushL( self ); |
|
399 self->ConstructL(); |
|
400 CleanupStack::Pop( self ); |
|
401 return self; |
|
402 } |
|
403 |
|
404 // -------------------------------------------------------------------------- |
|
405 // CPbk2FilteredViewStackObserver::ConstructL |
|
406 // -------------------------------------------------------------------------- |
|
407 // |
|
408 void CPbk2FilteredViewStackObserver::ConstructL() |
|
409 { |
|
410 } |
|
411 |
|
412 // -------------------------------------------------------------------------- |
|
413 // CPbk2FilteredViewStackObserver::~CPbk2FilteredViewStackObserver |
|
414 // -------------------------------------------------------------------------- |
|
415 // |
|
416 CPbk2FilteredViewStackObserver::~CPbk2FilteredViewStackObserver() |
|
417 { |
|
418 } |
|
419 |
|
420 // -------------------------------------------------------------------------- |
|
421 // CPbk2FilteredViewStackObserver::TopViewChangedL |
|
422 // -------------------------------------------------------------------------- |
|
423 // |
|
424 void CPbk2FilteredViewStackObserver::TopViewChangedL( |
|
425 MVPbkContactViewBase& aOldView ) |
|
426 { |
|
427 ( iControl.*iTopViewChangedFuncPtr )( aOldView ); |
|
428 } |
|
429 |
|
430 // -------------------------------------------------------------------------- |
|
431 // CPbk2FilteredViewStackObserver::TopViewUpdatedL |
|
432 // -------------------------------------------------------------------------- |
|
433 // |
|
434 void CPbk2FilteredViewStackObserver::TopViewUpdatedL() |
|
435 { |
|
436 ( iControl.*iTopViewUpdatedFuncPtr )(); |
|
437 } |
|
438 |
|
439 // -------------------------------------------------------------------------- |
|
440 // CPbk2FilteredViewStackObserver::BaseViewChangedL |
|
441 // -------------------------------------------------------------------------- |
|
442 // |
|
443 void CPbk2FilteredViewStackObserver::BaseViewChangedL() |
|
444 { |
|
445 ( iControl.*iBaseViewChangedFuncPtr )(); |
|
446 } |
|
447 |
|
448 // -------------------------------------------------------------------------- |
|
449 // CPbk2FilteredViewStackObserver::ViewStackError |
|
450 // -------------------------------------------------------------------------- |
|
451 // |
|
452 void CPbk2FilteredViewStackObserver::ViewStackError( TInt aError ) |
|
453 { |
|
454 ( iControl.*iViewStackErrorFuncPtr )( aError ); |
|
455 } |
|
456 |
|
457 // -------------------------------------------------------------------------- |
|
458 // CPbk2FilteredViewStackObserver::ContactAddedToBaseView |
|
459 // -------------------------------------------------------------------------- |
|
460 // |
|
461 void CPbk2FilteredViewStackObserver::ContactAddedToBaseView( |
|
462 MVPbkContactViewBase& aBaseView, TInt aIndex, |
|
463 const MVPbkContactLink& aContactLink ) |
|
464 { |
|
465 ( iControl.*iContactAddedToBaseViewFuncPtr )( aBaseView, |
|
466 aIndex, aContactLink ); |
|
467 } |
|
468 |
|
469 // -------------------------------------------------------------------------- |
|
470 // CPbk2ListBoxSelectionObserver::CPbk2ListBoxSelectionObserver |
|
471 // -------------------------------------------------------------------------- |
|
472 // |
|
473 CPbk2ListBoxSelectionObserver::CPbk2ListBoxSelectionObserver( |
|
474 CPbk2NamesListControl& aControl, CEikListBox& aListBox, |
|
475 MPbk2UiControlEventSender& aEventSender ) |
|
476 : iControl( aControl ), |
|
477 iListBox( aListBox ), |
|
478 iEventSender( aEventSender ) |
|
479 { |
|
480 } |
|
481 |
|
482 // -------------------------------------------------------------------------- |
|
483 // CPbk2ListBoxSelectionObserver::ConstructL |
|
484 // -------------------------------------------------------------------------- |
|
485 // |
|
486 void CPbk2ListBoxSelectionObserver::ConstructL() |
|
487 { |
|
488 iListBox.AddSelectionObserverL( this ); |
|
489 } |
|
490 |
|
491 // -------------------------------------------------------------------------- |
|
492 // CPbk2ListBoxSelectionObserver::NewL |
|
493 // -------------------------------------------------------------------------- |
|
494 // |
|
495 CPbk2ListBoxSelectionObserver* CPbk2ListBoxSelectionObserver::NewL( |
|
496 CPbk2NamesListControl& aControl, |
|
497 CEikListBox& aListBox, |
|
498 MPbk2UiControlEventSender& aEventSender ) |
|
499 { |
|
500 CPbk2ListBoxSelectionObserver* self = |
|
501 new( ELeave ) CPbk2ListBoxSelectionObserver( aControl, aListBox, |
|
502 aEventSender ); |
|
503 CleanupStack::PushL( self ); |
|
504 self->ConstructL(); |
|
505 CleanupStack::Pop( self ); |
|
506 return self; |
|
507 } |
|
508 |
|
509 // -------------------------------------------------------------------------- |
|
510 // CPbk2ListBoxSelectionObserver::~CPbk2ListBoxSelectionObserver |
|
511 // -------------------------------------------------------------------------- |
|
512 // |
|
513 CPbk2ListBoxSelectionObserver::~CPbk2ListBoxSelectionObserver() |
|
514 { |
|
515 iListBox.RemoveSelectionObserver( this ); |
|
516 } |
|
517 |
|
518 // -------------------------------------------------------------------------- |
|
519 // CPbk2ListBoxSelectionObserver::SelectionModeChanged |
|
520 // -------------------------------------------------------------------------- |
|
521 // |
|
522 void CPbk2ListBoxSelectionObserver::SelectionModeChanged( |
|
523 CEikListBox* aListBox, TBool aSelectionModeEnabled ) |
|
524 { |
|
525 if ( &iListBox == aListBox ) |
|
526 { |
|
527 TPbk2ControlEvent event( |
|
528 TPbk2ControlEvent::EControlEntersSelectionMode ); |
|
529 if ( !aSelectionModeEnabled ) |
|
530 { |
|
531 event.iEventType = |
|
532 TPbk2ControlEvent::EControlLeavesSelectionMode; |
|
533 } |
|
534 TRAPD( res, iEventSender.SendEventToObserversL( event ) ); |
|
535 HandleError( res ); |
|
536 if ( res != KErrNone ) |
|
537 { |
|
538 iControl.Reset(); |
|
539 } |
|
540 } |
|
541 } |
|
542 |
|
543 // -------------------------------------------------------------------------- |
|
544 // CPbk2NamesListControl::CPbk2NamesListControl |
|
545 // -------------------------------------------------------------------------- |
|
546 // |
|
547 EXPORT_C CPbk2NamesListControl::CPbk2NamesListControl |
|
548 (const CCoeControl* aContainer, |
|
549 CVPbkContactManager& aManager, |
|
550 MVPbkContactViewBase& aView, |
|
551 MPbk2ContactNameFormatter& aNameFormatter, |
|
552 CPbk2StorePropertyArray& aStoreProperties) : |
|
553 iContactManager( aManager ), |
|
554 iBaseView( &aView ), |
|
555 iContainer( aContainer ), |
|
556 iNameFormatter( aNameFormatter ), |
|
557 iStoreProperties( aStoreProperties ), |
|
558 iAllowPointerEvents( ETrue ) |
|
559 { |
|
560 } |
|
561 |
|
562 // -------------------------------------------------------------------------- |
|
563 // CPbk2NamesListControl::CPbk2NamesListControl |
|
564 // -------------------------------------------------------------------------- |
|
565 // |
|
566 CPbk2NamesListControl::CPbk2NamesListControl |
|
567 (const CCoeControl* aContainer, |
|
568 CVPbkContactManager& aManager, |
|
569 MVPbkContactViewBase& aView, |
|
570 MPbk2ContactNameFormatter& aNameFormatter, |
|
571 CPbk2StorePropertyArray& aStoreProperties, |
|
572 CPbk2ThumbnailManager* aThumbManager) : |
|
573 iContactManager( aManager ), |
|
574 iBaseView( &aView ), |
|
575 iContainer( aContainer ), |
|
576 iNameFormatter( aNameFormatter ), |
|
577 iStoreProperties( aStoreProperties ), |
|
578 iThumbManager( aThumbManager ), //TODO |
|
579 iAllowPointerEvents( ETrue ) |
|
580 { |
|
581 } |
|
582 |
|
583 // -------------------------------------------------------------------------- |
|
584 // CPbk2NamesListControl::~CPbk2NamesListControl |
|
585 // -------------------------------------------------------------------------- |
|
586 // |
|
587 CPbk2NamesListControl::~CPbk2NamesListControl() |
|
588 { |
|
589 if ( iViewStack && iStackObserver ) |
|
590 { |
|
591 iViewStack->RemoveStackObserver( *iStackObserver ); |
|
592 } |
|
593 |
|
594 if (iCommand) |
|
595 { |
|
596 // inform the command that the control is deleted |
|
597 iCommand->ResetUiControl(*this); |
|
598 } |
|
599 iObservers.Reset(); |
|
600 iCommandItems.ResetAndDestroy(); |
|
601 delete iListBoxSelectionObserver; |
|
602 delete iStateFactory; |
|
603 delete iListBox; |
|
604 delete iFindBox; |
|
605 delete iThumbnailLoader; |
|
606 delete iEventSender; |
|
607 delete iStackObserver; |
|
608 delete iUiExtension; |
|
609 delete iViewStack; |
|
610 delete iSearchFilter; |
|
611 |
|
612 if (iOwnBaseView) |
|
613 { |
|
614 delete iBaseView; |
|
615 } |
|
616 if(iFeatureManagerInitilized) |
|
617 { |
|
618 FeatureManager::UnInitializeLib(); |
|
619 } |
|
620 |
|
621 // if thumbmanager, remove observer |
|
622 if( iThumbManager ) |
|
623 { |
|
624 iThumbManager->RemoveObserver(); |
|
625 } |
|
626 |
|
627 } |
|
628 |
|
629 // -------------------------------------------------------------------------- |
|
630 // CPbk2NamesListControl::NewL |
|
631 // -------------------------------------------------------------------------- |
|
632 // |
|
633 EXPORT_C CPbk2NamesListControl* CPbk2NamesListControl::NewL( |
|
634 TInt aResourceId, |
|
635 const CCoeControl* aContainer, |
|
636 CVPbkContactManager& aManager, |
|
637 MVPbkContactViewBase& aView, |
|
638 MPbk2ContactNameFormatter& aNameFormatter, |
|
639 CPbk2StorePropertyArray& aStoreProperties ) |
|
640 { |
|
641 CPbk2NamesListControl* self = new (ELeave) CPbk2NamesListControl( |
|
642 aContainer, aManager, aView, aNameFormatter, aStoreProperties ); |
|
643 CleanupStack::PushL(self); |
|
644 self->ConstructL( aResourceId); |
|
645 CleanupStack::Pop(self); |
|
646 return self; |
|
647 } |
|
648 |
|
649 |
|
650 // -------------------------------------------------------------------------- |
|
651 // CPbk2NamesListControl::NewL |
|
652 // -------------------------------------------------------------------------- |
|
653 // |
|
654 EXPORT_C CPbk2NamesListControl* CPbk2NamesListControl::NewL( |
|
655 TInt aResourceId, |
|
656 const CCoeControl* aContainer, |
|
657 CVPbkContactManager& aManager, |
|
658 MVPbkContactViewBase& aView, |
|
659 MPbk2ContactNameFormatter& aNameFormatter, |
|
660 CPbk2StorePropertyArray& aStoreProperties, |
|
661 CPbk2ThumbnailManager* aThumbManager ) //TODO |
|
662 { |
|
663 CPbk2NamesListControl* self = new (ELeave) CPbk2NamesListControl( |
|
664 aContainer, aManager, aView, aNameFormatter, aStoreProperties, aThumbManager ); |
|
665 CleanupStack::PushL(self); |
|
666 self->ConstructL( aResourceId); |
|
667 CleanupStack::Pop(self); |
|
668 return self; |
|
669 } |
|
670 |
|
671 // -------------------------------------------------------------------------- |
|
672 // CPbk2NamesListControl::ConstructL |
|
673 // -------------------------------------------------------------------------- |
|
674 // |
|
675 inline void CPbk2NamesListControl::ConstructL( |
|
676 TInt aResourceId) |
|
677 { |
|
678 if (!iContainer) |
|
679 { |
|
680 User::Leave(KErrGeneral); |
|
681 } |
|
682 |
|
683 // First set container |
|
684 SetContainerWindowL(*iContainer); |
|
685 |
|
686 TResourceReader resReader; |
|
687 CCoeEnv::Static()->CreateResourceReaderLC(resReader, aResourceId); |
|
688 ConstructFromResourceL(resReader); |
|
689 CleanupStack::PopAndDestroy(); // resReader |
|
690 FeatureManager::InitializeLibL(); |
|
691 iFeatureManagerInitilized = ETrue; |
|
692 } |
|
693 |
|
694 // -------------------------------------------------------------------------- |
|
695 // CPbk2NamesListControl::ConstructFromResourceL |
|
696 // -------------------------------------------------------------------------- |
|
697 // |
|
698 inline void CPbk2NamesListControl::ConstructFromResourceL |
|
699 ( TResourceReader& aReader ) |
|
700 { |
|
701 iSearchFilter = CPbk2PredictiveSearchFilter::NewL(); |
|
702 |
|
703 if(FeatureManager::FeatureSupported(KFeatureIdFfContactsPredictiveSearch)) |
|
704 |
|
705 { |
|
706 iViewStack = CPbk2PredictiveViewStack::NewL( *iBaseView, *iSearchFilter, |
|
707 iNameFormatter ); |
|
708 } |
|
709 else |
|
710 { |
|
711 iViewStack = CPbk2FilteredViewStack::NewL( *iBaseView ); |
|
712 } |
|
713 |
|
714 iViewStack->AddObserverL( *this ); |
|
715 |
|
716 iStackObserver = CPbk2FilteredViewStackObserver::NewL |
|
717 ( *this, |
|
718 &CPbk2NamesListControl::HandleTopViewChangedL, |
|
719 &CPbk2NamesListControl::HandleTopViewUpdatedL, |
|
720 &CPbk2NamesListControl::HandleBaseViewChangedL, |
|
721 &CPbk2NamesListControl::HandleViewStackError, |
|
722 &CPbk2NamesListControl::HandleContactAddedToBaseView ); |
|
723 iEventSender = CPbk2UiControlEventSender::NewL( *this, iObservers ); |
|
724 iViewStack->AddStackObserverL( *iStackObserver ); |
|
725 |
|
726 |
|
727 CPbk2UIExtensionManager* extManager = |
|
728 CPbk2UIExtensionManager::InstanceL(); |
|
729 extManager->PushL(); |
|
730 |
|
731 iUiExtension = extManager->FactoryL()->CreatePbk2UiControlExtensionL |
|
732 ( iContactManager ); |
|
733 |
|
734 CleanupStack::PopAndDestroy(); // extManager |
|
735 |
|
736 // peek listbox type from resource |
|
737 TInt flags = aReader.ReadInt32(); |
|
738 aReader.Rewind( sizeof( TInt32 ) ); |
|
739 |
|
740 // Create the listbox and its model |
|
741 if( flags & KPbk2ContactViewListControlDoubleRow ) |
|
742 { |
|
743 iDoubleListBox = CPbk2ContactViewDoubleListBox::NewL |
|
744 ( *this, aReader, iContactManager, |
|
745 *iViewStack, iNameFormatter, iStoreProperties, |
|
746 iUiExtension, *iSearchFilter, *iThumbManager ); |
|
747 |
|
748 if( iThumbManager ) |
|
749 { |
|
750 iThumbManager->SetObserver( *iDoubleListBox ); |
|
751 iViewStack->AddObserverL( *iThumbManager ); |
|
752 } |
|
753 |
|
754 iListBox = iDoubleListBox; |
|
755 } |
|
756 else |
|
757 { |
|
758 iListBox = CPbk2ContactViewListBox::NewL |
|
759 ( *this, aReader, iContactManager, |
|
760 *iViewStack, iNameFormatter, iStoreProperties, |
|
761 iUiExtension, *iSearchFilter ); |
|
762 |
|
763 //TODO at this point remove observer |
|
764 if( iThumbManager ) |
|
765 { |
|
766 iThumbManager->RemoveObserver(); |
|
767 } |
|
768 iDoubleListBox = NULL; |
|
769 } |
|
770 |
|
771 iListBox->SetObserver( this ); |
|
772 iListBox->SetScrollEventObserver( this ); |
|
773 iListBox->SetListBoxObserver(this); |
|
774 iUiExtension->SetContactUiControlUpdate( this ); |
|
775 // set command item updater |
|
776 TAny* ext = iUiExtension->ContactUiControlExtensionExtension( |
|
777 TUid::Uid( KPbk2ContactUiControlExtensionExtensionUID ) ); |
|
778 if( ext ) |
|
779 { |
|
780 static_cast<MPbk2ContactUiControlDoubleListboxExtension*>(ext)-> |
|
781 SetCommandItemUpdater( this ); |
|
782 } |
|
783 |
|
784 if ( iListBox->Flags() & KPbk2ContactViewListControlFindBox ) |
|
785 { |
|
786 // Create a find box |
|
787 if ( iSearchFilter->IsPredictiveActivated() ) |
|
788 { |
|
789 iFindBox = CAknSearchField::NewL |
|
790 (*this, CAknSearchField::ESearch, NULL, KSearchFieldLength); |
|
791 } |
|
792 else |
|
793 { |
|
794 iFindBox = CAknSearchField::NewL |
|
795 (*this, CAknSearchField::EAdaptiveSearch, NULL, KSearchFieldLength); |
|
796 } |
|
797 |
|
798 iSearchFilter->SetAknSearchFieldL( iFindBox ); |
|
799 |
|
800 iFindBox->MakeVisible( EFalse ); |
|
801 iFindBox->SetObserver( this ); |
|
802 iFindBox->AddAdaptiveSearchTextObserverL( this ); |
|
803 } |
|
804 |
|
805 // If list box supports selection then construct an observer that |
|
806 // handles the event sending when the selection mode changes. |
|
807 if ( iListBox->IsSelectionListBox() ) |
|
808 { |
|
809 iListBoxSelectionObserver = CPbk2ListBoxSelectionObserver::NewL( |
|
810 *this, *iListBox, *iEventSender ); |
|
811 } |
|
812 |
|
813 PBK2_DEBUG_PRINT(PBK2_DEBUG_STRING |
|
814 ("CPbk2NamesListControl::ConstructL find box created")); |
|
815 |
|
816 // Instantiate the state factory |
|
817 iStateFactory = CPbk2NamesListStateFactory::NewL( *this, *iListBox, |
|
818 *iViewStack, iFindBox, *iThumbnailLoader, *iEventSender, |
|
819 iNameFormatter, iCommandItems, *iSearchFilter ); |
|
820 |
|
821 // Create the initial state |
|
822 iCurrentState = &iStateFactory->ActivateStartupStateL( iCurrentState ); |
|
823 |
|
824 PBK2_DEBUG_PRINT(PBK2_DEBUG_STRING |
|
825 ("CPbk2NamesListControl::ConstructFromResourceL end")); |
|
826 } |
|
827 |
|
828 // -------------------------------------------------------------------------- |
|
829 // CPbk2NamesListControl::AddObserverL |
|
830 // -------------------------------------------------------------------------- |
|
831 // |
|
832 EXPORT_C void CPbk2NamesListControl::AddObserverL |
|
833 ( MPbk2ControlObserver& aObserver ) |
|
834 { |
|
835 User::LeaveIfError(iObservers.Append(&aObserver)); |
|
836 } |
|
837 |
|
838 // -------------------------------------------------------------------------- |
|
839 // CPbk2NamesListControl::RemoveObserver |
|
840 // -------------------------------------------------------------------------- |
|
841 // |
|
842 EXPORT_C void CPbk2NamesListControl::RemoveObserver |
|
843 ( MPbk2ControlObserver& aObserver ) |
|
844 { |
|
845 const TInt index = iObservers.Find(&aObserver); |
|
846 if (index >= 0) |
|
847 { |
|
848 iObservers.Remove(index); |
|
849 } |
|
850 } |
|
851 |
|
852 // -------------------------------------------------------------------------- |
|
853 // CPbk2NamesListControl::Reset |
|
854 // -------------------------------------------------------------------------- |
|
855 // |
|
856 EXPORT_C void CPbk2NamesListControl::Reset() |
|
857 { |
|
858 PBK2_DEBUG_PRINT(PBK2_DEBUG_STRING("CPbk2NamesListControl::Reset(0x%x) - IN"), |
|
859 this ); |
|
860 |
|
861 // Unmark all contacts and reset the toolbar so that the Call button |
|
862 // won't be dimmed |
|
863 TRAP_IGNORE( ProcessCommandL( EAknUnmarkAll ) ); |
|
864 // Reset find box |
|
865 TRAP_IGNORE( ResetFindL() ); |
|
866 // Destroy all the filtered views from the stack |
|
867 iViewStack->Reset(); |
|
868 // Refresh observer to get the view state |
|
869 iViewStack->RemoveObserver( *this ); |
|
870 // Shouldn't leave because the observer was first removed. |
|
871 // The control updates its state when the asynchronous Virtual Phonebook |
|
872 // view event arrives. |
|
873 TRAP_IGNORE( iViewStack->AddObserverL( *this ) ); |
|
874 |
|
875 const TInt firstContactIndex = 0; |
|
876 // Best effort: try to reset the focus. |
|
877 TRAP_IGNORE( iCurrentState->SetFocusedContactIndexL( firstContactIndex ) ); |
|
878 //scroll listbox into beginning (ignore focus that may be below promotion items) |
|
879 iListBox->SetTopItemIndex(firstContactIndex); |
|
880 |
|
881 // Switch to the background state. This enables the next state to avtivate fully (ActivateStateL()) once phonebook |
|
882 // comes from the background. |
|
883 TRAP_IGNORE( iCurrentState = &iStateFactory->ActivateHiddenStateL( iCurrentState ); ); |
|
884 |
|
885 PBK2_DEBUG_PRINT(PBK2_DEBUG_STRING("CPbk2NamesListControl::Reset() - OUT")); |
|
886 } |
|
887 |
|
888 // -------------------------------------------------------------------------- |
|
889 // CPbk2NamesListControl::SetViewL |
|
890 // -------------------------------------------------------------------------- |
|
891 // |
|
892 EXPORT_C void CPbk2NamesListControl::SetViewL( MVPbkContactViewBase& aView ) |
|
893 { |
|
894 // Control will receive a view event asynchronously from the stack |
|
895 iViewStack->SetNewBaseViewL( aView ); |
|
896 |
|
897 if (iOwnBaseView) |
|
898 { |
|
899 delete iBaseView; |
|
900 iBaseView = NULL; |
|
901 } |
|
902 |
|
903 iBaseView = &aView; |
|
904 iOwnBaseView = EFalse; |
|
905 |
|
906 iEventSender->Reset(); |
|
907 } |
|
908 |
|
909 // -------------------------------------------------------------------------- |
|
910 // CPbk2NamesListControl::GiveViewL |
|
911 // -------------------------------------------------------------------------- |
|
912 // |
|
913 EXPORT_C void CPbk2NamesListControl::GiveViewL( MVPbkContactViewBase* aView ) |
|
914 { |
|
915 SetViewL( *aView ); |
|
916 iOwnBaseView = ETrue; |
|
917 } |
|
918 |
|
919 EXPORT_C void CPbk2NamesListControl::AllowPointerEvents( TBool aAllow ) |
|
920 { |
|
921 iAllowPointerEvents = aAllow; |
|
922 } |
|
923 |
|
924 // -------------------------------------------------------------------------- |
|
925 // CPbk2NamesListControl::SetCurrentGroupLinkL |
|
926 // -------------------------------------------------------------------------- |
|
927 // |
|
928 EXPORT_C void CPbk2NamesListControl::SetCurrentGroupLinkL( MVPbkContactLink* aGroupLinktoSet) |
|
929 { |
|
930 // This is used only when predictive search is enabled |
|
931 if(FeatureManager::FeatureSupported(KFeatureIdFfContactsPredictiveSearch)) |
|
932 { |
|
933 static_cast<CPbk2PredictiveViewStack*> (iViewStack)->SetCurrentGroupLinkL(aGroupLinktoSet); |
|
934 } |
|
935 return; |
|
936 } |
|
937 |
|
938 // -------------------------------------------------------------------------- |
|
939 // CPbk2NamesListControl::View |
|
940 // -------------------------------------------------------------------------- |
|
941 // |
|
942 MVPbkContactViewBase& CPbk2NamesListControl::View() |
|
943 { |
|
944 return *iViewStack; |
|
945 } |
|
946 |
|
947 // -------------------------------------------------------------------------- |
|
948 // CPbk2NamesListControl::MakeVisible |
|
949 // -------------------------------------------------------------------------- |
|
950 // |
|
951 void CPbk2NamesListControl::MakeVisible(TBool aVisible) |
|
952 { |
|
953 PBK2_DEBUG_PRINT(PBK2_DEBUG_STRING( |
|
954 "CPbk2NamesListControl::MakeVisible(0x%x,%d)"), |
|
955 this, aVisible); |
|
956 |
|
957 CCoeControl::MakeVisible(aVisible); |
|
958 iCurrentState->MakeComponentsVisible(aVisible); |
|
959 } |
|
960 |
|
961 // -------------------------------------------------------------------------- |
|
962 // CPbk2NamesListControl::ActivateL |
|
963 // -------------------------------------------------------------------------- |
|
964 // |
|
965 void CPbk2NamesListControl::ActivateL() |
|
966 { |
|
967 // First, call base class implementation |
|
968 CCoeControl::ActivateL(); |
|
969 // Then do own initialization |
|
970 iCurrentState->ActivateL(); |
|
971 } |
|
972 |
|
973 // -------------------------------------------------------------------------- |
|
974 // CPbk2NamesListControl::OfferKeyEventL |
|
975 // -------------------------------------------------------------------------- |
|
976 // |
|
977 TKeyResponse CPbk2NamesListControl::OfferKeyEventL |
|
978 ( const TKeyEvent& aKeyEvent, TEventCode aType ) |
|
979 { |
|
980 if(FeatureManager::FeatureSupported(KFeatureIdFfContactsPredictiveSearch)) |
|
981 { |
|
982 if( iCurrentState->NamesListState() == EStateReady || |
|
983 iCurrentState->NamesListState() == EStateFiltered ) |
|
984 { |
|
985 iSearchFilter->FilterL( aKeyEvent, aType, iFindBox ); |
|
986 } |
|
987 } |
|
988 |
|
989 TKeyResponse result = iSearchFilter->OfferKeyEventL( aKeyEvent, aType ); |
|
990 |
|
991 if ( result == EKeyWasNotConsumed ) |
|
992 { |
|
993 result = iCurrentState->OfferKeyEventL( aKeyEvent, aType ); |
|
994 } |
|
995 |
|
996 // Ignore Send Key up and down events to prevent Dialer appearance |
|
997 // on top of Phonebook application. |
|
998 if ( result == EKeyWasNotConsumed && iListBox->NumberOfItems() != 0 ) |
|
999 { |
|
1000 if ( ( aType == EEventKeyDown || aType == EEventKeyUp ) |
|
1001 && aKeyEvent.iScanCode == EStdKeyYes ) |
|
1002 { |
|
1003 result = EKeyWasConsumed; |
|
1004 } |
|
1005 } |
|
1006 |
|
1007 return result; |
|
1008 } |
|
1009 |
|
1010 // -------------------------------------------------------------------------- |
|
1011 // CPbk2NamesListControl::CountComponentControls |
|
1012 // -------------------------------------------------------------------------- |
|
1013 // |
|
1014 TInt CPbk2NamesListControl::CountComponentControls() const |
|
1015 { |
|
1016 return iCurrentState->CountComponentControls(); |
|
1017 } |
|
1018 |
|
1019 // -------------------------------------------------------------------------- |
|
1020 // CPbk2NamesListControl::ComponentControl |
|
1021 // -------------------------------------------------------------------------- |
|
1022 // |
|
1023 CCoeControl* CPbk2NamesListControl::ComponentControl(TInt aIndex) const |
|
1024 { |
|
1025 // This is not forwarded to the states because these controls are |
|
1026 // always existing. It does not matter what is the state. |
|
1027 switch (aIndex) |
|
1028 { |
|
1029 case 0: |
|
1030 { |
|
1031 return iListBox; |
|
1032 } |
|
1033 case 1: |
|
1034 { |
|
1035 return iFindBox; |
|
1036 } |
|
1037 default: |
|
1038 { |
|
1039 // Illegal state |
|
1040 __ASSERT_DEBUG( EFalse, Panic( EPanicLogic_ComponentControl ) ); |
|
1041 return NULL; |
|
1042 } |
|
1043 } |
|
1044 } |
|
1045 |
|
1046 // -------------------------------------------------------------------------- |
|
1047 // CPbk2NamesListControl::FocusChanged |
|
1048 // -------------------------------------------------------------------------- |
|
1049 // |
|
1050 void CPbk2NamesListControl::FocusChanged( TDrawNow aDrawNow ) |
|
1051 { |
|
1052 if ( iListBox ) |
|
1053 { |
|
1054 iListBox->SetFocus( IsFocused(), aDrawNow ); |
|
1055 } |
|
1056 |
|
1057 if ( iFindBox && iFindBox->IsVisible() ) |
|
1058 { |
|
1059 iFindBox->SetFocus( IsFocused(), aDrawNow ); |
|
1060 if ( aDrawNow == EDrawNow && IsFocused() ) |
|
1061 { |
|
1062 iFindBox->DrawDeferred(); |
|
1063 } |
|
1064 } |
|
1065 |
|
1066 if (iCurrentState && IsNonFocusing()) |
|
1067 { |
|
1068 iCurrentState->CoeControl().SetFocus(IsFocused(), aDrawNow); |
|
1069 } |
|
1070 if ( IsFocused() ) |
|
1071 { |
|
1072 ShowThumbnail(); |
|
1073 } |
|
1074 else |
|
1075 { |
|
1076 HideThumbnail(); |
|
1077 } |
|
1078 ReportEventL( MCoeControlObserver::EEventStateChanged ); |
|
1079 } |
|
1080 |
|
1081 // -------------------------------------------------------------------------- |
|
1082 // CPbk2NamesListControl::SizeChanged |
|
1083 // -------------------------------------------------------------------------- |
|
1084 // |
|
1085 void CPbk2NamesListControl::SizeChanged() |
|
1086 { |
|
1087 iCurrentState->SizeChanged(); |
|
1088 } |
|
1089 |
|
1090 // -------------------------------------------------------------------------- |
|
1091 // CPbk2NamesListControl::Draw |
|
1092 // -------------------------------------------------------------------------- |
|
1093 // |
|
1094 void CPbk2NamesListControl::Draw(const TRect& aRect) const |
|
1095 { |
|
1096 CWindowGc& gc = SystemGc(); |
|
1097 iCurrentState->Draw(aRect, gc); |
|
1098 } |
|
1099 |
|
1100 // -------------------------------------------------------------------------- |
|
1101 // CPbk2NamesListControl::HandleResourceChange |
|
1102 // -------------------------------------------------------------------------- |
|
1103 // |
|
1104 void CPbk2NamesListControl::HandleResourceChange(TInt aType) |
|
1105 { |
|
1106 CCoeControl::HandleResourceChange(aType); |
|
1107 if ( iFindBox != NULL && aType == KAknMessageFocusLost ) |
|
1108 { |
|
1109 iFindBox->DrawDeferred(); |
|
1110 } |
|
1111 |
|
1112 /* This is useless...no need to show or hide thumbnail on layout/skin change...thumbnail will handle it's own resouce change event |
|
1113 if ( aType == KEikDynamicLayoutVariantSwitch || |
|
1114 aType == KAknsMessageSkinChange ) |
|
1115 { |
|
1116 if ( IsFocused() ) |
|
1117 { |
|
1118 RDebug::Print( _L("### NamesList::HandleResourceChangeL - show") ); |
|
1119 ShowThumbnail(); |
|
1120 } |
|
1121 else |
|
1122 { |
|
1123 RDebug::Print( _L("### NamesList::HandleResourceChangeL - hide") ); |
|
1124 HideThumbnail(); |
|
1125 } |
|
1126 }*/ |
|
1127 } |
|
1128 |
|
1129 // -------------------------------------------------------------------------- |
|
1130 // CPbk2NamesListControl::HandlePointerEventL |
|
1131 // -------------------------------------------------------------------------- |
|
1132 // |
|
1133 void CPbk2NamesListControl::HandlePointerEventL( |
|
1134 const TPointerEvent& aPointerEvent ) |
|
1135 { |
|
1136 if( !iAllowPointerEvents ) |
|
1137 { |
|
1138 return; |
|
1139 } |
|
1140 if ( AknLayoutUtils::PenEnabled() ) |
|
1141 { |
|
1142 iCurrentState->HandlePointerEventL( aPointerEvent ); |
|
1143 } |
|
1144 } |
|
1145 |
|
1146 // -------------------------------------------------------------------------- |
|
1147 // CPbk2NamesListControl::ParentControl |
|
1148 // -------------------------------------------------------------------------- |
|
1149 // |
|
1150 MPbk2ContactUiControl* CPbk2NamesListControl::ParentControl() const |
|
1151 { |
|
1152 // Name list controls has no parent |
|
1153 return NULL; |
|
1154 } |
|
1155 |
|
1156 // -------------------------------------------------------------------------- |
|
1157 // CPbk2NamesListControl::NumberOfContacts |
|
1158 // -------------------------------------------------------------------------- |
|
1159 // |
|
1160 TInt CPbk2NamesListControl::NumberOfContacts() const |
|
1161 { |
|
1162 TInt ret( iCurrentState->NumberOfContacts() ); |
|
1163 return ret; |
|
1164 } |
|
1165 |
|
1166 // -------------------------------------------------------------------------- |
|
1167 // CPbk2NamesListControl::FocusedContactL |
|
1168 // -------------------------------------------------------------------------- |
|
1169 // |
|
1170 const MVPbkBaseContact* CPbk2NamesListControl::FocusedContactL() const |
|
1171 { |
|
1172 return iCurrentState->FocusedContactL(); |
|
1173 } |
|
1174 |
|
1175 // -------------------------------------------------------------------------- |
|
1176 // CPbk2NamesListControl::FocusedViewContactL |
|
1177 // -------------------------------------------------------------------------- |
|
1178 // |
|
1179 const MVPbkViewContact* CPbk2NamesListControl::FocusedViewContactL() const |
|
1180 { |
|
1181 return iCurrentState->FocusedViewContactL(); |
|
1182 } |
|
1183 |
|
1184 // -------------------------------------------------------------------------- |
|
1185 // CPbk2NamesListControl::FocusedStoreContact |
|
1186 // -------------------------------------------------------------------------- |
|
1187 // |
|
1188 const MVPbkStoreContact* CPbk2NamesListControl::FocusedStoreContact() const |
|
1189 { |
|
1190 return iCurrentState->FocusedStoreContact(); |
|
1191 } |
|
1192 |
|
1193 // -------------------------------------------------------------------------- |
|
1194 // CPbk2NamesListControl::SetFocusedContactL |
|
1195 // -------------------------------------------------------------------------- |
|
1196 // |
|
1197 void CPbk2NamesListControl::SetFocusedContactL |
|
1198 ( const MVPbkBaseContact& aContact ) |
|
1199 { |
|
1200 iCurrentState->SetFocusedContactL(aContact); |
|
1201 } |
|
1202 |
|
1203 // -------------------------------------------------------------------------- |
|
1204 // CPbk2NamesListControl::SetFocusedContactL |
|
1205 // -------------------------------------------------------------------------- |
|
1206 // |
|
1207 void CPbk2NamesListControl::SetFocusedContactL( |
|
1208 const MVPbkContactBookmark& aContactBookmark ) |
|
1209 { |
|
1210 iCurrentState->SetFocusedContactL( aContactBookmark ); |
|
1211 } |
|
1212 |
|
1213 // -------------------------------------------------------------------------- |
|
1214 // CPbk2NamesListControl::SetFocusedContactL |
|
1215 // -------------------------------------------------------------------------- |
|
1216 // |
|
1217 void CPbk2NamesListControl::SetFocusedContactL( |
|
1218 const MVPbkContactLink& aContactLink ) |
|
1219 { |
|
1220 iCurrentState->SetFocusedContactL( aContactLink ); |
|
1221 } |
|
1222 |
|
1223 // -------------------------------------------------------------------------- |
|
1224 // CPbk2NamesListControl::FocusedContactIndex |
|
1225 // -------------------------------------------------------------------------- |
|
1226 // |
|
1227 TInt CPbk2NamesListControl::FocusedContactIndex() const |
|
1228 { |
|
1229 return iCurrentState->FocusedContactIndex(); |
|
1230 } |
|
1231 |
|
1232 // -------------------------------------------------------------------------- |
|
1233 // CPbk2NamesListControl::SetFocusedContactIndexL |
|
1234 // -------------------------------------------------------------------------- |
|
1235 // |
|
1236 void CPbk2NamesListControl::SetFocusedContactIndexL( TInt aIndex ) |
|
1237 { |
|
1238 iCurrentState->SetFocusedContactIndexL( aIndex ); |
|
1239 } |
|
1240 |
|
1241 // -------------------------------------------------------------------------- |
|
1242 // CPbk2NamesListControl::NumberOfContactFields |
|
1243 // -------------------------------------------------------------------------- |
|
1244 // |
|
1245 TInt CPbk2NamesListControl::NumberOfContactFields() const |
|
1246 { |
|
1247 return iCurrentState->NumberOfContactFields(); |
|
1248 } |
|
1249 |
|
1250 // -------------------------------------------------------------------------- |
|
1251 // CPbk2NamesListControl::FocusedField |
|
1252 // -------------------------------------------------------------------------- |
|
1253 // |
|
1254 const MVPbkBaseContactField* CPbk2NamesListControl::FocusedField() const |
|
1255 { |
|
1256 return iCurrentState->FocusedField(); |
|
1257 } |
|
1258 |
|
1259 // -------------------------------------------------------------------------- |
|
1260 // CPbk2NamesListControl::FocusedFieldIndex |
|
1261 // -------------------------------------------------------------------------- |
|
1262 // |
|
1263 TInt CPbk2NamesListControl::FocusedFieldIndex() const |
|
1264 { |
|
1265 return iCurrentState->FocusedFieldIndex(); |
|
1266 } |
|
1267 |
|
1268 // -------------------------------------------------------------------------- |
|
1269 // CPbk2NamesListControl::SetFocusedFieldIndex |
|
1270 // -------------------------------------------------------------------------- |
|
1271 // |
|
1272 void CPbk2NamesListControl::SetFocusedFieldIndex( TInt /*aIndex*/ ) |
|
1273 { |
|
1274 // Do nothing |
|
1275 } |
|
1276 |
|
1277 // -------------------------------------------------------------------------- |
|
1278 // CPbk2NamesListControl::ContactsMarked |
|
1279 // -------------------------------------------------------------------------- |
|
1280 // |
|
1281 TBool CPbk2NamesListControl::ContactsMarked() const |
|
1282 { |
|
1283 return iCurrentState->ContactsMarked(); |
|
1284 } |
|
1285 |
|
1286 // -------------------------------------------------------------------------- |
|
1287 // CPbk2NamesListControl::SelectedContactsL |
|
1288 // -------------------------------------------------------------------------- |
|
1289 // |
|
1290 MVPbkContactLinkArray* |
|
1291 CPbk2NamesListControl::SelectedContactsL() const |
|
1292 { |
|
1293 return iCurrentState->SelectedContactsL(); |
|
1294 } |
|
1295 |
|
1296 // -------------------------------------------------------------------------- |
|
1297 // CPbk2NamesListControl::SelectedContactsOrFocusedContactL |
|
1298 // -------------------------------------------------------------------------- |
|
1299 // |
|
1300 MVPbkContactLinkArray* |
|
1301 CPbk2NamesListControl::SelectedContactsOrFocusedContactL() const |
|
1302 { |
|
1303 return iCurrentState->SelectedContactsOrFocusedContactL(); |
|
1304 } |
|
1305 |
|
1306 // -------------------------------------------------------------------------- |
|
1307 // CPbk2NamesListControl::SelectedContactsIteratorL |
|
1308 // -------------------------------------------------------------------------- |
|
1309 // |
|
1310 MPbk2ContactLinkIterator* |
|
1311 CPbk2NamesListControl::SelectedContactsIteratorL() const |
|
1312 { |
|
1313 return iCurrentState->SelectedContactsIteratorL(); |
|
1314 } |
|
1315 |
|
1316 // -------------------------------------------------------------------------- |
|
1317 // CPbk2NamesListControl::SelectedContactStoresL |
|
1318 // -------------------------------------------------------------------------- |
|
1319 // |
|
1320 CArrayPtr<MVPbkContactStore>* |
|
1321 CPbk2NamesListControl::SelectedContactStoresL() const |
|
1322 { |
|
1323 // This is not a contact store control |
|
1324 return NULL; |
|
1325 } |
|
1326 |
|
1327 // -------------------------------------------------------------------------- |
|
1328 // CPbk2NamesListControl::ClearMarks |
|
1329 // -------------------------------------------------------------------------- |
|
1330 // |
|
1331 void CPbk2NamesListControl::ClearMarks() |
|
1332 { |
|
1333 iCurrentState->ClearMarks(); |
|
1334 } |
|
1335 |
|
1336 // -------------------------------------------------------------------------- |
|
1337 // CPbk2NamesListControl::SetSelectedContactL |
|
1338 // -------------------------------------------------------------------------- |
|
1339 // |
|
1340 void CPbk2NamesListControl::SetSelectedContactL |
|
1341 ( TInt aIndex, TBool aSelected ) |
|
1342 { |
|
1343 iCurrentState->SetSelectedContactL( aIndex, aSelected ); |
|
1344 } |
|
1345 |
|
1346 // -------------------------------------------------------------------------- |
|
1347 // CPbk2NamesListControl::SetSelectedContactL |
|
1348 // -------------------------------------------------------------------------- |
|
1349 // |
|
1350 void CPbk2NamesListControl::SetSelectedContactL( |
|
1351 const MVPbkContactBookmark& aContactBookmark, |
|
1352 TBool aSelected ) |
|
1353 { |
|
1354 iCurrentState->SetSelectedContactL( aContactBookmark, aSelected ); |
|
1355 } |
|
1356 |
|
1357 // -------------------------------------------------------------------------- |
|
1358 // CPbk2NamesListControl::SetSelectedContactL |
|
1359 // -------------------------------------------------------------------------- |
|
1360 // |
|
1361 void CPbk2NamesListControl::SetSelectedContactL( |
|
1362 const MVPbkContactLink& aContactLink, |
|
1363 TBool aSelected ) |
|
1364 { |
|
1365 iCurrentState->SetSelectedContactL( aContactLink, aSelected ); |
|
1366 } |
|
1367 TInt CPbk2NamesListControl::CommandItemCount() const |
|
1368 { |
|
1369 MPbk2ContactUiControl2* tempCurrentState = |
|
1370 reinterpret_cast<MPbk2ContactUiControl2*> |
|
1371 (iCurrentState->ContactUiControlExtension |
|
1372 (KMPbk2ContactUiControlExtension2Uid )); |
|
1373 return tempCurrentState->CommandItemCount(); |
|
1374 } |
|
1375 |
|
1376 const MPbk2UiControlCmdItem& |
|
1377 CPbk2NamesListControl::CommandItemAt( TInt aIndex ) const |
|
1378 { |
|
1379 MPbk2ContactUiControl2* tempCurrentState = |
|
1380 reinterpret_cast<MPbk2ContactUiControl2*> |
|
1381 (iCurrentState->ContactUiControlExtension |
|
1382 (KMPbk2ContactUiControlExtension2Uid )); |
|
1383 return tempCurrentState->CommandItemAt( aIndex ); |
|
1384 } |
|
1385 |
|
1386 const MPbk2UiControlCmdItem* CPbk2NamesListControl::FocusedCommandItem() const |
|
1387 { |
|
1388 MPbk2ContactUiControl2* tempCurrentState = |
|
1389 reinterpret_cast<MPbk2ContactUiControl2*> |
|
1390 (iCurrentState->ContactUiControlExtension |
|
1391 (KMPbk2ContactUiControlExtension2Uid )); |
|
1392 return tempCurrentState->FocusedCommandItem(); |
|
1393 } |
|
1394 |
|
1395 void CPbk2NamesListControl::DeleteCommandItemL( TInt aIndex ) |
|
1396 { |
|
1397 iCommandItems.Remove(aIndex); |
|
1398 iCurrentState->HandleCommandEventL(MPbk2NamesListState::EItemRemoved, aIndex); |
|
1399 } |
|
1400 |
|
1401 void CPbk2NamesListControl::AddCommandItemL(MPbk2UiControlCmdItem* aCommand, TInt aIndex) |
|
1402 { |
|
1403 // Fix ETKI-7NADZC |
|
1404 DeleteIfAlreadyAdded(aCommand); |
|
1405 |
|
1406 // add aCommand to iCommandItems |
|
1407 if (aIndex > iCommandItems.Count()) |
|
1408 { |
|
1409 aIndex = iCommandItems.Count(); |
|
1410 } |
|
1411 iCommandItems.Insert(aCommand, aIndex); |
|
1412 iCurrentState->HandleCommandEventL(MPbk2NamesListState::EItemAdded, aIndex); |
|
1413 } |
|
1414 |
|
1415 void CPbk2NamesListControl::DeleteIfAlreadyAdded(const MPbk2UiControlCmdItem* aCommand) |
|
1416 { |
|
1417 for ( TInt n = 0; n < iCommandItems.Count(); ++n) |
|
1418 { |
|
1419 MPbk2UiControlCmdItem* cmd = iCommandItems[n]; |
|
1420 if(cmd->CommandId() == aCommand->CommandId()) |
|
1421 { |
|
1422 iCommandItems.Remove(n); |
|
1423 delete cmd; |
|
1424 break; |
|
1425 } |
|
1426 } |
|
1427 } |
|
1428 |
|
1429 // -------------------------------------------------------------------------- |
|
1430 // CPbk2NamesListControl::DynInitMenuPaneL |
|
1431 // -------------------------------------------------------------------------- |
|
1432 // |
|
1433 void CPbk2NamesListControl::DynInitMenuPaneL( |
|
1434 TInt aResourceId, CEikMenuPane* aMenuPane) const |
|
1435 { |
|
1436 iCurrentState->DynInitMenuPaneL(aResourceId, aMenuPane); |
|
1437 } |
|
1438 |
|
1439 // -------------------------------------------------------------------------- |
|
1440 // CPbk2NamesListControl::ProcessCommandL |
|
1441 // -------------------------------------------------------------------------- |
|
1442 // |
|
1443 void CPbk2NamesListControl::ProcessCommandL( TInt aCommandId ) const |
|
1444 { |
|
1445 iCurrentState->ProcessCommandL(aCommandId); |
|
1446 } |
|
1447 |
|
1448 // -------------------------------------------------------------------------- |
|
1449 // CPbk2NamesListControl::UpdateAfterCommandExecution |
|
1450 // -------------------------------------------------------------------------- |
|
1451 // |
|
1452 void CPbk2NamesListControl::UpdateAfterCommandExecution() |
|
1453 { |
|
1454 if( iCommand ) |
|
1455 { |
|
1456 /// Reset command pointer, command has completed |
|
1457 iCommand->ResetUiControl(*this); |
|
1458 iCommand = NULL; |
|
1459 } |
|
1460 TRAP_IGNORE( ProcessCommandL( EAknUnmarkAll); ); |
|
1461 if( iSearchFilter ) |
|
1462 { |
|
1463 TRAP_IGNORE( iSearchFilter->ReDrawL(ETrue); ); |
|
1464 } |
|
1465 } |
|
1466 |
|
1467 // -------------------------------------------------------------------------- |
|
1468 // CPbk2NamesListControl::GetMenuFilteringFlagsL |
|
1469 // -------------------------------------------------------------------------- |
|
1470 // |
|
1471 TInt CPbk2NamesListControl::GetMenuFilteringFlagsL() const |
|
1472 { |
|
1473 return iCurrentState->GetMenuFilteringFlagsL(); |
|
1474 } |
|
1475 |
|
1476 // -------------------------------------------------------------------------- |
|
1477 // CPbk2NamesListControl::ControlStateL |
|
1478 // -------------------------------------------------------------------------- |
|
1479 // |
|
1480 CPbk2ViewState* CPbk2NamesListControl::ControlStateL() const |
|
1481 { |
|
1482 CPbk2ViewState* state = CPbk2ViewState::NewLC(); |
|
1483 const MVPbkBaseContact* focusedContact = FocusedContactL(); |
|
1484 if (focusedContact) |
|
1485 { |
|
1486 MVPbkContactLink* link = focusedContact->CreateLinkLC(); |
|
1487 if (link) |
|
1488 { |
|
1489 CleanupStack::Pop(); // link |
|
1490 state->SetFocusedContact(link); |
|
1491 } |
|
1492 } |
|
1493 |
|
1494 const MVPbkViewContact* topContact = iCurrentState->TopContactL(); |
|
1495 if ( topContact ) |
|
1496 { |
|
1497 MVPbkContactLink* link = topContact->CreateLinkLC(); |
|
1498 if (link) |
|
1499 { |
|
1500 CleanupStack::Pop(); // link |
|
1501 state->SetTopContact( link ); |
|
1502 } |
|
1503 } |
|
1504 |
|
1505 if (ContactsMarked()) |
|
1506 { |
|
1507 state->SetMarkedContacts(SelectedContactsL()); |
|
1508 } |
|
1509 CleanupStack::Pop(); // state |
|
1510 return state; |
|
1511 } |
|
1512 |
|
1513 // -------------------------------------------------------------------------- |
|
1514 // CPbk2NamesListControl::RestoreControlStateL |
|
1515 // -------------------------------------------------------------------------- |
|
1516 // |
|
1517 void CPbk2NamesListControl::RestoreControlStateL(CPbk2ViewState* aState) |
|
1518 { |
|
1519 PBK2_DEBUG_PRINT(PBK2_DEBUG_STRING |
|
1520 ("CPbk2NamesListControl::RestoreControlStateL(0x%x,0x%x)"), |
|
1521 this, aState); |
|
1522 |
|
1523 if (aState) |
|
1524 { |
|
1525 iCurrentState->RestoreControlStateL(aState); |
|
1526 } |
|
1527 } |
|
1528 |
|
1529 // -------------------------------------------------------------------------- |
|
1530 // CPbk2NamesListControl::FindTextL |
|
1531 // -------------------------------------------------------------------------- |
|
1532 // |
|
1533 const TDesC& CPbk2NamesListControl::FindTextL() |
|
1534 { |
|
1535 return iCurrentState->FindTextL(); |
|
1536 } |
|
1537 |
|
1538 // -------------------------------------------------------------------------- |
|
1539 // CPbk2NamesListControl::ResetFindL |
|
1540 // -------------------------------------------------------------------------- |
|
1541 // |
|
1542 void CPbk2NamesListControl::ResetFindL() |
|
1543 { |
|
1544 iCurrentState->ResetFindL(); |
|
1545 } |
|
1546 |
|
1547 // -------------------------------------------------------------------------- |
|
1548 // CPbk2NamesListControl::ShowThumbnail |
|
1549 // -------------------------------------------------------------------------- |
|
1550 // |
|
1551 void CPbk2NamesListControl::ShowThumbnail() |
|
1552 { |
|
1553 iCurrentState->ShowThumbnail(); |
|
1554 } |
|
1555 |
|
1556 // -------------------------------------------------------------------------- |
|
1557 // CPbk2NamesListControl::HideThumbnail |
|
1558 // -------------------------------------------------------------------------- |
|
1559 // |
|
1560 void CPbk2NamesListControl::HideThumbnail() |
|
1561 { |
|
1562 iCurrentState->HideThumbnail(); |
|
1563 } |
|
1564 |
|
1565 |
|
1566 // -------------------------------------------------------------------------- |
|
1567 // CPbk2NamesListControl::SetBlank |
|
1568 // -------------------------------------------------------------------------- |
|
1569 // |
|
1570 void CPbk2NamesListControl::SetBlank(TBool aBlank) |
|
1571 { |
|
1572 MakeVisible( !aBlank ); |
|
1573 |
|
1574 // The focus status of CAknSearchField* iFindBox is expected to be |
|
1575 // consistent with CPbk2NamesListControl when setting blank. |
|
1576 |
|
1577 if ( iFindBox ) |
|
1578 { |
|
1579 if ( iFindBox->IsVisible() ) |
|
1580 { |
|
1581 iFindBox->SetFocus( IsFocused() ); |
|
1582 } |
|
1583 } |
|
1584 |
|
1585 iCurrentState->SetBlank( aBlank ); |
|
1586 } |
|
1587 |
|
1588 // -------------------------------------------------------------------------- |
|
1589 // CPbk2NamesListControl::RegisterCommand |
|
1590 // -------------------------------------------------------------------------- |
|
1591 // |
|
1592 void CPbk2NamesListControl::RegisterCommand( |
|
1593 MPbk2Command* aCommand) |
|
1594 { |
|
1595 iCommand = aCommand; |
|
1596 } |
|
1597 |
|
1598 // -------------------------------------------------------------------------- |
|
1599 // CPbk2NamesListControl::SetTextL |
|
1600 // -------------------------------------------------------------------------- |
|
1601 // |
|
1602 void CPbk2NamesListControl::SetTextL( const TDesC& aText ) |
|
1603 { |
|
1604 iCurrentState->SetTextL( aText ); |
|
1605 } |
|
1606 |
|
1607 // -------------------------------------------------------------------------- |
|
1608 // CPbk2NamesListControl::ContactUiControlExtension |
|
1609 // -------------------------------------------------------------------------- |
|
1610 // |
|
1611 TAny* CPbk2NamesListControl::ContactUiControlExtension(TUid aExtensionUid ) |
|
1612 { |
|
1613 if( aExtensionUid == KMPbk2ContactUiControlExtension2Uid ) |
|
1614 { |
|
1615 return static_cast<MPbk2ContactUiControl2*>( this ); |
|
1616 } |
|
1617 |
|
1618 return NULL; |
|
1619 |
|
1620 } |
|
1621 |
|
1622 // -------------------------------------------------------------------------- |
|
1623 // CPbk2NamesListControl::ContactViewReady |
|
1624 // -------------------------------------------------------------------------- |
|
1625 // |
|
1626 void CPbk2NamesListControl::ContactViewReady |
|
1627 ( MVPbkContactViewBase& aView ) |
|
1628 { |
|
1629 PBK2_DEBUG_PRINT(PBK2_DEBUG_STRING |
|
1630 ("CPbk2NamesListControl::ContactViewReady(0x%x)"), this ); |
|
1631 TRAPD( error, DoHandleContactViewReadyL( aView ) ); |
|
1632 HandleError( error ); |
|
1633 } |
|
1634 |
|
1635 // -------------------------------------------------------------------------- |
|
1636 // CPbk2NamesListControl::ContactViewUnavailable |
|
1637 // -------------------------------------------------------------------------- |
|
1638 // |
|
1639 void CPbk2NamesListControl::ContactViewUnavailable |
|
1640 ( MVPbkContactViewBase& aView ) |
|
1641 { |
|
1642 PBK2_DEBUG_PRINT(PBK2_DEBUG_STRING |
|
1643 ("CPbk2NamesListControl::ContactViewUnavailable(0x%x)"), this); |
|
1644 |
|
1645 if ( &aView == iViewStack ) |
|
1646 { |
|
1647 TRAPD( err, iCurrentState = |
|
1648 &iStateFactory->ActivateNotReadyStateL( iCurrentState ) ); |
|
1649 HandleError( err ); |
|
1650 RelayoutControls(); |
|
1651 TRAP( err, iEventSender->SendEventToObserversL( |
|
1652 TPbk2ControlEvent::EUnavailable ) ); |
|
1653 HandleError( err ); |
|
1654 } |
|
1655 } |
|
1656 |
|
1657 // -------------------------------------------------------------------------- |
|
1658 // CPbk2NamesListControl::ContactAddedToView |
|
1659 // -------------------------------------------------------------------------- |
|
1660 // |
|
1661 void CPbk2NamesListControl::ContactAddedToView( |
|
1662 MVPbkContactViewBase& aView, |
|
1663 TInt aIndex, |
|
1664 const MVPbkContactLink& /*aContactLink*/) |
|
1665 { |
|
1666 PBK2_DEBUG_PRINT(PBK2_DEBUG_STRING |
|
1667 ("CPbk2NamesListControl::ContactAddedToView()")); |
|
1668 |
|
1669 if (&aView == iViewStack) |
|
1670 { |
|
1671 TRAPD(err, DoHandleContactAdditionL(aIndex)); |
|
1672 HandleError(err); |
|
1673 } |
|
1674 } |
|
1675 |
|
1676 // -------------------------------------------------------------------------- |
|
1677 // CPbk2NamesListControl::ContactRemovedFromView |
|
1678 // -------------------------------------------------------------------------- |
|
1679 // |
|
1680 void CPbk2NamesListControl::ContactRemovedFromView( |
|
1681 MVPbkContactViewBase& aView, |
|
1682 TInt aIndex, |
|
1683 const MVPbkContactLink& /*aContactLink*/ ) |
|
1684 { |
|
1685 PBK2_DEBUG_PRINT(PBK2_DEBUG_STRING |
|
1686 ("CPbk2NamesListControl::ContactRemovedFromView()")); |
|
1687 |
|
1688 if (&aView == iViewStack) |
|
1689 { |
|
1690 TRAPD(err, DoHandleContactRemovalL(aIndex)); |
|
1691 HandleError(err); |
|
1692 } |
|
1693 } |
|
1694 |
|
1695 // -------------------------------------------------------------------------- |
|
1696 // CPbk2NamesListControl::ContactViewError |
|
1697 // -------------------------------------------------------------------------- |
|
1698 // |
|
1699 void CPbk2NamesListControl::ContactViewError( |
|
1700 MVPbkContactViewBase& /*aView*/, |
|
1701 TInt aError, |
|
1702 TBool /*aErrorNotified*/) |
|
1703 { |
|
1704 PBK2_DEBUG_PRINT(PBK2_DEBUG_STRING |
|
1705 ("CPbk2NamesListControl::ContactViewError(%d)"), aError); |
|
1706 |
|
1707 // Error comes from the active view or from find view stack. |
|
1708 // Actions are same in both cases. Show error note by forwarding |
|
1709 // the error to CCoeEnv and try to reset control. Do reset asychronously |
|
1710 // because the ContactViewError can be coming from view that is |
|
1711 // destroyed when the control is reset. |
|
1712 HandleError(aError); |
|
1713 Reset(); |
|
1714 } |
|
1715 |
|
1716 // -------------------------------------------------------------------------- |
|
1717 // CPbk2NamesListControl::FocusedItemPointed |
|
1718 // -------------------------------------------------------------------------- |
|
1719 // |
|
1720 TBool CPbk2NamesListControl::FocusedItemPointed() |
|
1721 { |
|
1722 return iCurrentState->FocusedItemPointed(); |
|
1723 } |
|
1724 |
|
1725 // -------------------------------------------------------------------------- |
|
1726 // CPbk2NamesListControl::FocusableItemPointed |
|
1727 // -------------------------------------------------------------------------- |
|
1728 // |
|
1729 TBool CPbk2NamesListControl::FocusableItemPointed() |
|
1730 { |
|
1731 return iCurrentState->FocusableItemPointed(); |
|
1732 } |
|
1733 |
|
1734 // -------------------------------------------------------------------------- |
|
1735 // CPbk2NamesListControl::SearchFieldPointed |
|
1736 // -------------------------------------------------------------------------- |
|
1737 // |
|
1738 TBool CPbk2NamesListControl::SearchFieldPointed() |
|
1739 { |
|
1740 return iCurrentState->SearchFieldPointed(); |
|
1741 } |
|
1742 |
|
1743 // -------------------------------------------------------------------------- |
|
1744 // CPbk2NamesListControl::HandleControlEventL |
|
1745 // -------------------------------------------------------------------------- |
|
1746 // |
|
1747 void CPbk2NamesListControl::HandleControlEventL |
|
1748 ( CCoeControl* aControl, TCoeEvent aEventType ) |
|
1749 { |
|
1750 iCurrentState->HandleControlEventL( aControl, aEventType, 0 ); |
|
1751 } |
|
1752 |
|
1753 // -------------------------------------------------------------------------- |
|
1754 // CPbk2NamesListControl::UpdateContact |
|
1755 // -------------------------------------------------------------------------- |
|
1756 // |
|
1757 void CPbk2NamesListControl::UpdateContact |
|
1758 ( const MVPbkContactLink& aContactLink ) |
|
1759 { |
|
1760 TInt listBoxRow = KErrNotFound; |
|
1761 |
|
1762 TRAPD( err, listBoxRow = iViewStack->IndexOfLinkL( aContactLink ) ); |
|
1763 if ( err ) |
|
1764 { |
|
1765 iEikonEnv->NotifyIdleErrorWhileRedrawing( err ); |
|
1766 } |
|
1767 |
|
1768 MPbk2ContactUiControl2* tempCurrentState = |
|
1769 reinterpret_cast<MPbk2ContactUiControl2*> |
|
1770 (iCurrentState->ContactUiControlExtension |
|
1771 (KMPbk2ContactUiControlExtension2Uid )); |
|
1772 |
|
1773 if(tempCurrentState) |
|
1774 { |
|
1775 listBoxRow += tempCurrentState->CommandItemCount(); |
|
1776 } |
|
1777 if ( listBoxRow >= 0 ) |
|
1778 { |
|
1779 // If visible |
|
1780 if ( listBoxRow >= iListBox->TopItemIndex() && |
|
1781 listBoxRow <= iListBox->BottomItemIndex() ) |
|
1782 { |
|
1783 iListBox->RedrawItem( listBoxRow ); |
|
1784 } |
|
1785 } |
|
1786 } |
|
1787 |
|
1788 // -------------------------------------------------------------------------- |
|
1789 // CPbk2NamesListControl::UpdateCommandItem |
|
1790 // -------------------------------------------------------------------------- |
|
1791 // |
|
1792 void CPbk2NamesListControl::UpdateCommandItem( TInt aCommandId ) |
|
1793 { |
|
1794 const TInt count = CommandItemCount(); |
|
1795 const TInt top = iListBox->TopItemIndex(); |
|
1796 const TInt bottom = iListBox->BottomItemIndex(); |
|
1797 |
|
1798 for( TInt i = 0; i < count; ++i ) |
|
1799 { |
|
1800 if( Rng( top, i, bottom ) ) // is in visible range |
|
1801 { |
|
1802 if( CommandItemAt( i ).CommandId() == aCommandId ) |
|
1803 { |
|
1804 iListBox->RedrawItem( i ); |
|
1805 break; // only one command with same id |
|
1806 } |
|
1807 } |
|
1808 } |
|
1809 } |
|
1810 |
|
1811 // -------------------------------------------------------------------------- |
|
1812 // CPbk2NamesListControl::Redraw |
|
1813 // -------------------------------------------------------------------------- |
|
1814 // |
|
1815 void CPbk2NamesListControl::Redraw() |
|
1816 { |
|
1817 PBK2_DEBUG_PRINT(PBK2_DEBUG_STRING( |
|
1818 "CPbk2NamesListControl(0x%x)::Redraw"), this ); |
|
1819 |
|
1820 // Do not use DrawNow because: |
|
1821 // 1) DrawNow will draw the control everytime it's called. This can |
|
1822 // cause flickering in list box focus e.g. when the application view |
|
1823 // is restoring the control state. |
|
1824 // 2) Avoid unnecessary drawing because DrawDeferred can be called many |
|
1825 // times in short interval but it will draw the control only once. |
|
1826 DrawDeferred(); |
|
1827 } |
|
1828 |
|
1829 // -------------------------------------------------------------------------- |
|
1830 // CPbk2NamesListControl::DoHandleContactViewReadyL |
|
1831 // -------------------------------------------------------------------------- |
|
1832 // |
|
1833 void CPbk2NamesListControl::DoHandleContactViewReadyL |
|
1834 ( MVPbkContactViewBase& /*aView*/ ) |
|
1835 { |
|
1836 // Change state |
|
1837 SelectAndChangeReadyStateL(); |
|
1838 |
|
1839 //When contact view is ready, state is activated. If there are multiple stores |
|
1840 //state doesn't get event when other stores are ready. EContactViewUpdated event is |
|
1841 //sent when contact view is ready, so after state activation, state can get multiple |
|
1842 //contact view updated events. |
|
1843 iCurrentState->HandleContactViewEventL( MPbk2NamesListState::EContactViewUpdated, 0 ); |
|
1844 |
|
1845 // Check that there is still focus in list |
|
1846 // Focus may be lost if for example store goes unavailable |
|
1847 iListBox->CheckFocusIndex(); |
|
1848 // Control is ready and visible, inform observers |
|
1849 TBool eventSent = iEventSender->SendEventToObserversL( |
|
1850 TPbk2ControlEvent::EReady ); |
|
1851 // If Ready-event has been already sent, send |
|
1852 // ContactSetChanged-event instead. |
|
1853 if ( !eventSent ) |
|
1854 { |
|
1855 iEventSender->SendEventToObserversL( TPbk2ControlEvent:: |
|
1856 EContactSetChanged ); |
|
1857 } |
|
1858 } |
|
1859 |
|
1860 // -------------------------------------------------------------------------- |
|
1861 // CPbk2NamesListControl::DoHandleContactAdditionL |
|
1862 // |
|
1863 // NOTE: See also CPbk2FilteredViewStackObserver::ContactAddedToBaseView and |
|
1864 // CPbk2NamesListControl::DoContactAddedToBaseView |
|
1865 // -------------------------------------------------------------------------- |
|
1866 // |
|
1867 void CPbk2NamesListControl::DoHandleContactAdditionL( TInt aIndex ) |
|
1868 { |
|
1869 //Prevent messing with focus with always-on when Phonebook hidden in |
|
1870 //reseted state. Otherwise background-added contacts will change focus. |
|
1871 //This would cause Phonebook not to look like freshly started when opened again. |
|
1872 if(iCurrentState->NamesListState() != CPbk2NamesListControl::EStateHidden) |
|
1873 { |
|
1874 SelectAndChangeReadyStateL(); |
|
1875 } |
|
1876 |
|
1877 iCurrentState->HandleContactViewEventL |
|
1878 ( MPbk2NamesListState::EItemAdded, aIndex ); |
|
1879 |
|
1880 // At least names list view needs control event about contact addition, |
|
1881 // so it knows to update CBAs |
|
1882 iEventSender->SendEventToObserversL( TPbk2ControlEvent::EItemAdded ); |
|
1883 } |
|
1884 |
|
1885 // -------------------------------------------------------------------------- |
|
1886 // CPbk2NamesListControl::DoHandleContactRemovalL |
|
1887 // -------------------------------------------------------------------------- |
|
1888 // |
|
1889 void CPbk2NamesListControl::DoHandleContactRemovalL( TInt aIndex ) |
|
1890 { |
|
1891 iCurrentState->HandleContactViewEventL |
|
1892 ( MPbk2NamesListState::EItemRemoved, aIndex ); |
|
1893 SelectAndChangeReadyStateL(); |
|
1894 iEventSender->SendEventToObserversL( TPbk2ControlEvent::EItemRemoved ); |
|
1895 } |
|
1896 |
|
1897 // -------------------------------------------------------------------------- |
|
1898 // CPbk2NamesListControl::SelectAndChangeReadyStateL |
|
1899 // Changes between ready states (ready, empty, filtered). |
|
1900 // Can't handle a change to unavailable state |
|
1901 // -------------------------------------------------------------------------- |
|
1902 // |
|
1903 void CPbk2NamesListControl::SelectAndChangeReadyStateL() |
|
1904 { |
|
1905 if ( iViewStack->ContactCountL() == 0 ) |
|
1906 { |
|
1907 if ( iViewStack->Level() > 0 ) |
|
1908 { |
|
1909 // If view was filtered beyond matches, activate filtered state |
|
1910 iCurrentState = &iStateFactory->ActivateFilteredStateL |
|
1911 ( iCurrentState ); |
|
1912 } |
|
1913 else |
|
1914 { |
|
1915 // Empty state used only if there are no contacts |
|
1916 // in the base view |
|
1917 iCurrentState = &iStateFactory->ActivateEmptyStateL |
|
1918 ( iCurrentState ); |
|
1919 } |
|
1920 } |
|
1921 else |
|
1922 { |
|
1923 iCurrentState = |
|
1924 &iStateFactory->ActivateReadyStateL( iCurrentState ); |
|
1925 } |
|
1926 |
|
1927 // Controls have to be relayouted always. Relayouting only when |
|
1928 // state was changed is not enough, it results to drawing problems. |
|
1929 // Calling only Redraw() is not enough also. |
|
1930 RelayoutControls(); |
|
1931 } |
|
1932 |
|
1933 // -------------------------------------------------------------------------- |
|
1934 // CPbk2NamesListControl::RelayoutControls |
|
1935 // -------------------------------------------------------------------------- |
|
1936 // |
|
1937 void CPbk2NamesListControl::RelayoutControls() |
|
1938 { |
|
1939 SizeChanged(); |
|
1940 MakeVisible( IsVisible() ); |
|
1941 Redraw(); |
|
1942 } |
|
1943 |
|
1944 // -------------------------------------------------------------------------- |
|
1945 // CPbk2NamesListControl::HandleTopViewChangedL |
|
1946 // -------------------------------------------------------------------------- |
|
1947 // |
|
1948 void CPbk2NamesListControl::HandleTopViewChangedL |
|
1949 ( MVPbkContactViewBase& aOldView ) |
|
1950 { |
|
1951 SelectAndChangeReadyStateL(); |
|
1952 |
|
1953 iCurrentState->TopViewChangedL( aOldView ); |
|
1954 |
|
1955 // Inform observers |
|
1956 iEventSender->SendEventToObserversL( |
|
1957 TPbk2ControlEvent::EContactSetChanged ); |
|
1958 } |
|
1959 |
|
1960 // -------------------------------------------------------------------------- |
|
1961 // CPbk2NamesListControl::HandleTopViewUpdatedL |
|
1962 // -------------------------------------------------------------------------- |
|
1963 // |
|
1964 void CPbk2NamesListControl::HandleTopViewUpdatedL() |
|
1965 { |
|
1966 PBK2_DEBUG_PRINT(PBK2_DEBUG_STRING |
|
1967 ("CPbk2NamesListControl::HandleTopViewUpdatedL(0x%x)"), this ); |
|
1968 |
|
1969 SelectAndChangeReadyStateL(); |
|
1970 |
|
1971 iCurrentState->TopViewUpdatedL(); |
|
1972 } |
|
1973 |
|
1974 // -------------------------------------------------------------------------- |
|
1975 // CPbk2NamesListControl::HandleBaseViewChangedL |
|
1976 // -------------------------------------------------------------------------- |
|
1977 // |
|
1978 void CPbk2NamesListControl::HandleBaseViewChangedL() |
|
1979 { |
|
1980 PBK2_DEBUG_PRINT(PBK2_DEBUG_STRING |
|
1981 ("CPbk2NamesListControl::HandleBaseViewChangedL(0x%x)"), this ); |
|
1982 |
|
1983 SelectAndChangeReadyStateL(); |
|
1984 |
|
1985 iCurrentState->BaseViewChangedL(); |
|
1986 |
|
1987 iEventSender->SendEventToObserversL( |
|
1988 TPbk2ControlEvent::EContactSetChanged ); |
|
1989 } |
|
1990 |
|
1991 // -------------------------------------------------------------------------- |
|
1992 // CPbk2NamesListControl::HandleViewStackError |
|
1993 // -------------------------------------------------------------------------- |
|
1994 // |
|
1995 void CPbk2NamesListControl::HandleViewStackError( TInt aError ) |
|
1996 { |
|
1997 PBK2_DEBUG_PRINT(PBK2_DEBUG_STRING |
|
1998 ("CPbk2NamesListControl::HandleBaseViewChangedL(0x%x, %d)"), |
|
1999 this, aError ); |
|
2000 |
|
2001 HandleError( aError ); |
|
2002 Reset(); |
|
2003 } |
|
2004 |
|
2005 // -------------------------------------------------------------------------- |
|
2006 // CPbk2NamesListControl::HandleContactAddedToBaseView |
|
2007 // -------------------------------------------------------------------------- |
|
2008 // |
|
2009 void CPbk2NamesListControl::HandleContactAddedToBaseView |
|
2010 ( MVPbkContactViewBase& /*aBaseView*/, |
|
2011 TInt /*aIndex*/, const MVPbkContactLink& /*aContactLink*/ ) |
|
2012 { |
|
2013 // The find box must be reset when new items are added to |
|
2014 // the list box. When find text is reset, the possible filter |
|
2015 // result (subset of contacts) of the previous find criteria must be |
|
2016 // reset too. So, we reset both the find box and the view stack. |
|
2017 TRAPD( res, |
|
2018 { |
|
2019 // This will reset back to base view |
|
2020 iCurrentState->ResetFindL(); |
|
2021 }); |
|
2022 HandleError( res ); |
|
2023 Reset(); |
|
2024 |
|
2025 // Do not handle contact addition here (DoHandleContactAdditionL), |
|
2026 // ContactAddedToView to notification is sent separately |
|
2027 } |
|
2028 |
|
2029 // -------------------------------------------------------------------------- |
|
2030 // |
|
2031 // -------------------------------------------------------------------------- |
|
2032 // |
|
2033 void CPbk2NamesListControl::HandleScrollEventL(CEikScrollBar* aScrollBar, TEikScrollEvent aEventType) |
|
2034 { |
|
2035 // iDidMove= EFalse ; |
|
2036 |
|
2037 switch( aEventType ) |
|
2038 { |
|
2039 // drag events -> hide thumbnail |
|
2040 // AL: this isn't very efficient way of doing this... |
|
2041 // ...thumbnail loader interface should be extended to |
|
2042 // enable thumbnail window to be hidden/shown without |
|
2043 // destroying and reloading the bitmaps... |
|
2044 case EEikScrollThumbDragHoriz: |
|
2045 case EEikScrollThumbDragVert: |
|
2046 { |
|
2047 iDidMove = ETrue; |
|
2048 HideThumbnail(); |
|
2049 break; |
|
2050 } |
|
2051 |
|
2052 // release events |
|
2053 case EEikScrollThumbReleaseHoriz: |
|
2054 case EEikScrollThumbReleaseVert: |
|
2055 { |
|
2056 // AL: this isn't very efficient way of doing this... |
|
2057 // ...thumbnail loader interface should be extended to |
|
2058 // enable thumbnail window to be hidden/shown without |
|
2059 // destroying and reloading the bitmaps... |
|
2060 if( iDidMove ) |
|
2061 { |
|
2062 iDidMove = EFalse; |
|
2063 ShowThumbnail(); |
|
2064 } |
|
2065 break; |
|
2066 } |
|
2067 |
|
2068 default: |
|
2069 { |
|
2070 iDidMove= EFalse ; |
|
2071 |
|
2072 if( iThumbnailLoader ) |
|
2073 { |
|
2074 iThumbnailLoader->Refresh(); |
|
2075 } |
|
2076 |
|
2077 |
|
2078 } |
|
2079 } |
|
2080 |
|
2081 // To avoid slow redraw of the scrollbar, make sure it gets drawn. Fixes MJAA-7ZGHRH. |
|
2082 aScrollBar->DrawNow(); |
|
2083 } |
|
2084 // -------------------------------------------------------------------------- |
|
2085 // CPbk2NamesListControl::HandleListBoxEventL |
|
2086 // Deal with the Panning/Flick event from listbox |
|
2087 // -------------------------------------------------------------------------- |
|
2088 // |
|
2089 void CPbk2NamesListControl::HandleListBoxEventL( CEikListBox* /*aListBox*/, TListBoxEvent aEventType ) |
|
2090 { |
|
2091 switch( aEventType ) |
|
2092 { |
|
2093 case EEventPanningStarted: |
|
2094 case EEventFlickStarted: |
|
2095 { |
|
2096 // Hide Thumbnial as the listbox is |
|
2097 // Panning/Flicking |
|
2098 HideThumbnail(); |
|
2099 break; |
|
2100 } |
|
2101 |
|
2102 case EEventPanningStopped: |
|
2103 case EEventFlickStopped: |
|
2104 { |
|
2105 // Show Thumbnial after the listbox |
|
2106 // Panned/Flicked |
|
2107 ShowThumbnail(); |
|
2108 break; |
|
2109 } |
|
2110 case EEventItemSingleClicked: |
|
2111 case EEventItemDoubleClicked: |
|
2112 { |
|
2113 iEventSender->SendEventToObserversL( |
|
2114 TPbk2ControlEvent::EContactDoubleTapped ); |
|
2115 break; |
|
2116 } |
|
2117 |
|
2118 default: |
|
2119 break; |
|
2120 } |
|
2121 } |
|
2122 |
|
2123 // -------------------------------------------------------------------------- |
|
2124 // CPbk2NamesListControl::AdaptiveSearchTextChanged |
|
2125 // |
|
2126 // -------------------------------------------------------------------------- |
|
2127 // |
|
2128 void CPbk2NamesListControl::AdaptiveSearchTextChanged( CAknSearchField* aSearchField ) |
|
2129 { |
|
2130 //send event to current state |
|
2131 //ETrue means that the event came from adaptvie search grid. |
|
2132 iCurrentState->HandleControlEventL( aSearchField, MCoeControlObserver::EEventStateChanged, ETrue ); |
|
2133 } |
|
2134 |
|
2135 // -------------------------------------------------------------------------- |
|
2136 // CPbk2NamesListControl::HandleForegroundEventL |
|
2137 // |
|
2138 // -------------------------------------------------------------------------- |
|
2139 // |
|
2140 void CPbk2NamesListControl::HandleForegroundEventL(TBool aForeground) |
|
2141 { |
|
2142 if ( iSearchFilter ) |
|
2143 { |
|
2144 iSearchFilter->HandleForegroundEventL( aForeground ); |
|
2145 } |
|
2146 } |
|
2147 |
|
2148 |
|
2149 // End of File |