|
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 empty state. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include "CPbk2NamesListEmptyState.h" |
|
21 |
|
22 // Phonebook 2 |
|
23 #include "CPbk2ContactViewListBox.h" |
|
24 #include "CPbk2ThumbnailLoader.h" |
|
25 #include "CPbk2NamesListControl.h" |
|
26 #include <Pbk2MenuFilteringFlags.hrh> |
|
27 #include "PmuCommands.hrh" // For accessing EPmuCmdCascadingBackup |
|
28 #include "Pbk2USimUI.hrh" // For accessing EPsu2CmdCascadingSimMemory |
|
29 #include <Pbk2Commands.hrh> |
|
30 #include <Pbk2InternalUID.h> |
|
31 #include <pbk2doublelistboxcmditemextension.h> |
|
32 |
|
33 // virtual phonebook |
|
34 #include <CVPbkContactLinkArray.h> |
|
35 #include <MVPbkContactLink.h> |
|
36 |
|
37 // System includes |
|
38 #include <eikmenup.h> |
|
39 #include <aknsfld.h> |
|
40 |
|
41 // Debugging headers |
|
42 #include <Pbk2Debug.h> |
|
43 |
|
44 |
|
45 /// Unnamed namespace for local definitions |
|
46 namespace { |
|
47 |
|
48 const TInt KNumberOfContacts = 0; |
|
49 const TInt KNumberOfControls = 1; |
|
50 |
|
51 } /// namespace |
|
52 |
|
53 |
|
54 // -------------------------------------------------------------------------- |
|
55 // CPbk2NamesListEmptyState::CPbk2NamesListEmptyState |
|
56 // -------------------------------------------------------------------------- |
|
57 // |
|
58 inline CPbk2NamesListEmptyState::CPbk2NamesListEmptyState( |
|
59 const CCoeControl* aParent, |
|
60 CPbk2ContactViewListBox& aListBox, |
|
61 CAknSearchField* aFindBox, |
|
62 CPbk2ThumbnailLoader& aThumbnailLoader, |
|
63 RPointerArray<MPbk2UiControlCmdItem>& aCommandItems ) : |
|
64 iParent( *aParent ), |
|
65 iListBox( aListBox ), |
|
66 iFindBox( aFindBox ), |
|
67 iThumbnailLoader( aThumbnailLoader ), |
|
68 iCommandItems( aCommandItems ) |
|
69 { |
|
70 } |
|
71 |
|
72 // -------------------------------------------------------------------------- |
|
73 // CPbk2NamesListEmptyState::~CPbk2NamesListEmptyState |
|
74 // -------------------------------------------------------------------------- |
|
75 // |
|
76 CPbk2NamesListEmptyState::~CPbk2NamesListEmptyState() |
|
77 { |
|
78 } |
|
79 |
|
80 // -------------------------------------------------------------------------- |
|
81 // CPbk2NamesListEmptyState::NewL |
|
82 // -------------------------------------------------------------------------- |
|
83 // |
|
84 CPbk2NamesListEmptyState* CPbk2NamesListEmptyState::NewLC |
|
85 ( const CCoeControl* aParent, CPbk2ContactViewListBox& aListBox, |
|
86 CAknSearchField* aFindBox, CPbk2ThumbnailLoader& aThumbnailLoader, |
|
87 RPointerArray<MPbk2UiControlCmdItem>& aCommandItems ) |
|
88 { |
|
89 CPbk2NamesListEmptyState* self = new ( ELeave ) CPbk2NamesListEmptyState |
|
90 ( aParent, aListBox, aFindBox, aThumbnailLoader, aCommandItems ); |
|
91 CleanupStack::PushL( self ); |
|
92 return self; |
|
93 } |
|
94 |
|
95 |
|
96 // -------------------------------------------------------------------------- |
|
97 // CPbk2NamesListEmptyState::UnsubscribeCmdItemsVisibility |
|
98 // -------------------------------------------------------------------------- |
|
99 // |
|
100 void CPbk2NamesListEmptyState::UnsubscribeCmdItemsVisibility() const |
|
101 { |
|
102 for ( TInt i = 0; i < iCommandItems.Count(); ++i ) |
|
103 { |
|
104 iCommandItems[i]->SetVisibilityObserver( NULL ); |
|
105 } |
|
106 } |
|
107 |
|
108 // -------------------------------------------------------------------------- |
|
109 // CPbk2NamesListEmptyState::SubscribeCmdItemsVisibility |
|
110 // -------------------------------------------------------------------------- |
|
111 // |
|
112 void CPbk2NamesListEmptyState::SubscribeCmdItemsVisibility() |
|
113 { |
|
114 for ( TInt i = 0; i < iCommandItems.Count(); ++i ) |
|
115 { |
|
116 iCommandItems[i]->SetVisibilityObserver( this ); |
|
117 } |
|
118 } |
|
119 |
|
120 |
|
121 // -------------------------------------------------------------------------- |
|
122 // CPbk2NamesListEmptyState::ActivateStateL |
|
123 // -------------------------------------------------------------------------- |
|
124 // |
|
125 void CPbk2NamesListEmptyState::ActivateStateL() |
|
126 { |
|
127 AllowCommandsToShowThemselves( ETrue ); |
|
128 |
|
129 // hide findbox since there is no contact |
|
130 if ( iFindBox && iFindBox->IsVisible() ) |
|
131 { |
|
132 iFindBox->MakeVisible( EFalse ); |
|
133 } |
|
134 |
|
135 } |
|
136 |
|
137 // -------------------------------------------------------------------------- |
|
138 // CPbk2NamesListEmptyState::DeactivateState |
|
139 // -------------------------------------------------------------------------- |
|
140 // |
|
141 void CPbk2NamesListEmptyState::DeactivateState() |
|
142 { |
|
143 AllowCommandsToShowThemselves( EFalse ); |
|
144 |
|
145 if ( iFindBox && !iFindBox->IsFocused() ) |
|
146 { |
|
147 iFindBox->SetFocus( ETrue ); |
|
148 } |
|
149 } |
|
150 |
|
151 // -------------------------------------------------------------------------- |
|
152 // CPbk2NamesListEmptyState::CountComponentControls |
|
153 // -------------------------------------------------------------------------- |
|
154 // |
|
155 TInt CPbk2NamesListEmptyState::CountComponentControls() const |
|
156 { |
|
157 return KNumberOfControls; |
|
158 } |
|
159 |
|
160 // -------------------------------------------------------------------------- |
|
161 // CPbk2NamesListEmptyState::ComponentControl |
|
162 // -------------------------------------------------------------------------- |
|
163 // |
|
164 CCoeControl* CPbk2NamesListEmptyState::ComponentControl |
|
165 ( TInt /*aIndex*/ ) const |
|
166 { |
|
167 return &iListBox; |
|
168 } |
|
169 |
|
170 // -------------------------------------------------------------------------- |
|
171 // CPbk2NamesListEmptyState::SizeChanged |
|
172 // -------------------------------------------------------------------------- |
|
173 // |
|
174 void CPbk2NamesListEmptyState::SizeChanged() |
|
175 { |
|
176 const TRect rect(iParent.Rect()); |
|
177 PBK2_DEBUG_PRINT(PBK2_DEBUG_STRING |
|
178 ("CPbk2NamesListEmptyState::SizeChanged(0x%x), rect=(%d,%d,%d,%d)"), |
|
179 this, rect.iTl.iX, rect.iTl.iY, rect.iBr.iX, rect.iBr.iY); |
|
180 |
|
181 AknLayoutUtils::LayoutControl(&iListBox, rect, |
|
182 AKN_LAYOUT_WINDOW_list_gen_pane(0)); |
|
183 } |
|
184 |
|
185 // -------------------------------------------------------------------------- |
|
186 // CPbk2NamesListEmptyState::MakeComponentsVisible |
|
187 // -------------------------------------------------------------------------- |
|
188 // |
|
189 void CPbk2NamesListEmptyState::MakeComponentsVisible(TBool aVisible) |
|
190 { |
|
191 PBK2_DEBUG_PRINT(PBK2_DEBUG_STRING |
|
192 ("CPbk2NamesListEmptyState::MakeComponentsVisible(0x%x,%d)"), |
|
193 this, aVisible); |
|
194 |
|
195 iListBox.MakeVisible(aVisible); |
|
196 |
|
197 CEikScrollBar *scrollBar = iListBox.ScrollBarFrame()->GetScrollBarHandle |
|
198 (CEikScrollBar::EVertical); |
|
199 if ( scrollBar ) |
|
200 { |
|
201 scrollBar->MakeVisible(aVisible); |
|
202 } |
|
203 } |
|
204 |
|
205 // -------------------------------------------------------------------------- |
|
206 // CPbk2NamesListEmptyState::ActivateL |
|
207 // -------------------------------------------------------------------------- |
|
208 // |
|
209 void CPbk2NamesListEmptyState::ActivateL() |
|
210 { |
|
211 // Do nothing |
|
212 } |
|
213 |
|
214 // -------------------------------------------------------------------------- |
|
215 // CPbk2NamesListEmptyState::Draw |
|
216 // -------------------------------------------------------------------------- |
|
217 // |
|
218 void CPbk2NamesListEmptyState::Draw |
|
219 (const TRect& aRect, CWindowGc& aGc) const |
|
220 { |
|
221 PBK2_DEBUG_PRINT(PBK2_DEBUG_STRING( |
|
222 "CPbk2NamesListEmptyState::Draw(0x%x, TRect(%d,%d,%d,%d))"), |
|
223 this, aRect.iTl.iX, aRect.iTl.iY, aRect.iBr.iX, aRect.iBr.iY); |
|
224 |
|
225 // Draw the skin background |
|
226 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
|
227 MAknsControlContext* cc = |
|
228 AknsDrawUtils::ControlContext( &iListBox ); |
|
229 |
|
230 if ( !AknsDrawUtils::Background( skin, cc, &iListBox, aGc, aRect ) ) |
|
231 { |
|
232 // Blank background if no skin present |
|
233 aGc.SetPenStyle( CGraphicsContext::ENullPen ); |
|
234 aGc.SetBrushStyle( CGraphicsContext::ESolidBrush ); |
|
235 aGc.DrawRect( aRect ); |
|
236 } |
|
237 } |
|
238 |
|
239 // -------------------------------------------------------------------------- |
|
240 // CPbk2NamesListEmptyState::OfferKeyEventL |
|
241 // -------------------------------------------------------------------------- |
|
242 // |
|
243 TKeyResponse CPbk2NamesListEmptyState::OfferKeyEventL |
|
244 (const TKeyEvent& aKeyEvent, TEventCode aType) |
|
245 { |
|
246 TKeyResponse result( EKeyWasNotConsumed ); |
|
247 // Offer the event to listbox |
|
248 result = iListBox.OfferKeyEventL(aKeyEvent, aType); |
|
249 return result; |
|
250 } |
|
251 |
|
252 // -------------------------------------------------------------------------- |
|
253 // CPbk2NamesListEmptyState::HandlePointerEventL |
|
254 // -------------------------------------------------------------------------- |
|
255 // |
|
256 void CPbk2NamesListEmptyState::HandlePointerEventL |
|
257 ( const TPointerEvent& aPointerEvent ) |
|
258 { |
|
259 iListBox.HandlePointerEventL( aPointerEvent ); |
|
260 } |
|
261 |
|
262 // -------------------------------------------------------------------------- |
|
263 // CPbk2NamesListEmptyState::NamesListState |
|
264 // -------------------------------------------------------------------------- |
|
265 // |
|
266 TInt CPbk2NamesListEmptyState::NamesListState() const |
|
267 { |
|
268 return CPbk2NamesListControl::EStateEmpty; |
|
269 } |
|
270 |
|
271 // -------------------------------------------------------------------------- |
|
272 // CPbk2NamesListEmptyState::HandleContactViewEventL |
|
273 // -------------------------------------------------------------------------- |
|
274 // |
|
275 void CPbk2NamesListEmptyState::HandleContactViewEventL |
|
276 ( TInt aEvent, TInt aIndex ) |
|
277 { |
|
278 // need to calculate list index from contact |
|
279 // view index |
|
280 TInt listIndex = CommandItemCount() + aIndex; |
|
281 HandleListboxEventL(aEvent, listIndex, EFalse ); |
|
282 } |
|
283 |
|
284 // -------------------------------------------------------------------------- |
|
285 // CPbk2NamesListEmptyState::HandleCommandEventL |
|
286 // -------------------------------------------------------------------------- |
|
287 // |
|
288 void CPbk2NamesListEmptyState::HandleCommandEventL |
|
289 (TInt aEvent, TInt /* aListboxIndex */) |
|
290 { |
|
291 HandleListboxEventL(aEvent, 0, ETrue ); |
|
292 } |
|
293 |
|
294 // -------------------------------------------------------------------------- |
|
295 // CPbk2NamesListEmptyState::HandleListboxEventL |
|
296 // -------------------------------------------------------------------------- |
|
297 // |
|
298 void CPbk2NamesListEmptyState::HandleListboxEventL |
|
299 (TInt aEvent, TInt aListboxIndex, |
|
300 TBool /*aMantainFocus*/) |
|
301 { |
|
302 iListBox.HandleEventL( aEvent, aListboxIndex ); |
|
303 iParent.DrawDeferred(); |
|
304 } |
|
305 // -------------------------------------------------------------------------- |
|
306 // CPbk2NamesListEmptyState::CoeControl |
|
307 // -------------------------------------------------------------------------- |
|
308 // |
|
309 CCoeControl& CPbk2NamesListEmptyState::CoeControl() |
|
310 { |
|
311 return const_cast<CCoeControl&>(iParent); |
|
312 } |
|
313 |
|
314 // -------------------------------------------------------------------------- |
|
315 // CPbk2NamesListEmptyState::HandleControlEventL |
|
316 // -------------------------------------------------------------------------- |
|
317 // |
|
318 void CPbk2NamesListEmptyState::HandleControlEventL( CCoeControl* /*aControl*/, |
|
319 MCoeControlObserver::TCoeEvent /*aEventType*/, TInt /*aParam */) |
|
320 { |
|
321 // Do nothing in empty state |
|
322 } |
|
323 |
|
324 // -------------------------------------------------------------------------- |
|
325 // CPbk2NamesListEmptyState::TopContactL |
|
326 // -------------------------------------------------------------------------- |
|
327 // |
|
328 const MVPbkViewContact* CPbk2NamesListEmptyState::TopContactL() |
|
329 { |
|
330 return NULL; |
|
331 } |
|
332 |
|
333 // -------------------------------------------------------------------------- |
|
334 // CPbk2NamesListEmptyState::ParentControl |
|
335 // -------------------------------------------------------------------------- |
|
336 // |
|
337 MPbk2ContactUiControl* CPbk2NamesListEmptyState::ParentControl() const |
|
338 { |
|
339 // Names list control does not have a parent control |
|
340 return NULL; |
|
341 } |
|
342 |
|
343 // -------------------------------------------------------------------------- |
|
344 // CPbk2NamesListEmptyState::NumberOfContacts |
|
345 // -------------------------------------------------------------------------- |
|
346 // |
|
347 TInt CPbk2NamesListEmptyState::NumberOfContacts() const |
|
348 { |
|
349 // The listbox can also have command items. |
|
350 TInt result = iListBox.NumberOfItems() - CommandItemCount(); |
|
351 if ( result < 0 ) |
|
352 { |
|
353 result = KNumberOfContacts; // No contacts |
|
354 } |
|
355 return result; |
|
356 } |
|
357 |
|
358 // -------------------------------------------------------------------------- |
|
359 // CPbk2NamesListEmptyState::FocusedContactL |
|
360 // -------------------------------------------------------------------------- |
|
361 // |
|
362 const MVPbkBaseContact* CPbk2NamesListEmptyState::FocusedContactL() const |
|
363 { |
|
364 return NULL; |
|
365 } |
|
366 |
|
367 // -------------------------------------------------------------------------- |
|
368 // CPbk2NamesListEmptyState::FocusedViewContactL |
|
369 // -------------------------------------------------------------------------- |
|
370 // |
|
371 const MVPbkViewContact* CPbk2NamesListEmptyState::FocusedViewContactL() const |
|
372 { |
|
373 return NULL; |
|
374 } |
|
375 |
|
376 // -------------------------------------------------------------------------- |
|
377 // CPbk2NamesListEmptyState::FocusedStoreContact |
|
378 // -------------------------------------------------------------------------- |
|
379 // |
|
380 const MVPbkStoreContact* CPbk2NamesListEmptyState::FocusedStoreContact() const |
|
381 { |
|
382 return NULL; |
|
383 } |
|
384 |
|
385 // -------------------------------------------------------------------------- |
|
386 // CPbk2NamesListEmptyState::SetFocusedContactL |
|
387 // -------------------------------------------------------------------------- |
|
388 // |
|
389 void CPbk2NamesListEmptyState::SetFocusedContactL |
|
390 ( const MVPbkBaseContact& /*aContact*/ ) |
|
391 { |
|
392 // Do nothing |
|
393 } |
|
394 |
|
395 // -------------------------------------------------------------------------- |
|
396 // CPbk2NamesListEmptyState::SetFocusedContactL |
|
397 // -------------------------------------------------------------------------- |
|
398 // |
|
399 void CPbk2NamesListEmptyState::SetFocusedContactL |
|
400 ( const MVPbkContactBookmark& /*aContactBookmark*/ ) |
|
401 { |
|
402 // Do nothing |
|
403 } |
|
404 |
|
405 // -------------------------------------------------------------------------- |
|
406 // CPbk2NamesListEmptyState::SetFocusedContactL |
|
407 // -------------------------------------------------------------------------- |
|
408 // |
|
409 void CPbk2NamesListEmptyState::SetFocusedContactL |
|
410 ( const MVPbkContactLink& /*aContactLink*/ ) |
|
411 { |
|
412 // Do nothing |
|
413 } |
|
414 |
|
415 // -------------------------------------------------------------------------- |
|
416 // CPbk2NamesListEmptyState::FocusedContactIndex |
|
417 // -------------------------------------------------------------------------- |
|
418 // |
|
419 TInt CPbk2NamesListEmptyState::FocusedContactIndex() const |
|
420 { |
|
421 return KErrNotFound; |
|
422 } |
|
423 |
|
424 // -------------------------------------------------------------------------- |
|
425 // CPbk2NamesListEmptyState::SetFocusedContactIndex |
|
426 // -------------------------------------------------------------------------- |
|
427 // |
|
428 void CPbk2NamesListEmptyState::SetFocusedContactIndexL( TInt /*aIndex*/ ) |
|
429 { |
|
430 // Do nothing |
|
431 } |
|
432 |
|
433 // -------------------------------------------------------------------------- |
|
434 // CPbk2NamesListEmptyState::NumberOfContactFields |
|
435 // -------------------------------------------------------------------------- |
|
436 // |
|
437 TInt CPbk2NamesListEmptyState::NumberOfContactFields() const |
|
438 { |
|
439 return KErrNotSupported; |
|
440 } |
|
441 |
|
442 // -------------------------------------------------------------------------- |
|
443 // CPbk2NamesListEmptyState::FocusedField |
|
444 // -------------------------------------------------------------------------- |
|
445 // |
|
446 const MVPbkBaseContactField* CPbk2NamesListEmptyState::FocusedField() const |
|
447 { |
|
448 return NULL; |
|
449 } |
|
450 |
|
451 // -------------------------------------------------------------------------- |
|
452 // CPbk2NamesListEmptyState::FocusedFieldIndex |
|
453 // -------------------------------------------------------------------------- |
|
454 // |
|
455 TInt CPbk2NamesListEmptyState::FocusedFieldIndex() const |
|
456 { |
|
457 return KErrNotFound; |
|
458 } |
|
459 |
|
460 // -------------------------------------------------------------------------- |
|
461 // CPbk2NamesListEmptyState::SetFocusedFieldIndex |
|
462 // -------------------------------------------------------------------------- |
|
463 // |
|
464 void CPbk2NamesListEmptyState::SetFocusedFieldIndex( TInt /*aIndex*/ ) |
|
465 { |
|
466 // Do nothing |
|
467 } |
|
468 |
|
469 // -------------------------------------------------------------------------- |
|
470 // CPbk2NamesListEmptyState::ContactsMarked |
|
471 // -------------------------------------------------------------------------- |
|
472 // |
|
473 TBool CPbk2NamesListEmptyState::ContactsMarked() const |
|
474 { |
|
475 return EFalse; |
|
476 } |
|
477 |
|
478 // -------------------------------------------------------------------------- |
|
479 // CPbk2NamesListEmptyState::SelectedContactsL |
|
480 // -------------------------------------------------------------------------- |
|
481 // |
|
482 MVPbkContactLinkArray* CPbk2NamesListEmptyState::SelectedContactsL() const |
|
483 { |
|
484 return NULL; |
|
485 } |
|
486 |
|
487 // -------------------------------------------------------------------------- |
|
488 // CPbk2NamesListEmptyState::SelectedContactsOrFocusedContactL |
|
489 // -------------------------------------------------------------------------- |
|
490 // |
|
491 MVPbkContactLinkArray* |
|
492 CPbk2NamesListEmptyState::SelectedContactsOrFocusedContactL() const |
|
493 { |
|
494 CVPbkContactLinkArray* array = NULL; |
|
495 // my card is showing on empty list, check if the wanted contact is it |
|
496 TInt currentItem = iListBox.CurrentItemIndex(); |
|
497 // if focused index is command item |
|
498 if( currentItem < CommandItemCount() ) |
|
499 { |
|
500 // check if the command is my card ( this search is copied from CommandItemAt - function to avoid const cast) |
|
501 // Some of the commands might be disabled. Skip those. |
|
502 TInt enabledCount = 0; |
|
503 TInt indexOfResult = KErrNotFound; |
|
504 for ( TInt n = 0; n < iCommandItems.Count() && indexOfResult == KErrNotFound; ++n ) |
|
505 { |
|
506 if ( iCommandItems[ n ]->IsEnabled() ) |
|
507 { |
|
508 enabledCount++; |
|
509 if ( enabledCount-1 == currentItem ) |
|
510 { |
|
511 indexOfResult = n; |
|
512 } |
|
513 } |
|
514 } |
|
515 MPbk2UiControlCmdItem* item = iCommandItems[ indexOfResult ]; |
|
516 // check if the command item was a my card |
|
517 if( item->CommandId() == EPbk2CmdOpenMyCard ) |
|
518 { |
|
519 // get extension point and my card link |
|
520 TAny* object = item->ControlCmdItemExtension( TUid::Uid( KPbk2ControlCmdItemExtensionUID ) ); |
|
521 if( object ) |
|
522 { |
|
523 MPbk2DoubleListboxCmdItemExtension* extension = |
|
524 static_cast<MPbk2DoubleListboxCmdItemExtension*>( object ); |
|
525 // if extension exists |
|
526 if( extension ) |
|
527 { |
|
528 const MVPbkContactLink* link = extension->Link(); |
|
529 // if link exists, add it to the array |
|
530 if( link ) |
|
531 { |
|
532 array = CVPbkContactLinkArray::NewLC(); |
|
533 array->AppendL( link->CloneLC() ); |
|
534 CleanupStack::Pop( 2 ); // array, link |
|
535 } |
|
536 } |
|
537 } |
|
538 } |
|
539 } |
|
540 return array; |
|
541 } |
|
542 |
|
543 // -------------------------------------------------------------------------- |
|
544 // CPbk2NamesListEmptyState::SelectedContactsIteratorL |
|
545 // -------------------------------------------------------------------------- |
|
546 // |
|
547 MPbk2ContactLinkIterator* |
|
548 CPbk2NamesListEmptyState::SelectedContactsIteratorL() const |
|
549 { |
|
550 return NULL; |
|
551 } |
|
552 |
|
553 // -------------------------------------------------------------------------- |
|
554 // CPbk2NamesListEmptyState::SelectedContactStoresL |
|
555 // -------------------------------------------------------------------------- |
|
556 // |
|
557 CArrayPtr<MVPbkContactStore>* |
|
558 CPbk2NamesListEmptyState::SelectedContactStoresL() const |
|
559 { |
|
560 // This is not a state of the contact store control |
|
561 return NULL; |
|
562 } |
|
563 |
|
564 // -------------------------------------------------------------------------- |
|
565 // CPbk2NamesListEmptyState::ClearMarks |
|
566 // -------------------------------------------------------------------------- |
|
567 // |
|
568 void CPbk2NamesListEmptyState::ClearMarks() |
|
569 { |
|
570 // Do nothing |
|
571 } |
|
572 |
|
573 // -------------------------------------------------------------------------- |
|
574 // CPbk2NamesListEmptyState::SetSelectedContactL |
|
575 // -------------------------------------------------------------------------- |
|
576 // |
|
577 void CPbk2NamesListEmptyState::SetSelectedContactL( |
|
578 TInt /*aIndex*/, TBool /*aSelected*/) |
|
579 { |
|
580 // Do nothing |
|
581 } |
|
582 |
|
583 // -------------------------------------------------------------------------- |
|
584 // CPbk2NamesListEmptyState::SetSelectedContactL |
|
585 // -------------------------------------------------------------------------- |
|
586 // |
|
587 void CPbk2NamesListEmptyState::SetSelectedContactL( |
|
588 const MVPbkContactBookmark& /*aContactBookmark*/, |
|
589 TBool /*aSelected*/ ) |
|
590 { |
|
591 // Do nothing |
|
592 } |
|
593 |
|
594 // -------------------------------------------------------------------------- |
|
595 // CPbk2NamesListEmptyState::SetSelectedContactL |
|
596 // -------------------------------------------------------------------------- |
|
597 // |
|
598 void CPbk2NamesListEmptyState::SetSelectedContactL( |
|
599 const MVPbkContactLink& /*aContactLink*/, |
|
600 TBool /*aSelected*/ ) |
|
601 { |
|
602 // Do nothing |
|
603 } |
|
604 |
|
605 // -------------------------------------------------------------------------- |
|
606 // CPbk2NamesListEmptyState::CommandItemCount |
|
607 // -------------------------------------------------------------------------- |
|
608 // |
|
609 TInt CPbk2NamesListEmptyState::CommandItemCount() const |
|
610 { |
|
611 // Some of the commands might be disabled. Don't count those. |
|
612 TInt enabledCommandCount = 0; |
|
613 for ( TInt n = 0; n < iCommandItems.Count(); ++n ) |
|
614 { |
|
615 if ( iCommandItems[ n ]->IsEnabled() ) |
|
616 { |
|
617 enabledCommandCount++; |
|
618 } |
|
619 } |
|
620 return enabledCommandCount; |
|
621 } |
|
622 |
|
623 // -------------------------------------------------------------------------- |
|
624 // CPbk2NamesListEmptyState::CommandItemAt |
|
625 // -------------------------------------------------------------------------- |
|
626 // |
|
627 const MPbk2UiControlCmdItem& |
|
628 CPbk2NamesListEmptyState::CommandItemAt( TInt aIndex ) const |
|
629 { |
|
630 // Some of the commands might be disabled. Skip those. |
|
631 TInt enabledCount = 0; |
|
632 TInt indexOfResult = KErrNotFound; |
|
633 for ( TInt n = 0; n < iCommandItems.Count()&& indexOfResult == KErrNotFound; ++n ) |
|
634 |
|
635 { |
|
636 if ( iCommandItems[ n ]->IsEnabled() ) |
|
637 { |
|
638 enabledCount++; |
|
639 if ( enabledCount-1 == aIndex ) |
|
640 { |
|
641 indexOfResult = n; |
|
642 } |
|
643 } |
|
644 } |
|
645 return *iCommandItems[ indexOfResult ]; |
|
646 } |
|
647 |
|
648 // -------------------------------------------------------------------------- |
|
649 // CPbk2NamesListEmptyState::FocusedCommandItem |
|
650 // -------------------------------------------------------------------------- |
|
651 // |
|
652 const MPbk2UiControlCmdItem* |
|
653 CPbk2NamesListEmptyState::FocusedCommandItem() const |
|
654 { |
|
655 const MPbk2UiControlCmdItem* cmdItem = NULL; |
|
656 // Is the focus on a command item: |
|
657 TInt focusListIndex = iListBox.CurrentItemIndex(); |
|
658 const TInt commandItemCount = CommandItemCount(); |
|
659 if ( focusListIndex != KErrNotFound && focusListIndex < commandItemCount ) |
|
660 { |
|
661 // Yes it's a command item. |
|
662 cmdItem = &CommandItemAt(focusListIndex); |
|
663 } |
|
664 return cmdItem; |
|
665 } |
|
666 |
|
667 // -------------------------------------------------------------------------- |
|
668 // CPbk2NamesListEmptyState::DeleteCommandItemL |
|
669 // -------------------------------------------------------------------------- |
|
670 // |
|
671 void CPbk2NamesListEmptyState::DeleteCommandItemL( TInt /*aIndex*/ ) |
|
672 { |
|
673 // ownership & management of iCommandItems is wasted in names list |
|
674 // control. Do nothing here |
|
675 } |
|
676 |
|
677 // -------------------------------------------------------------------------- |
|
678 // CPbk2NamesListEmptyState::AddCommandItemL |
|
679 // -------------------------------------------------------------------------- |
|
680 // |
|
681 void CPbk2NamesListEmptyState::AddCommandItemL(MPbk2UiControlCmdItem* /*aCommand*/, TInt /*aIndex*/) |
|
682 { |
|
683 // ownership & management of iCommandItems is wasted in names list |
|
684 // control. Do nothing here |
|
685 } |
|
686 |
|
687 // -------------------------------------------------------------------------- |
|
688 // CPbk2NamesListEmptyState::DynInitMenuPaneL |
|
689 // -------------------------------------------------------------------------- |
|
690 // |
|
691 void CPbk2NamesListEmptyState::DynInitMenuPaneL( |
|
692 TInt aResourceId, CEikMenuPane* aMenuPane) const |
|
693 { |
|
694 AknSelectionService::HandleMarkableListDynInitMenuPane |
|
695 (aResourceId, aMenuPane, &iListBox); |
|
696 |
|
697 //No contacts visible in this state |
|
698 TInt pos; // Stores the position of the searched menu item. |
|
699 // This position is not needed or used anywhere |
|
700 |
|
701 if (aMenuPane->MenuItemExists(EAknUnmarkAll, pos)) |
|
702 { |
|
703 aMenuPane->SetItemDimmed(EAknUnmarkAll, ETrue); |
|
704 } |
|
705 if (aMenuPane->MenuItemExists(EAknMarkAll, pos)) |
|
706 { |
|
707 aMenuPane->SetItemDimmed(EAknMarkAll, ETrue); |
|
708 } |
|
709 } |
|
710 |
|
711 // -------------------------------------------------------------------------- |
|
712 // CPbk2NamesListEmptyState::ProcessCommandL |
|
713 // -------------------------------------------------------------------------- |
|
714 // |
|
715 void CPbk2NamesListEmptyState::ProcessCommandL |
|
716 ( TInt /*aCommandId*/ ) const |
|
717 { |
|
718 // Do nothing |
|
719 } |
|
720 |
|
721 // -------------------------------------------------------------------------- |
|
722 // CPbk2NamesListEmptyState::UpdateAfterCommandExecution |
|
723 // -------------------------------------------------------------------------- |
|
724 // |
|
725 void CPbk2NamesListEmptyState::UpdateAfterCommandExecution() |
|
726 { |
|
727 // Do nothing |
|
728 } |
|
729 |
|
730 // -------------------------------------------------------------------------- |
|
731 // CPbk2NamesListEmptyState::GetMenuFilteringFlagsL |
|
732 // -------------------------------------------------------------------------- |
|
733 // |
|
734 TInt CPbk2NamesListEmptyState::GetMenuFilteringFlagsL() const |
|
735 { |
|
736 return KPbk2MenuFilteringFlagsNone | KPbk2ListContainsNoMarkedItems; |
|
737 } |
|
738 |
|
739 |
|
740 // -------------------------------------------------------------------------- |
|
741 // CPbk2NamesListEmptyState::ControlStateL |
|
742 // -------------------------------------------------------------------------- |
|
743 // |
|
744 CPbk2ViewState* CPbk2NamesListEmptyState::ControlStateL() const |
|
745 { |
|
746 // State objects do not handle control state changes |
|
747 return NULL; |
|
748 } |
|
749 |
|
750 // -------------------------------------------------------------------------- |
|
751 // CPbk2NamesListEmptyState::RestoreControlStateL |
|
752 // -------------------------------------------------------------------------- |
|
753 // |
|
754 void CPbk2NamesListEmptyState::RestoreControlStateL |
|
755 ( CPbk2ViewState* /*aState*/ ) |
|
756 { |
|
757 // State objects do not handle control state changes |
|
758 } |
|
759 |
|
760 // -------------------------------------------------------------------------- |
|
761 // CPbk2NamesListEmptyState::FindTextL |
|
762 // -------------------------------------------------------------------------- |
|
763 // |
|
764 const TDesC& CPbk2NamesListEmptyState::FindTextL() |
|
765 { |
|
766 return KNullDesC; |
|
767 } |
|
768 |
|
769 // -------------------------------------------------------------------------- |
|
770 // CPbk2NamesListEmptyState::ResetFindL |
|
771 // -------------------------------------------------------------------------- |
|
772 // |
|
773 void CPbk2NamesListEmptyState::ResetFindL() |
|
774 { |
|
775 // Do nothing |
|
776 } |
|
777 |
|
778 // -------------------------------------------------------------------------- |
|
779 // CPbk2NamesListEmptyState::HideThumbnail |
|
780 // -------------------------------------------------------------------------- |
|
781 // |
|
782 void CPbk2NamesListEmptyState::HideThumbnail() |
|
783 { |
|
784 // Do nothing |
|
785 } |
|
786 |
|
787 // -------------------------------------------------------------------------- |
|
788 // CPbk2NamesListEmptyState::ShowThumbnail |
|
789 // -------------------------------------------------------------------------- |
|
790 // |
|
791 void CPbk2NamesListEmptyState::ShowThumbnail() |
|
792 { |
|
793 // Do nothing |
|
794 } |
|
795 |
|
796 // -------------------------------------------------------------------------- |
|
797 // CPbk2NamesListEmptyState::SetBlank |
|
798 // -------------------------------------------------------------------------- |
|
799 // |
|
800 void CPbk2NamesListEmptyState::SetBlank( TBool aBlank ) |
|
801 { |
|
802 if (!aBlank) |
|
803 { |
|
804 // Redraw |
|
805 iParent.DrawDeferred(); |
|
806 TRAPD( error, iListBox.UpdateScrollBarsL() ); |
|
807 if ( error != KErrNone ) |
|
808 { |
|
809 CCoeEnv::Static()->HandleError( error ); |
|
810 } |
|
811 } |
|
812 } |
|
813 |
|
814 // -------------------------------------------------------------------------- |
|
815 // CPbk2NamesListEmptyState::RegisterCommand |
|
816 // -------------------------------------------------------------------------- |
|
817 // |
|
818 void CPbk2NamesListEmptyState::RegisterCommand( |
|
819 MPbk2Command* /*aCommand*/) |
|
820 { |
|
821 // Do nothing |
|
822 } |
|
823 |
|
824 // -------------------------------------------------------------------------- |
|
825 // CPbk2NamesListEmptyState::SetTextL |
|
826 // -------------------------------------------------------------------------- |
|
827 // |
|
828 void CPbk2NamesListEmptyState::SetTextL( const TDesC& aText ) |
|
829 { |
|
830 iListBox.View()->SetListEmptyTextL( aText ); |
|
831 } |
|
832 |
|
833 // -------------------------------------------------------------------------- |
|
834 // CPbk2NamesListEmptyState::ContactUiControlExtension |
|
835 // -------------------------------------------------------------------------- |
|
836 // |
|
837 TAny* CPbk2NamesListEmptyState::ContactUiControlExtension(TUid aExtensionUid ) |
|
838 { |
|
839 if( aExtensionUid == KMPbk2ContactUiControlExtension2Uid ) |
|
840 { |
|
841 return static_cast<MPbk2ContactUiControl2*>( this ); |
|
842 } |
|
843 |
|
844 return NULL; |
|
845 } |
|
846 // -------------------------------------------------------------------------- |
|
847 // CPbk2NamesListEmptyState::FocusedItemPointed |
|
848 // -------------------------------------------------------------------------- |
|
849 // |
|
850 TBool CPbk2NamesListEmptyState::FocusedItemPointed() |
|
851 { |
|
852 return iListBox.FocusedItemPointed(); |
|
853 } |
|
854 |
|
855 // -------------------------------------------------------------------------- |
|
856 // CPbk2NamesListEmptyState::FocusableItemPointed |
|
857 // -------------------------------------------------------------------------- |
|
858 // |
|
859 TBool CPbk2NamesListEmptyState::FocusableItemPointed() |
|
860 { |
|
861 return iListBox.FocusableItemPointed(); |
|
862 } |
|
863 |
|
864 // -------------------------------------------------------------------------- |
|
865 // CPbk2NamesListEmptyState::SearchFieldPointed |
|
866 // -------------------------------------------------------------------------- |
|
867 // |
|
868 TBool CPbk2NamesListEmptyState::SearchFieldPointed() |
|
869 { |
|
870 return EFalse; |
|
871 } |
|
872 |
|
873 // -------------------------------------------------------------------------- |
|
874 // CPbk2NamesListEmptyState::TopViewChangedL |
|
875 // -------------------------------------------------------------------------- |
|
876 // |
|
877 void CPbk2NamesListEmptyState::TopViewChangedL( |
|
878 MVPbkContactViewBase& /*aOldView*/ ) |
|
879 { |
|
880 // Do nothing |
|
881 } |
|
882 |
|
883 // -------------------------------------------------------------------------- |
|
884 // CPbk2NamesListEmptyState::TopViewUpdatedL |
|
885 // -------------------------------------------------------------------------- |
|
886 // |
|
887 void CPbk2NamesListEmptyState::TopViewUpdatedL() |
|
888 { |
|
889 // Do nothing |
|
890 } |
|
891 |
|
892 // -------------------------------------------------------------------------- |
|
893 // CPbk2NamesListEmptyState::BaseViewChangedL |
|
894 // -------------------------------------------------------------------------- |
|
895 // |
|
896 void CPbk2NamesListEmptyState::BaseViewChangedL() |
|
897 { |
|
898 // Do nothing |
|
899 } |
|
900 |
|
901 // -------------------------------------------------------------------------- |
|
902 // CPbk2NamesListEmptyState::ViewStackError |
|
903 // -------------------------------------------------------------------------- |
|
904 // |
|
905 void CPbk2NamesListEmptyState::ViewStackError( TInt /*aError*/ ) |
|
906 { |
|
907 // Do nothing |
|
908 } |
|
909 |
|
910 // -------------------------------------------------------------------------- |
|
911 // CPbk2NamesListEmptyState::ContactAddedToBaseView |
|
912 // -------------------------------------------------------------------------- |
|
913 // |
|
914 void CPbk2NamesListEmptyState::ContactAddedToBaseView( |
|
915 MVPbkContactViewBase& /*aBaseView*/, |
|
916 TInt /*aIndex*/, |
|
917 const MVPbkContactLink& /*aContactLink*/ ) |
|
918 { |
|
919 // Do nothing |
|
920 } |
|
921 |
|
922 // -------------------------------------------------------------------------- |
|
923 // CPbk2NamesListEmptyState::IsContactAtListboxIndex |
|
924 // Tells whether the listbox line contains a contact or not. |
|
925 // Does not check that the aListboxIndex is within range of listbox. |
|
926 // -------------------------------------------------------------------------- |
|
927 // |
|
928 TBool CPbk2NamesListEmptyState::IsContactAtListboxIndex( TInt aListboxIndex ) const |
|
929 { |
|
930 // There can be command items at the top of the list. |
|
931 // The command items are not contacts. |
|
932 const TInt enabledCommandCount = CommandItemCount(); |
|
933 return aListboxIndex >= enabledCommandCount; |
|
934 } |
|
935 |
|
936 // -------------------------------------------------------------------------- |
|
937 // CPbk2NamesListEmptyState::AllowCommandsToShowThemselves |
|
938 // -------------------------------------------------------------------------- |
|
939 // |
|
940 void CPbk2NamesListEmptyState::AllowCommandsToShowThemselves( TBool aVisible ) |
|
941 { |
|
942 if ( aVisible ) |
|
943 { |
|
944 // ownership not transferred |
|
945 iListBox.SetListCommands( &iCommandItems ); |
|
946 SubscribeCmdItemsVisibility(); |
|
947 UpdateCommandEnabled( EPbk2CmdRcl, ETrue ); |
|
948 UpdateCommandEnabled( EPbk2CmdAddFavourites, EFalse ); |
|
949 //MyCard is stored separately and may also contain data |
|
950 UpdateCommandEnabled( EPbk2CmdOpenMyCard, ETrue ); |
|
951 } |
|
952 else |
|
953 { |
|
954 UnsubscribeCmdItemsVisibility(); |
|
955 iListBox.SetListCommands( NULL ); |
|
956 } |
|
957 } |
|
958 // -------------------------------------------------------------------------- |
|
959 // CPbk2NamesListEmptyState::CmdItemVisibilityChanged |
|
960 // -------------------------------------------------------------------------- |
|
961 // |
|
962 void CPbk2NamesListEmptyState::CmdItemVisibilityChanged( TInt aCmdItemId, TBool aVisible ) |
|
963 { |
|
964 TInt cmdItemIndex = FindCommand(aCmdItemId); |
|
965 TRAP_IGNORE( HandleCommandEventL( |
|
966 (aVisible ? EItemAdded : EItemRemoved), |
|
967 cmdItemIndex) ); |
|
968 } |
|
969 |
|
970 // -------------------------------------------------------------------------- |
|
971 // CPbk2NamesListEmptyState::UpdateCommandEnabled |
|
972 // -------------------------------------------------------------------------- |
|
973 // |
|
974 void CPbk2NamesListEmptyState::UpdateCommandEnabled( TInt aCommandId, TBool aEnabled ) |
|
975 { |
|
976 for ( TInt i = 0; i < iCommandItems.Count(); i++ ) |
|
977 { |
|
978 if ( iCommandItems[i]->CommandId() == aCommandId ) |
|
979 { |
|
980 iCommandItems[i]->SetEnabled( aEnabled ); |
|
981 break; |
|
982 } |
|
983 } |
|
984 } |
|
985 // -------------------------------------------------------------------------- |
|
986 // CPbk2NamesListEmptyState::IsCommandEnabled |
|
987 // -------------------------------------------------------------------------- |
|
988 // |
|
989 TBool CPbk2NamesListEmptyState::IsCommandEnabled(TInt aCommandId) const |
|
990 { |
|
991 TBool res = EFalse; |
|
992 for ( TInt i = 0; i < iCommandItems.Count(); i++ ) |
|
993 { |
|
994 if ( iCommandItems[i]->CommandId() == aCommandId ) |
|
995 { |
|
996 res = iCommandItems[i]->IsEnabled(); |
|
997 break; |
|
998 } |
|
999 } |
|
1000 return res; |
|
1001 } |
|
1002 |
|
1003 // -------------------------------------------------------------------------- |
|
1004 // CPbk2NamesListEmptyState::FindCommand |
|
1005 // Search for a command in iCommandItems and returns its index |
|
1006 // -------------------------------------------------------------------------- |
|
1007 // |
|
1008 TInt CPbk2NamesListEmptyState::FindCommand(TInt aCommandId) const |
|
1009 { |
|
1010 TInt result = KErrNotFound; |
|
1011 for ( TInt i = 0; i < iCommandItems.Count(); ++i ) |
|
1012 { |
|
1013 if ( iCommandItems[i]->CommandId() == aCommandId ) |
|
1014 { |
|
1015 result = i; |
|
1016 break; |
|
1017 } |
|
1018 |
|
1019 } |
|
1020 return result; |
|
1021 } |
|
1022 |
|
1023 // -------------------------------------------------------------------------- |
|
1024 // CPbk2NamesListEmptyState::CalculateListboxIndex |
|
1025 // -------------------------------------------------------------------------- |
|
1026 // |
|
1027 TInt CPbk2NamesListEmptyState::CalculateListboxIndex(TInt aCommandIndex) const |
|
1028 { |
|
1029 TInt num(KErrNotFound); |
|
1030 for ( TInt i = 0; i < aCommandIndex; ++i ) |
|
1031 { |
|
1032 if(iCommandItems[i]->IsEnabled()) |
|
1033 { |
|
1034 ++num; |
|
1035 } |
|
1036 } |
|
1037 return num; |
|
1038 } |
|
1039 |
|
1040 // -------------------------------------------------------------------------- |
|
1041 // CPbk2NamesListEmptyState::UnmarkCommands |
|
1042 // -------------------------------------------------------------------------- |
|
1043 // |
|
1044 void CPbk2NamesListEmptyState::UnmarkCommands() const |
|
1045 { |
|
1046 for ( TInt i = 0; i < CommandItemCount(); i++ ) |
|
1047 { |
|
1048 iListBox.View()->DeselectItem( i ); |
|
1049 } |
|
1050 } |
|
1051 |
|
1052 // End of File |