126 // CPbk2NamesListEmptyState::ActivateStateL |
122 // CPbk2NamesListEmptyState::ActivateStateL |
127 // -------------------------------------------------------------------------- |
123 // -------------------------------------------------------------------------- |
128 // |
124 // |
129 void CPbk2NamesListEmptyState::ActivateStateL() |
125 void CPbk2NamesListEmptyState::ActivateStateL() |
130 { |
126 { |
131 AllowCommandsToShowThemselves( ETrue ); |
127 AllowCommandsToShowThemselves( ETrue ); |
132 CPbk2NamesListControl& namesListControl = |
128 |
133 reinterpret_cast<CPbk2NamesListControl&>(CoeControl()); |
129 // hide findbox since there is no contact |
134 if( namesListControl.GetMarkingMode() ) |
|
135 { |
|
136 // If NamesListEmptyState and Marking mode are both active, |
|
137 // the Marking mode should be canceled. |
|
138 iListBox.SetMarkingMode(EFalse); |
|
139 CEikonEnv* eikonEnv = CEikonEnv::Static(); |
|
140 if ( eikonEnv && eikonEnv->AppUiFactory() ) |
|
141 { |
|
142 CEikStatusPane* statusPane = eikonEnv->AppUiFactory()->StatusPane(); |
|
143 if ( statusPane ) |
|
144 { |
|
145 |
|
146 CAknNavigationControlContainer* naviPane = |
|
147 (CAknNavigationControlContainer *)statusPane->ControlL( |
|
148 TUid::Uid(EEikStatusPaneUidNavi)); |
|
149 CAknNavigationDecorator* decorator = naviPane->Top(); |
|
150 naviPane->Pop( decorator ); |
|
151 naviPane->DrawDeferred(); |
|
152 } |
|
153 } |
|
154 } |
|
155 |
|
156 // hide findbox since there is no contact |
|
157 if ( iFindBox && iFindBox->IsVisible() ) |
130 if ( iFindBox && iFindBox->IsVisible() ) |
158 { |
131 { |
159 iFindBox->MakeVisible( EFalse ); |
132 iFindBox->MakeVisible( EFalse ); |
160 } |
133 } |
161 |
134 |
162 } |
135 } |
163 |
136 |
164 // -------------------------------------------------------------------------- |
137 // -------------------------------------------------------------------------- |
165 // CPbk2NamesListEmptyState::DeactivateState |
138 // CPbk2NamesListEmptyState::DeactivateState |
166 // -------------------------------------------------------------------------- |
139 // -------------------------------------------------------------------------- |
167 // |
140 // |
168 void CPbk2NamesListEmptyState::DeactivateState() |
141 void CPbk2NamesListEmptyState::DeactivateState() |
169 { |
142 { |
170 AllowCommandsToShowThemselves( EFalse ); |
143 AllowCommandsToShowThemselves( EFalse ); |
171 |
144 |
172 if ( iFindBox && !iFindBox->IsFocused() ) |
145 if ( iFindBox && !iFindBox->IsFocused() ) |
173 { |
146 { |
174 iFindBox->SetFocus( ETrue ); |
147 iFindBox->SetFocus( ETrue ); |
175 } |
148 } |
176 } |
149 } |
322 // CPbk2NamesListEmptyState::HandleListboxEventL |
295 // CPbk2NamesListEmptyState::HandleListboxEventL |
323 // -------------------------------------------------------------------------- |
296 // -------------------------------------------------------------------------- |
324 // |
297 // |
325 void CPbk2NamesListEmptyState::HandleListboxEventL |
298 void CPbk2NamesListEmptyState::HandleListboxEventL |
326 (TInt aEvent, TInt aListboxIndex, |
299 (TInt aEvent, TInt aListboxIndex, |
327 TBool /*aMantainFocus*/) |
300 TBool /*aMantainFocus*/) |
328 { |
301 { |
329 iListBox.HandleEventL( aEvent, aListboxIndex ); |
302 iListBox.HandleEventL( aEvent, aListboxIndex ); |
330 iParent.DrawDeferred(); |
303 iParent.DrawDeferred(); |
331 } |
304 } |
332 // -------------------------------------------------------------------------- |
305 // -------------------------------------------------------------------------- |
516 // -------------------------------------------------------------------------- |
489 // -------------------------------------------------------------------------- |
517 // |
490 // |
518 MVPbkContactLinkArray* |
491 MVPbkContactLinkArray* |
519 CPbk2NamesListEmptyState::SelectedContactsOrFocusedContactL() const |
492 CPbk2NamesListEmptyState::SelectedContactsOrFocusedContactL() const |
520 { |
493 { |
521 CVPbkContactLinkArray* array = NULL; |
494 CVPbkContactLinkArray* array = NULL; |
522 // my card is showing on empty list, check if the wanted contact is it |
495 // my card is showing on empty list, check if the wanted contact is it |
523 TInt currentItem = iListBox.CurrentItemIndex(); |
496 TInt currentItem = iListBox.CurrentItemIndex(); |
524 // if focused index is command item |
497 // if focused index is command item |
525 if( currentItem < CommandItemCount() ) |
498 if( currentItem < CommandItemCount() ) |
526 { |
499 { |
527 // check if the command is my card ( this search is copied from CommandItemAt - function to avoid const cast) |
500 // check if the command is my card ( this search is copied from CommandItemAt - function to avoid const cast) |
528 // Some of the commands might be disabled. Skip those. |
501 // Some of the commands might be disabled. Skip those. |
529 TInt enabledCount = 0; |
502 TInt enabledCount = 0; |
530 TInt indexOfResult = KErrNotFound; |
503 TInt indexOfResult = KErrNotFound; |
531 for ( TInt n = 0; n < iCommandItems.Count() && indexOfResult == KErrNotFound; ++n ) |
504 for ( TInt n = 0; n < iCommandItems.Count() && indexOfResult == KErrNotFound; ++n ) |
532 { |
505 { |
533 if ( iCommandItems[ n ]->IsEnabled() ) |
506 if ( iCommandItems[ n ]->IsEnabled() ) |
534 { |
507 { |
535 enabledCount++; |
508 enabledCount++; |
536 if ( enabledCount-1 == currentItem ) |
509 if ( enabledCount-1 == currentItem ) |
537 { |
510 { |
538 indexOfResult = n; |
511 indexOfResult = n; |
539 } |
512 } |
540 } |
513 } |
541 } |
514 } |
542 MPbk2UiControlCmdItem* item = iCommandItems[ indexOfResult ]; |
515 MPbk2UiControlCmdItem* item = iCommandItems[ indexOfResult ]; |
543 // check if the command item was a my card |
516 // check if the command item was a my card |
544 if( item->CommandId() == EPbk2CmdOpenMyCard ) |
517 if( item->CommandId() == EPbk2CmdOpenMyCard ) |
545 { |
518 { |
546 // get extension point and my card link |
519 // get extension point and my card link |
547 TAny* object = item->ControlCmdItemExtension( TUid::Uid( KPbk2ControlCmdItemExtensionUID ) ); |
520 TAny* object = item->ControlCmdItemExtension( TUid::Uid( KPbk2ControlCmdItemExtensionUID ) ); |
548 if( object ) |
521 if( object ) |
549 { |
522 { |
550 MPbk2DoubleListboxCmdItemExtension* extension = |
523 MPbk2DoubleListboxCmdItemExtension* extension = |
551 static_cast<MPbk2DoubleListboxCmdItemExtension*>( object ); |
524 static_cast<MPbk2DoubleListboxCmdItemExtension*>( object ); |
552 // if extension exists |
525 // if extension exists |
553 if( extension ) |
526 if( extension ) |
554 { |
527 { |
555 const MVPbkContactLink* link = extension->Link(); |
528 const MVPbkContactLink* link = extension->Link(); |
556 // if link exists, add it to the array |
529 // if link exists, add it to the array |
557 if( link ) |
530 if( link ) |
558 { |
531 { |
559 array = CVPbkContactLinkArray::NewLC(); |
532 array = CVPbkContactLinkArray::NewLC(); |
560 array->AppendL( link->CloneLC() ); |
533 array->AppendL( link->CloneLC() ); |
561 CleanupStack::Pop( 2 ); // array, link |
534 CleanupStack::Pop( 2 ); // array, link |
562 } |
535 } |
563 } |
536 } |
564 } |
537 } |
565 } |
538 } |
566 } |
539 } |
567 return array; |
540 return array; |
568 } |
541 } |
569 |
542 |
570 // -------------------------------------------------------------------------- |
543 // -------------------------------------------------------------------------- |
571 // CPbk2NamesListEmptyState::SelectedContactsIteratorL |
544 // CPbk2NamesListEmptyState::SelectedContactsIteratorL |
572 // -------------------------------------------------------------------------- |
545 // -------------------------------------------------------------------------- |
632 // -------------------------------------------------------------------------- |
605 // -------------------------------------------------------------------------- |
633 // CPbk2NamesListEmptyState::CommandItemCount |
606 // CPbk2NamesListEmptyState::CommandItemCount |
634 // -------------------------------------------------------------------------- |
607 // -------------------------------------------------------------------------- |
635 // |
608 // |
636 TInt CPbk2NamesListEmptyState::CommandItemCount() const |
609 TInt CPbk2NamesListEmptyState::CommandItemCount() const |
637 { |
610 { |
638 // Some of the commands might be disabled. Don't count those. |
611 // Some of the commands might be disabled. Don't count those. |
639 TInt enabledCommandCount = 0; |
612 TInt enabledCommandCount = 0; |
640 for ( TInt n = 0; n < iCommandItems.Count(); ++n ) |
613 for ( TInt n = 0; n < iCommandItems.Count(); ++n ) |
641 { |
614 { |
642 if ( iCommandItems[ n ]->IsEnabled() ) |
615 if ( iCommandItems[ n ]->IsEnabled() ) |
643 { |
616 { |
644 enabledCommandCount++; |
617 enabledCommandCount++; |
645 } |
618 } |
646 } |
619 } |
647 return enabledCommandCount; |
620 return enabledCommandCount; |
648 } |
621 } |
649 |
622 |
650 // -------------------------------------------------------------------------- |
623 // -------------------------------------------------------------------------- |
651 // CPbk2NamesListEmptyState::CommandItemAt |
624 // CPbk2NamesListEmptyState::CommandItemAt |
652 // -------------------------------------------------------------------------- |
625 // -------------------------------------------------------------------------- |
653 // |
626 // |
654 const MPbk2UiControlCmdItem& |
627 const MPbk2UiControlCmdItem& |
655 CPbk2NamesListEmptyState::CommandItemAt( TInt aIndex ) const |
628 CPbk2NamesListEmptyState::CommandItemAt( TInt aIndex ) const |
656 { |
629 { |
657 // Some of the commands might be disabled. Skip those. |
630 // Some of the commands might be disabled. Skip those. |
658 TInt enabledCount = 0; |
631 TInt enabledCount = 0; |
659 TInt indexOfResult = KErrNotFound; |
632 TInt indexOfResult = KErrNotFound; |
660 for ( TInt n = 0; n < iCommandItems.Count()&& indexOfResult == KErrNotFound; ++n ) |
633 for ( TInt n = 0; n < iCommandItems.Count()&& indexOfResult == KErrNotFound; ++n ) |
661 |
634 |
662 { |
635 { |
663 if ( iCommandItems[ n ]->IsEnabled() ) |
636 if ( iCommandItems[ n ]->IsEnabled() ) |
664 { |
637 { |
665 enabledCount++; |
638 enabledCount++; |
666 if ( enabledCount-1 == aIndex ) |
639 if ( enabledCount-1 == aIndex ) |
667 { |
640 { |
668 indexOfResult = n; |
641 indexOfResult = n; |
669 } |
642 } |
670 } |
643 } |
671 } |
644 } |
672 return *iCommandItems[ indexOfResult ]; |
645 return *iCommandItems[ indexOfResult ]; |
673 } |
646 } |
674 |
647 |
675 // -------------------------------------------------------------------------- |
648 // -------------------------------------------------------------------------- |
676 // CPbk2NamesListEmptyState::FocusedCommandItem |
649 // CPbk2NamesListEmptyState::FocusedCommandItem |
677 // -------------------------------------------------------------------------- |
650 // -------------------------------------------------------------------------- |
678 // |
651 // |
679 const MPbk2UiControlCmdItem* |
652 const MPbk2UiControlCmdItem* |
680 CPbk2NamesListEmptyState::FocusedCommandItem() const |
653 CPbk2NamesListEmptyState::FocusedCommandItem() const |
681 { |
654 { |
682 const MPbk2UiControlCmdItem* cmdItem = NULL; |
655 const MPbk2UiControlCmdItem* cmdItem = NULL; |
683 // Is the focus on a command item: |
656 // Is the focus on a command item: |
684 TInt focusListIndex = iListBox.CurrentItemIndex(); |
657 TInt focusListIndex = iListBox.CurrentItemIndex(); |
685 const TInt commandItemCount = CommandItemCount(); |
658 const TInt commandItemCount = CommandItemCount(); |
686 if ( focusListIndex != KErrNotFound && focusListIndex < commandItemCount ) |
659 if ( focusListIndex != KErrNotFound && focusListIndex < commandItemCount ) |
687 { |
660 { |
688 // Yes it's a command item. |
661 // Yes it's a command item. |
689 cmdItem = &CommandItemAt(focusListIndex); |
662 cmdItem = &CommandItemAt(focusListIndex); |
690 } |
663 } |
691 return cmdItem; |
664 return cmdItem; |
692 } |
665 } |
693 |
666 |
694 // -------------------------------------------------------------------------- |
667 // -------------------------------------------------------------------------- |
695 // CPbk2NamesListEmptyState::DeleteCommandItemL |
668 // CPbk2NamesListEmptyState::DeleteCommandItemL |
696 // -------------------------------------------------------------------------- |
669 // -------------------------------------------------------------------------- |
697 // |
670 // |
698 void CPbk2NamesListEmptyState::DeleteCommandItemL( TInt /*aIndex*/ ) |
671 void CPbk2NamesListEmptyState::DeleteCommandItemL( TInt /*aIndex*/ ) |
699 { |
672 { |
700 // ownership & management of iCommandItems is wasted in names list |
673 // ownership & management of iCommandItems is wasted in names list |
701 // control. Do nothing here |
674 // control. Do nothing here |
702 } |
675 } |
703 |
676 |
704 // -------------------------------------------------------------------------- |
677 // -------------------------------------------------------------------------- |
723 |
696 |
724 //No contacts visible in this state |
697 //No contacts visible in this state |
725 TInt pos; // Stores the position of the searched menu item. |
698 TInt pos; // Stores the position of the searched menu item. |
726 // This position is not needed or used anywhere |
699 // This position is not needed or used anywhere |
727 |
700 |
728 if ( aMenuPane->MenuItemExists ( EAknCmdMarkingModeEnter, pos ) ) |
701 if (aMenuPane->MenuItemExists(EAknUnmarkAll, pos)) |
729 { |
702 { |
730 aMenuPane->SetItemDimmed( EAknCmdMarkingModeEnter, ETrue ); |
703 aMenuPane->SetItemDimmed(EAknUnmarkAll, ETrue); |
|
704 } |
|
705 if (aMenuPane->MenuItemExists(EAknMarkAll, pos)) |
|
706 { |
|
707 aMenuPane->SetItemDimmed(EAknMarkAll, ETrue); |
731 } |
708 } |
732 } |
709 } |
733 |
710 |
734 // -------------------------------------------------------------------------- |
711 // -------------------------------------------------------------------------- |
735 // CPbk2NamesListEmptyState::ProcessCommandL |
712 // CPbk2NamesListEmptyState::ProcessCommandL |
965 if ( aVisible ) |
942 if ( aVisible ) |
966 { |
943 { |
967 // ownership not transferred |
944 // ownership not transferred |
968 iListBox.SetListCommands( &iCommandItems ); |
945 iListBox.SetListCommands( &iCommandItems ); |
969 SubscribeCmdItemsVisibility(); |
946 SubscribeCmdItemsVisibility(); |
970 UpdateCommandEnabled( EPbk2CmdRcl, ETrue ); |
947 UpdateCommandEnabled( EPbk2CmdRcl, ETrue ); |
971 UpdateCommandEnabled( EPbk2CmdAddFavourites, EFalse ); |
948 UpdateCommandEnabled( EPbk2CmdAddFavourites, EFalse ); |
972 //MyCard is stored separately and may also contain data |
949 //MyCard is stored separately and may also contain data |
973 UpdateCommandEnabled( EPbk2CmdOpenMyCard, ETrue ); |
950 UpdateCommandEnabled( EPbk2CmdOpenMyCard, ETrue ); |
974 } |
951 } |
975 else |
952 else |
976 { |
953 { |
977 UnsubscribeCmdItemsVisibility(); |
954 UnsubscribeCmdItemsVisibility(); |
983 // -------------------------------------------------------------------------- |
960 // -------------------------------------------------------------------------- |
984 // |
961 // |
985 void CPbk2NamesListEmptyState::CmdItemVisibilityChanged( TInt aCmdItemId, TBool aVisible ) |
962 void CPbk2NamesListEmptyState::CmdItemVisibilityChanged( TInt aCmdItemId, TBool aVisible ) |
986 { |
963 { |
987 TInt cmdItemIndex = FindCommand(aCmdItemId); |
964 TInt cmdItemIndex = FindCommand(aCmdItemId); |
988 TRAP_IGNORE( |
965 TRAP_IGNORE( HandleCommandEventL( |
989 // If command item is changed to be visible, set its hidden selection to ETrue. |
|
990 if( aVisible ) |
|
991 { |
|
992 TInt enableCmdCount = EnabledCommandCount(); |
|
993 TListItemProperties prop( iListBox.ItemDrawer()->Properties(enableCmdCount) ); |
|
994 prop.SetHiddenSelection(aVisible); |
|
995 iListBox.ItemDrawer()->SetPropertiesL(enableCmdCount-1, prop); |
|
996 } |
|
997 |
|
998 HandleCommandEventL( |
|
999 (aVisible ? EItemAdded : EItemRemoved), |
966 (aVisible ? EItemAdded : EItemRemoved), |
1000 cmdItemIndex); |
967 cmdItemIndex) ); |
1001 ); |
|
1002 } |
968 } |
1003 |
969 |
1004 // -------------------------------------------------------------------------- |
970 // -------------------------------------------------------------------------- |
1005 // CPbk2NamesListEmptyState::UpdateCommandEnabled |
971 // CPbk2NamesListEmptyState::UpdateCommandEnabled |
1006 // -------------------------------------------------------------------------- |
972 // -------------------------------------------------------------------------- |