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