appinstaller/AppMngr2/src/appmngr2packagesview.cpp
changeset 0 ba25891c3a9e
equal deleted inserted replaced
-1:000000000000 0:ba25891c3a9e
       
     1 /*
       
     2 * Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:   List view that shows installation files
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include "appmngr2packagesview.h"       // CAppMngr2PackagesView
       
    20 #include "appmngr2packagescontainer.h"  // CAppMngr2PackagesContainer
       
    21 #include <appmngr2infobase.h>           // CAppMngr2InfoBase
       
    22 #include <appmngr2debugutils.h>         // FLOG macros
       
    23 #include <eikmenub.h>                   // CEikMenuPane
       
    24 #include <akntitle.h>                   // CAknTitlePane
       
    25 #include <StringLoader.h>               // StringLoader
       
    26 #include <appmngr2common.hrh>           // Generic command IDs
       
    27 #include <avkon.hrh>                    // EAknSoftkeyOk
       
    28 #include <appmngr2.rsg>                 // Resource IDs
       
    29 
       
    30 
       
    31 // ======== MEMBER FUNCTIONS ========
       
    32 
       
    33 // ---------------------------------------------------------------------------
       
    34 // CAppMngr2PackagesView::NewL()
       
    35 // ---------------------------------------------------------------------------
       
    36 //
       
    37 CAppMngr2PackagesView* CAppMngr2PackagesView::NewL()
       
    38     {
       
    39     CAppMngr2PackagesView* self = new (ELeave) CAppMngr2PackagesView;
       
    40     CleanupStack::PushL( self );
       
    41     self->ConstructL();
       
    42     CleanupStack::Pop( self );
       
    43     return self;
       
    44     }
       
    45 
       
    46 // ---------------------------------------------------------------------------
       
    47 // CAppMngr2PackagesView::~CAppMngr2PackagesView
       
    48 // ---------------------------------------------------------------------------
       
    49 //
       
    50 CAppMngr2PackagesView::~CAppMngr2PackagesView()
       
    51     {
       
    52     FLOG( "CAppMngr2PackagesView::~CAppMngr2PackagesView" );
       
    53     }
       
    54 
       
    55 // ---------------------------------------------------------------------------
       
    56 // CAppMngr2PackagesView::Id()
       
    57 // ---------------------------------------------------------------------------
       
    58 //
       
    59 TUid CAppMngr2PackagesView::Id() const
       
    60     {
       
    61     return KPackagesViewId;
       
    62     }
       
    63 
       
    64 // ---------------------------------------------------------------------------
       
    65 // CAppMngr2PackagesView::HandleCommandL()
       
    66 // ---------------------------------------------------------------------------
       
    67 //
       
    68 void CAppMngr2PackagesView::HandleCommandL( TInt aCommand )
       
    69     {
       
    70     FLOG( "CAppMngr2PackagesView::HandleCommandL( %d )", aCommand );
       
    71     switch( aCommand )
       
    72         {
       
    73         case EAknSoftkeyOk:
       
    74             iContainer->HandleGenericCommandL( EAppMngr2CmdInstall );
       
    75             break;
       
    76 
       
    77         default:
       
    78             CAppMngr2ListView::HandleCommandL( aCommand );
       
    79             break;
       
    80         }
       
    81     }
       
    82 
       
    83 // ---------------------------------------------------------------------------
       
    84 // CAppMngr2PackagesView::DynInitMenuPaneL()
       
    85 // ---------------------------------------------------------------------------
       
    86 //
       
    87 void CAppMngr2PackagesView::DynInitMenuPaneL( TInt aResourceId,
       
    88         CEikMenuPane* aMenuPane )
       
    89     {
       
    90     CAppMngr2ListView::DynInitMenuPaneL( aResourceId, aMenuPane );
       
    91     
       
    92     if( aResourceId == R_APPMNGR2_PACKAGES_MENU )
       
    93         {
       
    94         if( iContainer == NULL || iContainer->IsListEmpty() )
       
    95             {
       
    96             aMenuPane->SetItemDimmed( EAppMngr2CmdInstall, ETrue );
       
    97             aMenuPane->SetItemDimmed( EAppMngr2CmdViewDetails, ETrue );
       
    98             aMenuPane->SetItemDimmed( EAppMngr2CmdRemove, ETrue );
       
    99             }
       
   100         else
       
   101             {
       
   102             CAppMngr2InfoBase& currentItem = iContainer->CurrentItem();
       
   103             if( !currentItem.SupportsGenericCommand( EAppMngr2CmdInstall ) )
       
   104                 {
       
   105                 aMenuPane->SetItemDimmed( EAppMngr2CmdInstall, ETrue );
       
   106                 }
       
   107             if( !currentItem.SupportsGenericCommand( EAppMngr2CmdViewDetails ) )
       
   108                 {
       
   109                 aMenuPane->SetItemDimmed( EAppMngr2CmdViewDetails, ETrue );
       
   110                 }
       
   111             if( !currentItem.SupportsGenericCommand( EAppMngr2CmdRemove ) )
       
   112                 {
       
   113                 aMenuPane->SetItemDimmed( EAppMngr2CmdRemove, ETrue );
       
   114                 }
       
   115             AddDynamicMenuItemsL( currentItem, aMenuPane );
       
   116             }
       
   117         }
       
   118     }
       
   119 
       
   120 // ---------------------------------------------------------------------------
       
   121 // CAppMngr2PackagesView::CreateContainerL()
       
   122 // ---------------------------------------------------------------------------
       
   123 //
       
   124 CAppMngr2ListContainer* CAppMngr2PackagesView::CreateContainerL()
       
   125     {
       
   126     return CAppMngr2PackagesContainer::NewL( *this );
       
   127     }
       
   128 
       
   129 // ---------------------------------------------------------------------------
       
   130 // CAppMngr2PackagesView::SetDefaultMiddleSoftkeyCommandL()
       
   131 // ---------------------------------------------------------------------------
       
   132 //
       
   133 void CAppMngr2PackagesView::SetDefaultMiddleSoftkeyCommandL()
       
   134     {
       
   135     if( iContainer && !iContainer->IsListEmpty() )
       
   136         {
       
   137         SetMiddleSoftkeyCommandL( R_AM_MSK_INSTALL, EAppMngr2CmdInstall );
       
   138         }
       
   139     // else the list is empty, and also the MSK is empty
       
   140     }
       
   141 
       
   142 // ---------------------------------------------------------------------------
       
   143 // CAppMngr2PackagesView::SetTitleL()
       
   144 // ---------------------------------------------------------------------------
       
   145 //
       
   146 void CAppMngr2PackagesView::SetTitleL( CAknTitlePane& aTitlePane )
       
   147     {
       
   148     HBufC* title = StringLoader::LoadLC( R_AM_TITLE_NOT_INSTALLED );
       
   149     aTitlePane.SetTextL( *title );
       
   150     CleanupStack::PopAndDestroy( title );
       
   151     }
       
   152 
       
   153 // ---------------------------------------------------------------------------
       
   154 // CAppMngr2PackagesView::CAppMngr2PackagesView()
       
   155 // ---------------------------------------------------------------------------
       
   156 //
       
   157 CAppMngr2PackagesView::CAppMngr2PackagesView() : CAppMngr2ListView()
       
   158     {
       
   159     FLOG( "CAppMngr2PackagesView::CAppMngr2PackagesView" );
       
   160     }
       
   161 
       
   162 // ---------------------------------------------------------------------------
       
   163 // CAppMngr2PackagesView::ConstructL()
       
   164 // ---------------------------------------------------------------------------
       
   165 //
       
   166 void CAppMngr2PackagesView::ConstructL()
       
   167     {
       
   168     CAppMngr2ListView::ConstructL( R_APPMNGR2_PACKAGES_VIEW );
       
   169     }
       
   170