uifw/AvKon/tsrc/bc/bctestlauncher/src/bctestlauncherview.cpp
changeset 0 2f259fa3e83a
equal deleted inserted replaced
-1:000000000000 0:2f259fa3e83a
       
     1 /*
       
     2 * Copyright (c) 2006-2007 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:  Implementation of application view class.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include <avkon.hrh>
       
    20 #include <aknviewappui.h>
       
    21 #include <akntabgrp.h>
       
    22 #include <aknnavide.h>
       
    23 #include <e32std.h>
       
    24 #include <e32base.h>
       
    25 #include <eiktxlbm.h>
       
    26 #include <akndef.h>
       
    27 #include <centralrepository.h>
       
    28 #include <aknlistquerydialog.h> 
       
    29 #include <bctestlauncher.rsg>
       
    30 
       
    31 #include "bctestlauncherview.h"
       
    32 #include "bctestlaunchercontainer.h"
       
    33 #include "bctestrunner.h"
       
    34 #include "bctestapplication.h"
       
    35 #include "streamlogger.h"
       
    36 
       
    37 // ============================ LOCAL FUNCTIONS ==============================
       
    38 namespace BCTest
       
    39     {
       
    40 	inline static CEikMenuPaneItem::SData& BuildItem( 
       
    41 	    const TDesC& aName, const TInt aID )
       
    42 	    {
       
    43 		static CEikMenuPaneItem::SData item;
       
    44 		item.iCommandId = aID;
       
    45 		item.iText = aName;
       
    46 		item.iFlags= EEikMenuItemSymbolOn;
       
    47 		item.iCascadeId = 0;
       
    48 		return item;
       
    49 	    }
       
    50     }
       
    51 
       
    52 // ============================ MEMBER FUNCTIONS =============================
       
    53 
       
    54 // ---------------------------------------------------------------------------
       
    55 // CBCTestLauncherView::CBCTestLauncherView()
       
    56 // C++ default constructor can NOT contain any code, that
       
    57 // might leave.
       
    58 // ---------------------------------------------------------------------------
       
    59 //
       
    60 CBCTestLauncherView::CBCTestLauncherView( RArray<CBCTestApplication*>* aList )
       
    61     : iContainer( NULL ), iSelectApps( aList )
       
    62     {
       
    63     }
       
    64 
       
    65 // ---------------------------------------------------------------------------
       
    66 // CBCTestLauncherView::ConstructL
       
    67 // Symbian 2nd phase constructor can leave.
       
    68 // ---------------------------------------------------------------------------
       
    69 //
       
    70 void CBCTestLauncherView::ConstructL()
       
    71     {
       
    72     BaseConstructL( R_BCTESTLAUNCHER_VIEW );
       
    73 	
       
    74 	//construct the app list menu
       
    75     }
       
    76  
       
    77 // ---------------------------------------------------------------------------
       
    78 // CBCTestLauncherView::~CBCTestLauncherView
       
    79 // Destructor.
       
    80 // ---------------------------------------------------------------------------
       
    81 //
       
    82 CBCTestLauncherView::~CBCTestLauncherView()
       
    83     {
       
    84     if ( iContainer )
       
    85         {
       
    86         AppUi()->RemoveFromStack( iContainer );
       
    87         }
       
    88 
       
    89     delete iContainer;
       
    90     }
       
    91 
       
    92 // ---------------------------------------------------------------------------
       
    93 // TUid CAknAtPbarView::Id()
       
    94 // returns view Id.
       
    95 // ---------------------------------------------------------------------------
       
    96 //
       
    97 TUid CBCTestLauncherView::Id() const
       
    98     {
       
    99     return KViewId;
       
   100     }
       
   101 
       
   102 // ---------------------------------------------------------------------------
       
   103 // CAknAtPbarView::HandleCommandL( TInt aCommand )
       
   104 // handles commands.
       
   105 // ---------------------------------------------------------------------------
       
   106 //
       
   107 void CBCTestLauncherView::HandleCommandL( TInt aCommand )
       
   108     {   
       
   109     switch ( aCommand )
       
   110         {
       
   111         case EAknCmdExit:
       
   112         case EAknSoftkeyBack:
       
   113         case EEikCmdExit:                        
       
   114             AppUi()->HandleCommandL( EEikCmdExit );
       
   115             return; // this can never be reached
       
   116         case ESdkVersion:
       
   117         	iContainer->SetSdkVersion();
       
   118             return; // this can never be reached
       
   119         }
       
   120 
       
   121 	TInt number = aCommand - EBCTestLauncherStart;
       
   122 	if( number >= 0 && number < ( *iSelectApps ).Count() )
       
   123 		{
       
   124 		Reset();
       
   125 		( *iSelectApps )[number]->Select();
       
   126 		}
       
   127 
       
   128 	AppUi()->HandleCommandL( aCommand );
       
   129     }
       
   130 
       
   131 // ---------------------------------------------------------------------------
       
   132 // CAknAtPbarView::HandleClientRectChange()
       
   133 // 
       
   134 // ---------------------------------------------------------------------------
       
   135 void CBCTestLauncherView::HandleClientRectChange()
       
   136     {
       
   137     if ( iContainer )
       
   138         {
       
   139         iContainer->SetRect( ClientRect() );
       
   140         }
       
   141     }
       
   142 
       
   143 // ---------------------------------------------------------------------------
       
   144 // CBCTestLauncherView::DoActivateL(...)
       
   145 // 
       
   146 // ---------------------------------------------------------------------------
       
   147 void CBCTestLauncherView::DoActivateL(
       
   148     const TVwsViewId& /*aPrevViewId*/, TUid /*aCustomMessageId*/,
       
   149     const TDesC8& /*aCustomMessage*/ )
       
   150     {
       
   151     iContainer = new( ELeave ) CBCTestLauncherContainer;
       
   152     iContainer->SetMopParent( this );
       
   153     iContainer->ConstructL( ClientRect() );
       
   154     AppUi()->AddToStackL( *this, iContainer, ECoeStackPriorityDefault );
       
   155     }
       
   156 
       
   157 // ---------------------------------------------------------------------------
       
   158 // CBCTestLauncherView::DoDeactivate()
       
   159 // 
       
   160 // ---------------------------------------------------------------------------
       
   161 void CBCTestLauncherView::DoDeactivate()
       
   162     {
       
   163     if ( iContainer )
       
   164         {
       
   165         AppUi()->RemoveFromStack( iContainer );
       
   166         }
       
   167 
       
   168     delete iContainer;
       
   169     iContainer = NULL;
       
   170     }
       
   171 
       
   172 // ---------------------------------------------------------------------------
       
   173 // CBCTestLauncherView::RunSelectionL()
       
   174 // 
       
   175 // ---------------------------------------------------------------------------
       
   176 TBool CBCTestLauncherView::SelectL()
       
   177     {
       
   178 	_LIT( KPrefix, "1\t" );
       
   179 
       
   180 	CListBoxView::CSelectionIndexArray* indexArray = 
       
   181 	    new( ELeave )CArrayFixFlat<TInt>( ( *iSelectApps ).Count() ); 
       
   182 	CleanupStack::PushL( indexArray );
       
   183 
       
   184 	CAknListQueryDialog* dlg = 
       
   185 	    new( ELeave ) CAknListQueryDialog( indexArray );
       
   186 	dlg->PrepareLC(R_BCTESTLAUNCHER_MULTI_SELECTION_QUERY);
       
   187 
       
   188 	CDesCArray* items = static_cast<CDesCArray*>( static_cast<
       
   189 	    CTextListBoxModel*>( dlg->ListBox()->Model() )->ItemTextArray() );
       
   190 	items->Reset();
       
   191 	for( TInt i = 0; i < ( *iSelectApps ).Count(); ++i )
       
   192 	    {
       
   193 		TBuf<KNameLength> text( KPrefix );
       
   194 		text += ( *iSelectApps )[i]->Name();
       
   195 		items->AppendL( text );
       
   196 	    }
       
   197 
       
   198 	TBool res = EFalse;
       
   199     if ( dlg->RunLD() )
       
   200         {
       
   201 		Reset();
       
   202         for (TInt i = 0; i < indexArray->Count(); ++i)
       
   203             {
       
   204             ( *iSelectApps )[ indexArray->At( i ) ]->Select(); 
       
   205             }
       
   206 		res = ETrue;
       
   207         }
       
   208 
       
   209     CleanupStack::PopAndDestroy(); // indexArray
       
   210 	return res;
       
   211     }
       
   212 
       
   213 void CBCTestLauncherView::Reset()
       
   214 	{
       
   215 	for( TInt i = 0; i < ( *iSelectApps ).Count(); ++i )
       
   216 		{
       
   217 		( *iSelectApps )[i]->Select( EFalse ); 
       
   218 		}
       
   219 	}
       
   220 
       
   221 // ---------------------------------------------------------------------------
       
   222 // CBCTestLauncherView::DynInitMenuPaneL()
       
   223 // 
       
   224 // ---------------------------------------------------------------------------
       
   225 //
       
   226 void CBCTestLauncherView::DynInitMenuPaneL( 
       
   227     TInt aResourceId, CEikMenuPane* aMenuPane )
       
   228 	{
       
   229 	if( R_BCTESTLAUNCHER_SEPARATE_TESTS == aResourceId )
       
   230 		{
       
   231 		for( TInt i = 0; i < ( *iSelectApps ).Count(); ++i )
       
   232 			{
       
   233 			aMenuPane->AddMenuItemL( 
       
   234 			    BCTest::BuildItem( ( *iSelectApps )[i]->Name(), 
       
   235 				EBCTestLauncherStart + i ) );
       
   236 			}
       
   237 		}
       
   238 	}
       
   239