1494 // -------------------------------------------------------------------------- |
1494 // -------------------------------------------------------------------------- |
1495 // |
1495 // |
1496 void CPbk2NamesListReadyState::DynInitMenuPaneL( |
1496 void CPbk2NamesListReadyState::DynInitMenuPaneL( |
1497 TInt aResourceId, CEikMenuPane* aMenuPane) const |
1497 TInt aResourceId, CEikMenuPane* aMenuPane) const |
1498 { |
1498 { |
|
1499 AknSelectionService::HandleMarkableListDynInitMenuPane |
|
1500 (aResourceId, aMenuPane, &iListBox); |
|
1501 |
|
1502 TInt focusedItem = iListBox.View()->CurrentItemIndex(); |
|
1503 TBool markHidden = iListBox.View()->ItemIsSelected( focusedItem ); |
|
1504 TBool unmarkHidden = !iListBox.View()->ItemIsSelected( focusedItem ); |
|
1505 TBool markAllHidden = ( iListBox.Model()->NumberOfItems() == 0 ) || |
|
1506 ( iListBox.SelectionIndexes()->Count() == iListBox.Model()->NumberOfItems() ); |
|
1507 TBool unmarkAllHidden = ( iListBox.Model()->NumberOfItems() == 0 ) || |
|
1508 ( iListBox.SelectionIndexes()->Count() == 0 ); |
|
1509 |
|
1510 TInt position; |
|
1511 if (aMenuPane->MenuItemExists(EAknCmdMark, position)) |
|
1512 { |
|
1513 aMenuPane->SetItemDimmed(EAknCmdMark, markHidden); |
|
1514 } |
|
1515 if (aMenuPane->MenuItemExists(EAknCmdUnmark, position)) |
|
1516 { |
|
1517 aMenuPane->SetItemDimmed(EAknCmdUnmark, unmarkHidden); |
|
1518 } |
|
1519 if (aMenuPane->MenuItemExists(EAknMarkAll, position)) |
|
1520 { |
|
1521 aMenuPane->SetItemDimmed(EAknMarkAll, markAllHidden); |
|
1522 } |
|
1523 if (aMenuPane->MenuItemExists(EAknUnmarkAll, position)) |
|
1524 { |
|
1525 aMenuPane->SetItemDimmed(EAknUnmarkAll, unmarkAllHidden); |
|
1526 } |
|
1527 |
|
1528 // When all contacts are marked in the listbox, the command items are not marked. |
|
1529 // This code snippet dims out the Mark All menu item which is shown since the |
|
1530 // list box cannot differentiate a command and a contact item |
|
1531 |
1499 TInt commandItemCount = CommandItemCount(); |
1532 TInt commandItemCount = CommandItemCount(); |
1500 |
1533 |
1501 // Stores the position of the searched menu item. |
1534 |
1502 // This position is not needed or used anywhere |
1535 if ((iListBox.SelectionIndexes()->Count() + commandItemCount ) == iListBox.Model()->NumberOfItems()) |
1503 TInt pos; |
1536 { |
1504 |
1537 TInt i; // Stores the position of the searched menu item. |
1505 if ((iListBox.SelectionIndexes()->Count() + commandItemCount ) |
1538 // This position is not needed or used anywhere |
1506 == iListBox.Model()->NumberOfItems()) |
1539 if (aMenuPane->MenuItemExists(EAknMarkAll, i)) |
1507 { |
1540 { |
1508 if (aMenuPane->MenuItemExists( EAknCmdMarkingModeEnter, pos ) ) |
1541 aMenuPane->SetItemDimmed(EAknMarkAll, ETrue); |
1509 { |
1542 } |
1510 aMenuPane->SetItemDimmed( EAknCmdMarkingModeEnter, ETrue ); |
1543 } |
1511 } |
1544 |
1512 } |
1545 // If there's any, command items are always placed at the top of the list box. |
|
1546 // By comparing the list box current item index with the command item count, we are trying to find out |
|
1547 // if the current focused item is command item or not. |
1513 |
1548 |
1514 } |
1549 } |
1515 |
1550 |
1516 // -------------------------------------------------------------------------- |
1551 // -------------------------------------------------------------------------- |
1517 // CPbk2NamesListReadyState::ProcessCommandL |
1552 // CPbk2NamesListReadyState::ProcessCommandL |
1894 |
1929 |
1895 // Markings must be checked before HandleItemAdditionL or |
1930 // Markings must be checked before HandleItemAdditionL or |
1896 // HandleItemRemovalL because they reset markings |
1931 // HandleItemRemovalL because they reset markings |
1897 TBool marked = ContactsMarked(); |
1932 TBool marked = ContactsMarked(); |
1898 |
1933 |
1899 // Handle list box changes |
1934 // Promotion item "Add to favourites" and "My card" should be visible, |
1900 // Promotion item "Add to favourites" should not be visible if top view is |
1935 // the conditions are as following: |
1901 // not base view (iViewStack.Level() !== 0). Remote search may be shown when there |
1936 // 1. Top view is base view (iViewStack.Level() == 0). |
1902 // is text entered in find box. MyCard enabled similarly as add favorites. |
1937 // 2. There is no text entered in find box. |
1903 TBool addFavoOk = iViewStack.Level() == 0 && !(iFindBox && iFindBox->TextLength()); |
1938 // 3. There is text entered in find box, but the text is space. |
1904 UpdateCommandEnabled( EPbk2CmdAddFavourites, addFavoOk ); |
1939 // When promotion item "Add to favourites" and "My card" are visible, |
1905 UpdateCommandEnabled( EPbk2CmdRcl, !addFavoOk ); |
1940 // remote search should not be shown. |
1906 UpdateCommandEnabled( EPbk2CmdOpenMyCard, addFavoOk ); |
1941 TBool showFavAndMyCard = ETrue; |
|
1942 if ( iFindBox ) |
|
1943 { |
|
1944 RBuf searchText; |
|
1945 searchText.CreateL ( iFindBox->TextLength() ); |
|
1946 iFindBox->GetSearchText( searchText ); |
|
1947 CleanupClosePushL( searchText ); |
|
1948 searchText.TrimLeft(); |
|
1949 if ( searchText.Length() != 0 ) |
|
1950 { |
|
1951 showFavAndMyCard = EFalse; |
|
1952 } |
|
1953 CleanupStack::PopAndDestroy( &searchText ); |
|
1954 } |
|
1955 if ( iViewStack.Level() != 0 ) |
|
1956 { |
|
1957 showFavAndMyCard = EFalse; |
|
1958 } |
|
1959 |
|
1960 // Update the list box. |
|
1961 UpdateCommandEnabled( EPbk2CmdAddFavourites, showFavAndMyCard ); |
|
1962 UpdateCommandEnabled( EPbk2CmdRcl, !showFavAndMyCard ); |
|
1963 UpdateCommandEnabled( EPbk2CmdOpenMyCard, showFavAndMyCard ); |
1907 |
1964 |
1908 if ( countAfter > countBefore ) //count does not contain command items |
1965 if ( countAfter > countBefore ) //count does not contain command items |
1909 { |
1966 { |
1910 iListBox.HandleItemAdditionL(); |
1967 iListBox.HandleItemAdditionL(); |
1911 } |
1968 } |
2040 // -------------------------------------------------------------------------- |
2097 // -------------------------------------------------------------------------- |
2041 // |
2098 // |
2042 void CPbk2NamesListReadyState::CmdItemVisibilityChanged( TInt aCmdItemId, TBool aVisible ) |
2099 void CPbk2NamesListReadyState::CmdItemVisibilityChanged( TInt aCmdItemId, TBool aVisible ) |
2043 { |
2100 { |
2044 TInt cmdItemIndex = FindCommand(aCmdItemId); |
2101 TInt cmdItemIndex = FindCommand(aCmdItemId); |
2045 TInt cmdListBoxIndex = EnabledCommandCount(); |
2102 TRAP_IGNORE( HandleCommandEventL( |
2046 if( aVisible ) |
2103 (aVisible ? EItemAdded : EItemRemoved), |
2047 { |
2104 cmdItemIndex) ); |
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 ); |
|
2061 } |
2105 } |
2062 |
2106 |
2063 // -------------------------------------------------------------------------- |
2107 // -------------------------------------------------------------------------- |
2064 // CPbk2NamesListReadyState::RestoreMarkedContactsL |
2108 // CPbk2NamesListReadyState::RestoreMarkedContactsL |
2065 // Marks specified contacts in the listbox. |
2109 // Marks specified contacts in the listbox. |
2101 const MVPbkContactBookmarkCollection& aSelectedItems ) |
2145 const MVPbkContactBookmarkCollection& aSelectedItems ) |
2102 { |
2146 { |
2103 PBK2_DEBUG_PRINT(PBK2_DEBUG_STRING |
2147 PBK2_DEBUG_PRINT(PBK2_DEBUG_STRING |
2104 ("CPbk2NamesListReadyState::RestoreMarkedItemsL: %d items"), |
2148 ("CPbk2NamesListReadyState::RestoreMarkedItemsL: %d items"), |
2105 aSelectedItems.Count() ); |
2149 aSelectedItems.Count() ); |
2106 |
2150 |
|
2151 DisableRedrawEnablePushL(); |
|
2152 iListBox.ClearSelection(); |
2107 const TInt count = aSelectedItems.Count(); |
2153 const TInt count = aSelectedItems.Count(); |
2108 if ( count > 0 ) |
2154 for ( TInt i = 0; i < count; ++i ) |
2109 { |
2155 { |
2110 CListBoxView::CSelectionIndexArray* updateSelections = |
2156 TInt index = iViewStack.IndexOfBookmarkL( aSelectedItems.At( i ) ) + CommandItemCount(); |
2111 new(ELeave) CArrayFixFlat<TInt>( count ); |
2157 if ( index >= 0 ) |
2112 CleanupStack::PushL( updateSelections ); |
2158 { |
2113 |
2159 iListBox.View()->SelectItemL( index ); |
2114 // Get the index of each selected item. If one of items could not be found, break. |
2160 } |
2115 for ( TInt i = 0; i < count; ++i ) |
2161 } |
2116 { |
2162 CleanupStack::PopAndDestroy(); // DisableRedrawEnablePushL |
2117 TInt index = iViewStack.IndexOfBookmarkL( aSelectedItems.At( i ) ) + CommandItemCount(); |
|
2118 if ( index >= 0 ) |
|
2119 { |
|
2120 updateSelections->AppendL( index ); |
|
2121 } |
|
2122 else |
|
2123 { |
|
2124 break; |
|
2125 } |
|
2126 } |
|
2127 |
|
2128 // If all the selected items can be found in iViewStack, update the list box. |
|
2129 // The list box will change nothing if some of selected items are not found in iViewStack. |
|
2130 if ( updateSelections->Count() == count ) |
|
2131 { |
|
2132 DisableRedrawEnablePushL(); |
|
2133 iListBox.ClearSelection(); |
|
2134 iListBox.SetSelectionIndexesL( updateSelections ); |
|
2135 CleanupStack::PopAndDestroy(); // DisableRedrawEnablePushL |
|
2136 } |
|
2137 |
|
2138 CleanupStack::PopAndDestroy( updateSelections ); // Destroy updateSelections |
|
2139 } |
|
2140 } |
2163 } |
2141 |
2164 |
2142 // -------------------------------------------------------------------------- |
2165 // -------------------------------------------------------------------------- |
2143 // CPbk2NamesListReadyState::DisableRedrawEnablePushL |
2166 // CPbk2NamesListReadyState::DisableRedrawEnablePushL |
2144 // -------------------------------------------------------------------------- |
2167 // -------------------------------------------------------------------------- |