launcher/src/launcherviewapps.cpp
branchRCL_3
changeset 22 fad26422216a
equal deleted inserted replaced
21:b3cee849fa46 22:fad26422216a
       
     1 /*
       
     2 * Copyright (c) 2009 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:  
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include <aknViewAppUi.h>
       
    21 #include <avkon.hrh>
       
    22 #include <launcher.rsg>
       
    23 #include <AknUtils.h>
       
    24 #include <eikmenup.h>
       
    25 
       
    26 #include "launcherviewapps.h"
       
    27 #include "launchercontainerapps.h" 
       
    28 
       
    29 // ================= MEMBER FUNCTIONS =======================
       
    30 
       
    31 // ---------------------------------------------------------
       
    32 // CLauncherViewApps::ConstructL(const TRect& aRect)
       
    33 // EPOC two-phased constructor
       
    34 // ---------------------------------------------------------
       
    35 //
       
    36 void CLauncherViewApps::ConstructL(CLauncherEngine* aEngine)
       
    37     {
       
    38     BaseConstructL( R_LAUNCHER_VIEW1 );
       
    39 
       
    40     iContainer = new (ELeave) CLauncherContainerApps;
       
    41     iContainer->SetMopParent(this);
       
    42     iContainer->ConstructL( ClientRect(), aEngine );
       
    43 
       
    44     AppUi()->AddToStackL( *this, iContainer );
       
    45 
       
    46     // add data to the listbox and as default mark all as selected
       
    47     iContainer->UpdateFileListL();
       
    48     AknSelectionService::HandleMarkableListProcessCommandL( EAknMarkAll, iContainer->ListBox() );
       
    49 
       
    50     aEngine->SetContainerApps(iContainer);
       
    51 
       
    52     }
       
    53 
       
    54 // ---------------------------------------------------------
       
    55 // CLauncherViewApps::~CLauncherViewApps()
       
    56 // ---------------------------------------------------------
       
    57 //
       
    58 CLauncherViewApps::~CLauncherViewApps()
       
    59     {
       
    60     AppUi()->RemoveFromViewStack( *this, iContainer );
       
    61     delete iContainer;
       
    62     }
       
    63 
       
    64 // ---------------------------------------------------------
       
    65 // TUid CLauncherViewApps::Id()
       
    66 // ?implementation_description
       
    67 // ---------------------------------------------------------
       
    68 //
       
    69 TUid CLauncherViewApps::Id() const
       
    70     {
       
    71     return KViewId;
       
    72     }
       
    73 
       
    74 // ------------------------------------------------------------------------------
       
    75 // CLauncherViewApps::DynInitMenuPaneL(TInt aResourceId,CEikMenuPane* aMenuPane)
       
    76 //  This function is called by the EIKON framework just before it displays
       
    77 //  a menu pane. Its default implementation is empty, and by overriding it,
       
    78 //  the application can set the state of menu items dynamically according
       
    79 //  to the state of application data.
       
    80 // ------------------------------------------------------------------------------
       
    81 //
       
    82 
       
    83 void CLauncherViewApps::DynInitMenuPaneL(TInt aResourceId, CEikMenuPane* aMenuPane)
       
    84     {
       
    85     if (aResourceId == R_LAUNCHER_VIEW1_MENU)
       
    86         {
       
    87         // launch start check
       
    88         aMenuPane->SetItemDimmed(ECmdLaunchApps, iContainer->Engine()->LaunchingIsActive());
       
    89 
       
    90         // hide launch options when launching is active
       
    91         aMenuPane->SetItemDimmed(ECmdLaunchOptions, iContainer->Engine()->LaunchingIsActive());
       
    92 
       
    93         // EAknMarkAll
       
    94         TBool allSelected = iContainer->ListBox()->SelectionIndexes()->Count() == iContainer->ListBox()->Model()->NumberOfItems();
       
    95         aMenuPane->SetItemDimmed(EAknMarkAll, allSelected);
       
    96 
       
    97         // EAknUnmarkAll
       
    98         TBool noneSelected = iContainer->ListBox()->SelectionIndexes()->Count() == 0;
       
    99         aMenuPane->SetItemDimmed(EAknUnmarkAll, noneSelected); 
       
   100         }
       
   101 
       
   102 	else if (aResourceId == R_LAUNCHER_LAUNCHOPTIONS_SUBMENU)
       
   103 	    {
       
   104 	    if (iContainer->Engine()->SkipHiddenAndEmbedOnly())
       
   105             aMenuPane->SetItemButtonState(ECmdSkipHiddenAndEmbedOnly, EEikMenuItemSymbolOn);
       
   106 	    else
       
   107             aMenuPane->SetItemButtonState(ECmdDoNotSkipAnyFiles, EEikMenuItemSymbolOn);
       
   108 	    } 
       
   109 
       
   110     else
       
   111         {
       
   112         AppUi()->DynInitMenuPaneL(aResourceId, aMenuPane);
       
   113         }
       
   114     }
       
   115 
       
   116 // ---------------------------------------------------------
       
   117 // CLauncherViewApps::HandleCommandL(TInt aCommand)
       
   118 // ---------------------------------------------------------
       
   119 //
       
   120 void CLauncherViewApps::HandleCommandL(TInt aCommand)
       
   121     {  
       
   122     switch ( aCommand )
       
   123         {
       
   124         case ECmdLaunchAppsWithAutoClose:
       
   125             {
       
   126             iContainer->Engine()->StartAppLaunchingL(iContainer->SelectedApps(), ETrue);
       
   127             break;
       
   128             }
       
   129          
       
   130         case ECmdLaunchAppsWithoutAutoClose:
       
   131             {
       
   132             iContainer->Engine()->StartAppLaunchingL(iContainer->SelectedApps(), EFalse);
       
   133             break;
       
   134             }
       
   135 
       
   136         case ECmdSkipHiddenAndEmbedOnly:
       
   137             {
       
   138             iContainer->Engine()->SetSkipHiddenAndEmbedOnly(ETrue);
       
   139             break;
       
   140             }
       
   141 
       
   142         case ECmdDoNotSkipAnyFiles:
       
   143             {
       
   144             iContainer->Engine()->SetSkipHiddenAndEmbedOnly(EFalse);
       
   145             break;
       
   146             }
       
   147                         
       
   148         case ECmdRefreshList:
       
   149             {
       
   150             iContainer->UpdateFileListL();
       
   151             AknSelectionService::HandleMarkableListProcessCommandL( EAknMarkAll, iContainer->ListBox() );
       
   152             break;
       
   153             }
       
   154 
       
   155         case EAknCmdMark:
       
   156         case EAknCmdUnmark:
       
   157         case EAknUnmarkAll:
       
   158         case EAknMarkAll:
       
   159             {
       
   160             AknSelectionService::HandleMarkableListProcessCommandL( aCommand, iContainer->ListBox() );
       
   161             break;
       
   162             }
       
   163         
       
   164         default:
       
   165             {
       
   166             AppUi()->HandleCommandL( aCommand );
       
   167             break;
       
   168             }
       
   169         }
       
   170     }
       
   171 
       
   172 // ---------------------------------------------------------
       
   173 // CLauncherViewApps::HandleClientRectChange()
       
   174 // ---------------------------------------------------------
       
   175 //
       
   176 void CLauncherViewApps::HandleClientRectChange()
       
   177     {
       
   178     if ( iContainer )
       
   179         {
       
   180         iContainer->SetRect( ClientRect() );
       
   181         }
       
   182     }
       
   183 
       
   184 // ---------------------------------------------------------
       
   185 // CLauncherViewApps::DoActivateL(...)
       
   186 // ---------------------------------------------------------
       
   187 //
       
   188 void CLauncherViewApps::DoActivateL(
       
   189    const TVwsViewId& /*aPrevViewId*/,TUid /*aCustomMessageId*/,
       
   190    const TDesC8& /*aCustomMessage*/)
       
   191     {
       
   192     //AppUi()->AddToStackL( *this, iContainer );
       
   193     iContainer->ActivateL();
       
   194     iContainer->MakeVisible(ETrue);
       
   195     }
       
   196 
       
   197 // ---------------------------------------------------------
       
   198 // CLauncherViewApps::DoDeactivate()
       
   199 // ---------------------------------------------------------
       
   200 //
       
   201 void CLauncherViewApps::DoDeactivate()
       
   202     {
       
   203     iContainer->MakeVisible(EFalse);
       
   204     //AppUi()->RemoveFromViewStack( *this, iContainer );
       
   205     }
       
   206 
       
   207 // End of File
       
   208