734 if ( !iSearchFieldPointed && FocusableItemPointed() && |
734 if ( !iSearchFieldPointed && FocusableItemPointed() && |
735 aPointerEvent.iType == TPointerEvent::EButton1Up ) |
735 aPointerEvent.iType == TPointerEvent::EButton1Up ) |
736 { |
736 { |
737 // Send selection events based on marking |
737 // Send selection events based on marking |
738 TInt focusIndex = iListBox.CurrentItemIndex(); |
738 TInt focusIndex = iListBox.CurrentItemIndex(); |
|
739 TInt commands = CommandItemCount(); |
739 const TBool markedAfter = iListBox.View()->ItemIsSelected( focusIndex ); |
740 const TBool markedAfter = iListBox.View()->ItemIsSelected( focusIndex ); |
740 |
741 |
741 TPbk2ControlEvent event( TPbk2ControlEvent::EContactSelected ); |
742 TPbk2ControlEvent event( TPbk2ControlEvent::EContactSelected ); |
742 event.iInt = focusIndex; |
743 event.iInt = focusIndex; |
743 if ( !markedAfter ) |
744 if ( !markedAfter ) |
744 { |
745 { |
745 event.iEventType = TPbk2ControlEvent::EContactUnselected; |
746 event.iEventType = TPbk2ControlEvent::EContactUnselected; |
|
747 } |
|
748 else if ( focusIndex < commands) |
|
749 { |
|
750 UnmarkCommands(); |
746 } |
751 } |
747 iEventSender.SendEventToObserversL( event ); |
752 iEventSender.SendEventToObserversL( event ); |
748 |
753 |
749 } |
754 } |
750 |
755 |
1489 // -------------------------------------------------------------------------- |
1494 // -------------------------------------------------------------------------- |
1490 // |
1495 // |
1491 void CPbk2NamesListReadyState::DynInitMenuPaneL( |
1496 void CPbk2NamesListReadyState::DynInitMenuPaneL( |
1492 TInt aResourceId, CEikMenuPane* aMenuPane) const |
1497 TInt aResourceId, CEikMenuPane* aMenuPane) const |
1493 { |
1498 { |
1494 AknSelectionService::HandleMarkableListDynInitMenuPane |
|
1495 (aResourceId, aMenuPane, &iListBox); |
|
1496 |
|
1497 TInt focusedItem = iListBox.View()->CurrentItemIndex(); |
|
1498 TBool markHidden = iListBox.View()->ItemIsSelected( focusedItem ); |
|
1499 TBool unmarkHidden = !iListBox.View()->ItemIsSelected( focusedItem ); |
|
1500 TBool markAllHidden = ( iListBox.Model()->NumberOfItems() == 0 ) || |
|
1501 ( iListBox.SelectionIndexes()->Count() == iListBox.Model()->NumberOfItems() ); |
|
1502 TBool unmarkAllHidden = ( iListBox.Model()->NumberOfItems() == 0 ) || |
|
1503 ( iListBox.SelectionIndexes()->Count() == 0 ); |
|
1504 |
|
1505 TInt position; |
|
1506 if (aMenuPane->MenuItemExists(EAknCmdMark, position)) |
|
1507 { |
|
1508 aMenuPane->SetItemDimmed(EAknCmdMark, markHidden); |
|
1509 } |
|
1510 if (aMenuPane->MenuItemExists(EAknCmdUnmark, position)) |
|
1511 { |
|
1512 aMenuPane->SetItemDimmed(EAknCmdUnmark, unmarkHidden); |
|
1513 } |
|
1514 if (aMenuPane->MenuItemExists(EAknMarkAll, position)) |
|
1515 { |
|
1516 aMenuPane->SetItemDimmed(EAknMarkAll, markAllHidden); |
|
1517 } |
|
1518 if (aMenuPane->MenuItemExists(EAknUnmarkAll, position)) |
|
1519 { |
|
1520 aMenuPane->SetItemDimmed(EAknUnmarkAll, unmarkAllHidden); |
|
1521 } |
|
1522 |
|
1523 // When all contacts are marked in the listbox, the command items are not marked. |
|
1524 // This code snippet dims out the Mark All menu item which is shown since the |
|
1525 // list box cannot differentiate a command and a contact item |
|
1526 |
|
1527 TInt commandItemCount = CommandItemCount(); |
1499 TInt commandItemCount = CommandItemCount(); |
1528 |
1500 |
1529 |
1501 // Stores the position of the searched menu item. |
1530 if ((iListBox.SelectionIndexes()->Count() + commandItemCount ) == iListBox.Model()->NumberOfItems()) |
1502 // This position is not needed or used anywhere |
1531 { |
1503 TInt pos; |
1532 TInt i; // Stores the position of the searched menu item. |
1504 |
1533 // This position is not needed or used anywhere |
1505 if ((iListBox.SelectionIndexes()->Count() + commandItemCount ) |
1534 if (aMenuPane->MenuItemExists(EAknMarkAll, i)) |
1506 == iListBox.Model()->NumberOfItems()) |
1535 { |
1507 { |
1536 aMenuPane->SetItemDimmed(EAknMarkAll, ETrue); |
1508 if (aMenuPane->MenuItemExists( EAknCmdMarkingModeEnter, pos ) ) |
1537 } |
1509 { |
1538 } |
1510 aMenuPane->SetItemDimmed( EAknCmdMarkingModeEnter, ETrue ); |
1539 |
1511 } |
1540 // If there's any, command items are always placed at the top of the list box. |
1512 } |
1541 // By comparing the list box current item index with the command item count, we are trying to find out |
|
1542 // if the current focused item is command item or not. |
|
1543 |
1513 |
1544 } |
1514 } |
1545 |
1515 |
1546 // -------------------------------------------------------------------------- |
1516 // -------------------------------------------------------------------------- |
1547 // CPbk2NamesListReadyState::ProcessCommandL |
1517 // CPbk2NamesListReadyState::ProcessCommandL |
2070 // -------------------------------------------------------------------------- |
2040 // -------------------------------------------------------------------------- |
2071 // |
2041 // |
2072 void CPbk2NamesListReadyState::CmdItemVisibilityChanged( TInt aCmdItemId, TBool aVisible ) |
2042 void CPbk2NamesListReadyState::CmdItemVisibilityChanged( TInt aCmdItemId, TBool aVisible ) |
2073 { |
2043 { |
2074 TInt cmdItemIndex = FindCommand(aCmdItemId); |
2044 TInt cmdItemIndex = FindCommand(aCmdItemId); |
2075 TRAP_IGNORE( HandleCommandEventL( |
2045 TInt cmdListBoxIndex = EnabledCommandCount(); |
2076 (aVisible ? EItemAdded : EItemRemoved), |
2046 if( aVisible ) |
2077 cmdItemIndex) ); |
2047 { |
|
2048 cmdListBoxIndex--; |
|
2049 } |
|
2050 // Update the HiddenSelection property of the command items. |
|
2051 TListItemProperties prop( iListBox.ItemDrawer()->Properties(cmdListBoxIndex) ); |
|
2052 prop.SetHiddenSelection(aVisible); |
|
2053 |
|
2054 TRAP_IGNORE( |
|
2055 iListBox.ItemDrawer()->SetPropertiesL(cmdListBoxIndex, prop); |
|
2056 |
|
2057 HandleCommandEventL( |
|
2058 (aVisible ? EItemAdded : EItemRemoved), |
|
2059 cmdItemIndex); |
|
2060 ); |
2078 } |
2061 } |
2079 |
2062 |
2080 // -------------------------------------------------------------------------- |
2063 // -------------------------------------------------------------------------- |
2081 // CPbk2NamesListReadyState::RestoreMarkedContactsL |
2064 // CPbk2NamesListReadyState::RestoreMarkedContactsL |
2082 // Marks specified contacts in the listbox. |
2065 // Marks specified contacts in the listbox. |