appinstaller/AppMngr2/src/appmngr2listcontainer.cpp
branchRCL_3
changeset 65 7333d7932ef7
parent 15 51c0f5edf5ef
child 66 8b7f4e561641
equal deleted inserted replaced
62:5cc91383ab1e 65:7333d7932ef7
     1 /*
     1 /*
     2 * Copyright (c) 2008-2010 Nokia Corporation and/or its subsidiary(-ies).
     2 * Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     4 * This component and the accompanying materials are made available
     5 * under the terms of "Eclipse Public License v1.0"
     5 * under the terms of "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
    62 // ---------------------------------------------------------------------------
    62 // ---------------------------------------------------------------------------
    63 //
    63 //
    64 TKeyResponse CAppMngr2ListContainer::OfferKeyEventL(
    64 TKeyResponse CAppMngr2ListContainer::OfferKeyEventL(
    65         const TKeyEvent& aKeyEvent, TEventCode aType )
    65         const TKeyEvent& aKeyEvent, TEventCode aType )
    66     {
    66     {
    67     TKeyResponse response = iListBox->OfferKeyEventL( aKeyEvent, aType );
    67     TKeyResponse response = iListBox->OfferKeyEventL( aKeyEvent, aType ); 
    68     if( aKeyEvent.iCode == EKeyUpArrow || aKeyEvent.iCode == EKeyDownArrow )
    68     if( aKeyEvent.iCode == EKeyUpArrow || aKeyEvent.iCode == EKeyDownArrow )
    69         {
    69         {
    70         iView.UpdateMiddleSoftkeyCommandL();
    70         iView.UpdateMiddleSoftkeyCommandL();
    71         iView.CurrentItemSelectedByUser( ETrue );
    71         iView.CurrentItemSelectedByUser( ETrue );
    72         }
    72         }
   176 // ---------------------------------------------------------------------------
   176 // ---------------------------------------------------------------------------
   177 //
   177 //
   178 void CAppMngr2ListContainer::RefreshL( TBool aPreserveSelectedItem,
   178 void CAppMngr2ListContainer::RefreshL( TBool aPreserveSelectedItem,
   179         TBool& aSelectedItemChanged, TInt aMoreRefreshesExpected )
   179         TBool& aSelectedItemChanged, TInt aMoreRefreshesExpected )
   180     {
   180     {
   181     FLOG( "CAppMngr2ListContainer::RefreshL( %d %d %d ) begin",
   181     FLOG( "CAppMngr2ListContainer::RefreshL( %d )", aPreserveSelectedItem );
   182             aPreserveSelectedItem, aSelectedItemChanged, aMoreRefreshesExpected );
   182     
   183 
       
   184     // Record the item text of the current item if selection must be preserved in
   183     // Record the item text of the current item if selection must be preserved in
   185     // the current item. The item text is used to identify the item later, so that
   184     // the current item. The item text is used to identify the item later, so that
   186     // it can be selected again.
   185     // it can be selected again.
   187     HBufC* itemText = NULL;
   186     HBufC* itemText = NULL;
   188     TInt currentItemIndex = iListBox->CurrentItemIndex();
   187     TInt currentItemIndex = iListBox->CurrentItemIndex();
   194 
   193 
   195     SetEmptyTextL( aMoreRefreshesExpected );    // defines empty text in first refresh
   194     SetEmptyTextL( aMoreRefreshesExpected );    // defines empty text in first refresh
   196     CreateItemArrayL();                         // resets the item array
   195     CreateItemArrayL();                         // resets the item array
   197     PopulateItemArrayL();                       // fills in new items
   196     PopulateItemArrayL();                       // fills in new items
   198     iListBox->HandleItemAdditionL();            // re-calculates size and scrollbar
   197     iListBox->HandleItemAdditionL();            // re-calculates size and scrollbar
   199 
   198     
   200     // If selection must be preserved, search the item in new item array
   199     // If selection must be preserved, search the item in new item array
   201     // and select it again. Make sure to delete itemText if it was allocated.
   200     // and select it again. Make sure to delete itemText if it was allocated.
   202     TBool currentItemSet = EFalse;
   201     TBool currentItemSet = EFalse;
   203     TInt itemCount = iItemArray->Count();
   202     TInt itemCount = iItemArray->Count();
   204     if( itemText )
   203     if( itemText )
   211                 currentItemSet = ETrue;
   210                 currentItemSet = ETrue;
   212                 }
   211                 }
   213             }
   212             }
   214         CleanupStack::PopAndDestroy( itemText );
   213         CleanupStack::PopAndDestroy( itemText );
   215         }
   214         }
   216 
   215     
   217     // If item is not found (it may have been deleted), then tell to the
   216     // If item is not found (it may have been deleted), then tell to the
   218     // caller that the selected item was changed and select another item
   217     // caller that the selected item was changed and select another item
   219     // from the same row number than the previously selected item.
   218     // from the same row number than the previously selected item.
   220     aSelectedItemChanged = !currentItemSet;
   219     aSelectedItemChanged = !currentItemSet;
   221     if( aSelectedItemChanged )
   220     if( aSelectedItemChanged )
   231         if( currentItemIndex != iListBox->CurrentItemIndex() )
   230         if( currentItemIndex != iListBox->CurrentItemIndex() )
   232             {
   231             {
   233             iListBox->SetCurrentItemIndex( currentItemIndex );
   232             iListBox->SetCurrentItemIndex( currentItemIndex );
   234             }
   233             }
   235         }
   234         }
   236 
       
   237     FLOG( "CAppMngr2ListContainer::RefreshL() end" );
       
   238     }
   235     }
   239 
   236 
   240 // ---------------------------------------------------------------------------
   237 // ---------------------------------------------------------------------------
   241 // CAppMngr2ListContainer::ConstructL()
   238 // CAppMngr2ListContainer::ConstructL()
   242 // ---------------------------------------------------------------------------
   239 // ---------------------------------------------------------------------------
   247     SetRect( aRect );
   244     SetRect( aRect );
   248     iListBox = new (ELeave) CAknDoubleLargeStyleListBox;
   245     iListBox = new (ELeave) CAknDoubleLargeStyleListBox;
   249     iListBox->SetContainerWindowL( *this );
   246     iListBox->SetContainerWindowL( *this );
   250     iListBox->ConstructL( this, EAknListBoxSelectionList );
   247     iListBox->ConstructL( this, EAknListBoxSelectionList );
   251     iListBox->SetListBoxObserver( this );
   248     iListBox->SetListBoxObserver( this );
   252 
   249     
   253     // Dont display default "(no data)" empty text
   250     // Dont display default "(no data)" empty text
   254     iListBox->View()->SetListEmptyTextL( KNullDesC );
   251     iListBox->View()->SetListEmptyTextL( KNullDesC );
   255 
   252 
   256     LoadIconsL();
   253     LoadIconsL();
   257     CreateItemArrayL();
   254     CreateItemArrayL();
   258     PopulateItemArrayL();
   255     PopulateItemArrayL();
   259 
   256     
   260     iListBox->CreateScrollBarFrameL();
   257     iListBox->CreateScrollBarFrameL();
   261     iListBox->ScrollBarFrame()->SetScrollBarVisibilityL(
   258     iListBox->ScrollBarFrame()->SetScrollBarVisibilityL(
   262             CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto );
   259             CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto );
   263     iListBox->SetRect( aRect.Size() );
   260     iListBox->SetRect( aRect.Size() );
   264 
   261     
   265     // Enable marquee effect
   262     // Enable marquee effect
   266     iListBox->ItemDrawer()->ColumnData()->EnableMarqueeL( ETrue );
   263     iListBox->ItemDrawer()->ColumnData()->EnableMarqueeL( ETrue );
   267     }
   264     }
   268 
   265 
   269 // ---------------------------------------------------------------------------
   266 // ---------------------------------------------------------------------------
   312 // ---------------------------------------------------------------------------
   309 // ---------------------------------------------------------------------------
   313 //
   310 //
   314 void CAppMngr2ListContainer::PopulateItemArrayL()
   311 void CAppMngr2ListContainer::PopulateItemArrayL()
   315     {
   312     {
   316     FLOG( "CAppMngr2ListContainer::PopulateItemArrayL()" );
   313     FLOG( "CAppMngr2ListContainer::PopulateItemArrayL()" );
   317 
   314     
   318     CArrayPtr<CGulIcon>* iconArray = iListBox->ItemDrawer()->ColumnData()->IconArray();
   315     CArrayPtr<CGulIcon>* iconArray = iListBox->ItemDrawer()->ColumnData()->IconArray();
   319     DeleteItemSpecificIcons( *iconArray );
   316     DeleteItemSpecificIcons( *iconArray );
   320 
   317     
   321     TInt count = ItemCount();
   318     TInt count = ItemCount();
   322     for( TInt index = 0; index < count; index++ )
   319     for( TInt index = 0; index < count; index++ )
   323         {
   320         {
   324         const CAppMngr2InfoBase& appInfo = ItemInfo( index );
   321         const CAppMngr2InfoBase& appInfo = ItemInfo( index );
   325 
   322 
   330         // Get icon indexes that plugin loaded in LoadIconsL()
   327         // Get icon indexes that plugin loaded in LoadIconsL()
   331         TInt iconIndexBase;
   328         TInt iconIndexBase;
   332         TInt iconIndexMax;
   329         TInt iconIndexMax;
   333         Model().GetIconIndexesL( appInfo.Runtime().RuntimeUid(),
   330         Model().GetIconIndexesL( appInfo.Runtime().RuntimeUid(),
   334                 iconIndexBase, iconIndexMax );
   331                 iconIndexBase, iconIndexMax );
   335 
   332         
   336         // Get list icon index from plugin
   333         // Get list icon index from plugin
   337         TInt iconIndex = appInfo.IconIndex();
   334         TInt iconIndex = appInfo.IconIndex();
   338 
   335         
   339         // Convert index into the range of 0 .. (icons - 1)
   336         // Convert index into the range of 0 .. (icons - 1)
   340         if( iconIndex == EAppMngr2UseSpecificIcon )
   337         if( iconIndex == EAppMngr2UseSpecificIcon )
   341             {
   338             {
   342             CGulIcon* icon = NULL;
   339             CGulIcon* icon = NULL;
   343             TRAP_IGNORE( icon = appInfo.SpecificIconL() );
   340             TRAP_IGNORE( icon = appInfo.SpecificIconL() );
   367             if( iconIndex < iconIndexBase || iconIndex >= iconIndexMax )
   364             if( iconIndex < iconIndexBase || iconIndex >= iconIndexMax )
   368                 {
   365                 {
   369                 iconIndex = EAppMngr2IconIndex_QgnPropUnknown;
   366                 iconIndex = EAppMngr2IconIndex_QgnPropUnknown;
   370                 }
   367                 }
   371             }
   368             }
   372         // Sanity check - index must be in range, otherwise list panics
   369         // Sanity check - index must be in range, otherwise list panics 
   373         if( iconIndex < 0 || iconIndex >= iconArray->Count() )
   370         if( iconIndex < 0 || iconIndex >= iconArray->Count() )
   374             {
   371             {
   375             iconIndex = EAppMngr2IconIndex_QgnPropUnknown;
   372             iconIndex = EAppMngr2IconIndex_QgnPropUnknown;
   376             }
   373             }
   377 
   374 
   378         // Get indicator icon index from plugin
   375         // Get indicator icon index from plugin
   379         TInt indIconIndex = appInfo.IndicatorIconIndex();
   376         TInt indIconIndex = appInfo.IndicatorIconIndex();
   380 
   377         
   381         // Convert indicator icon index into the range of 0 .. (icons-1) or
   378         // Convert indicator icon index into the range of 0 .. (icons-1) or
   382         // leave special value EAppMngr2NoIndicatorIcon in it
   379         // leave special value EAppMngr2NoIndicatorIcon in it
   383         if( indIconIndex == EAppMngr2UseSpecificIcon )
   380         if( indIconIndex == EAppMngr2UseSpecificIcon )
   384             {
   381             {
   385             CGulIcon* icon = NULL;
   382             CGulIcon* icon = NULL;