stifui/stifui/src/Testmodulesmenuview.cpp
branchRCL_3
changeset 9 404ad6c9bc20
parent 8 87e9ebfbe96a
child 11 454d022d514b
equal deleted inserted replaced
8:87e9ebfbe96a 9:404ad6c9bc20
     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: This file contains CTestModulesMenuView class 
       
    15 * definition.
       
    16 *
       
    17 */
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include  <aknViewAppUi.h>
       
    21 #include  <Stifui.rsg>
       
    22 
       
    23 #include  <barsread.h>	//TResourceReader
       
    24 #include  "TestModulesMenuView.h"
       
    25 #include  "TestModulesMenuContainer.h"
       
    26 #include  "Stifui.hrh"
       
    27 
       
    28 #include "AppUIAppUi.h" // For ShowNotImplementedYet() method
       
    29 
       
    30 // ================= MEMBER FUNCTIONS =======================
       
    31 // ----------------------------------------------------------------------------
       
    32 // CTestModulesMenuView::ConstructL
       
    33 // 
       
    34 // Symbian OS two-phased constructor.
       
    35 // ----------------------------------------------------------------------------
       
    36 //
       
    37 void CTestModulesMenuView::ConstructL()
       
    38     {
       
    39     CView::ConstructL();
       
    40     BaseConstructL( R_APPUI_TESTMODULESMENUVIEW );
       
    41     }
       
    42 
       
    43 // ----------------------------------------------------------------------------
       
    44 // CTestModulesMenuView::~CTestCaseOutputView
       
    45 // 
       
    46 // Destructor.
       
    47 // ----------------------------------------------------------------------------
       
    48 //
       
    49 CTestModulesMenuView::~CTestModulesMenuView()
       
    50     {
       
    51     if ( iContainer )
       
    52         {
       
    53         AppUi()->RemoveFromViewStack( *this, iContainer );
       
    54         delete iContainer;
       
    55         iContainer = NULL;
       
    56         }
       
    57     delete iNaviDecorator;
       
    58     iNaviDecorator = NULL;
       
    59     }
       
    60 
       
    61 // ----------------------------------------------------------------------------
       
    62 // CTestModulesMenuView::Id
       
    63 // 
       
    64 // Returns view´s id.
       
    65 // ----------------------------------------------------------------------------
       
    66 //
       
    67 TUid CTestModulesMenuView::Id() const
       
    68     {
       
    69     return TUid::Uid(ETestModulesMenuViewId); //KTestCaseMenuViewId;
       
    70     }
       
    71 
       
    72 // ----------------------------------------------------------------------------
       
    73 // CTestModulesMenuView::HandleCommandL
       
    74 // 
       
    75 // Handles a command.
       
    76 // ----------------------------------------------------------------------------
       
    77 //
       
    78 void CTestModulesMenuView::HandleCommandL(TInt aCommand)
       
    79     {   
       
    80     switch ( aCommand )
       
    81         {
       
    82         case EAknSoftkeyOk:
       
    83             {
       
    84             iEikonEnv->InfoMsg( _L("TestCase Menu ok") );
       
    85             break;
       
    86             }
       
    87         case EAknSoftkeyBack:
       
    88             {
       
    89             AppUi()->HandleCommandL(EAppUIGoBack);
       
    90             break;
       
    91             }
       
    92         // Next is removed from Stifui.rss file in 
       
    93         // RESOURCE MENU_PANE r_appui_testmodulesmenuview_menu's
       
    94         // items section. If want back to use remeve comment there
       
    95         //case ECmdOpenModule:
       
    96         //    {
       
    97             //TFileName fileName;
       
    98             //AknCommonDialogs::RunSelectDlgLD (fileName,
       
    99             //                                  R_MEMORY_SELECTION_DIALOG,
       
   100             //                                  R_FILE_SELECTION_DIALOG
       
   101             //
       
   102             //);
       
   103         //    ShowNotImplementedYet();
       
   104         //    break;
       
   105         //    }
       
   106         case ECmdAddModule:
       
   107             {
       
   108             TInt ret = ((CAppUIAppUi*)AppUi())->UIStoreHandler()->LoadAllModules();
       
   109             if( KErrNone != ret )
       
   110                 {
       
   111                 iEikonEnv->InfoMsg( _L("Module adding fails!") );
       
   112                 break;
       
   113                 }
       
   114 
       
   115             AppUi()->HandleCommandL( EAppUIGoBack );
       
   116             //ShowNotImplementedYet();
       
   117             break;
       
   118             }
       
   119         case ECmdRemoveModule:
       
   120             {
       
   121             TInt moduleNumber = iContainer->CurrentItemIndex();
       
   122             RRefArray<TDesC> allModules;
       
   123             TInt ret = ((CAppUIAppUi*)AppUi())->UIStoreHandler()->Modules( allModules );
       
   124             if( KErrNone != ret )
       
   125                 {
       
   126                 allModules.Reset();
       
   127                 allModules.Close();
       
   128                 User::Leave( ret );
       
   129                 }
       
   130             // No modules exist...break...
       
   131             if( allModules.Count() == 0 )
       
   132                 {
       
   133                 iEikonEnv->InfoMsg( _L("No modules available!") );
       
   134                 allModules.Reset();
       
   135                 allModules.Close();
       
   136                 break;
       
   137                 }
       
   138             // Module found...remove module...
       
   139             ret = ((CAppUIAppUi*)AppUi())->UIStoreHandler()->RemoveTestModule(
       
   140                                         allModules[ moduleNumber ] );
       
   141             if( KErrNone != ret )
       
   142                 {
       
   143                 User::Leave( ret );
       
   144                 }
       
   145             allModules.Reset();
       
   146             allModules.Close();
       
   147 
       
   148             //iContainer->UpdateView();
       
   149             AppUi()->HandleCommandL( EAppUIGoBack );
       
   150             //ShowNotImplementedYet();
       
   151             break;
       
   152             }
       
   153         default:
       
   154             {
       
   155             AppUi()->HandleCommandL( aCommand );
       
   156             break;
       
   157             }
       
   158         }
       
   159     }
       
   160 
       
   161 // ----------------------------------------------------------------------------
       
   162 // CTestModulesMenuView::DynInitMenuPaneL
       
   163 // 
       
   164 // Initializes menu pane.
       
   165 // ----------------------------------------------------------------------------
       
   166 //
       
   167 void CTestModulesMenuView::DynInitMenuPaneL(TInt aResourceId, CEikMenuPane* /* aMenuPane */)
       
   168     {
       
   169 
       
   170     if (R_APPUI_TESTMODULESMENUVIEW_MENU == aResourceId)
       
   171         {
       
   172         /*switch ( iData->StartedCaseInOutputView()->State() )
       
   173             {
       
   174             case ENotStarted:
       
   175                 {
       
   176                 aMenuPane->SetItemDimmed( ECmdOpenModule, ETrue );
       
   177                 aMenuPane->SetItemDimmed( ECmdAddModule, ETrue );
       
   178                 aMenuPane->SetItemDimmed( ECmdRemoveModule, ETrue );
       
   179                 break;
       
   180                 }
       
   181             case ERunning:
       
   182                 {
       
   183                 aMenuPane->SetItemDimmed( ECmdResumeTestCase, ETrue );
       
   184                 break;
       
   185                 }
       
   186             case EPaused:
       
   187                 {
       
   188                 aMenuPane->SetItemDimmed( ECmdPauseTestCase, ETrue );
       
   189                 break;
       
   190                 }
       
   191             case EPassed:
       
   192             case EFailed:
       
   193             case EAborted:
       
   194             case EExecuted:
       
   195                 {
       
   196                 aMenuPane->SetItemDimmed( ECmdPauseTestCase, ETrue );
       
   197                 aMenuPane->SetItemDimmed( ECmdResumeTestCase, ETrue );
       
   198                 aMenuPane->SetItemDimmed( ECmdAbortTestCase, ETrue );
       
   199                 break;
       
   200                 }
       
   201             }*/
       
   202         }
       
   203     }
       
   204 
       
   205 // ----------------------------------------------------------------------------
       
   206 // CTestModulesMenuView::HandleClientRectChange
       
   207 // 
       
   208 // Handles client rect changes.
       
   209 // ----------------------------------------------------------------------------
       
   210 //
       
   211 void CTestModulesMenuView::HandleClientRectChange()
       
   212     {
       
   213     if ( iContainer )
       
   214         {
       
   215         iContainer->SetRect( ClientRect() );
       
   216         }
       
   217     }
       
   218 
       
   219 // ----------------------------------------------------------------------------
       
   220 // CTestModulesMenuView::HandleListBoxEventL
       
   221 // 
       
   222 // Handles listbox events.
       
   223 // ----------------------------------------------------------------------------
       
   224 //
       
   225 void CTestModulesMenuView::HandleListBoxEventL(CEikListBox* /*aListBox*/, TListBoxEvent aEventType)
       
   226 	{
       
   227 	if ( ( aEventType == EEventEnterKeyPressed ) || ( aEventType == EEventItemDoubleClicked ) )
       
   228 		{
       
   229         // Open or edit test module or ???
       
   230         }
       
   231     }
       
   232 
       
   233 // ----------------------------------------------------------------------------
       
   234 // CTestModulesMenuView::DoActivateL
       
   235 // 
       
   236 // Initializes view when activated.
       
   237 // ----------------------------------------------------------------------------
       
   238 //
       
   239 void CTestModulesMenuView::DoActivateL(
       
   240    const TVwsViewId& /*aPrevViewId*/,TUid /*aCustomMessageId*/,
       
   241    const TDesC8& /*aCustomMessage*/)
       
   242     {
       
   243     if (!iContainer)
       
   244         {
       
   245         iContainer = new (ELeave) CTestModulesMenuContainer;
       
   246         iContainer->SetMopParent(this);
       
   247         iContainer->ConstructL( ClientRect(), this);
       
   248         AppUi()->AddToStackL( *this, iContainer );
       
   249         } 
       
   250     CEikStatusPane* sp=iEikonEnv->AppUiFactory()->StatusPane();
       
   251 	CAknNavigationControlContainer* np= (CAknNavigationControlContainer *)sp->ControlL(TUid::Uid(EEikStatusPaneUidNavi));
       
   252 	
       
   253 	TResourceReader reader;
       
   254 	iCoeEnv->CreateResourceReaderLC(reader,R_NAVITITLE_MODULES);
       
   255 	iNaviDecorator = np->CreateNavigationLabelL( reader );
       
   256 	CleanupStack::PopAndDestroy(); // resource reader
       
   257 	np->PushL(*iNaviDecorator);
       
   258    }
       
   259 
       
   260 // ----------------------------------------------------------------------------
       
   261 // CTestModulesMenuView::DoDeactivate
       
   262 // 
       
   263 // Deactivates view.
       
   264 // ----------------------------------------------------------------------------
       
   265 //
       
   266 void CTestModulesMenuView::DoDeactivate()
       
   267     {
       
   268     if ( iContainer )
       
   269         {
       
   270         iContainer->SaveActiveLine();
       
   271         AppUi()->RemoveFromViewStack( *this, iContainer );
       
   272         delete iContainer;
       
   273         iContainer = NULL;
       
   274         }
       
   275     delete iNaviDecorator;
       
   276     iNaviDecorator = NULL;
       
   277     }
       
   278 
       
   279 // End of File
       
   280