stifui/stifui/src/TestModulesMenuContainer.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 CTestModulesListBoxModel class
       
    15 * definition.
       
    16 *
       
    17 */
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include <aknlists.h>  // ListBox
       
    21 #include <barsread.h> // for TResourceReader
       
    22 #include <aknnotewrappers.h>
       
    23 
       
    24 #include "Stifui.hrh"
       
    25 #include <Stifui.rsg>
       
    26 
       
    27 //#include "UIStoreIf.h"         
       
    28 //#include "UIStore.h"            
       
    29 //#include "UIEngine.h"           
       
    30 //#include "UIEngineContainer.h"  
       
    31 
       
    32 #include <stifinternal/UIStoreIf.h>
       
    33 #include <stifinternal/UIStore.h>
       
    34 #include <stifinternal/UIEngine.h>
       
    35 #include <stifinternal/UIEngineContainer.h>
       
    36 
       
    37 #include "TestModulesMenuContainer.h"
       
    38 #include "AppUIAppUi.h"
       
    39 
       
    40 #include "MenuListBox.h"
       
    41 
       
    42 // ================= MEMBER FUNCTIONS =======================
       
    43 // ----------------------------------------------------------------------------
       
    44 // CTestModulesListBoxModel::NewL
       
    45 // 
       
    46 // Two-phased constructor.
       
    47 // ----------------------------------------------------------------------------
       
    48 //
       
    49 CTestModulesListBoxModel* CTestModulesListBoxModel::NewL(RRefArray<TDesC> aTestModules)
       
    50     {
       
    51 
       
    52     CTestModulesListBoxModel* self = new ( ELeave ) CTestModulesListBoxModel();
       
    53     CleanupStack::PushL( self );
       
    54     self->iBuffer = HBufC::NewL( 130 );
       
    55     self->iTestModules = aTestModules;
       
    56     CleanupStack::Pop();
       
    57     return self;
       
    58 
       
    59     }
       
    60 
       
    61 // ----------------------------------------------------------------------------
       
    62 // CTestModulesListBoxModel::ConstructL
       
    63 // 
       
    64 // Symbian OS two phased constructor.
       
    65 // Completes the construction of the object.
       
    66 // ----------------------------------------------------------------------------
       
    67 //
       
    68 void CTestModulesListBoxModel::ConstructL()
       
    69     {
       
    70     //iBuffer = HBufC::NewLC( KMaxInfoName + KMaxName + 2 );
       
    71 
       
    72     }
       
    73 
       
    74 // ----------------------------------------------------------------------------
       
    75 // CTestModulesListBoxModel::~CTestCaseOutputView
       
    76 // 
       
    77 // Destructor.
       
    78 // ----------------------------------------------------------------------------
       
    79 //
       
    80 CTestModulesListBoxModel::~CTestModulesListBoxModel()
       
    81     {
       
    82     delete iBuffer;
       
    83     
       
    84     }
       
    85 
       
    86 // ----------------------------------------------------------------------------
       
    87 // CTestModulesListBoxModel::MdcaCount
       
    88 // 
       
    89 // Returns the number of descriptor elements in the array.
       
    90 // ----------------------------------------------------------------------------
       
    91 //
       
    92 TInt CTestModulesListBoxModel::MdcaCount() const
       
    93     {
       
    94     return iTestModules.Count();
       
    95     }
       
    96 
       
    97 // ----------------------------------------------------------------------------
       
    98 // CTestModulesListBoxModel::MdcaPoint
       
    99 // 
       
   100 // Indexes into a descriptor array.
       
   101 // ----------------------------------------------------------------------------
       
   102 //
       
   103 TPtrC CTestModulesListBoxModel::MdcaPoint(TInt aIndex) const
       
   104     {
       
   105     TPtrC testModule = (iTestModules)[aIndex];
       
   106     TPtr buffer( iBuffer->Des() );
       
   107     buffer.Zero();
       
   108 
       
   109     buffer.Append(_L("\t"));
       
   110     buffer.Append( testModule );
       
   111     
       
   112     return *iBuffer;
       
   113     
       
   114     }
       
   115 
       
   116 // ----------------------------------------------------------------------------
       
   117 // CTestModulesMenuContainer::ConstructL
       
   118 // 
       
   119 // Symbian OS two phased constructor.
       
   120 // ----------------------------------------------------------------------------
       
   121 //
       
   122 void CTestModulesMenuContainer::ConstructL(const TRect& aRect, MEikListBoxObserver* aListBoxObserver)
       
   123     {
       
   124     _LIT( KErrMessage, "Error loading modules! Check Test engine log.");
       
   125     CreateWindowL();
       
   126 
       
   127   	iListBox = CMenuListBox::NewL(ETestModulesMenuViewId);
       
   128 	iListBox->SetContainerWindowL( *this );
       
   129 	iListBox->SetListBoxObserver( aListBoxObserver /*this*/ ); // jos peritty MEikListBoxObserver:sta
       
   130     iListBox->ConstructL(this, EAknListBoxSelectionList /*EAknListBoxMarkableList*/ );
       
   131         ((CAppUIAppUi*)iCoeEnv->AppUi())->iLogger->Log(_L("StartCasesContainer: ListBox constructed"));
       
   132 
       
   133     //Create Scroller control for ListBox and set its visibility
       
   134     iListBox->CreateScrollBarFrameL(ETrue);
       
   135     iListBox->ScrollBarFrame()->SetScrollBarVisibilityL(CEikScrollBarFrame::EOff,CEikScrollBarFrame::EAuto);
       
   136 
       
   137     iUIStore = ( (CAppUIAppUi*)iCoeEnv->AppUi() )->UIStoreHandler();
       
   138 
       
   139     if( iUIStore )
       
   140         {
       
   141         /*const CFixedFlatArray<TTestInfo>& allCases = iData->AllCases();
       
   142         const TInt KTestCaseCount = allCases.Count();
       
   143         for (TInt i=0; i < KTestCaseCount; i++)
       
   144             {
       
   145             iTestCasesInView.Append(&(allCases[i]));
       
   146             } */
       
   147 
       
   148         //RRefArray<TDesC> modules;
       
   149         TInt ret = iUIStore->Modules( iModules );
       
   150         if( ret != KErrNone )
       
   151             {
       
   152              //iModules.Reset();
       
   153              //iModules.Close();
       
   154 			TMessageBoxUtil::ShowErrorNoteL( KErrMessage );
       
   155             }
       
   156        
       
   157         iListBoxModel = CTestModulesListBoxModel::NewL( iModules );
       
   158         ((CAppUIAppUi*)iCoeEnv->AppUi())->iLogger->Log(_L("StartCasesContainer: ListBox model"));
       
   159 
       
   160 
       
   161          iListBox->Model()->SetItemTextArray(iListBoxModel);
       
   162         ((CAppUIAppUi*)iCoeEnv->AppUi())->iLogger->Log(_L("StartCasesContainer: ListBox model set"));
       
   163         
       
   164         }
       
   165     else
       
   166         {
       
   167         // General error becouse UIStore should be opened in AppUI when
       
   168         // program starts.
       
   169         User::Leave( KErrGeneral );
       
   170         }
       
   171 
       
   172     iListBox->ActivateL();
       
   173     ((CMenuListBox*)iListBox)->SetPreviousFocus();
       
   174     SetRect(aRect);
       
   175     ActivateL();
       
   176     }
       
   177 
       
   178 // ----------------------------------------------------------------------------
       
   179 // CTestModulesMenuContainer::~CTestCaseOutputView
       
   180 // 
       
   181 // Destructor.
       
   182 // ----------------------------------------------------------------------------
       
   183 //
       
   184 CTestModulesMenuContainer::~CTestModulesMenuContainer()
       
   185     {
       
   186     
       
   187 		iModules.Reset();
       
   188         iModules.Close();
       
   189 
       
   190 	if( iListBox )
       
   191 		{
       
   192 		delete iListBox;
       
   193 		iListBox = NULL;
       
   194 		}
       
   195 		
       
   196 	}
       
   197 
       
   198 // ----------------------------------------------------------------------------
       
   199 // CTestModulesMenuContainer::SizeChanged
       
   200 // 
       
   201 // Called by framework when the view size is changed.
       
   202 // ----------------------------------------------------------------------------
       
   203 //
       
   204 void CTestModulesMenuContainer::SizeChanged()
       
   205     {
       
   206     if ( iListBox )
       
   207 		{
       
   208 		iListBox->SetRect( Rect() ); // Sets rectangle of listbox.
       
   209 		}
       
   210 
       
   211     }
       
   212 
       
   213 // ----------------------------------------------------------------------------
       
   214 // CTestModulesMenuContainer::CountComponentControls
       
   215 // 
       
   216 // Gets a count of the component controls of this list box control.
       
   217 // ----------------------------------------------------------------------------
       
   218 //
       
   219 TInt CTestModulesMenuContainer::CountComponentControls() const
       
   220     {
       
   221     return 1; // return nbr of controls inside this container
       
   222 
       
   223     }
       
   224 
       
   225 // ----------------------------------------------------------------------------
       
   226 // CTestModulesMenuContainer::ComponentControl
       
   227 // 
       
   228 // Gets a pointer to the specified component control.
       
   229 // ----------------------------------------------------------------------------
       
   230 //
       
   231 CCoeControl* CTestModulesMenuContainer::ComponentControl(TInt aIndex) const
       
   232     {
       
   233     switch ( aIndex )
       
   234         {
       
   235 		case 0: 
       
   236 			return iListBox;
       
   237         default:
       
   238             return NULL;
       
   239         }
       
   240 
       
   241     }
       
   242 
       
   243 // ----------------------------------------------------------------------------
       
   244 // CTestModulesMenuContainer::Draw
       
   245 // 
       
   246 // Draw a control, called by window server.
       
   247 // ----------------------------------------------------------------------------
       
   248 //
       
   249 void CTestModulesMenuContainer::Draw(const TRect& /*aRect*/) const
       
   250     {
       
   251     }
       
   252 
       
   253 // ----------------------------------------------------------------------------
       
   254 // CTestModulesMenuContainer::OfferKeyEventL
       
   255 // 
       
   256 // Handles key events.
       
   257 // ----------------------------------------------------------------------------
       
   258 //
       
   259 TKeyResponse CTestModulesMenuContainer::OfferKeyEventL(
       
   260 	const TKeyEvent& aKeyEvent, TEventCode aType)
       
   261     {
       
   262 	if (aType != EEventKey)
       
   263 	    {
       
   264 		return EKeyWasNotConsumed;
       
   265 	    }
       
   266 
       
   267     switch ( aKeyEvent.iCode )
       
   268         {
       
   269         case EKeyLeftArrow:
       
   270         case EKeyRightArrow:
       
   271 			{   /* Left ja right key eventit valitetaan AppUille joka hoitaa siirtymisen toisiin nakymiin */
       
   272 			return EKeyWasNotConsumed;
       
   273             //break;
       
   274             }
       
   275         default:
       
   276 			{
       
   277 			//Muut Key eventit valitetaan listboxille, joka hoitaa ne
       
   278 			if (iListBox)
       
   279 				{
       
   280 				return iListBox->OfferKeyEventL( aKeyEvent, aType );
       
   281 				}
       
   282 			}
       
   283         }
       
   284     return EKeyWasNotConsumed;
       
   285     }
       
   286 
       
   287 // ----------------------------------------------------------------------------
       
   288 // CTestModulesMenuContainer::CurrentItemIndex
       
   289 // 
       
   290 // Returns current item index in list box.
       
   291 // ----------------------------------------------------------------------------
       
   292 //
       
   293 TInt CTestModulesMenuContainer::CurrentItemIndex()
       
   294     {
       
   295     return iListBox->CurrentItemIndex();
       
   296 
       
   297     }
       
   298 
       
   299 // ----------------------------------------------------------------------------
       
   300 // CTestModulesMenuContainer::SaveActiveLine
       
   301 //
       
   302 // Makes the iListBox member save its focus position
       
   303 // ----------------------------------------------------------------------------
       
   304 //
       
   305 void CTestModulesMenuContainer::SaveActiveLine()
       
   306 	{
       
   307 	((CMenuListBox*)iListBox)->SaveFocusPosition();
       
   308 	}
       
   309 
       
   310 // End of File