|
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 #include <CPbk2ThumbnailManager.h> |
|
45 #include <Pbk2CommonUi.rsg> |
|
46 #include <Pbk2UIControls.rsg> |
|
47 #include "CPbk2AppUi.h" |
|
48 |
|
49 // Virtual Phonebook |
|
50 #include <MVPbkContactViewBase.h> |
|
51 #include <MVPbkViewContact.h> |
|
52 #include <MVPbkContactLink.h> |
|
53 #include <CVPbkContactLinkArray.h> |
|
54 |
|
55 // System includes |
|
56 #include <barsread.h> |
|
57 #include <aknsfld.h> |
|
58 #include <AknPriv.hrh> |
|
59 #include <featmgr.h> |
|
60 #include <AknWaitDialog.h> |
|
61 |
|
62 // Debugging headers |
|
63 #include <Pbk2Debug.h> |
|
64 |
|
65 |
|
66 /// Unnamed namespace for local definitions |
|
67 namespace { |
|
68 |
|
69 /** |
|
70 * Handles errors. |
|
71 * |
|
72 * @param aErrorCode Error code. |
|
73 */ |
|
74 void HandleError( TInt aErrorCode ) |
|
75 { |
|
76 if ( aErrorCode != KErrNone ) |
|
77 { |
|
78 // Display standard error message |
|
79 CEikonEnv::Static()->HandleError( aErrorCode ); |
|
80 } |
|
81 } |
|
82 |
|
83 #ifdef _DEBUG |
|
84 enum TPanicCode |
|
85 { |
|
86 EPanicLogic_ComponentControl = 1, |
|
87 }; |
|
88 |
|
89 void Panic(TPanicCode aReason) |
|
90 { |
|
91 _LIT(KPanicText, "CPbk2NamesListControl"); |
|
92 User::Panic(KPanicText, aReason); |
|
93 } |
|
94 #endif // _DEBUG |
|
95 |
|
96 } /// namespace |
|
97 |
|
98 /** |
|
99 * A helper class for sending control events. |
|
100 */ |
|
101 NONSHARABLE_CLASS( CPbk2UiControlEventSender ) : public CBase, |
|
102 public MPbk2UiControlEventSender |
|
103 { |
|
104 public: // Construction and destruction |
|
105 |
|
106 /** |
|
107 * Creates a new instance of this class. |
|
108 * |
|
109 * @param aControl Control. |
|
110 * @param aObservers Observers. |
|
111 * @return A new instance of this class. |
|
112 */ |
|
113 static CPbk2UiControlEventSender* NewL( |
|
114 CPbk2NamesListControl& aControl, |
|
115 RPointerArray<MPbk2ControlObserver>& aObservers ); |
|
116 |
|
117 /** |
|
118 * Destructor. |
|
119 */ |
|
120 ~CPbk2UiControlEventSender(); |
|
121 |
|
122 public: /// From MPbk2UiControlEventSender |
|
123 TBool SendEventToObserversL( |
|
124 const TPbk2ControlEvent& aEvent ); |
|
125 void Reset(); |
|
126 |
|
127 private: // Implementation |
|
128 CPbk2UiControlEventSender( |
|
129 CPbk2NamesListControl& aControl, |
|
130 RPointerArray<MPbk2ControlObserver>& aObservers ); |
|
131 void ConstructL(); |
|
132 TBool SendEvent( |
|
133 const TPbk2ControlEvent& aEvent ); |
|
134 |
|
135 private: // Data |
|
136 /// Ref: Control |
|
137 CPbk2NamesListControl& iControl; |
|
138 /// Ref: Observers |
|
139 RPointerArray<MPbk2ControlObserver>& iObservers; |
|
140 /// Own: Indicates has the ready event been sent |
|
141 TBool iReadyEventSend; |
|
142 }; |
|
143 |
|
144 /** |
|
145 * A helper class for hiding inheritance of MPbk2FilteredViewStackObserver |
|
146 * from CPbk2NamesListControl. |
|
147 */ |
|
148 class CPbk2FilteredViewStackObserver : public CBase, |
|
149 public MPbk2FilteredViewStackObserver |
|
150 { |
|
151 public: /// Typedefs |
|
152 typedef void( CPbk2NamesListControl::* TopViewChangedFuncPtr ) |
|
153 ( MVPbkContactViewBase& aOldView ); |
|
154 typedef void( CPbk2NamesListControl::* ViewStackErrorFuncPtr ) |
|
155 ( TInt aError ); |
|
156 typedef void( CPbk2NamesListControl::* ContactAddedToBaseViewFuncPtr ) |
|
157 ( MVPbkContactViewBase& aBaseView, |
|
158 TInt aIndex, const MVPbkContactLink& aContactLink ); |
|
159 typedef void( CPbk2NamesListControl::* TopViewUpdatedFuncPtr )(); |
|
160 typedef void( CPbk2NamesListControl::* BaseViewChangedFuncPtr )(); |
|
161 |
|
162 public: // Construction and destruction |
|
163 |
|
164 /** |
|
165 * Creates a new instance of this class. |
|
166 * |
|
167 * @param aControl Control. |
|
168 * @param aViewStack View stack. |
|
169 * @param aTopViewChangedFuncPtr Top view changed function pointer. |
|
170 * @param aTopViewUpdatedFuncPtr Top view updated function pointer. |
|
171 * @param aBaseViewChangedFuncPtr Base view changed function pointer. |
|
172 * @param aViewStackErrorFuncPtr View stack error function pointer. |
|
173 * @param aContactAddedToBaseViewFuncPtr Contact added to base view function pointer. |
|
174 * @return A new instance of this class. |
|
175 */ |
|
176 static CPbk2FilteredViewStackObserver* NewL( |
|
177 CPbk2NamesListControl& aControl, |
|
178 TopViewChangedFuncPtr aTopViewChangedFuncPtr, |
|
179 TopViewUpdatedFuncPtr aTopViewUpdatedFuncPtr, |
|
180 BaseViewChangedFuncPtr aBaseViewChangedFuncPtr, |
|
181 ViewStackErrorFuncPtr aViewStackErrorFuncPtr, |
|
182 ContactAddedToBaseViewFuncPtr aContactAddedToBaseViewFuncPtr ); |
|
183 |
|
184 /** |
|
185 * Destructor. |
|
186 */ |
|
187 ~CPbk2FilteredViewStackObserver(); |
|
188 |
|
189 private: // From MPbk2FilteredViewStackObserver |
|
190 void TopViewChangedL( |
|
191 MVPbkContactViewBase& aOldView ); |
|
192 void TopViewUpdatedL(); |
|
193 void BaseViewChangedL(); |
|
194 void ViewStackError( |
|
195 TInt aError ); |
|
196 void ContactAddedToBaseView( |
|
197 MVPbkContactViewBase& aBaseView, |
|
198 TInt aIndex, |
|
199 const MVPbkContactLink& aContactLink ); |
|
200 |
|
201 private: // Implementation |
|
202 CPbk2FilteredViewStackObserver( |
|
203 CPbk2NamesListControl& aControl, |
|
204 TopViewChangedFuncPtr aTopViewChangedFuncPtr, |
|
205 TopViewUpdatedFuncPtr aTopViewUpdatedFuncPtr, |
|
206 BaseViewChangedFuncPtr aBaseViewChangedFuncPtr, |
|
207 ViewStackErrorFuncPtr aViewStackErrorFuncPtr, |
|
208 ContactAddedToBaseViewFuncPtr aContactAddedToBaseViewFuncPtr ); |
|
209 void ConstructL(); |
|
210 |
|
211 private: // Data |
|
212 /// Ref: Control |
|
213 CPbk2NamesListControl& iControl; |
|
214 /// Ref: Top view changed function pointer |
|
215 TopViewChangedFuncPtr iTopViewChangedFuncPtr; |
|
216 /// Ref: Top view updated function pointer |
|
217 TopViewUpdatedFuncPtr iTopViewUpdatedFuncPtr; |
|
218 /// Ref: Base view changed function pointer |
|
219 BaseViewChangedFuncPtr iBaseViewChangedFuncPtr; |
|
220 /// Ref: View stack error function pointer |
|
221 ViewStackErrorFuncPtr iViewStackErrorFuncPtr; |
|
222 /// Ref: Contact added to base view function pointer |
|
223 ContactAddedToBaseViewFuncPtr iContactAddedToBaseViewFuncPtr; |
|
224 }; |
|
225 |
|
226 /** |
|
227 * An observer for list box selections. Sends control events |
|
228 * when the list box enters to or from the selection mode. |
|
229 */ |
|
230 NONSHARABLE_CLASS( CPbk2ListBoxSelectionObserver ) : public CBase, |
|
231 private MListBoxSelectionObserver |
|
232 { |
|
233 public: // Interface |
|
234 |
|
235 /** |
|
236 * Creates a new instance of this class. |
|
237 * |
|
238 * @param aListBox The list box that is observed. |
|
239 * @param aEventSender An event sender for sending control |
|
240 * events. |
|
241 * @return A new instance of this class. |
|
242 */ |
|
243 static CPbk2ListBoxSelectionObserver* NewL( |
|
244 CPbk2NamesListControl& aControl, |
|
245 CEikListBox& aListBox, |
|
246 MPbk2UiControlEventSender& aEventSender ); |
|
247 |
|
248 /** |
|
249 * Destructor |
|
250 */ |
|
251 ~CPbk2ListBoxSelectionObserver(); |
|
252 |
|
253 private: /// From MListBoxSelectionObserver |
|
254 void SelectionModeChanged( |
|
255 CEikListBox* aListBox, |
|
256 TBool aSelectionModeEnabled ); |
|
257 |
|
258 private: // Implementation |
|
259 CPbk2ListBoxSelectionObserver( |
|
260 CPbk2NamesListControl& aControl, |
|
261 CEikListBox& aListBox, |
|
262 MPbk2UiControlEventSender& aEventSender ); |
|
263 void ConstructL(); |
|
264 |
|
265 private: // Data |
|
266 /// Ref: Control |
|
267 CPbk2NamesListControl& iControl; |
|
268 /// Ref: List box |
|
269 CEikListBox& iListBox; |
|
270 /// Ref: Event sender |
|
271 MPbk2UiControlEventSender& iEventSender; |
|
272 }; |
|
273 |
|
274 |
|
275 /** |
|
276 * Background Task Handler. |
|
277 */ |
|
278 NONSHARABLE_CLASS(CPbk2NamesListControlBgTask) : public CActive |
|
279 { |
|
280 |
|
281 public: |
|
282 CPbk2NamesListControlBgTask( CPbk2NamesListControl& aControl ); |
|
283 ~CPbk2NamesListControlBgTask(); |
|
284 |
|
285 void AddEvent( CPbk2NamesListControl::TPbk2NamesListBgEvents aEvent ); |
|
286 void ClearAllEvents(); |
|
287 void RemoveEvent( CPbk2NamesListControl::TPbk2NamesListBgEvents aEvent ); |
|
288 |
|
289 private: // From CActive |
|
290 void DoCancel(); |
|
291 void RunL(); |
|
292 TInt RunError(TInt aError); |
|
293 |
|
294 private: |
|
295 //Owns |
|
296 RArray <CPbk2NamesListControl::TPbk2NamesListBgEvents> iEventQueue; |
|
297 |
|
298 //doesnt Own |
|
299 CPbk2NamesListControl& iControl; |
|
300 }; |
|
301 |
|
302 /** |
|
303 * A helper class for mass update cases. |
|
304 */ |
|
305 NONSHARABLE_CLASS( CPbk2HandleMassUpdate ) : public CBase |
|
306 { |
|
307 public: // Construction and destruction |
|
308 /** |
|
309 * Creates new instance of this class. |
|
310 * @return new instance of this class. |
|
311 */ |
|
312 static CPbk2HandleMassUpdate* NewL(CEikListBox& iListBox); |
|
313 |
|
314 /** |
|
315 * Destructor. |
|
316 */ |
|
317 ~CPbk2HandleMassUpdate(); |
|
318 |
|
319 public: |
|
320 /** |
|
321 * Call this function after each update event. |
|
322 * @return ETrue if this event is part of a mass update. |
|
323 */ |
|
324 TBool MassUpdateCheckThis(); |
|
325 |
|
326 /** |
|
327 * Call this function to check if mass update process is ongoing. |
|
328 * @return ETrue if mass update process is ongoing. |
|
329 */ |
|
330 TBool MassUpdateDetected(); |
|
331 |
|
332 /** |
|
333 * Call this function to skip the showing of blocking progress note. |
|
334 * When done MassUpdateSkipProgressNote( EFalse ) must be called to reset. |
|
335 */ |
|
336 void MassUpdateSkipProgressNote( TBool aSkip ); |
|
337 |
|
338 private: |
|
339 CPbk2HandleMassUpdate(CEikListBox& iListBox); |
|
340 void ConstructL(); |
|
341 TBool HandleMassUpdateCheckL(); |
|
342 void HandleMassUpdateBurstL( |
|
343 const TTimeIntervalMicroSeconds aFromFirst, |
|
344 const TInt64 aDeltaMax64); |
|
345 void HandleMassUpdateResetCounters(); |
|
346 void HandleMassUpdateDone(); |
|
347 static TInt HandleMassUpdateTimerCallBack(TAny* aAny); |
|
348 |
|
349 private: |
|
350 CEikListBox& iListBox; |
|
351 TBool iHandleMassUpdateDetected; |
|
352 TTime iHandleMassUpdateFirst; |
|
353 TTime iHandleMassUpdatePrev; |
|
354 TInt iHandleMassUpdateCount; |
|
355 TBool iHandleMassUpdateSkipDialog; |
|
356 CPeriodic* iHandleMassUpdateTimer; |
|
357 CAknWaitDialog* iHandleMassUpdateDialog; |
|
358 }; |
|
359 |
|
360 // -------------------------------------------------------------------------- |
|
361 // CPbk2UiControlEventSender::CPbk2UiControlEventSender |
|
362 // -------------------------------------------------------------------------- |
|
363 // |
|
364 CPbk2UiControlEventSender::CPbk2UiControlEventSender |
|
365 ( CPbk2NamesListControl& aControl, |
|
366 RPointerArray<MPbk2ControlObserver>& aObservers ) : |
|
367 iControl( aControl ), |
|
368 iObservers( aObservers ) |
|
369 { |
|
370 } |
|
371 |
|
372 // -------------------------------------------------------------------------- |
|
373 // CPbk2UiControlEventSender::NewL |
|
374 // -------------------------------------------------------------------------- |
|
375 // |
|
376 CPbk2UiControlEventSender* CPbk2UiControlEventSender::NewL( |
|
377 CPbk2NamesListControl& aControl, |
|
378 RPointerArray<MPbk2ControlObserver>& aObservers ) |
|
379 { |
|
380 CPbk2UiControlEventSender* self = |
|
381 new ( ELeave ) CPbk2UiControlEventSender( aControl, aObservers ); |
|
382 return self; |
|
383 } |
|
384 |
|
385 // -------------------------------------------------------------------------- |
|
386 // CPbk2UiControlEventSender::~CPbk2UiControlEventSender |
|
387 // -------------------------------------------------------------------------- |
|
388 // |
|
389 CPbk2UiControlEventSender::~CPbk2UiControlEventSender() |
|
390 { |
|
391 } |
|
392 |
|
393 // -------------------------------------------------------------------------- |
|
394 // CPbk2UiControlEventSender::SendEventToObserversL |
|
395 // Sends control observer events in reverse order to disable the possibility |
|
396 // of crash if aObserver is changed during the loop. |
|
397 // -------------------------------------------------------------------------- |
|
398 // |
|
399 TBool CPbk2UiControlEventSender::SendEventToObserversL( |
|
400 const TPbk2ControlEvent& aEvent ) |
|
401 { |
|
402 // Loop backwards in case some observer destroys itself in the |
|
403 // event handler |
|
404 TBool okToSendEvent( SendEvent( aEvent ) ); |
|
405 for ( TInt i = iObservers.Count() - 1; i >= 0 && okToSendEvent; --i ) |
|
406 { |
|
407 iObservers[i]->HandleControlEventL( iControl, aEvent ); |
|
408 } |
|
409 |
|
410 return okToSendEvent; |
|
411 } |
|
412 |
|
413 // -------------------------------------------------------------------------- |
|
414 // CPbk2UiControlEventSender::Reset |
|
415 // Resets event sender |
|
416 // -------------------------------------------------------------------------- |
|
417 // |
|
418 void CPbk2UiControlEventSender::Reset() |
|
419 { |
|
420 iReadyEventSend = EFalse; |
|
421 } |
|
422 |
|
423 // -------------------------------------------------------------------------- |
|
424 // CPbk2UiControlEventSender::SendEvent |
|
425 // Makes sure that ready event is send only ones and reset the status |
|
426 // if control goes unavailable |
|
427 // -------------------------------------------------------------------------- |
|
428 // |
|
429 TBool CPbk2UiControlEventSender::SendEvent |
|
430 ( const TPbk2ControlEvent& aEvent ) |
|
431 { |
|
432 TBool ret( ETrue ); |
|
433 if ( aEvent.iEventType == TPbk2ControlEvent::EUnavailable ) |
|
434 { |
|
435 iReadyEventSend = EFalse; |
|
436 } |
|
437 else if ( aEvent.iEventType == TPbk2ControlEvent::EReady ) |
|
438 { |
|
439 if ( iReadyEventSend ) |
|
440 { |
|
441 ret = EFalse; |
|
442 } |
|
443 else |
|
444 { |
|
445 iReadyEventSend = ETrue; |
|
446 } |
|
447 } |
|
448 return ret; |
|
449 } |
|
450 |
|
451 // -------------------------------------------------------------------------- |
|
452 // CPbk2FilteredViewStackObserver::CPbk2FilteredViewStackObserver |
|
453 // -------------------------------------------------------------------------- |
|
454 // |
|
455 CPbk2FilteredViewStackObserver::CPbk2FilteredViewStackObserver( |
|
456 CPbk2NamesListControl& aControl, |
|
457 TopViewChangedFuncPtr aTopViewChangedFuncPtr, |
|
458 TopViewUpdatedFuncPtr aTopViewUpdatedFuncPtr, |
|
459 BaseViewChangedFuncPtr aBaseViewChangedFuncPtr, |
|
460 ViewStackErrorFuncPtr aViewStackErrorFuncPtr, |
|
461 ContactAddedToBaseViewFuncPtr aContactAddedToBaseViewFuncPtr ) : |
|
462 iControl( aControl ), |
|
463 iTopViewChangedFuncPtr( aTopViewChangedFuncPtr ), |
|
464 iTopViewUpdatedFuncPtr( aTopViewUpdatedFuncPtr ), |
|
465 iBaseViewChangedFuncPtr( aBaseViewChangedFuncPtr ), |
|
466 iViewStackErrorFuncPtr( aViewStackErrorFuncPtr ), |
|
467 iContactAddedToBaseViewFuncPtr( aContactAddedToBaseViewFuncPtr ) |
|
468 { |
|
469 } |
|
470 |
|
471 // -------------------------------------------------------------------------- |
|
472 // CPbk2FilteredViewStackObserver::NewL |
|
473 // -------------------------------------------------------------------------- |
|
474 // |
|
475 CPbk2FilteredViewStackObserver* CPbk2FilteredViewStackObserver::NewL( |
|
476 CPbk2NamesListControl& aControl, |
|
477 TopViewChangedFuncPtr aTopViewChangedFuncPtr, |
|
478 TopViewUpdatedFuncPtr aTopViewUpdatedFuncPtr, |
|
479 BaseViewChangedFuncPtr aBaseViewChangedFuncPtr, |
|
480 ViewStackErrorFuncPtr aViewStackErrorFuncPtr, |
|
481 ContactAddedToBaseViewFuncPtr aContactAddedToBaseViewFuncPtr ) |
|
482 { |
|
483 CPbk2FilteredViewStackObserver* self = |
|
484 new ( ELeave ) CPbk2FilteredViewStackObserver( aControl, |
|
485 aTopViewChangedFuncPtr, |
|
486 aTopViewUpdatedFuncPtr, |
|
487 aBaseViewChangedFuncPtr, |
|
488 aViewStackErrorFuncPtr, |
|
489 aContactAddedToBaseViewFuncPtr ); |
|
490 CleanupStack::PushL( self ); |
|
491 self->ConstructL(); |
|
492 CleanupStack::Pop( self ); |
|
493 return self; |
|
494 } |
|
495 |
|
496 // -------------------------------------------------------------------------- |
|
497 // CPbk2FilteredViewStackObserver::ConstructL |
|
498 // -------------------------------------------------------------------------- |
|
499 // |
|
500 void CPbk2FilteredViewStackObserver::ConstructL() |
|
501 { |
|
502 } |
|
503 |
|
504 // -------------------------------------------------------------------------- |
|
505 // CPbk2FilteredViewStackObserver::~CPbk2FilteredViewStackObserver |
|
506 // -------------------------------------------------------------------------- |
|
507 // |
|
508 CPbk2FilteredViewStackObserver::~CPbk2FilteredViewStackObserver() |
|
509 { |
|
510 } |
|
511 |
|
512 // -------------------------------------------------------------------------- |
|
513 // CPbk2FilteredViewStackObserver::TopViewChangedL |
|
514 // -------------------------------------------------------------------------- |
|
515 // |
|
516 void CPbk2FilteredViewStackObserver::TopViewChangedL( |
|
517 MVPbkContactViewBase& aOldView ) |
|
518 { |
|
519 ( iControl.*iTopViewChangedFuncPtr )( aOldView ); |
|
520 } |
|
521 |
|
522 // -------------------------------------------------------------------------- |
|
523 // CPbk2FilteredViewStackObserver::TopViewUpdatedL |
|
524 // -------------------------------------------------------------------------- |
|
525 // |
|
526 void CPbk2FilteredViewStackObserver::TopViewUpdatedL() |
|
527 { |
|
528 ( iControl.*iTopViewUpdatedFuncPtr )(); |
|
529 } |
|
530 |
|
531 // -------------------------------------------------------------------------- |
|
532 // CPbk2FilteredViewStackObserver::BaseViewChangedL |
|
533 // -------------------------------------------------------------------------- |
|
534 // |
|
535 void CPbk2FilteredViewStackObserver::BaseViewChangedL() |
|
536 { |
|
537 ( iControl.*iBaseViewChangedFuncPtr )(); |
|
538 } |
|
539 |
|
540 // -------------------------------------------------------------------------- |
|
541 // CPbk2FilteredViewStackObserver::ViewStackError |
|
542 // -------------------------------------------------------------------------- |
|
543 // |
|
544 void CPbk2FilteredViewStackObserver::ViewStackError( TInt aError ) |
|
545 { |
|
546 ( iControl.*iViewStackErrorFuncPtr )( aError ); |
|
547 } |
|
548 |
|
549 // -------------------------------------------------------------------------- |
|
550 // CPbk2FilteredViewStackObserver::ContactAddedToBaseView |
|
551 // -------------------------------------------------------------------------- |
|
552 // |
|
553 void CPbk2FilteredViewStackObserver::ContactAddedToBaseView( |
|
554 MVPbkContactViewBase& aBaseView, TInt aIndex, |
|
555 const MVPbkContactLink& aContactLink ) |
|
556 { |
|
557 ( iControl.*iContactAddedToBaseViewFuncPtr )( aBaseView, |
|
558 aIndex, aContactLink ); |
|
559 } |
|
560 |
|
561 // -------------------------------------------------------------------------- |
|
562 // CPbk2ListBoxSelectionObserver::CPbk2ListBoxSelectionObserver |
|
563 // -------------------------------------------------------------------------- |
|
564 // |
|
565 CPbk2ListBoxSelectionObserver::CPbk2ListBoxSelectionObserver( |
|
566 CPbk2NamesListControl& aControl, CEikListBox& aListBox, |
|
567 MPbk2UiControlEventSender& aEventSender ) |
|
568 : iControl( aControl ), |
|
569 iListBox( aListBox ), |
|
570 iEventSender( aEventSender ) |
|
571 { |
|
572 } |
|
573 |
|
574 // -------------------------------------------------------------------------- |
|
575 // CPbk2ListBoxSelectionObserver::ConstructL |
|
576 // -------------------------------------------------------------------------- |
|
577 // |
|
578 void CPbk2ListBoxSelectionObserver::ConstructL() |
|
579 { |
|
580 iListBox.AddSelectionObserverL( this ); |
|
581 } |
|
582 |
|
583 // -------------------------------------------------------------------------- |
|
584 // CPbk2ListBoxSelectionObserver::NewL |
|
585 // -------------------------------------------------------------------------- |
|
586 // |
|
587 CPbk2ListBoxSelectionObserver* CPbk2ListBoxSelectionObserver::NewL( |
|
588 CPbk2NamesListControl& aControl, |
|
589 CEikListBox& aListBox, |
|
590 MPbk2UiControlEventSender& aEventSender ) |
|
591 { |
|
592 CPbk2ListBoxSelectionObserver* self = |
|
593 new( ELeave ) CPbk2ListBoxSelectionObserver( aControl, aListBox, |
|
594 aEventSender ); |
|
595 CleanupStack::PushL( self ); |
|
596 self->ConstructL(); |
|
597 CleanupStack::Pop( self ); |
|
598 return self; |
|
599 } |
|
600 |
|
601 // -------------------------------------------------------------------------- |
|
602 // CPbk2ListBoxSelectionObserver::~CPbk2ListBoxSelectionObserver |
|
603 // -------------------------------------------------------------------------- |
|
604 // |
|
605 CPbk2ListBoxSelectionObserver::~CPbk2ListBoxSelectionObserver() |
|
606 { |
|
607 iListBox.RemoveSelectionObserver( this ); |
|
608 } |
|
609 |
|
610 // -------------------------------------------------------------------------- |
|
611 // CPbk2ListBoxSelectionObserver::SelectionModeChanged |
|
612 // -------------------------------------------------------------------------- |
|
613 // |
|
614 void CPbk2ListBoxSelectionObserver::SelectionModeChanged( |
|
615 CEikListBox* aListBox, TBool aSelectionModeEnabled ) |
|
616 { |
|
617 if ( &iListBox == aListBox ) |
|
618 { |
|
619 TPbk2ControlEvent event( |
|
620 TPbk2ControlEvent::EControlEntersSelectionMode ); |
|
621 if ( !aSelectionModeEnabled ) |
|
622 { |
|
623 event.iEventType = |
|
624 TPbk2ControlEvent::EControlLeavesSelectionMode; |
|
625 } |
|
626 TRAPD( res, iEventSender.SendEventToObserversL( event ) ); |
|
627 HandleError( res ); |
|
628 if ( res != KErrNone ) |
|
629 { |
|
630 iControl.Reset(); |
|
631 } |
|
632 } |
|
633 } |
|
634 |
|
635 // -------------------------------------------------------------------------- |
|
636 // CPbk2HandleMassUpdate::NewL |
|
637 // -------------------------------------------------------------------------- |
|
638 // |
|
639 CPbk2HandleMassUpdate* CPbk2HandleMassUpdate::NewL(CEikListBox& aListBox) |
|
640 { |
|
641 CPbk2HandleMassUpdate* self = |
|
642 new( ELeave ) CPbk2HandleMassUpdate(aListBox); |
|
643 CleanupStack::PushL( self ); |
|
644 self->ConstructL(); |
|
645 CleanupStack::Pop( self ); |
|
646 return self; |
|
647 } |
|
648 |
|
649 // -------------------------------------------------------------------------- |
|
650 // CPbk2HandleMassUpdate::~CPbk2HandleMassUpdate |
|
651 // -------------------------------------------------------------------------- |
|
652 // |
|
653 CPbk2HandleMassUpdate::~CPbk2HandleMassUpdate() |
|
654 { |
|
655 delete iHandleMassUpdateDialog; |
|
656 delete iHandleMassUpdateTimer; |
|
657 } |
|
658 |
|
659 // -------------------------------------------------------------------------- |
|
660 // CPbk2HandleMassUpdate::CPbk2HandleMassUpdate |
|
661 // -------------------------------------------------------------------------- |
|
662 // |
|
663 CPbk2HandleMassUpdate::CPbk2HandleMassUpdate(CEikListBox& aListBox) : |
|
664 iListBox(aListBox) |
|
665 { |
|
666 } |
|
667 |
|
668 // -------------------------------------------------------------------------- |
|
669 // CPbk2HandleMassUpdate::ConstructL |
|
670 // -------------------------------------------------------------------------- |
|
671 // |
|
672 void CPbk2HandleMassUpdate::ConstructL() |
|
673 { |
|
674 iHandleMassUpdateTimer = CPeriodic::NewL( CActive::EPriorityIdle ); |
|
675 } |
|
676 |
|
677 // -------------------------------------------------------------------------- |
|
678 // CPbk2HandleMassUpdate::HandleMassUpdateCheckThis |
|
679 // |
|
680 // Functionality to detect mass updates done to contact database and to prevent |
|
681 // e.g nameslist flickering when constant updates are happening in background |
|
682 // when pc sync etc is adding hundreds of contacts in line |
|
683 // -------------------------------------------------------------------------- |
|
684 // |
|
685 TBool CPbk2HandleMassUpdate::MassUpdateCheckThis() |
|
686 { |
|
687 TBool ret(EFalse); |
|
688 const TInt KNbrUpdBeforeMassCheck(5); |
|
689 iHandleMassUpdateTimer->Cancel(); |
|
690 |
|
691 if( iHandleMassUpdateCount > KNbrUpdBeforeMassCheck ) |
|
692 { |
|
693 //candidates to be checked are they continual of a mass update |
|
694 TRAP_IGNORE(ret = HandleMassUpdateCheckL()); |
|
695 } |
|
696 else if( iHandleMassUpdateCount > 0 ) |
|
697 { |
|
698 //Subsequent updates that are handled normally even if |
|
699 // they would be first ones in a mass update burst |
|
700 iHandleMassUpdateCount++; |
|
701 iHandleMassUpdatePrev.UniversalTime(); |
|
702 } |
|
703 else |
|
704 { |
|
705 //very first update, reset time & counter |
|
706 HandleMassUpdateResetCounters(); |
|
707 } |
|
708 return ret; |
|
709 } |
|
710 |
|
711 // -------------------------------------------------------------------------- |
|
712 // CPbk2HandleMassUpdate::MassUpdateDetected |
|
713 // -------------------------------------------------------------------------- |
|
714 // |
|
715 TBool CPbk2HandleMassUpdate::MassUpdateDetected() |
|
716 { |
|
717 return iHandleMassUpdateDetected; |
|
718 } |
|
719 |
|
720 // -------------------------------------------------------------------------- |
|
721 // CPbk2HandleMassUpdate::MassUpdateSkipProgressNote |
|
722 // -------------------------------------------------------------------------- |
|
723 // |
|
724 void CPbk2HandleMassUpdate::MassUpdateSkipProgressNote( TBool aSkip ) |
|
725 { |
|
726 iHandleMassUpdateSkipDialog = aSkip; |
|
727 HandleMassUpdateResetCounters(); |
|
728 } |
|
729 |
|
730 // -------------------------------------------------------------------------- |
|
731 // CPbk2HandleMassUpdate::HandleMassUpdateCheckL |
|
732 // -------------------------------------------------------------------------- |
|
733 // |
|
734 TBool CPbk2HandleMassUpdate::HandleMassUpdateCheckL() |
|
735 { |
|
736 //KDeltaAverage time per update to be considered as mass |
|
737 //update. One occasional update can take KDeltaMax time as long as |
|
738 //average time not exeeded (therefore timeout for the very first updates in |
|
739 //practice is also KDeltaAverage). |
|
740 const TInt64 KDeltaAverage(2000000); |
|
741 const TInt64 KDeltaMax(KDeltaAverage * 2); |
|
742 const TTimeIntervalMicroSeconds KMaxPrev(KDeltaMax); |
|
743 TBool ret(EFalse); |
|
744 |
|
745 TTime now; |
|
746 now.UniversalTime(); |
|
747 TTimeIntervalMicroSeconds fromFirst = |
|
748 now.MicroSecondsFrom(iHandleMassUpdateFirst); |
|
749 TTimeIntervalMicroSeconds fromPrev = |
|
750 now.MicroSecondsFrom(iHandleMassUpdatePrev); |
|
751 TTimeIntervalMicroSeconds maxCumu(KDeltaAverage * iHandleMassUpdateCount); |
|
752 |
|
753 if( fromFirst < maxCumu && fromPrev < KMaxPrev ) |
|
754 { |
|
755 //mass update burst ongoing |
|
756 HandleMassUpdateBurstL(fromFirst, KDeltaMax); |
|
757 ret = ETrue; |
|
758 } |
|
759 else if(iHandleMassUpdateDetected) |
|
760 { |
|
761 //mass update burst ended |
|
762 HandleMassUpdateDone(); |
|
763 ret = ETrue; |
|
764 } |
|
765 else |
|
766 { |
|
767 //just normal update so reset counters |
|
768 HandleMassUpdateResetCounters(); |
|
769 } |
|
770 return ret; |
|
771 } |
|
772 |
|
773 // -------------------------------------------------------------------------- |
|
774 // CPbk2HandleMassUpdate::HandleMassUpdateBurstL |
|
775 // -------------------------------------------------------------------------- |
|
776 // |
|
777 void CPbk2HandleMassUpdate::HandleMassUpdateBurstL( |
|
778 const TTimeIntervalMicroSeconds aFromFirst, |
|
779 const TInt64 aDeltaMax64) |
|
780 { |
|
781 const TInt64 KMinWaitBeforeBlockUi(1500000); |
|
782 const TTimeIntervalMicroSeconds KWait(KMinWaitBeforeBlockUi); |
|
783 |
|
784 //mass update burst ongoing, nameslist behaviour can be altered |
|
785 iHandleMassUpdateDetected=ETrue; |
|
786 iHandleMassUpdateCount++; |
|
787 iHandleMassUpdatePrev.UniversalTime(); |
|
788 iListBox.UpdateScrollBarsL(); |
|
789 |
|
790 if( !iHandleMassUpdateDialog && |
|
791 !iHandleMassUpdateSkipDialog && |
|
792 aFromFirst > KWait) |
|
793 { |
|
794 //mass update burst ongoing, ok also to block ui |
|
795 iHandleMassUpdateDialog = new(ELeave) CAknWaitDialog |
|
796 (reinterpret_cast<CEikDialog**>(&iHandleMassUpdateDialog), EFalse); |
|
797 iHandleMassUpdateDialog->SetTone(CAknNoteDialog::ENoTone); |
|
798 iHandleMassUpdateDialog->ExecuteLD(R_QTN_GEN_NOTE_SYNCHRONIZING_PROGRESS); |
|
799 //ExecuteLD above handles validity of pointer iHandleMassUpdateDialog plus |
|
800 //cleanupstack |
|
801 } |
|
802 else if( iHandleMassUpdateDialog && iHandleMassUpdateSkipDialog) |
|
803 { |
|
804 //burst ongoing but do not not block ui |
|
805 TRAP_IGNORE(iHandleMassUpdateDialog->ProcessFinishedL()); |
|
806 delete iHandleMassUpdateDialog; |
|
807 iHandleMassUpdateDialog = NULL; |
|
808 } |
|
809 |
|
810 TCallBack callback(HandleMassUpdateTimerCallBack, this); |
|
811 TTimeIntervalMicroSeconds32 delta32(aDeltaMax64); |
|
812 iHandleMassUpdateTimer->Start( delta32, delta32, callback ); |
|
813 } |
|
814 |
|
815 // ---------------------------------------------------------------------------- |
|
816 // CPbk2HandleMassUpdate::HandleMassUpdateResetCounters |
|
817 // ---------------------------------------------------------------------------- |
|
818 // |
|
819 void CPbk2HandleMassUpdate::HandleMassUpdateResetCounters() |
|
820 { |
|
821 iHandleMassUpdateCount = 1; //set as first candidate for next burst |
|
822 iHandleMassUpdateFirst.UniversalTime(); |
|
823 iHandleMassUpdatePrev=iHandleMassUpdateFirst; |
|
824 } |
|
825 |
|
826 // ---------------------------------------------------------------------------- |
|
827 // CPbk2HandleMassUpdate::HandleMassUpdateTimerCallBack |
|
828 // ---------------------------------------------------------------------------- |
|
829 // |
|
830 TInt CPbk2HandleMassUpdate::HandleMassUpdateTimerCallBack(TAny* aAny) |
|
831 { |
|
832 CPbk2HandleMassUpdate* self = static_cast<CPbk2HandleMassUpdate*>( aAny ); |
|
833 self->iHandleMassUpdateTimer->Cancel(); |
|
834 self->HandleMassUpdateDone(); |
|
835 return KErrNone; |
|
836 } |
|
837 |
|
838 // ---------------------------------------------------------------------------- |
|
839 // CPbk2HandleMassUpdate::HandleMassUpdateDone |
|
840 // ---------------------------------------------------------------------------- |
|
841 // |
|
842 void CPbk2HandleMassUpdate::HandleMassUpdateDone() |
|
843 { |
|
844 if( iHandleMassUpdateDialog ) |
|
845 { |
|
846 TRAP_IGNORE(iHandleMassUpdateDialog->ProcessFinishedL()); |
|
847 //The below 2 lines just in case... ProcessFinishedL already took care of these |
|
848 delete iHandleMassUpdateDialog; |
|
849 iHandleMassUpdateDialog = NULL; |
|
850 } |
|
851 |
|
852 iHandleMassUpdateDetected = EFalse; |
|
853 HandleMassUpdateResetCounters(); |
|
854 iListBox.SetCurrentItemIndex(0); |
|
855 iListBox.SetTopItemIndex(0); |
|
856 |
|
857 //Update the items of listbox in NameListView |
|
858 iListBox.DrawDeferred(); |
|
859 } |
|
860 |
|
861 ///////////////////////// End of helper classes ///////////////////////////// |
|
862 |
|
863 |
|
864 // -------------------------------------------------------------------------- |
|
865 // CPbk2NamesListControl::CPbk2NamesListControl |
|
866 // -------------------------------------------------------------------------- |
|
867 // |
|
868 EXPORT_C CPbk2NamesListControl::CPbk2NamesListControl |
|
869 (const CCoeControl* aContainer, |
|
870 CVPbkContactManager& aManager, |
|
871 MVPbkContactViewBase& aView, |
|
872 MPbk2ContactNameFormatter& aNameFormatter, |
|
873 CPbk2StorePropertyArray& aStoreProperties) : |
|
874 iContactManager( aManager ), |
|
875 iBaseView( &aView ), |
|
876 iContainer( aContainer ), |
|
877 iNameFormatter( aNameFormatter ), |
|
878 iStoreProperties( aStoreProperties ), |
|
879 iAllowPointerEvents( ETrue ), |
|
880 iOpeningCca( EFalse ), |
|
881 iMarkingModeOn( EFalse ) |
|
882 { |
|
883 } |
|
884 |
|
885 // -------------------------------------------------------------------------- |
|
886 // CPbk2NamesListControl::CPbk2NamesListControl |
|
887 // -------------------------------------------------------------------------- |
|
888 // |
|
889 CPbk2NamesListControl::CPbk2NamesListControl |
|
890 (const CCoeControl* aContainer, |
|
891 CVPbkContactManager& aManager, |
|
892 MVPbkContactViewBase& aView, |
|
893 MPbk2ContactNameFormatter& aNameFormatter, |
|
894 CPbk2StorePropertyArray& aStoreProperties, |
|
895 CPbk2ThumbnailManager* aThumbManager) : |
|
896 iContactManager( aManager ), |
|
897 iBaseView( &aView ), |
|
898 iContainer( aContainer ), |
|
899 iNameFormatter( aNameFormatter ), |
|
900 iStoreProperties( aStoreProperties ), |
|
901 iAllowPointerEvents( ETrue ), |
|
902 iThumbManager( aThumbManager ), |
|
903 iOpeningCca( EFalse ) |
|
904 { |
|
905 } |
|
906 |
|
907 // -------------------------------------------------------------------------- |
|
908 // CPbk2NamesListControl::~CPbk2NamesListControl |
|
909 // -------------------------------------------------------------------------- |
|
910 // |
|
911 CPbk2NamesListControl::~CPbk2NamesListControl() |
|
912 { |
|
913 ClearMarkedContactsInfo(); |
|
914 |
|
915 if (iBgTask) |
|
916 { |
|
917 delete iBgTask; |
|
918 iBgTask = NULL; |
|
919 } |
|
920 |
|
921 if ( iViewStack && iStackObserver ) |
|
922 { |
|
923 iViewStack->RemoveStackObserver( *iStackObserver ); |
|
924 } |
|
925 |
|
926 if( iThumbManager ) |
|
927 { |
|
928 TRAP_IGNORE( iThumbManager->SetContactViewL( NULL ) ); |
|
929 iThumbManager->RemoveObserver(); |
|
930 } |
|
931 |
|
932 if (iCommand) |
|
933 { |
|
934 // inform the command that the control is deleted |
|
935 iCommand->ResetUiControl(*this); |
|
936 } |
|
937 iObservers.Reset(); |
|
938 iCommandItems.ResetAndDestroy(); |
|
939 delete iCheckMassUpdate; |
|
940 delete iListBoxSelectionObserver; |
|
941 delete iStateFactory; |
|
942 delete iListBox; |
|
943 delete iFindBox; |
|
944 delete iThumbnailLoader; |
|
945 delete iEventSender; |
|
946 delete iStackObserver; |
|
947 delete iUiExtension; |
|
948 delete iViewStack; |
|
949 delete iSearchFilter; |
|
950 if( iOwnThumbManager ) |
|
951 { |
|
952 delete iThumbManager; |
|
953 } |
|
954 if (iOwnBaseView) |
|
955 { |
|
956 delete iBaseView; |
|
957 } |
|
958 if(iFeatureManagerInitilized) |
|
959 { |
|
960 FeatureManager::UnInitializeLib(); |
|
961 } |
|
962 } |
|
963 |
|
964 // -------------------------------------------------------------------------- |
|
965 // CPbk2NamesListControl::NewL |
|
966 // -------------------------------------------------------------------------- |
|
967 // |
|
968 EXPORT_C CPbk2NamesListControl* CPbk2NamesListControl::NewL( |
|
969 TInt aResourceId, |
|
970 const CCoeControl* aContainer, |
|
971 CVPbkContactManager& aManager, |
|
972 MVPbkContactViewBase& aView, |
|
973 MPbk2ContactNameFormatter& aNameFormatter, |
|
974 CPbk2StorePropertyArray& aStoreProperties ) |
|
975 { |
|
976 CPbk2NamesListControl* self = new (ELeave) CPbk2NamesListControl( |
|
977 aContainer, aManager, aView, aNameFormatter, aStoreProperties ); |
|
978 CleanupStack::PushL(self); |
|
979 self->ConstructL( aResourceId); |
|
980 CleanupStack::Pop(self); |
|
981 return self; |
|
982 } |
|
983 |
|
984 |
|
985 // -------------------------------------------------------------------------- |
|
986 // CPbk2NamesListControl::NewL |
|
987 // -------------------------------------------------------------------------- |
|
988 // |
|
989 EXPORT_C CPbk2NamesListControl* CPbk2NamesListControl::NewL( |
|
990 TInt aResourceId, |
|
991 const CCoeControl* aContainer, |
|
992 CVPbkContactManager& aManager, |
|
993 MVPbkContactViewBase& aView, |
|
994 MPbk2ContactNameFormatter& aNameFormatter, |
|
995 CPbk2StorePropertyArray& aStoreProperties, |
|
996 CPbk2ThumbnailManager* aThumbManager ) |
|
997 { |
|
998 CPbk2NamesListControl* self = new (ELeave) CPbk2NamesListControl( |
|
999 aContainer, aManager, aView, aNameFormatter, aStoreProperties, aThumbManager ); |
|
1000 CleanupStack::PushL(self); |
|
1001 self->ConstructL( aResourceId); |
|
1002 CleanupStack::Pop(self); |
|
1003 return self; |
|
1004 } |
|
1005 |
|
1006 // -------------------------------------------------------------------------- |
|
1007 // CPbk2NamesListControl::ConstructL |
|
1008 // |
|
1009 // Note that NewL (and hence ConstructL) will not be called when custom control |
|
1010 // constructed. Instead public constructor and ConstructFromResourceL are |
|
1011 // called (happens when ServerApp launches custom fetch dialog) |
|
1012 // -------------------------------------------------------------------------- |
|
1013 // |
|
1014 inline void CPbk2NamesListControl::ConstructL( |
|
1015 TInt aResourceId) |
|
1016 { |
|
1017 if (!iContainer) |
|
1018 { |
|
1019 User::Leave(KErrGeneral); |
|
1020 } |
|
1021 |
|
1022 // First set container |
|
1023 SetContainerWindowL(*iContainer); |
|
1024 |
|
1025 TResourceReader resReader; |
|
1026 CCoeEnv::Static()->CreateResourceReaderLC(resReader, aResourceId); |
|
1027 ConstructFromResourceL(resReader); |
|
1028 CleanupStack::PopAndDestroy(); // resReader |
|
1029 FeatureManager::InitializeLibL(); |
|
1030 iFeatureManagerInitilized = ETrue; |
|
1031 } |
|
1032 |
|
1033 // -------------------------------------------------------------------------- |
|
1034 // CPbk2NamesListControl::ConstructFromResourceL |
|
1035 // -------------------------------------------------------------------------- |
|
1036 // |
|
1037 inline void CPbk2NamesListControl::ConstructFromResourceL |
|
1038 ( TResourceReader& aReader ) |
|
1039 { |
|
1040 iSearchFilter = CPbk2PredictiveSearchFilter::NewL(); |
|
1041 |
|
1042 if(FeatureManager::FeatureSupported(KFeatureIdFfContactsPredictiveSearch)) |
|
1043 |
|
1044 { |
|
1045 iViewStack = CPbk2PredictiveViewStack::NewL( *iBaseView, *iSearchFilter, |
|
1046 iNameFormatter ); |
|
1047 } |
|
1048 else |
|
1049 { |
|
1050 iViewStack = CPbk2FilteredViewStack::NewL( *iBaseView ); |
|
1051 } |
|
1052 |
|
1053 iViewStack->AddObserverL( *this ); |
|
1054 |
|
1055 iStackObserver = CPbk2FilteredViewStackObserver::NewL |
|
1056 ( *this, |
|
1057 &CPbk2NamesListControl::HandleTopViewChangedL, |
|
1058 &CPbk2NamesListControl::HandleTopViewUpdatedL, |
|
1059 &CPbk2NamesListControl::HandleBaseViewChangedL, |
|
1060 &CPbk2NamesListControl::HandleViewStackError, |
|
1061 &CPbk2NamesListControl::HandleContactAddedToBaseView ); |
|
1062 iEventSender = CPbk2UiControlEventSender::NewL( *this, iObservers ); |
|
1063 iViewStack->AddStackObserverL( *iStackObserver ); |
|
1064 |
|
1065 |
|
1066 CPbk2UIExtensionManager* extManager = |
|
1067 CPbk2UIExtensionManager::InstanceL(); |
|
1068 extManager->PushL(); |
|
1069 |
|
1070 iUiExtension = extManager->FactoryL()->CreatePbk2UiControlExtensionL |
|
1071 ( iContactManager ); |
|
1072 |
|
1073 CleanupStack::PopAndDestroy(); // extManager |
|
1074 |
|
1075 // peek listbox type from resource |
|
1076 TInt flags = aReader.ReadInt32(); |
|
1077 aReader.Rewind( sizeof( TInt32 ) ); |
|
1078 |
|
1079 // Create the listbox and its model |
|
1080 if( flags & KPbk2ContactViewListControlDoubleRow ) |
|
1081 { |
|
1082 if( !iThumbManager ) |
|
1083 { |
|
1084 iThumbManager = CPbk2ThumbnailManager::NewL( iContactManager ); |
|
1085 iOwnThumbManager = ETrue; |
|
1086 } |
|
1087 |
|
1088 iDoubleListBox = CPbk2ContactViewDoubleListBox::NewL |
|
1089 ( *this, aReader, iContactManager, |
|
1090 *iViewStack, iNameFormatter, iStoreProperties, |
|
1091 iUiExtension, *iSearchFilter, *iThumbManager ); |
|
1092 |
|
1093 iThumbManager->SetObserver( *iDoubleListBox ); |
|
1094 iThumbManager->SetContactViewL( iViewStack ); |
|
1095 |
|
1096 iListBox = iDoubleListBox; |
|
1097 } |
|
1098 else |
|
1099 { |
|
1100 iListBox = CPbk2ContactViewListBox::NewL |
|
1101 ( *this, aReader, iContactManager, |
|
1102 *iViewStack, iNameFormatter, iStoreProperties, |
|
1103 iUiExtension, *iSearchFilter ); |
|
1104 |
|
1105 if( iThumbManager ) |
|
1106 { |
|
1107 iThumbManager->RemoveObserver(); |
|
1108 } |
|
1109 iDoubleListBox = NULL; |
|
1110 } |
|
1111 |
|
1112 iListBox->SetObserver( this ); |
|
1113 iListBox->SetScrollEventObserver( this ); |
|
1114 iListBox->SetListBoxObserver(this); |
|
1115 |
|
1116 iListBox->SetMarkingModeObserver( this ); |
|
1117 |
|
1118 iUiExtension->SetContactUiControlUpdate( this ); |
|
1119 // set command item updater |
|
1120 TAny* ext = iUiExtension->ContactUiControlExtensionExtension( |
|
1121 TUid::Uid( KPbk2ContactUiControlExtensionExtensionUID ) ); |
|
1122 if( ext ) |
|
1123 { |
|
1124 static_cast<MPbk2ContactUiControlDoubleListboxExtension*>(ext)-> |
|
1125 SetCommandItemUpdater( this ); |
|
1126 } |
|
1127 |
|
1128 if ( iListBox->Flags() & KPbk2ContactViewListControlFindBox ) |
|
1129 { |
|
1130 // Create a find box |
|
1131 if ( iSearchFilter->IsPredictiveActivated() ) |
|
1132 { |
|
1133 iFindBox = CAknSearchField::NewL |
|
1134 (*this, CAknSearchField::ESearch, NULL, KSearchFieldLength); |
|
1135 } |
|
1136 else |
|
1137 { |
|
1138 iFindBox = CAknSearchField::NewL |
|
1139 (*this, CAknSearchField::EAdaptiveSearch, NULL, KSearchFieldLength); |
|
1140 } |
|
1141 |
|
1142 iSearchFilter->SetAknSearchFieldL( iFindBox ); |
|
1143 |
|
1144 iFindBox->MakeVisible( EFalse ); |
|
1145 iFindBox->SetObserver( this ); |
|
1146 iFindBox->AddAdaptiveSearchTextObserverL( this ); |
|
1147 } |
|
1148 |
|
1149 // If list box supports selection then construct an observer that |
|
1150 // handles the event sending when the selection mode changes. |
|
1151 if ( iListBox->IsSelectionListBox() ) |
|
1152 { |
|
1153 iListBoxSelectionObserver = CPbk2ListBoxSelectionObserver::NewL( |
|
1154 *this, *iListBox, *iEventSender ); |
|
1155 } |
|
1156 |
|
1157 PBK2_DEBUG_PRINT(PBK2_DEBUG_STRING |
|
1158 ("CPbk2NamesListControl::ConstructL find box created")); |
|
1159 |
|
1160 // Instantiate the state factory |
|
1161 iStateFactory = CPbk2NamesListStateFactory::NewL( *this, *iListBox, |
|
1162 *iViewStack, iFindBox, *iThumbnailLoader, *iEventSender, |
|
1163 iNameFormatter, iCommandItems, *iSearchFilter ); |
|
1164 |
|
1165 // Create the initial state |
|
1166 iCurrentState = &iStateFactory->ActivateStartupStateL( iCurrentState ); |
|
1167 |
|
1168 iBgTask = new (ELeave) CPbk2NamesListControlBgTask( *this ); |
|
1169 iCheckMassUpdate = CPbk2HandleMassUpdate::NewL(*iListBox); //iListbox created above |
|
1170 |
|
1171 PBK2_DEBUG_PRINT(PBK2_DEBUG_STRING |
|
1172 ("CPbk2NamesListControl::ConstructFromResourceL end")); |
|
1173 } |
|
1174 |
|
1175 // -------------------------------------------------------------------------- |
|
1176 // CPbk2NamesListControl::AddObserverL |
|
1177 // -------------------------------------------------------------------------- |
|
1178 // |
|
1179 EXPORT_C void CPbk2NamesListControl::AddObserverL |
|
1180 ( MPbk2ControlObserver& aObserver ) |
|
1181 { |
|
1182 User::LeaveIfError(iObservers.Append(&aObserver)); |
|
1183 } |
|
1184 |
|
1185 // -------------------------------------------------------------------------- |
|
1186 // CPbk2NamesListControl::RemoveObserver |
|
1187 // -------------------------------------------------------------------------- |
|
1188 // |
|
1189 EXPORT_C void CPbk2NamesListControl::RemoveObserver |
|
1190 ( MPbk2ControlObserver& aObserver ) |
|
1191 { |
|
1192 const TInt index = iObservers.Find(&aObserver); |
|
1193 if (index >= 0) |
|
1194 { |
|
1195 iObservers.Remove(index); |
|
1196 } |
|
1197 } |
|
1198 |
|
1199 // -------------------------------------------------------------------------- |
|
1200 // CPbk2NamesListControl::Reset |
|
1201 // -------------------------------------------------------------------------- |
|
1202 // |
|
1203 EXPORT_C void CPbk2NamesListControl::Reset() |
|
1204 { |
|
1205 PBK2_DEBUG_PRINT(PBK2_DEBUG_STRING("CPbk2NamesListControl::Reset(0x%x) - IN"), |
|
1206 this ); |
|
1207 |
|
1208 // Reset find box |
|
1209 TRAP_IGNORE( ResetFindL() ); |
|
1210 // Destroy all the filtered views from the stack |
|
1211 iViewStack->Reset(); |
|
1212 // Refresh observer to get the view state |
|
1213 iViewStack->RemoveObserver( *this ); |
|
1214 // Shouldn't leave because the observer was first removed. |
|
1215 // The control updates its state when the asynchronous Virtual Phonebook |
|
1216 // view event arrives. |
|
1217 TRAP_IGNORE( iViewStack->AddObserverL( *this ) ); |
|
1218 |
|
1219 const TInt firstContactIndex = 0; |
|
1220 // Best effort: try to reset the focus. |
|
1221 TRAP_IGNORE( iCurrentState->SetFocusedContactIndexL( firstContactIndex ) ); |
|
1222 //scroll listbox into beginning (ignore focus that may be below promotion items) |
|
1223 iListBox->SetTopItemIndex(firstContactIndex); |
|
1224 |
|
1225 //cancel the marking mode |
|
1226 iListBox->SetMarkingMode( EFalse ); |
|
1227 |
|
1228 // Switch to the background state. This enables the next state to avtivate fully (ActivateStateL()) once phonebook |
|
1229 // comes from the background. |
|
1230 TRAP_IGNORE( iCurrentState = &iStateFactory->ActivateHiddenStateL( iCurrentState ); ); |
|
1231 |
|
1232 PBK2_DEBUG_PRINT(PBK2_DEBUG_STRING("CPbk2NamesListControl::Reset() - OUT")); |
|
1233 } |
|
1234 |
|
1235 // -------------------------------------------------------------------------- |
|
1236 // CPbk2NamesListControl::SetViewL |
|
1237 // -------------------------------------------------------------------------- |
|
1238 // |
|
1239 EXPORT_C void CPbk2NamesListControl::SetViewL( MVPbkContactViewBase& aView ) |
|
1240 { |
|
1241 // Control will receive a view event asynchronously from the stack |
|
1242 iViewStack->SetNewBaseViewL( aView ); |
|
1243 |
|
1244 if (iOwnBaseView) |
|
1245 { |
|
1246 delete iBaseView; |
|
1247 iBaseView = NULL; |
|
1248 } |
|
1249 |
|
1250 iBaseView = &aView; |
|
1251 iOwnBaseView = EFalse; |
|
1252 |
|
1253 iEventSender->Reset(); |
|
1254 } |
|
1255 |
|
1256 // -------------------------------------------------------------------------- |
|
1257 // CPbk2NamesListControl::GiveViewL |
|
1258 // -------------------------------------------------------------------------- |
|
1259 // |
|
1260 EXPORT_C void CPbk2NamesListControl::GiveViewL( MVPbkContactViewBase* aView ) |
|
1261 { |
|
1262 SetViewL( *aView ); |
|
1263 iOwnBaseView = ETrue; |
|
1264 } |
|
1265 |
|
1266 EXPORT_C void CPbk2NamesListControl::AllowPointerEvents( TBool aAllow ) |
|
1267 { |
|
1268 iAllowPointerEvents = aAllow; |
|
1269 } |
|
1270 |
|
1271 // -------------------------------------------------------------------------- |
|
1272 // CPbk2NamesListControl::SetCurrentGroupLinkL |
|
1273 // -------------------------------------------------------------------------- |
|
1274 // |
|
1275 EXPORT_C void CPbk2NamesListControl::SetCurrentGroupLinkL( MVPbkContactLink* aGroupLinktoSet) |
|
1276 { |
|
1277 // This is used only when predictive search is enabled |
|
1278 if(FeatureManager::FeatureSupported(KFeatureIdFfContactsPredictiveSearch)) |
|
1279 { |
|
1280 static_cast<CPbk2PredictiveViewStack*> (iViewStack)->SetCurrentGroupLinkL(aGroupLinktoSet); |
|
1281 } |
|
1282 return; |
|
1283 } |
|
1284 |
|
1285 // -------------------------------------------------------------------------- |
|
1286 // CPbk2NamesListControl::MassUpdateSkipProgressNote |
|
1287 // -------------------------------------------------------------------------- |
|
1288 // |
|
1289 EXPORT_C void CPbk2NamesListControl::MassUpdateSkipProgressNote( TBool aSkip ) |
|
1290 { |
|
1291 iCheckMassUpdate->MassUpdateSkipProgressNote( aSkip ); |
|
1292 } |
|
1293 |
|
1294 // -------------------------------------------------------------------------- |
|
1295 // CPbk2NamesListControl::View |
|
1296 // -------------------------------------------------------------------------- |
|
1297 // |
|
1298 MVPbkContactViewBase& CPbk2NamesListControl::View() |
|
1299 { |
|
1300 return *iViewStack; |
|
1301 } |
|
1302 |
|
1303 // -------------------------------------------------------------------------- |
|
1304 // CPbk2NamesListControl::MakeVisible |
|
1305 // -------------------------------------------------------------------------- |
|
1306 // |
|
1307 void CPbk2NamesListControl::MakeVisible(TBool aVisible) |
|
1308 { |
|
1309 PBK2_DEBUG_PRINT(PBK2_DEBUG_STRING( |
|
1310 "CPbk2NamesListControl::MakeVisible(0x%x,%d)"), |
|
1311 this, aVisible); |
|
1312 |
|
1313 CCoeControl::MakeVisible(aVisible); |
|
1314 iCurrentState->MakeComponentsVisible(aVisible); |
|
1315 } |
|
1316 |
|
1317 // -------------------------------------------------------------------------- |
|
1318 // CPbk2NamesListControl::ActivateL |
|
1319 // -------------------------------------------------------------------------- |
|
1320 // |
|
1321 void CPbk2NamesListControl::ActivateL() |
|
1322 { |
|
1323 // First, call base class implementation |
|
1324 CCoeControl::ActivateL(); |
|
1325 // Then do own initialization |
|
1326 iCurrentState->ActivateL(); |
|
1327 } |
|
1328 |
|
1329 // -------------------------------------------------------------------------- |
|
1330 // CPbk2NamesListControl::OfferKeyEventL |
|
1331 // -------------------------------------------------------------------------- |
|
1332 // |
|
1333 TKeyResponse CPbk2NamesListControl::OfferKeyEventL |
|
1334 ( const TKeyEvent& aKeyEvent, TEventCode aType ) |
|
1335 { |
|
1336 if(FeatureManager::FeatureSupported(KFeatureIdFfContactsPredictiveSearch)) |
|
1337 { |
|
1338 if( iCurrentState->NamesListState() == EStateReady || |
|
1339 iCurrentState->NamesListState() == EStateFiltered ) |
|
1340 { |
|
1341 iSearchFilter->FilterL( aKeyEvent, aType, iFindBox ); |
|
1342 } |
|
1343 } |
|
1344 |
|
1345 TKeyResponse result = iSearchFilter->OfferKeyEventL( aKeyEvent, aType ); |
|
1346 |
|
1347 if ( result == EKeyWasNotConsumed ) |
|
1348 { |
|
1349 result = iCurrentState->OfferKeyEventL( aKeyEvent, aType ); |
|
1350 } |
|
1351 |
|
1352 // Ignore Send Key up and down events to prevent Dialer appearance |
|
1353 // on top of Phonebook application. |
|
1354 if ( result == EKeyWasNotConsumed && iListBox->NumberOfItems() != 0 ) |
|
1355 { |
|
1356 if ( ( aType == EEventKeyDown || aType == EEventKeyUp ) |
|
1357 && aKeyEvent.iScanCode == EStdKeyYes ) |
|
1358 { |
|
1359 result = EKeyWasConsumed; |
|
1360 } |
|
1361 } |
|
1362 |
|
1363 return result; |
|
1364 } |
|
1365 |
|
1366 // -------------------------------------------------------------------------- |
|
1367 // CPbk2NamesListControl::CountComponentControls |
|
1368 // -------------------------------------------------------------------------- |
|
1369 // |
|
1370 TInt CPbk2NamesListControl::CountComponentControls() const |
|
1371 { |
|
1372 return iCurrentState->CountComponentControls(); |
|
1373 } |
|
1374 |
|
1375 // -------------------------------------------------------------------------- |
|
1376 // CPbk2NamesListControl::ComponentControl |
|
1377 // -------------------------------------------------------------------------- |
|
1378 // |
|
1379 CCoeControl* CPbk2NamesListControl::ComponentControl(TInt aIndex) const |
|
1380 { |
|
1381 // This is not forwarded to the states because these controls are |
|
1382 // always existing. It does not matter what is the state. |
|
1383 switch (aIndex) |
|
1384 { |
|
1385 case 0: |
|
1386 { |
|
1387 return iListBox; |
|
1388 } |
|
1389 case 1: |
|
1390 { |
|
1391 return iFindBox; |
|
1392 } |
|
1393 default: |
|
1394 { |
|
1395 // Illegal state |
|
1396 __ASSERT_DEBUG( EFalse, Panic( EPanicLogic_ComponentControl ) ); |
|
1397 return NULL; |
|
1398 } |
|
1399 } |
|
1400 } |
|
1401 |
|
1402 // -------------------------------------------------------------------------- |
|
1403 // CPbk2NamesListControl::FocusChanged |
|
1404 // -------------------------------------------------------------------------- |
|
1405 // |
|
1406 void CPbk2NamesListControl::FocusChanged( TDrawNow aDrawNow ) |
|
1407 { |
|
1408 if ( iListBox ) |
|
1409 { |
|
1410 iListBox->SetFocus( IsFocused(), aDrawNow ); |
|
1411 } |
|
1412 |
|
1413 if ( iFindBox && iFindBox->IsVisible() ) |
|
1414 { |
|
1415 iFindBox->SetFocus( IsFocused(), aDrawNow ); |
|
1416 if ( aDrawNow == EDrawNow && IsFocused() ) |
|
1417 { |
|
1418 iFindBox->DrawDeferred(); |
|
1419 } |
|
1420 } |
|
1421 |
|
1422 if (iCurrentState && IsNonFocusing()) |
|
1423 { |
|
1424 iCurrentState->CoeControl().SetFocus(IsFocused(), aDrawNow); |
|
1425 } |
|
1426 if ( IsFocused() ) |
|
1427 { |
|
1428 ShowThumbnail(); |
|
1429 } |
|
1430 else |
|
1431 { |
|
1432 HideThumbnail(); |
|
1433 } |
|
1434 TRAP_IGNORE(ReportEventL( MCoeControlObserver::EEventStateChanged )); |
|
1435 } |
|
1436 |
|
1437 // -------------------------------------------------------------------------- |
|
1438 // CPbk2NamesListControl::SizeChanged |
|
1439 // -------------------------------------------------------------------------- |
|
1440 // |
|
1441 void CPbk2NamesListControl::SizeChanged() |
|
1442 { |
|
1443 iCurrentState->SizeChanged(); |
|
1444 } |
|
1445 |
|
1446 // -------------------------------------------------------------------------- |
|
1447 // CPbk2NamesListControl::Draw |
|
1448 // -------------------------------------------------------------------------- |
|
1449 // |
|
1450 void CPbk2NamesListControl::Draw(const TRect& aRect) const |
|
1451 { |
|
1452 CWindowGc& gc = SystemGc(); |
|
1453 iCurrentState->Draw(aRect, gc); |
|
1454 } |
|
1455 |
|
1456 // -------------------------------------------------------------------------- |
|
1457 // CPbk2NamesListControl::HandleResourceChange |
|
1458 // -------------------------------------------------------------------------- |
|
1459 // |
|
1460 void CPbk2NamesListControl::HandleResourceChange(TInt aType) |
|
1461 { |
|
1462 CCoeControl::HandleResourceChange(aType); |
|
1463 if ( iFindBox != NULL && aType == KAknMessageFocusLost ) |
|
1464 { |
|
1465 iFindBox->DrawDeferred(); |
|
1466 } |
|
1467 |
|
1468 /* This is useless...no need to show or hide thumbnail on layout/skin change...thumbnail will handle it's own resouce change event |
|
1469 if ( aType == KEikDynamicLayoutVariantSwitch || |
|
1470 aType == KAknsMessageSkinChange ) |
|
1471 { |
|
1472 if ( IsFocused() ) |
|
1473 { |
|
1474 RDebug::Print( _L("### NamesList::HandleResourceChangeL - show") ); |
|
1475 ShowThumbnail(); |
|
1476 } |
|
1477 else |
|
1478 { |
|
1479 RDebug::Print( _L("### NamesList::HandleResourceChangeL - hide") ); |
|
1480 HideThumbnail(); |
|
1481 } |
|
1482 }*/ |
|
1483 } |
|
1484 |
|
1485 // -------------------------------------------------------------------------- |
|
1486 // CPbk2NamesListControl::HandlePointerEventL |
|
1487 // -------------------------------------------------------------------------- |
|
1488 // |
|
1489 void CPbk2NamesListControl::HandlePointerEventL( |
|
1490 const TPointerEvent& aPointerEvent ) |
|
1491 { |
|
1492 if( !iAllowPointerEvents ) |
|
1493 { |
|
1494 //Passing event to listbox needed even if iCurrentState would be skipped (fix for ou1cimx1#316139) |
|
1495 iListBox->HandlePointerEventL( aPointerEvent ); |
|
1496 return; |
|
1497 } |
|
1498 if ( AknLayoutUtils::PenEnabled() ) |
|
1499 { |
|
1500 iCurrentState->HandlePointerEventL( aPointerEvent ); |
|
1501 } |
|
1502 } |
|
1503 |
|
1504 // -------------------------------------------------------------------------- |
|
1505 // CPbk2NamesListControl::ParentControl |
|
1506 // -------------------------------------------------------------------------- |
|
1507 // |
|
1508 MPbk2ContactUiControl* CPbk2NamesListControl::ParentControl() const |
|
1509 { |
|
1510 // Name list controls has no parent |
|
1511 return NULL; |
|
1512 } |
|
1513 |
|
1514 // -------------------------------------------------------------------------- |
|
1515 // CPbk2NamesListControl::NumberOfContacts |
|
1516 // -------------------------------------------------------------------------- |
|
1517 // |
|
1518 TInt CPbk2NamesListControl::NumberOfContacts() const |
|
1519 { |
|
1520 TInt ret( iCurrentState->NumberOfContacts() ); |
|
1521 return ret; |
|
1522 } |
|
1523 |
|
1524 // -------------------------------------------------------------------------- |
|
1525 // CPbk2NamesListControl::FocusedContactL |
|
1526 // -------------------------------------------------------------------------- |
|
1527 // |
|
1528 const MVPbkBaseContact* CPbk2NamesListControl::FocusedContactL() const |
|
1529 { |
|
1530 return iCurrentState->FocusedContactL(); |
|
1531 } |
|
1532 |
|
1533 // -------------------------------------------------------------------------- |
|
1534 // CPbk2NamesListControl::FocusedViewContactL |
|
1535 // -------------------------------------------------------------------------- |
|
1536 // |
|
1537 const MVPbkViewContact* CPbk2NamesListControl::FocusedViewContactL() const |
|
1538 { |
|
1539 return iCurrentState->FocusedViewContactL(); |
|
1540 } |
|
1541 |
|
1542 // -------------------------------------------------------------------------- |
|
1543 // CPbk2NamesListControl::FocusedStoreContact |
|
1544 // -------------------------------------------------------------------------- |
|
1545 // |
|
1546 const MVPbkStoreContact* CPbk2NamesListControl::FocusedStoreContact() const |
|
1547 { |
|
1548 return iCurrentState->FocusedStoreContact(); |
|
1549 } |
|
1550 |
|
1551 // -------------------------------------------------------------------------- |
|
1552 // CPbk2NamesListControl::SetFocusedContactL |
|
1553 // -------------------------------------------------------------------------- |
|
1554 // |
|
1555 void CPbk2NamesListControl::SetFocusedContactL |
|
1556 ( const MVPbkBaseContact& aContact ) |
|
1557 { |
|
1558 iCurrentState->SetFocusedContactL(aContact); |
|
1559 } |
|
1560 |
|
1561 // -------------------------------------------------------------------------- |
|
1562 // CPbk2NamesListControl::SetFocusedContactL |
|
1563 // -------------------------------------------------------------------------- |
|
1564 // |
|
1565 void CPbk2NamesListControl::SetFocusedContactL( |
|
1566 const MVPbkContactBookmark& aContactBookmark ) |
|
1567 { |
|
1568 iCurrentState->SetFocusedContactL( aContactBookmark ); |
|
1569 } |
|
1570 |
|
1571 // -------------------------------------------------------------------------- |
|
1572 // CPbk2NamesListControl::SetFocusedContactL |
|
1573 // -------------------------------------------------------------------------- |
|
1574 // |
|
1575 void CPbk2NamesListControl::SetFocusedContactL( |
|
1576 const MVPbkContactLink& aContactLink ) |
|
1577 { |
|
1578 iCurrentState->SetFocusedContactL( aContactLink ); |
|
1579 } |
|
1580 |
|
1581 // -------------------------------------------------------------------------- |
|
1582 // CPbk2NamesListControl::FocusedContactIndex |
|
1583 // -------------------------------------------------------------------------- |
|
1584 // |
|
1585 TInt CPbk2NamesListControl::FocusedContactIndex() const |
|
1586 { |
|
1587 return iCurrentState->FocusedContactIndex(); |
|
1588 } |
|
1589 |
|
1590 // -------------------------------------------------------------------------- |
|
1591 // CPbk2NamesListControl::SetFocusedContactIndexL |
|
1592 // -------------------------------------------------------------------------- |
|
1593 // |
|
1594 void CPbk2NamesListControl::SetFocusedContactIndexL( TInt aIndex ) |
|
1595 { |
|
1596 iCurrentState->SetFocusedContactIndexL( aIndex ); |
|
1597 } |
|
1598 |
|
1599 // -------------------------------------------------------------------------- |
|
1600 // CPbk2NamesListControl::NumberOfContactFields |
|
1601 // -------------------------------------------------------------------------- |
|
1602 // |
|
1603 TInt CPbk2NamesListControl::NumberOfContactFields() const |
|
1604 { |
|
1605 return iCurrentState->NumberOfContactFields(); |
|
1606 } |
|
1607 |
|
1608 // -------------------------------------------------------------------------- |
|
1609 // CPbk2NamesListControl::FocusedField |
|
1610 // -------------------------------------------------------------------------- |
|
1611 // |
|
1612 const MVPbkBaseContactField* CPbk2NamesListControl::FocusedField() const |
|
1613 { |
|
1614 return iCurrentState->FocusedField(); |
|
1615 } |
|
1616 |
|
1617 // -------------------------------------------------------------------------- |
|
1618 // CPbk2NamesListControl::FocusedFieldIndex |
|
1619 // -------------------------------------------------------------------------- |
|
1620 // |
|
1621 TInt CPbk2NamesListControl::FocusedFieldIndex() const |
|
1622 { |
|
1623 return iCurrentState->FocusedFieldIndex(); |
|
1624 } |
|
1625 |
|
1626 // -------------------------------------------------------------------------- |
|
1627 // CPbk2NamesListControl::SetFocusedFieldIndex |
|
1628 // -------------------------------------------------------------------------- |
|
1629 // |
|
1630 void CPbk2NamesListControl::SetFocusedFieldIndex( TInt /*aIndex*/ ) |
|
1631 { |
|
1632 // Do nothing |
|
1633 } |
|
1634 |
|
1635 // -------------------------------------------------------------------------- |
|
1636 // CPbk2NamesListControl::ContactsMarked |
|
1637 // -------------------------------------------------------------------------- |
|
1638 // |
|
1639 TBool CPbk2NamesListControl::ContactsMarked() const |
|
1640 { |
|
1641 return iCurrentState->ContactsMarked(); |
|
1642 } |
|
1643 |
|
1644 // -------------------------------------------------------------------------- |
|
1645 // CPbk2NamesListControl::SelectedContactsL |
|
1646 // -------------------------------------------------------------------------- |
|
1647 // |
|
1648 MVPbkContactLinkArray* |
|
1649 CPbk2NamesListControl::SelectedContactsL() const |
|
1650 { |
|
1651 return iCurrentState->SelectedContactsL(); |
|
1652 } |
|
1653 |
|
1654 // -------------------------------------------------------------------------- |
|
1655 // CPbk2NamesListControl::SelectedContactsOrFocusedContactL |
|
1656 // -------------------------------------------------------------------------- |
|
1657 // |
|
1658 MVPbkContactLinkArray* |
|
1659 CPbk2NamesListControl::SelectedContactsOrFocusedContactL() const |
|
1660 { |
|
1661 return iCurrentState->SelectedContactsOrFocusedContactL(); |
|
1662 } |
|
1663 |
|
1664 // -------------------------------------------------------------------------- |
|
1665 // CPbk2NamesListControl::SelectedContactsIteratorL |
|
1666 // -------------------------------------------------------------------------- |
|
1667 // |
|
1668 MPbk2ContactLinkIterator* |
|
1669 CPbk2NamesListControl::SelectedContactsIteratorL() const |
|
1670 { |
|
1671 return iCurrentState->SelectedContactsIteratorL(); |
|
1672 } |
|
1673 |
|
1674 // -------------------------------------------------------------------------- |
|
1675 // CPbk2NamesListControl::SelectedContactStoresL |
|
1676 // -------------------------------------------------------------------------- |
|
1677 // |
|
1678 CArrayPtr<MVPbkContactStore>* |
|
1679 CPbk2NamesListControl::SelectedContactStoresL() const |
|
1680 { |
|
1681 // This is not a contact store control |
|
1682 return NULL; |
|
1683 } |
|
1684 |
|
1685 // -------------------------------------------------------------------------- |
|
1686 // CPbk2NamesListControl::ClearMarks |
|
1687 // -------------------------------------------------------------------------- |
|
1688 // |
|
1689 void CPbk2NamesListControl::ClearMarks() |
|
1690 { |
|
1691 iCurrentState->ClearMarks(); |
|
1692 ClearMarkedContactsInfo(); |
|
1693 } |
|
1694 |
|
1695 // -------------------------------------------------------------------------- |
|
1696 // CPbk2NamesListControl::SetSelectedContactL |
|
1697 // -------------------------------------------------------------------------- |
|
1698 // |
|
1699 void CPbk2NamesListControl::SetSelectedContactL |
|
1700 ( TInt aIndex, TBool aSelected ) |
|
1701 { |
|
1702 iCurrentState->SetSelectedContactL( aIndex, aSelected ); |
|
1703 } |
|
1704 |
|
1705 // -------------------------------------------------------------------------- |
|
1706 // CPbk2NamesListControl::SetSelectedContactL |
|
1707 // -------------------------------------------------------------------------- |
|
1708 // |
|
1709 void CPbk2NamesListControl::SetSelectedContactL( |
|
1710 const MVPbkContactBookmark& aContactBookmark, |
|
1711 TBool aSelected ) |
|
1712 { |
|
1713 iCurrentState->SetSelectedContactL( aContactBookmark, aSelected ); |
|
1714 } |
|
1715 |
|
1716 // -------------------------------------------------------------------------- |
|
1717 // CPbk2NamesListControl::SetSelectedContactL |
|
1718 // -------------------------------------------------------------------------- |
|
1719 // |
|
1720 void CPbk2NamesListControl::SetSelectedContactL( |
|
1721 const MVPbkContactLink& aContactLink, |
|
1722 TBool aSelected ) |
|
1723 { |
|
1724 iCurrentState->SetSelectedContactL( aContactLink, aSelected ); |
|
1725 } |
|
1726 TInt CPbk2NamesListControl::CommandItemCount() const |
|
1727 { |
|
1728 MPbk2ContactUiControl2* tempCurrentState = |
|
1729 reinterpret_cast<MPbk2ContactUiControl2*> |
|
1730 (iCurrentState->ContactUiControlExtension |
|
1731 (KMPbk2ContactUiControlExtension2Uid )); |
|
1732 return tempCurrentState->CommandItemCount(); |
|
1733 } |
|
1734 |
|
1735 const MPbk2UiControlCmdItem& |
|
1736 CPbk2NamesListControl::CommandItemAt( TInt aIndex ) const |
|
1737 { |
|
1738 MPbk2ContactUiControl2* tempCurrentState = |
|
1739 reinterpret_cast<MPbk2ContactUiControl2*> |
|
1740 (iCurrentState->ContactUiControlExtension |
|
1741 (KMPbk2ContactUiControlExtension2Uid )); |
|
1742 return tempCurrentState->CommandItemAt( aIndex ); |
|
1743 } |
|
1744 |
|
1745 const MPbk2UiControlCmdItem* CPbk2NamesListControl::FocusedCommandItem() const |
|
1746 { |
|
1747 MPbk2ContactUiControl2* tempCurrentState = |
|
1748 reinterpret_cast<MPbk2ContactUiControl2*> |
|
1749 (iCurrentState->ContactUiControlExtension |
|
1750 (KMPbk2ContactUiControlExtension2Uid )); |
|
1751 return tempCurrentState->FocusedCommandItem(); |
|
1752 } |
|
1753 |
|
1754 void CPbk2NamesListControl::DeleteCommandItemL( TInt aIndex ) |
|
1755 { |
|
1756 iCommandItems.Remove(aIndex); |
|
1757 iCurrentState->HandleCommandEventL(MPbk2NamesListState::EItemRemoved, aIndex); |
|
1758 } |
|
1759 |
|
1760 void CPbk2NamesListControl::AddCommandItemL(MPbk2UiControlCmdItem* aCommand, TInt aIndex) |
|
1761 { |
|
1762 // Fix ETKI-7NADZC |
|
1763 DeleteIfAlreadyAdded(aCommand); |
|
1764 |
|
1765 // add aCommand to iCommandItems |
|
1766 if (aIndex > iCommandItems.Count()) |
|
1767 { |
|
1768 aIndex = iCommandItems.Count(); |
|
1769 } |
|
1770 iCommandItems.Insert(aCommand, aIndex); |
|
1771 iCurrentState->HandleCommandEventL(MPbk2NamesListState::EItemAdded, aIndex); |
|
1772 } |
|
1773 |
|
1774 void CPbk2NamesListControl::DeleteIfAlreadyAdded(const MPbk2UiControlCmdItem* aCommand) |
|
1775 { |
|
1776 for ( TInt n = 0; n < iCommandItems.Count(); ++n) |
|
1777 { |
|
1778 MPbk2UiControlCmdItem* cmd = iCommandItems[n]; |
|
1779 if(cmd->CommandId() == aCommand->CommandId()) |
|
1780 { |
|
1781 iCommandItems.Remove(n); |
|
1782 delete cmd; |
|
1783 break; |
|
1784 } |
|
1785 } |
|
1786 } |
|
1787 |
|
1788 // -------------------------------------------------------------------------- |
|
1789 // CPbk2NamesListControl::DynInitMenuPaneL |
|
1790 // -------------------------------------------------------------------------- |
|
1791 // |
|
1792 void CPbk2NamesListControl::DynInitMenuPaneL( |
|
1793 TInt aResourceId, CEikMenuPane* aMenuPane) const |
|
1794 { |
|
1795 iCurrentState->DynInitMenuPaneL(aResourceId, aMenuPane); |
|
1796 } |
|
1797 |
|
1798 // -------------------------------------------------------------------------- |
|
1799 // CPbk2NamesListControl::ProcessCommandL |
|
1800 // -------------------------------------------------------------------------- |
|
1801 // |
|
1802 void CPbk2NamesListControl::ProcessCommandL( TInt aCommandId ) const |
|
1803 { |
|
1804 iCurrentState->ProcessCommandL(aCommandId); |
|
1805 } |
|
1806 |
|
1807 // -------------------------------------------------------------------------- |
|
1808 // CPbk2NamesListControl::UpdateAfterCommandExecution |
|
1809 // -------------------------------------------------------------------------- |
|
1810 // |
|
1811 void CPbk2NamesListControl::UpdateAfterCommandExecution() |
|
1812 { |
|
1813 if( iCommand ) |
|
1814 { |
|
1815 /// Reset command pointer, command has completed |
|
1816 iCommand->ResetUiControl(*this); |
|
1817 iCommand = NULL; |
|
1818 } |
|
1819 TRAP_IGNORE( ProcessCommandL( EAknUnmarkAll); ); |
|
1820 if( iSearchFilter ) |
|
1821 { |
|
1822 TRAP_IGNORE( iSearchFilter->ReDrawL(ETrue); ); |
|
1823 } |
|
1824 } |
|
1825 |
|
1826 // -------------------------------------------------------------------------- |
|
1827 // CPbk2NamesListControl::GetMenuFilteringFlagsL |
|
1828 // -------------------------------------------------------------------------- |
|
1829 // |
|
1830 TInt CPbk2NamesListControl::GetMenuFilteringFlagsL() const |
|
1831 { |
|
1832 return iCurrentState->GetMenuFilteringFlagsL(); |
|
1833 } |
|
1834 |
|
1835 // -------------------------------------------------------------------------- |
|
1836 // CPbk2NamesListControl::ControlStateL |
|
1837 // -------------------------------------------------------------------------- |
|
1838 // |
|
1839 CPbk2ViewState* CPbk2NamesListControl::ControlStateL() const |
|
1840 { |
|
1841 CPbk2ViewState* state = CPbk2ViewState::NewLC(); |
|
1842 const MVPbkBaseContact* focusedContact = FocusedContactL(); |
|
1843 if (focusedContact) |
|
1844 { |
|
1845 MVPbkContactLink* link = focusedContact->CreateLinkLC(); |
|
1846 if (link) |
|
1847 { |
|
1848 CleanupStack::Pop(); // link |
|
1849 state->SetFocusedContact(link); |
|
1850 } |
|
1851 } |
|
1852 |
|
1853 const MVPbkViewContact* topContact = iCurrentState->TopContactL(); |
|
1854 if ( topContact ) |
|
1855 { |
|
1856 MVPbkContactLink* link = topContact->CreateLinkLC(); |
|
1857 if (link) |
|
1858 { |
|
1859 CleanupStack::Pop(); // link |
|
1860 state->SetTopContact( link ); |
|
1861 } |
|
1862 } |
|
1863 |
|
1864 if (ContactsMarked()) |
|
1865 { |
|
1866 state->SetMarkedContacts(SelectedContactsL()); |
|
1867 } |
|
1868 CleanupStack::Pop(); // state |
|
1869 return state; |
|
1870 } |
|
1871 |
|
1872 // -------------------------------------------------------------------------- |
|
1873 // CPbk2NamesListControl::RestoreControlStateL |
|
1874 // -------------------------------------------------------------------------- |
|
1875 // |
|
1876 void CPbk2NamesListControl::RestoreControlStateL(CPbk2ViewState* aState) |
|
1877 { |
|
1878 PBK2_DEBUG_PRINT(PBK2_DEBUG_STRING |
|
1879 ("CPbk2NamesListControl::RestoreControlStateL(0x%x,0x%x)"), |
|
1880 this, aState); |
|
1881 |
|
1882 if (aState) |
|
1883 { |
|
1884 iCurrentState->RestoreControlStateL(aState); |
|
1885 } |
|
1886 } |
|
1887 |
|
1888 // -------------------------------------------------------------------------- |
|
1889 // CPbk2NamesListControl::FindTextL |
|
1890 // -------------------------------------------------------------------------- |
|
1891 // |
|
1892 const TDesC& CPbk2NamesListControl::FindTextL() |
|
1893 { |
|
1894 return iCurrentState->FindTextL(); |
|
1895 } |
|
1896 |
|
1897 // -------------------------------------------------------------------------- |
|
1898 // CPbk2NamesListControl::ResetFindL |
|
1899 // -------------------------------------------------------------------------- |
|
1900 // |
|
1901 void CPbk2NamesListControl::ResetFindL() |
|
1902 { |
|
1903 iCurrentState->ResetFindL(); |
|
1904 } |
|
1905 |
|
1906 // -------------------------------------------------------------------------- |
|
1907 // CPbk2NamesListControl::ShowThumbnail |
|
1908 // -------------------------------------------------------------------------- |
|
1909 // |
|
1910 void CPbk2NamesListControl::ShowThumbnail() |
|
1911 { |
|
1912 iCurrentState->ShowThumbnail(); |
|
1913 } |
|
1914 |
|
1915 // -------------------------------------------------------------------------- |
|
1916 // CPbk2NamesListControl::HideThumbnail |
|
1917 // -------------------------------------------------------------------------- |
|
1918 // |
|
1919 void CPbk2NamesListControl::HideThumbnail() |
|
1920 { |
|
1921 iCurrentState->HideThumbnail(); |
|
1922 } |
|
1923 |
|
1924 |
|
1925 // -------------------------------------------------------------------------- |
|
1926 // CPbk2NamesListControl::SetBlank |
|
1927 // -------------------------------------------------------------------------- |
|
1928 // |
|
1929 void CPbk2NamesListControl::SetBlank(TBool aBlank) |
|
1930 { |
|
1931 MakeVisible( !aBlank ); |
|
1932 |
|
1933 // The focus status of CAknSearchField* iFindBox is expected to be |
|
1934 // consistent with CPbk2NamesListControl when setting blank. |
|
1935 |
|
1936 if ( iFindBox ) |
|
1937 { |
|
1938 if ( iFindBox->IsVisible() ) |
|
1939 { |
|
1940 iFindBox->SetFocus( IsFocused() ); |
|
1941 } |
|
1942 } |
|
1943 |
|
1944 iCurrentState->SetBlank( aBlank ); |
|
1945 } |
|
1946 |
|
1947 // -------------------------------------------------------------------------- |
|
1948 // CPbk2NamesListControl::RegisterCommand |
|
1949 // -------------------------------------------------------------------------- |
|
1950 // |
|
1951 void CPbk2NamesListControl::RegisterCommand( |
|
1952 MPbk2Command* aCommand) |
|
1953 { |
|
1954 iCommand = aCommand; |
|
1955 } |
|
1956 |
|
1957 // -------------------------------------------------------------------------- |
|
1958 // CPbk2NamesListControl::SetTextL |
|
1959 // -------------------------------------------------------------------------- |
|
1960 // |
|
1961 void CPbk2NamesListControl::SetTextL( const TDesC& aText ) |
|
1962 { |
|
1963 iCurrentState->SetTextL( aText ); |
|
1964 } |
|
1965 |
|
1966 // -------------------------------------------------------------------------- |
|
1967 // CPbk2NamesListControl::ContactUiControlExtension |
|
1968 // -------------------------------------------------------------------------- |
|
1969 // |
|
1970 TAny* CPbk2NamesListControl::ContactUiControlExtension(TUid aExtensionUid ) |
|
1971 { |
|
1972 if( aExtensionUid == KMPbk2ContactUiControlExtension2Uid ) |
|
1973 { |
|
1974 return static_cast<MPbk2ContactUiControl2*>( this ); |
|
1975 } |
|
1976 |
|
1977 return NULL; |
|
1978 |
|
1979 } |
|
1980 |
|
1981 // -------------------------------------------------------------------------- |
|
1982 // CPbk2NamesListControl::ContactViewReady |
|
1983 // -------------------------------------------------------------------------- |
|
1984 // |
|
1985 void CPbk2NamesListControl::ContactViewReady |
|
1986 ( MVPbkContactViewBase& aView ) |
|
1987 { |
|
1988 PBK2_DEBUG_PRINT(PBK2_DEBUG_STRING |
|
1989 ("CPbk2NamesListControl::ContactViewReady(0x%x)"), this ); |
|
1990 TRAPD( error, DoHandleContactViewReadyL( aView ) ); |
|
1991 HandleError( error ); |
|
1992 } |
|
1993 |
|
1994 // -------------------------------------------------------------------------- |
|
1995 // CPbk2NamesListControl::ContactViewUnavailable |
|
1996 // -------------------------------------------------------------------------- |
|
1997 // |
|
1998 void CPbk2NamesListControl::ContactViewUnavailable |
|
1999 ( MVPbkContactViewBase& aView ) |
|
2000 { |
|
2001 PBK2_DEBUG_PRINT(PBK2_DEBUG_STRING |
|
2002 ("CPbk2NamesListControl::ContactViewUnavailable(0x%x)"), this); |
|
2003 |
|
2004 if ( &aView == iViewStack ) |
|
2005 { |
|
2006 TRAPD( err, iCurrentState = |
|
2007 &iStateFactory->ActivateNotReadyStateL( iCurrentState ) ); |
|
2008 HandleError( err ); |
|
2009 RelayoutControls(); |
|
2010 TRAP( err, iEventSender->SendEventToObserversL( |
|
2011 TPbk2ControlEvent::EUnavailable ) ); |
|
2012 HandleError( err ); |
|
2013 } |
|
2014 } |
|
2015 |
|
2016 // -------------------------------------------------------------------------- |
|
2017 // CPbk2NamesListControl::ContactAddedToView |
|
2018 // -------------------------------------------------------------------------- |
|
2019 // |
|
2020 void CPbk2NamesListControl::ContactAddedToView( |
|
2021 MVPbkContactViewBase& aView, |
|
2022 TInt aIndex, |
|
2023 const MVPbkContactLink& /*aContactLink*/) |
|
2024 { |
|
2025 PBK2_DEBUG_PRINT(PBK2_DEBUG_STRING |
|
2026 ("CPbk2NamesListControl::ContactAddedToView()")); |
|
2027 |
|
2028 if (&aView == iViewStack) |
|
2029 { |
|
2030 if( !iCheckMassUpdate->MassUpdateDetected() ) |
|
2031 { |
|
2032 TRAPD(err, DoHandleContactAdditionL(aIndex)); |
|
2033 HandleError(err); |
|
2034 } |
|
2035 } |
|
2036 } |
|
2037 |
|
2038 // -------------------------------------------------------------------------- |
|
2039 // CPbk2NamesListControl::ContactRemovedFromView |
|
2040 // -------------------------------------------------------------------------- |
|
2041 // |
|
2042 void CPbk2NamesListControl::ContactRemovedFromView( |
|
2043 MVPbkContactViewBase& aView, |
|
2044 TInt aIndex, |
|
2045 const MVPbkContactLink& /*aContactLink*/ ) |
|
2046 { |
|
2047 PBK2_DEBUG_PRINT(PBK2_DEBUG_STRING |
|
2048 ("CPbk2NamesListControl::ContactRemovedFromView()")); |
|
2049 |
|
2050 if (&aView == iViewStack) |
|
2051 { |
|
2052 TRAPD(err, DoHandleContactRemovalL(aIndex)); |
|
2053 HandleError(err); |
|
2054 } |
|
2055 } |
|
2056 |
|
2057 // -------------------------------------------------------------------------- |
|
2058 // CPbk2NamesListControl::ContactViewError |
|
2059 // -------------------------------------------------------------------------- |
|
2060 // |
|
2061 void CPbk2NamesListControl::ContactViewError( |
|
2062 MVPbkContactViewBase& /*aView*/, |
|
2063 TInt aError, |
|
2064 TBool /*aErrorNotified*/) |
|
2065 { |
|
2066 PBK2_DEBUG_PRINT(PBK2_DEBUG_STRING |
|
2067 ("CPbk2NamesListControl::ContactViewError(%d)"), aError); |
|
2068 |
|
2069 // Error comes from the active view or from find view stack. |
|
2070 // Actions are same in both cases. Show error note by forwarding |
|
2071 // the error to CCoeEnv and try to reset control. Do reset asychronously |
|
2072 // because the ContactViewError can be coming from view that is |
|
2073 // destroyed when the control is reset. |
|
2074 HandleError(aError); |
|
2075 Reset(); |
|
2076 } |
|
2077 |
|
2078 // -------------------------------------------------------------------------- |
|
2079 // CPbk2NamesListControl::ContactViewObserverExtension |
|
2080 // -------------------------------------------------------------------------- |
|
2081 // |
|
2082 TAny* CPbk2NamesListControl::ContactViewObserverExtension( TUid aExtensionUid ) |
|
2083 { |
|
2084 if( aExtensionUid == KVPbkContactViewObserverExtension2Uid ) |
|
2085 { |
|
2086 return static_cast<MVPbkContactViewObserverExtension*>( this ); |
|
2087 } |
|
2088 return NULL; |
|
2089 } |
|
2090 |
|
2091 // -------------------------------------------------------------------------- |
|
2092 // CPbk2NamesListControl::FilteredContactRemovedFromView |
|
2093 // -------------------------------------------------------------------------- |
|
2094 // |
|
2095 void CPbk2NamesListControl::FilteredContactRemovedFromView( |
|
2096 MVPbkContactViewBase& /*aView*/ ) |
|
2097 { |
|
2098 DrawDeferred(); |
|
2099 } |
|
2100 |
|
2101 // -------------------------------------------------------------------------- |
|
2102 // CPbk2NamesListControl::FocusedItemPointed |
|
2103 // -------------------------------------------------------------------------- |
|
2104 // |
|
2105 TBool CPbk2NamesListControl::FocusedItemPointed() |
|
2106 { |
|
2107 return iCurrentState->FocusedItemPointed(); |
|
2108 } |
|
2109 |
|
2110 // -------------------------------------------------------------------------- |
|
2111 // CPbk2NamesListControl::FocusableItemPointed |
|
2112 // -------------------------------------------------------------------------- |
|
2113 // |
|
2114 TBool CPbk2NamesListControl::FocusableItemPointed() |
|
2115 { |
|
2116 return iCurrentState->FocusableItemPointed(); |
|
2117 } |
|
2118 |
|
2119 // -------------------------------------------------------------------------- |
|
2120 // CPbk2NamesListControl::SearchFieldPointed |
|
2121 // -------------------------------------------------------------------------- |
|
2122 // |
|
2123 TBool CPbk2NamesListControl::SearchFieldPointed() |
|
2124 { |
|
2125 return iCurrentState->SearchFieldPointed(); |
|
2126 } |
|
2127 |
|
2128 // -------------------------------------------------------------------------- |
|
2129 // CPbk2NamesListControl::HandleControlEventL |
|
2130 // -------------------------------------------------------------------------- |
|
2131 // |
|
2132 void CPbk2NamesListControl::HandleControlEventL |
|
2133 ( CCoeControl* aControl, TCoeEvent aEventType ) |
|
2134 { |
|
2135 iCurrentState->HandleControlEventL( aControl, aEventType, 0 ); |
|
2136 } |
|
2137 |
|
2138 // -------------------------------------------------------------------------- |
|
2139 // CPbk2NamesListControl::UpdateContact |
|
2140 // -------------------------------------------------------------------------- |
|
2141 // |
|
2142 void CPbk2NamesListControl::UpdateContact |
|
2143 ( const MVPbkContactLink& aContactLink ) |
|
2144 { |
|
2145 TInt listBoxRow = KErrNotFound; |
|
2146 |
|
2147 TRAPD( err, listBoxRow = iViewStack->IndexOfLinkL( aContactLink ) ); |
|
2148 if ( err ) |
|
2149 { |
|
2150 iEikonEnv->NotifyIdleErrorWhileRedrawing( err ); |
|
2151 } |
|
2152 |
|
2153 MPbk2ContactUiControl2* tempCurrentState = |
|
2154 reinterpret_cast<MPbk2ContactUiControl2*> |
|
2155 (iCurrentState->ContactUiControlExtension |
|
2156 (KMPbk2ContactUiControlExtension2Uid )); |
|
2157 |
|
2158 if(tempCurrentState) |
|
2159 { |
|
2160 listBoxRow += tempCurrentState->CommandItemCount(); |
|
2161 } |
|
2162 if ( listBoxRow >= 0 ) |
|
2163 { |
|
2164 // If visible |
|
2165 if ( listBoxRow >= iListBox->TopItemIndex() && |
|
2166 listBoxRow <= iListBox->BottomItemIndex() ) |
|
2167 { |
|
2168 iListBox->RedrawItem( listBoxRow ); |
|
2169 } |
|
2170 } |
|
2171 } |
|
2172 |
|
2173 // -------------------------------------------------------------------------- |
|
2174 // CPbk2NamesListControl::UpdateCommandItem |
|
2175 // -------------------------------------------------------------------------- |
|
2176 // |
|
2177 void CPbk2NamesListControl::UpdateCommandItem( TInt aCommandId ) |
|
2178 { |
|
2179 const TInt count = CommandItemCount(); |
|
2180 const TInt top = iListBox->TopItemIndex(); |
|
2181 const TInt bottom = iListBox->BottomItemIndex(); |
|
2182 |
|
2183 for( TInt i = 0; i < count; ++i ) |
|
2184 { |
|
2185 if( Rng( top, i, bottom ) ) // is in visible range |
|
2186 { |
|
2187 if( CommandItemAt( i ).CommandId() == aCommandId ) |
|
2188 { |
|
2189 iListBox->RedrawItem( i ); |
|
2190 break; // only one command with same id |
|
2191 } |
|
2192 } |
|
2193 } |
|
2194 } |
|
2195 |
|
2196 // -------------------------------------------------------------------------- |
|
2197 // CPbk2NamesListControl::Redraw |
|
2198 // -------------------------------------------------------------------------- |
|
2199 // |
|
2200 void CPbk2NamesListControl::Redraw() |
|
2201 { |
|
2202 PBK2_DEBUG_PRINT(PBK2_DEBUG_STRING( |
|
2203 "CPbk2NamesListControl(0x%x)::Redraw"), this ); |
|
2204 |
|
2205 // Do not use DrawNow because: |
|
2206 // 1) DrawNow will draw the control everytime it's called. This can |
|
2207 // cause flickering in list box focus e.g. when the application view |
|
2208 // is restoring the control state. |
|
2209 // 2) Avoid unnecessary drawing because DrawDeferred can be called many |
|
2210 // times in short interval but it will draw the control only once. |
|
2211 DrawDeferred(); |
|
2212 } |
|
2213 |
|
2214 // -------------------------------------------------------------------------- |
|
2215 // CPbk2NamesListControl::DoHandleContactViewReadyL |
|
2216 // -------------------------------------------------------------------------- |
|
2217 // |
|
2218 void CPbk2NamesListControl::DoHandleContactViewReadyL |
|
2219 ( MVPbkContactViewBase& /*aView*/ ) |
|
2220 { |
|
2221 // Change state |
|
2222 SelectAndChangeReadyStateL(); |
|
2223 |
|
2224 //When contact view is ready, state is activated. If there are multiple stores |
|
2225 //state doesn't get event when other stores are ready. EContactViewUpdated event is |
|
2226 //sent when contact view is ready, so after state activation, state can get multiple |
|
2227 //contact view updated events. |
|
2228 iCurrentState->HandleContactViewEventL( MPbk2NamesListState::EContactViewUpdated, 0 ); |
|
2229 |
|
2230 // Check that there is still focus in list |
|
2231 // Focus may be lost if for example store goes unavailable |
|
2232 iListBox->CheckFocusIndex(); |
|
2233 // Control is ready and visible, inform observers |
|
2234 TBool eventSent = iEventSender->SendEventToObserversL( |
|
2235 TPbk2ControlEvent::EReady ); |
|
2236 // If Ready-event has been already sent, send |
|
2237 // ContactSetChanged-event instead. |
|
2238 if ( !eventSent ) |
|
2239 { |
|
2240 iEventSender->SendEventToObserversL( TPbk2ControlEvent:: |
|
2241 EContactSetChanged ); |
|
2242 } |
|
2243 } |
|
2244 |
|
2245 // -------------------------------------------------------------------------- |
|
2246 // CPbk2NamesListControl::DoHandleContactAdditionL |
|
2247 // |
|
2248 // NOTE: See also CPbk2FilteredViewStackObserver::ContactAddedToBaseView and |
|
2249 // CPbk2NamesListControl::DoContactAddedToBaseView |
|
2250 // -------------------------------------------------------------------------- |
|
2251 // |
|
2252 void CPbk2NamesListControl::DoHandleContactAdditionL( TInt aIndex ) |
|
2253 { |
|
2254 //Prevent messing with focus with always-on when Phonebook hidden in |
|
2255 //reseted state. Otherwise background-added contacts will change focus. |
|
2256 //This would cause Phonebook not to look like freshly started when opened again. |
|
2257 //And also make sure foreground-added contact will show the new contact |
|
2258 //even though the focus is not seen. |
|
2259 if( (static_cast<CPbk2AppUi*>( |
|
2260 CEikonEnv::Static()->AppUi()))->IsForeground() ) |
|
2261 { |
|
2262 SelectAndChangeReadyStateL(); |
|
2263 } |
|
2264 |
|
2265 if( !iCheckMassUpdate->MassUpdateDetected() ) |
|
2266 { |
|
2267 iCurrentState->HandleContactViewEventL |
|
2268 ( MPbk2NamesListState::EItemAdded, aIndex ); |
|
2269 } |
|
2270 |
|
2271 // At least names list view needs control event about contact addition, |
|
2272 // so it knows to update CBAs |
|
2273 iEventSender->SendEventToObserversL( TPbk2ControlEvent::EItemAdded ); |
|
2274 } |
|
2275 |
|
2276 // -------------------------------------------------------------------------- |
|
2277 // CPbk2NamesListControl::DoHandleContactRemovalL |
|
2278 // -------------------------------------------------------------------------- |
|
2279 // |
|
2280 void CPbk2NamesListControl::DoHandleContactRemovalL( TInt aIndex ) |
|
2281 { |
|
2282 iCurrentState->HandleContactViewEventL |
|
2283 ( MPbk2NamesListState::EItemRemoved, aIndex ); |
|
2284 SelectAndChangeReadyStateL(); |
|
2285 iEventSender->SendEventToObserversL( TPbk2ControlEvent::EItemRemoved ); |
|
2286 } |
|
2287 |
|
2288 // -------------------------------------------------------------------------- |
|
2289 // CPbk2NamesListControl::SelectAndChangeReadyStateL |
|
2290 // Changes between ready states (ready, empty, filtered). |
|
2291 // Can't handle a change to unavailable state |
|
2292 // -------------------------------------------------------------------------- |
|
2293 // |
|
2294 void CPbk2NamesListControl::SelectAndChangeReadyStateL() |
|
2295 { |
|
2296 if ( iViewStack->ContactCountL() == 0 ) |
|
2297 { |
|
2298 if ( iViewStack->Level() > 0 ) |
|
2299 { |
|
2300 // If view was filtered beyond matches, activate filtered state |
|
2301 iCurrentState = &iStateFactory->ActivateFilteredStateL |
|
2302 ( iCurrentState ); |
|
2303 } |
|
2304 else |
|
2305 { |
|
2306 // Empty state used only if there are no contacts |
|
2307 // in the base view |
|
2308 iCurrentState = &iStateFactory->ActivateEmptyStateL |
|
2309 ( iCurrentState ); |
|
2310 } |
|
2311 } |
|
2312 else |
|
2313 { |
|
2314 iCurrentState = |
|
2315 &iStateFactory->ActivateReadyStateL( iCurrentState ); |
|
2316 } |
|
2317 |
|
2318 // Controls have to be relayouted always. Relayouting only when |
|
2319 // state was changed is not enough, it results to drawing problems. |
|
2320 // Calling only Redraw() is not enough also. |
|
2321 RelayoutControls(); |
|
2322 } |
|
2323 |
|
2324 // -------------------------------------------------------------------------- |
|
2325 // CPbk2NamesListControl::RelayoutControls |
|
2326 // -------------------------------------------------------------------------- |
|
2327 // |
|
2328 void CPbk2NamesListControl::RelayoutControls() |
|
2329 { |
|
2330 SizeChanged(); |
|
2331 MakeVisible( IsVisible() ); |
|
2332 Redraw(); |
|
2333 } |
|
2334 |
|
2335 // -------------------------------------------------------------------------- |
|
2336 // CPbk2NamesListControl::HandleTopViewChangedL |
|
2337 // -------------------------------------------------------------------------- |
|
2338 // |
|
2339 void CPbk2NamesListControl::HandleTopViewChangedL |
|
2340 ( MVPbkContactViewBase& aOldView ) |
|
2341 { |
|
2342 SelectAndChangeReadyStateL(); |
|
2343 |
|
2344 iCurrentState->TopViewChangedL( aOldView ); |
|
2345 |
|
2346 // Inform observers |
|
2347 iEventSender->SendEventToObserversL( |
|
2348 TPbk2ControlEvent::EContactSetChanged ); |
|
2349 } |
|
2350 |
|
2351 // -------------------------------------------------------------------------- |
|
2352 // CPbk2NamesListControl::HandleTopViewUpdatedL |
|
2353 // -------------------------------------------------------------------------- |
|
2354 // |
|
2355 void CPbk2NamesListControl::HandleTopViewUpdatedL() |
|
2356 { |
|
2357 PBK2_DEBUG_PRINT(PBK2_DEBUG_STRING |
|
2358 ("CPbk2NamesListControl::HandleTopViewUpdatedL(0x%x)"), this ); |
|
2359 |
|
2360 SelectAndChangeReadyStateL(); |
|
2361 |
|
2362 iCurrentState->TopViewUpdatedL(); |
|
2363 } |
|
2364 |
|
2365 // -------------------------------------------------------------------------- |
|
2366 // CPbk2NamesListControl::HandleBaseViewChangedL |
|
2367 // -------------------------------------------------------------------------- |
|
2368 // |
|
2369 void CPbk2NamesListControl::HandleBaseViewChangedL() |
|
2370 { |
|
2371 PBK2_DEBUG_PRINT(PBK2_DEBUG_STRING |
|
2372 ("CPbk2NamesListControl::HandleBaseViewChangedL(0x%x)"), this ); |
|
2373 |
|
2374 SelectAndChangeReadyStateL(); |
|
2375 |
|
2376 iCurrentState->BaseViewChangedL(); |
|
2377 |
|
2378 iEventSender->SendEventToObserversL( |
|
2379 TPbk2ControlEvent::EContactSetChanged ); |
|
2380 } |
|
2381 |
|
2382 // -------------------------------------------------------------------------- |
|
2383 // CPbk2NamesListControl::HandleViewStackError |
|
2384 // -------------------------------------------------------------------------- |
|
2385 // |
|
2386 void CPbk2NamesListControl::HandleViewStackError( TInt aError ) |
|
2387 { |
|
2388 PBK2_DEBUG_PRINT(PBK2_DEBUG_STRING |
|
2389 ("CPbk2NamesListControl::HandleBaseViewChangedL(0x%x, %d)"), |
|
2390 this, aError ); |
|
2391 |
|
2392 HandleError( aError ); |
|
2393 Reset(); |
|
2394 } |
|
2395 |
|
2396 // -------------------------------------------------------------------------- |
|
2397 // CPbk2NamesListControl::HandleContactAddedToBaseView |
|
2398 // -------------------------------------------------------------------------- |
|
2399 // |
|
2400 void CPbk2NamesListControl::HandleContactAddedToBaseView |
|
2401 ( MVPbkContactViewBase& /*aBaseView*/, |
|
2402 TInt /*aIndex*/, const MVPbkContactLink& /*aContactLink*/ ) |
|
2403 { |
|
2404 // The find box must be reset when new items are added to |
|
2405 // the list box. When find text is reset, the possible filter |
|
2406 // result (subset of contacts) of the previous find criteria must be |
|
2407 // reset too. So, we reset both the find box and the view stack. |
|
2408 TRAPD( res, |
|
2409 { |
|
2410 // This will reset back to base view, however retain original view |
|
2411 //when opening CCA |
|
2412 if( !iOpeningCca ) |
|
2413 { |
|
2414 iCurrentState->ResetFindL(); |
|
2415 } |
|
2416 }); |
|
2417 HandleError( res ); |
|
2418 |
|
2419 if( !iCheckMassUpdate->MassUpdateCheckThis() ) |
|
2420 { |
|
2421 // If it is the first time to goto a contat's cca card, then in cca we |
|
2422 // will set a defualt number to that contact by CmsSetVoiceCallDefault. |
|
2423 // Then db item changed event is notified to ui layer and names list control |
|
2424 // updated accordingly. But to end user that is not allowed, so use this |
|
2425 // flag to avoid this reset of ui control. |
|
2426 if( iOpeningCca ) |
|
2427 { |
|
2428 if( iCurrentState->NamesListState() == EStateEmpty ) |
|
2429 { |
|
2430 SelectAndChangeReadyStateL(); |
|
2431 } |
|
2432 } |
|
2433 else |
|
2434 { |
|
2435 if( !iMarkingModeOn ) |
|
2436 { |
|
2437 Reset(); |
|
2438 } |
|
2439 } |
|
2440 } |
|
2441 |
|
2442 // Do not handle contact addition here (DoHandleContactAdditionL), |
|
2443 // ContactAddedToView to notification is sent separately |
|
2444 } |
|
2445 |
|
2446 // -------------------------------------------------------------------------- |
|
2447 // |
|
2448 // -------------------------------------------------------------------------- |
|
2449 // |
|
2450 void CPbk2NamesListControl::HandleScrollEventL(CEikScrollBar* aScrollBar, TEikScrollEvent aEventType) |
|
2451 { |
|
2452 // iDidMove= EFalse ; |
|
2453 |
|
2454 switch( aEventType ) |
|
2455 { |
|
2456 // drag events -> hide thumbnail |
|
2457 // AL: this isn't very efficient way of doing this... |
|
2458 // ...thumbnail loader interface should be extended to |
|
2459 // enable thumbnail window to be hidden/shown without |
|
2460 // destroying and reloading the bitmaps... |
|
2461 case EEikScrollThumbDragHoriz: |
|
2462 case EEikScrollThumbDragVert: |
|
2463 { |
|
2464 iDidMove = ETrue; |
|
2465 HideThumbnail(); |
|
2466 break; |
|
2467 } |
|
2468 |
|
2469 // release events |
|
2470 case EEikScrollThumbReleaseHoriz: |
|
2471 case EEikScrollThumbReleaseVert: |
|
2472 { |
|
2473 // AL: this isn't very efficient way of doing this... |
|
2474 // ...thumbnail loader interface should be extended to |
|
2475 // enable thumbnail window to be hidden/shown without |
|
2476 // destroying and reloading the bitmaps... |
|
2477 if( iDidMove ) |
|
2478 { |
|
2479 iDidMove = EFalse; |
|
2480 ShowThumbnail(); |
|
2481 } |
|
2482 break; |
|
2483 } |
|
2484 |
|
2485 default: |
|
2486 { |
|
2487 iDidMove= EFalse ; |
|
2488 |
|
2489 if( iThumbnailLoader ) |
|
2490 { |
|
2491 iThumbnailLoader->Refresh(); |
|
2492 } |
|
2493 |
|
2494 |
|
2495 } |
|
2496 } |
|
2497 |
|
2498 // To avoid slow redraw of the scrollbar, make sure it gets drawn. Fixes MJAA-7ZGHRH. |
|
2499 aScrollBar->DrawNow(); |
|
2500 } |
|
2501 // -------------------------------------------------------------------------- |
|
2502 // CPbk2NamesListControl::HandleListBoxEventL |
|
2503 // Deal with the Panning/Flick event from listbox |
|
2504 // -------------------------------------------------------------------------- |
|
2505 // |
|
2506 void CPbk2NamesListControl::HandleListBoxEventL( CEikListBox* /*aListBox*/, TListBoxEvent aEventType ) |
|
2507 { |
|
2508 switch( aEventType ) |
|
2509 { |
|
2510 case EEventPanningStarted: |
|
2511 case EEventFlickStarted: |
|
2512 { |
|
2513 // Hide Thumbnial as the listbox is |
|
2514 // Panning/Flicking |
|
2515 HideThumbnail(); |
|
2516 break; |
|
2517 } |
|
2518 |
|
2519 case EEventPanningStopped: |
|
2520 case EEventFlickStopped: |
|
2521 { |
|
2522 // Show Thumbnial after the listbox |
|
2523 // Panned/Flicked |
|
2524 ShowThumbnail(); |
|
2525 break; |
|
2526 } |
|
2527 case EEventItemSingleClicked: |
|
2528 case EEventItemDoubleClicked: |
|
2529 { |
|
2530 iEventSender->SendEventToObserversL( |
|
2531 TPbk2ControlEvent::EContactDoubleTapped ); |
|
2532 break; |
|
2533 } |
|
2534 |
|
2535 default: |
|
2536 break; |
|
2537 } |
|
2538 } |
|
2539 |
|
2540 // -------------------------------------------------------------------------- |
|
2541 // CPbk2NamesListControl::AdaptiveSearchTextChanged |
|
2542 // |
|
2543 // -------------------------------------------------------------------------- |
|
2544 // |
|
2545 void CPbk2NamesListControl::AdaptiveSearchTextChanged( CAknSearchField* aSearchField ) |
|
2546 { |
|
2547 //send event to current state |
|
2548 //ETrue means that the event came from adaptvie search grid. |
|
2549 TRAP_IGNORE(iCurrentState->HandleControlEventL( aSearchField, MCoeControlObserver::EEventStateChanged, ETrue)); |
|
2550 } |
|
2551 |
|
2552 |
|
2553 // ----------------------------------------------------------------------------- |
|
2554 // CPbk2NamesListControl::MarkingModeStatusChanged |
|
2555 // ----------------------------------------------------------------------------- |
|
2556 // |
|
2557 void CPbk2NamesListControl::MarkingModeStatusChanged( TBool /*aActivated*/ ) |
|
2558 { |
|
2559 } |
|
2560 |
|
2561 // ----------------------------------------------------------------------------- |
|
2562 // CPbk2NamesListControl::ExitMarkingMode |
|
2563 // Called by avkon, if the return value is ETrue, |
|
2564 // the Marking mode will be canceled after any operation, |
|
2565 // otherwise the Marking mode keep active. |
|
2566 // ----------------------------------------------------------------------------- |
|
2567 // |
|
2568 TBool CPbk2NamesListControl::ExitMarkingMode() const |
|
2569 { |
|
2570 return ETrue; |
|
2571 } |
|
2572 |
|
2573 // -------------------------------------------------------------------------- |
|
2574 // CPbk2NamesListControl::HandleForegroundEventL |
|
2575 // -------------------------------------------------------------------------- |
|
2576 // |
|
2577 void CPbk2NamesListControl::HandleForegroundEventL(TBool aForeground) |
|
2578 { |
|
2579 if ( iSearchFilter ) |
|
2580 { |
|
2581 iSearchFilter->HandleForegroundEventL( aForeground ); |
|
2582 } |
|
2583 } |
|
2584 |
|
2585 // --------------------------------------------------------------------------- |
|
2586 // CPbk2NamesListControl::StoreMarkedContactsAndResetViewL |
|
2587 // --------------------------------------------------------------------------- |
|
2588 // |
|
2589 void CPbk2NamesListControl::StoreMarkedContactsAndResetViewL() |
|
2590 { |
|
2591 delete iSelectedLinkArray; |
|
2592 iSelectedLinkArray = NULL; |
|
2593 |
|
2594 iSelectedLinkArray = iCurrentState->SelectedContactsL(); |
|
2595 } |
|
2596 |
|
2597 |
|
2598 // --------------------------------------------------------------------------- |
|
2599 // CPbk2NamesListControl::RestoreMarkedContactsL |
|
2600 // --------------------------------------------------------------------------- |
|
2601 // |
|
2602 void CPbk2NamesListControl::RestoreMarkedContactsL() |
|
2603 { |
|
2604 //Set the Marked Contacts |
|
2605 if ( iSelectedLinkArray ) |
|
2606 { |
|
2607 for ( TInt index = 0; index<iSelectedLinkArray->Count(); index++ ) |
|
2608 { |
|
2609 iCurrentState->SetSelectedContactL( iSelectedLinkArray->At(index), ETrue ); |
|
2610 } |
|
2611 } |
|
2612 |
|
2613 delete iSelectedLinkArray; |
|
2614 iSelectedLinkArray = NULL; |
|
2615 } |
|
2616 |
|
2617 // --------------------------------------------------------------------------- |
|
2618 // CPbk2NamesListControl::ClearMarkedContactsInfo |
|
2619 // --------------------------------------------------------------------------- |
|
2620 // |
|
2621 void CPbk2NamesListControl::ClearMarkedContactsInfo() |
|
2622 { |
|
2623 if ( iBgTask ) |
|
2624 { |
|
2625 iBgTask->ClearAllEvents(); |
|
2626 } |
|
2627 delete iSelectedLinkArray; |
|
2628 iSelectedLinkArray = NULL; |
|
2629 } |
|
2630 |
|
2631 // --------------------------------------------------------------------------- |
|
2632 // CPbk2NamesListControl::HandleViewForegroundEventL |
|
2633 // --------------------------------------------------------------------------- |
|
2634 // |
|
2635 EXPORT_C void CPbk2NamesListControl::HandleViewForegroundEventL( TBool aForeground ) |
|
2636 { |
|
2637 if ( aForeground ) |
|
2638 { |
|
2639 if ( iBgTask ) |
|
2640 { |
|
2641 iBgTask->AddEvent( CPbk2NamesListControl::EStateRestoreMarkedContacts ); |
|
2642 } |
|
2643 } |
|
2644 else |
|
2645 { |
|
2646 if ( iBgTask ) |
|
2647 { |
|
2648 iBgTask->AddEvent( CPbk2NamesListControl::EStateSaveMarkedContacts ); |
|
2649 } |
|
2650 } |
|
2651 } |
|
2652 |
|
2653 // --------------------------------------------------------------------------- |
|
2654 // CPbk2NamesListControl::SetOpeningCca |
|
2655 // --------------------------------------------------------------------------- |
|
2656 // |
|
2657 EXPORT_C void CPbk2NamesListControl::SetOpeningCca( TBool aIsOpening ) |
|
2658 { |
|
2659 iOpeningCca = aIsOpening; |
|
2660 } |
|
2661 |
|
2662 // --------------------------------------------------------------------------- |
|
2663 // CPbk2NamesListControlBgTask::CPbk2NamesListControlBgTask |
|
2664 // --------------------------------------------------------------------------- |
|
2665 // |
|
2666 CPbk2NamesListControlBgTask::CPbk2NamesListControlBgTask( CPbk2NamesListControl& aControl ) : |
|
2667 CActive(CActive::EPriorityStandard), |
|
2668 iControl( aControl ) |
|
2669 { |
|
2670 CActiveScheduler::Add(this); |
|
2671 iEventQueue.Append(CPbk2NamesListControl::EStateBgTaskEmpty); |
|
2672 } |
|
2673 |
|
2674 // --------------------------------------------------------------------------- |
|
2675 // CPbk2NamesListControlBgTask::~CPbk2NamesListControlBgTask |
|
2676 // --------------------------------------------------------------------------- |
|
2677 // |
|
2678 CPbk2NamesListControlBgTask::~CPbk2NamesListControlBgTask() |
|
2679 { |
|
2680 Cancel(); |
|
2681 iEventQueue.Reset(); |
|
2682 } |
|
2683 |
|
2684 |
|
2685 // --------------------------------------------------------------------------- |
|
2686 // CPbk2NamesListControlBgTask::DoCancel |
|
2687 // --------------------------------------------------------------------------- |
|
2688 // |
|
2689 void CPbk2NamesListControlBgTask::DoCancel() |
|
2690 { |
|
2691 } |
|
2692 |
|
2693 // --------------------------------------------------------------------------- |
|
2694 // CPbk2NamesListControlBgTask::RunL |
|
2695 // --------------------------------------------------------------------------- |
|
2696 // |
|
2697 void CPbk2NamesListControlBgTask::RunL() |
|
2698 { |
|
2699 |
|
2700 if ( iEventQueue.Count() ) |
|
2701 { |
|
2702 switch ( iEventQueue[0] ) |
|
2703 { |
|
2704 case CPbk2NamesListControl::EStateSaveMarkedContacts: |
|
2705 iControl.StoreMarkedContactsAndResetViewL(); |
|
2706 iEventQueue.Remove( 0 ); |
|
2707 break; |
|
2708 |
|
2709 case CPbk2NamesListControl::EStateRestoreMarkedContacts: |
|
2710 iControl.RestoreMarkedContactsL(); |
|
2711 iEventQueue.Remove( 0 ); |
|
2712 break; |
|
2713 |
|
2714 case CPbk2NamesListControl::EStateBgTaskEmpty : |
|
2715 default: |
|
2716 iControl.ClearMarkedContactsInfo(); |
|
2717 break; |
|
2718 } |
|
2719 } |
|
2720 } |
|
2721 |
|
2722 // --------------------------------------------------------------------------- |
|
2723 // CPbk2NamesListControlBgTask::RunError |
|
2724 // --------------------------------------------------------------------------- |
|
2725 // |
|
2726 TInt CPbk2NamesListControlBgTask::RunError(TInt /*aError*/) |
|
2727 { |
|
2728 return KErrNone; |
|
2729 } |
|
2730 |
|
2731 // --------------------------------------------------------------------------- |
|
2732 // CPbk2NamesListControlBgTask::AddEvent |
|
2733 // --------------------------------------------------------------------------- |
|
2734 // |
|
2735 void CPbk2NamesListControlBgTask::AddEvent( CPbk2NamesListControl::TPbk2NamesListBgEvents aEvent ) |
|
2736 { |
|
2737 iEventQueue.Insert( aEvent, iEventQueue.Count() - 1 ); |
|
2738 if ( !IsActive() ) |
|
2739 { |
|
2740 TRequestStatus* status = &iStatus; |
|
2741 User::RequestComplete(status, KErrNone); |
|
2742 SetActive(); |
|
2743 } |
|
2744 } |
|
2745 |
|
2746 |
|
2747 // --------------------------------------------------------------------------- |
|
2748 // CPbk2NamesListControlBgTask::RemoveEvent |
|
2749 // --------------------------------------------------------------------------- |
|
2750 // |
|
2751 void CPbk2NamesListControlBgTask::RemoveEvent( CPbk2NamesListControl::TPbk2NamesListBgEvents aEvent ) |
|
2752 { |
|
2753 for ( TInt index = 0; index < iEventQueue.Count(); index++ ) |
|
2754 { |
|
2755 if ( aEvent == iEventQueue[index] ) |
|
2756 { |
|
2757 iEventQueue.Remove( index ); |
|
2758 if ( 0 == index ) |
|
2759 { |
|
2760 Cancel(); |
|
2761 } |
|
2762 break; |
|
2763 } |
|
2764 } |
|
2765 } |
|
2766 |
|
2767 |
|
2768 // --------------------------------------------------------------------------- |
|
2769 // CPbk2NamesListControlBgTask::ClearAllEvents |
|
2770 // --------------------------------------------------------------------------- |
|
2771 // |
|
2772 void CPbk2NamesListControlBgTask::ClearAllEvents() |
|
2773 { |
|
2774 iEventQueue.Reset(); |
|
2775 iEventQueue.Append( CPbk2NamesListControl::EStateBgTaskEmpty ); |
|
2776 Cancel(); |
|
2777 } |
|
2778 |
|
2779 // End of File |