appinstaller/AppMngr2/src/appmngr2installedview.cpp
changeset 80 9dcba1ee99f7
parent 77 d1838696558c
equal deleted inserted replaced
77:d1838696558c 80:9dcba1ee99f7
     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 installed applications
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include "appmngr2installedview.h"      // CAppMngr2InstalledView
       
    20 #include "appmngr2installedcontainer.h" // CAppMngr2InstalledContainer
       
    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 // CAppMngr2InstalledView::NewL
       
    35 // ---------------------------------------------------------------------------
       
    36 //
       
    37 CAppMngr2InstalledView* CAppMngr2InstalledView::NewL()
       
    38     {
       
    39     CAppMngr2InstalledView* self = new (ELeave) CAppMngr2InstalledView;
       
    40     CleanupStack::PushL( self );
       
    41     self->ConstructL();
       
    42     CleanupStack::Pop( self );
       
    43     return self;
       
    44     }
       
    45 
       
    46 // ---------------------------------------------------------------------------
       
    47 // CAppMngr2InstalledView::~CAppMngr2InstalledView
       
    48 // ---------------------------------------------------------------------------
       
    49 //
       
    50 CAppMngr2InstalledView::~CAppMngr2InstalledView()
       
    51     {
       
    52     FLOG( "CAppMngr2InstalledView::~CAppMngr2InstalledView" );
       
    53     }
       
    54 
       
    55 // ---------------------------------------------------------------------------
       
    56 // CAppMngr2InstalledView::Id()
       
    57 // ---------------------------------------------------------------------------
       
    58 //
       
    59 TUid CAppMngr2InstalledView::Id() const
       
    60     {
       
    61     return KInstalledViewId;
       
    62     }
       
    63 
       
    64 // ---------------------------------------------------------------------------
       
    65 // CAppMngr2InstalledView::HandleCommandL()
       
    66 // ---------------------------------------------------------------------------
       
    67 //
       
    68 void CAppMngr2InstalledView::HandleCommandL( TInt aCommand )
       
    69     {
       
    70     FLOG( "CAppMngr2InstalledView::HandleCommandL( %d )", aCommand );
       
    71     switch( aCommand )
       
    72         {
       
    73         case EAknSoftkeyOk:
       
    74             iContainer->HandleGenericCommandL( EAppMngr2CmdViewDetails );
       
    75             break;
       
    76 
       
    77         default:
       
    78             CAppMngr2ListView::HandleCommandL( aCommand );
       
    79             break;
       
    80         }
       
    81     }
       
    82 
       
    83 // ---------------------------------------------------------------------------
       
    84 // CAppMngr2InstalledView::DynInitMenuPaneL()
       
    85 // ---------------------------------------------------------------------------
       
    86 //
       
    87 void CAppMngr2InstalledView::DynInitMenuPaneL( TInt aResourceId,
       
    88         CEikMenuPane* aMenuPane )
       
    89     {
       
    90     CAppMngr2ListView::DynInitMenuPaneL( aResourceId, aMenuPane );
       
    91     
       
    92     if( aResourceId == R_APPMNGR2_INSTALLED_MENU )
       
    93         {
       
    94         if( iContainer == NULL || iContainer->IsListEmpty() )
       
    95             {
       
    96             aMenuPane->SetItemDimmed( EAppMngr2CmdViewDetails, ETrue );
       
    97             aMenuPane->SetItemDimmed( EAppMngr2CmdUninstall, ETrue );
       
    98             }
       
    99         else
       
   100             {
       
   101             CAppMngr2InfoBase& currentItem = iContainer->CurrentItem();
       
   102             if( !currentItem.SupportsGenericCommand( EAppMngr2CmdViewDetails ) )
       
   103                 {
       
   104                 aMenuPane->SetItemDimmed( EAppMngr2CmdViewDetails, ETrue );
       
   105                 }
       
   106             if( !currentItem.SupportsGenericCommand( EAppMngr2CmdUninstall ) )
       
   107                 {
       
   108                 aMenuPane->SetItemDimmed( EAppMngr2CmdViewDetails, ETrue );
       
   109                 }
       
   110             AddDynamicMenuItemsL( currentItem, aMenuPane );
       
   111             }
       
   112         }
       
   113     }
       
   114 
       
   115 // ---------------------------------------------------------------------------
       
   116 // CAppMngr2InstalledView::CreateContainerL()
       
   117 // ---------------------------------------------------------------------------
       
   118 //
       
   119 CAppMngr2ListContainer* CAppMngr2InstalledView::CreateContainerL()
       
   120     {
       
   121     return CAppMngr2InstalledContainer::NewL( *this );
       
   122     }
       
   123 
       
   124 // ---------------------------------------------------------------------------
       
   125 // CAppMngr2InstalledView::SetDefaultMiddleSoftkeyCommandL()
       
   126 // ---------------------------------------------------------------------------
       
   127 //
       
   128 void CAppMngr2InstalledView::SetDefaultMiddleSoftkeyCommandL()
       
   129     {
       
   130     if( iContainer && !iContainer->IsListEmpty() )
       
   131         {
       
   132         SetMiddleSoftkeyCommandL( R_AM_MSK_VIEW_DETAILS, EAppMngr2CmdViewDetails );
       
   133         }
       
   134     // else the list is empty, and also the MSK is empty
       
   135     }
       
   136 
       
   137 // ---------------------------------------------------------------------------
       
   138 // CAppMngr2InstalledView::SetTitleL()
       
   139 // ---------------------------------------------------------------------------
       
   140 //
       
   141 void CAppMngr2InstalledView::SetTitleL( CAknTitlePane& aTitlePane )
       
   142     {
       
   143     HBufC* title = StringLoader::LoadLC( R_AM_TITLE_INSTALLED );
       
   144     aTitlePane.SetTextL( *title );
       
   145     CleanupStack::PopAndDestroy( title );
       
   146     }
       
   147 
       
   148 // ---------------------------------------------------------------------------
       
   149 // CAppMngr2InstalledView::CAppMngr2InstalledView()
       
   150 // ---------------------------------------------------------------------------
       
   151 //
       
   152 CAppMngr2InstalledView::CAppMngr2InstalledView() : CAppMngr2ListView()
       
   153     {
       
   154     FLOG( "CAppMngr2InstalledView::CAppMngr2InstalledView" );
       
   155     }
       
   156 
       
   157 // ---------------------------------------------------------------------------
       
   158 // CAppMngr2InstalledView::ConstructL()
       
   159 // ---------------------------------------------------------------------------
       
   160 //
       
   161 void CAppMngr2InstalledView::ConstructL()
       
   162     {
       
   163     CAppMngr2ListView::ConstructL( R_APPMNGR2_INSTALLED_VIEW );
       
   164     }
       
   165