locationsystemui/locationsysui/locsuplsettingsui/src/locsuplsettingscontainer.cpp
branchRCL_3
changeset 44 2b4ea9893b66
parent 42 02ba3f1733c6
child 45 6b6920c56e2f
equal deleted inserted replaced
42:02ba3f1733c6 44:2b4ea9893b66
     1 /*
       
     2 * Copyright (c) 2006 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:  SUPL Settings UI View's container
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // System Includes
       
    20 #include <eikspane.h> 		// Status pane
       
    21 #include <akntitle.h>   	// CAknTitlePane
       
    22 #include <aknlists.h>
       
    23 #include <StringLoader.h>
       
    24 #include <locsuplsettingsui.rsg>
       
    25 #include <csxhelp/locsupl.hlp.hrh>          // Help File
       
    26 
       
    27 // User Includes
       
    28 #include "locsuplsettings.hrh"
       
    29 #include "locsuplsettingsuid.hrh"
       
    30 #include "locsuplsettingscontainer.h"
       
    31 #include "locsuplsettingslbmodel.h"
       
    32 #include "locsuplsettingsuiengine.h"
       
    33 #include "locsuplsettingsview.h"
       
    34 #include "locsupldebug.h"
       
    35 
       
    36 
       
    37 // ========================= MEMBER FUNCTIONS ================================
       
    38 
       
    39 // ---------------------------------------------------------------------------
       
    40 // CLocSUPLSettingsContainer::CLocSUPLSettingsContainer
       
    41 // Overloaded Constructor
       
    42 //
       
    43 // ---------------------------------------------------------------------------
       
    44 //	
       
    45 CLocSUPLSettingsContainer::CLocSUPLSettingsContainer( 
       
    46                                         CLocSUPLSettingsView&         aSettingsView )
       
    47     : iSettingsView( aSettingsView )
       
    48 	{
       
    49 	}
       
    50 	
       
    51 // ---------------------------------------------------------------------------
       
    52 // CLocSUPLSettingsContainer::~CLocSUPLSettingsContainer
       
    53 // Destructor
       
    54 //
       
    55 // ---------------------------------------------------------------------------	
       
    56 //
       
    57 CLocSUPLSettingsContainer::~CLocSUPLSettingsContainer()
       
    58 	{
       
    59 	DEBUG( + CLocSUPLSettingsContainer::~CLocSUPLSettingsContainer );	
       
    60 	// Delete the List box model only after deleting the list box
       
    61 	delete iListBox;
       
    62 	iListBox = NULL;
       
    63 	
       
    64 	delete iListBoxModel;
       
    65 	iListBoxModel = NULL;
       
    66 	DEBUG( - CLocSUPLSettingsContainer::~CLocSUPLSettingsContainer );	
       
    67 	}
       
    68 	
       
    69 // ---------------------------------------------------------------------------
       
    70 // CLocSUPLSettingsContainer* CLocSUPLSettingsContainer::NewL
       
    71 // Static Two phase constructor that instantiates the CLocSUPLSettingsContainer
       
    72 //
       
    73 // @param aRect							Client rectangle
       
    74 // @param aEngine                       Reference to the SUPL Settings
       
    75 //                                      engine 
       
    76 // @param aSettingsView                 Reference to the container's view
       
    77 // @return CLocSUPLSettingsContainer*	Reference to the object created
       
    78 // ---------------------------------------------------------------------------    
       
    79 //
       
    80 CLocSUPLSettingsContainer* CLocSUPLSettingsContainer::NewL( 
       
    81                     const TRect& 	                    aRect,
       
    82                           CLocSUPLSettingsUiEngine&     aEngine,
       
    83                           CLocSUPLSettingsView&         aSettingsView )
       
    84 	{	
       
    85  	DEBUG( + CLocSUPLSettingsContainer::NewL );	
       
    86    	CLocSUPLSettingsContainer* self = NewLC( aRect, 
       
    87                                              aEngine,
       
    88                                              aSettingsView );
       
    89 	CleanupStack::Pop( self );
       
    90 	DEBUG( - CLocSUPLSettingsContainer::NewL );	
       
    91 	return self;
       
    92 	}
       
    93 
       
    94 // ---------------------------------------------------------------------------
       
    95 // CLocSUPLSettingsContainer* CLocSUPLSettingsContainer::NewLC
       
    96 // Static Two phase contructor that instantiates the CLocSUPLSettingsContainer
       
    97 //
       
    98 // @param aRect							Client rectangle
       
    99 // @param aEngine                       Reference to the SUPL Settings
       
   100 //                                      engine 
       
   101 // @param @param aSettingsView                 Reference to the container's view
       
   102 // @return CLocSUPLSettingsContainer*	Reference to the object created
       
   103 // ---------------------------------------------------------------------------  
       
   104 //  
       
   105 CLocSUPLSettingsContainer* CLocSUPLSettingsContainer::NewLC( 
       
   106                     const TRect& 	                    aRect,
       
   107                           CLocSUPLSettingsUiEngine&     aEngine,
       
   108                           CLocSUPLSettingsView&         aSettingsView  )
       
   109 	{	
       
   110     CLocSUPLSettingsContainer* self = new ( ELeave ) CLocSUPLSettingsContainer(
       
   111                                                         aSettingsView );
       
   112 	CleanupStack::PushL( self );
       
   113 	self->ConstructL( aRect, aEngine );
       
   114 	return self;
       
   115 	}
       
   116 
       
   117 // --------------------------------------------------------------------------- 
       
   118 // void CLocSUPLSettingsContainer::ConstructL
       
   119 // Second phase of the two phase Construction process
       
   120 //
       
   121 // @param aRect				 Client rectangle
       
   122 // @param aEngine            Reference to the SUPL Settings engine
       
   123 // ---------------------------------------------------------------------------
       
   124 //
       
   125 void CLocSUPLSettingsContainer::ConstructL( 
       
   126                                     const TRect& 	aRect ,
       
   127                                           CLocSUPLSettingsUiEngine&     aEngine )
       
   128 	{
       
   129 	DEBUG( + CLocSUPLSettingsContainer::ConstructL );	
       
   130 	//Make this control a window-owning control
       
   131 	CreateWindowL(); 
       
   132 	
       
   133 	// Create a New Title for the View
       
   134 	MakeTitleL( R_SUPLVIEW_TITLE );
       
   135 	
       
   136 	CreateListboxL( aEngine );
       
   137 	
       
   138 	// Get the Help context
       
   139 	iContextName = KLOC_HLP_SUPL();
       
   140 	
       
   141     SetRect( aRect );
       
   142     ActivateL();
       
   143 	DEBUG( - CLocSUPLSettingsContainer::ConstructL );	
       
   144 	}	
       
   145 
       
   146 // ---------------------------------------------------------------------------
       
   147 // void CLocSUPLSettingsContainer::UpdateScreen
       
   148 // Refreshes the screen so that the list box reflects the latest contents
       
   149 // ---------------------------------------------------------------------------
       
   150 //
       
   151 void CLocSUPLSettingsContainer::UpdateScreen()
       
   152     {
       
   153 	DEBUG( + CLocSUPLSettingsContainer::UpdateScreen );	
       
   154     if ( iListBox )
       
   155         {
       
   156     	// Update Listbox items
       
   157     	TRAP_IGNORE( iListBox->HandleItemAdditionL() );
       
   158     	TRAP_IGNORE( iListBox->HandleItemRemovalL() );
       
   159         }
       
   160     DrawNow();
       
   161 	DEBUG( - CLocSUPLSettingsContainer::UpdateScreen );	
       
   162     }
       
   163 
       
   164 // -----------------------------------------------------------------------------
       
   165 // TInt CLocSUPLSettingsContainer::SelectedItemIndex
       
   166 // Returns the Selected element. The list box model defines the enumeration that
       
   167 // would determine the current element that has been selected
       
   168 //
       
   169 // @return TInt Index of the item selected
       
   170 // -----------------------------------------------------------------------------
       
   171 //
       
   172 TInt CLocSUPLSettingsContainer::SelectedItemIndex()
       
   173     {
       
   174     return iListBoxModel->ResolveSettingsItem( iListBox->CurrentItemIndex() );
       
   175     }
       
   176 			       
       
   177 // ---------------------------------------------------------------------------
       
   178 // void CLocSUPLSettingsContainer::HandleResourceChange
       
   179 //
       
   180 // ---------------------------------------------------------------------------	
       
   181 void CLocSUPLSettingsContainer::HandleResourceChange(TInt aType)
       
   182 	{
       
   183 	DEBUG( + CLocSUPLSettingsContainer::HandleResourceChange );	
       
   184 	// Pass the event to the base class
       
   185 	CCoeControl::HandleResourceChange(aType);
       
   186     switch( aType )
       
   187     	{
       
   188     	// Dynamic Layout switch
       
   189     	case KEikDynamicLayoutVariantSwitch:
       
   190     		{
       
   191     		iSettingsView.HandleScreenSizeChange();
       
   192 			break;
       
   193     		}
       
   194     	default:
       
   195     		{
       
   196     		break;
       
   197     		}
       
   198     	}
       
   199 	DEBUG( - CLocSUPLSettingsContainer::HandleResourceChange );	
       
   200 	}
       
   201    
       
   202 // -----------------------------------------------------------------------------
       
   203 // CLocSUPLSettingsContainer::GetHelpContext
       
   204 //
       
   205 // -----------------------------------------------------------------------------
       
   206 //
       
   207 void CLocSUPLSettingsContainer::GetHelpContext( TCoeHelpContext& aContext ) const
       
   208     {
       
   209 	DEBUG( + CLocSUPLSettingsContainer::GetHelpContext );	
       
   210     aContext.iContext = iContextName;
       
   211     aContext.iMajor = TUid::Uid( KLOCSUPLSETTINGSUIUID3 );
       
   212 	DEBUG( - CLocSUPLSettingsContainer::GetHelpContext );	
       
   213     }
       
   214     
       
   215 // ---------------------------------------------------------------------------
       
   216 // TInt CLocSUPLSettingsContainer::CountComponentControls
       
   217 //
       
   218 // ---------------------------------------------------------------------------
       
   219 TInt CLocSUPLSettingsContainer::CountComponentControls() const
       
   220 	{
       
   221 	return 1;
       
   222 	}
       
   223 
       
   224 // ---------------------------------------------------------------------------
       
   225 // CCoeControl* CLocSUPLSettingsContainer::ComponentControl
       
   226 //
       
   227 // ---------------------------------------------------------------------------
       
   228 CCoeControl* CLocSUPLSettingsContainer::ComponentControl( TInt /*aIndex*/ ) const
       
   229 	{
       
   230 	return iListBox;	
       
   231 	}
       
   232 
       
   233 // ---------------------------------------------------------------------------
       
   234 // void CLocSUPLSettingsContainer::OfferKeyEventL
       
   235 //
       
   236 // ---------------------------------------------------------------------------	
       
   237 //
       
   238 TKeyResponse CLocSUPLSettingsContainer::OfferKeyEventL( const TKeyEvent& aKeyEvent,
       
   239 										   					  TEventCode aType )
       
   240 	{
       
   241 	DEBUG( + CLocSUPLSettingsContainer::OfferKeyEventL );	
       
   242 	if( aType == EEventKey )
       
   243 		{
       
   244 		switch ( aKeyEvent.iScanCode )
       
   245 	        {
       
   246 	        case EStdKeyUpArrow:
       
   247 	        case EStdKeyDownArrow:
       
   248 	        	{        	
       
   249 	        	TKeyResponse keyresponse = iListBox->OfferKeyEventL( aKeyEvent, aType );        	
       
   250 	            iSettingsView.HandleCommandL( ELocSuplOpenChange );
       
   251 	            return keyresponse;	
       
   252 	        	}
       
   253 	        default:
       
   254 	        	{
       
   255 	        	break;	
       
   256 	        	}
       
   257 	        }		
       
   258 		}
       
   259 	DEBUG( - CLocSUPLSettingsContainer::OfferKeyEventL );	
       
   260     // now it's iListBox's job to process the key event
       
   261     return iListBox->OfferKeyEventL( aKeyEvent, aType ); 
       
   262 	}
       
   263 	    
       
   264 // ---------------------------------------------------------------------------
       
   265 // void CLocSUPLSettingsContainer::HandleListBoxEventL
       
   266 //
       
   267 // ---------------------------------------------------------------------------
       
   268 //
       
   269 void CLocSUPLSettingsContainer::HandleListBoxEventL( CEikListBox*  /* aListBox */, 
       
   270 		 						   					 TListBoxEvent aEventType )
       
   271 	{
       
   272 	DEBUG( + CLocSUPLSettingsContainer::HandleListBoxEventL );	
       
   273 	switch (aEventType)
       
   274         {
       
   275         case EEventItemClicked:
       
   276             {
       
   277             // The item is just selected here. Change the MSK to reflect
       
   278             // the Correct MSK value
       
   279             iSettingsView.HandleCommandL( ELocSuplOpenChange );
       
   280             break;    
       
   281             }
       
   282         // List box Item Selection
       
   283         case EEventEnterKeyPressed:
       
   284         case EEventItemSingleClicked: //case EEventItemDoubleClicked:
       
   285             {
       
   286             // Settings element has been selected. Command has to be issued to
       
   287             // change the settings configuration
       
   288             if ( SelectedItemIndex() == 0 )
       
   289                 {
       
   290                 iSettingsView.HandleCommandL( ELocSuplMSKChange );
       
   291                 }
       
   292             else if ( SelectedItemIndex() == 1 || SelectedItemIndex() == 2 )
       
   293                 {
       
   294                 iSettingsView.HandleCommandL( ELocSuplMSKOpen );
       
   295                 }
       
   296             break;	
       
   297             }
       
   298         default:
       
   299            break;
       
   300         }
       
   301 	DEBUG( - CLocSUPLSettingsContainer::HandleListBoxEventL );	
       
   302 	}
       
   303 	         		 	
       
   304 // ---------------------------------------------------------------------------
       
   305 // void CLocSUPLSettingsContainer::FocusChanged
       
   306 //
       
   307 // ---------------------------------------------------------------------------
       
   308 //
       
   309 void CLocSUPLSettingsContainer::FocusChanged( TDrawNow aDrawNow )
       
   310 	{
       
   311 	DEBUG( + CLocSUPLSettingsContainer::FocusChanged );	
       
   312 	CCoeControl::FocusChanged( aDrawNow );
       
   313 	// The focus event has to be explicitly handed over to all the compound
       
   314 	// controls since CCoeControl does not do that implicitly
       
   315 	if ( iListBox )
       
   316 		{
       
   317 		iListBox->SetFocus( IsFocused(), aDrawNow );				
       
   318 		}
       
   319 	DEBUG( - CLocSUPLSettingsContainer::FocusChanged );	
       
   320 	}
       
   321 		
       
   322 // ---------------------------------------------------------------------------
       
   323 // CLocSUPLSettingsContainer::SizeChanged
       
   324 // 
       
   325 // ---------------------------------------------------------------------------
       
   326 //
       
   327 void CLocSUPLSettingsContainer::SizeChanged()
       
   328 	{
       
   329 	DEBUG( + CLocSUPLSettingsContainer::SizeChanged );	
       
   330 	if ( iListBox )
       
   331 		{
       
   332 		iListBox->SetRect( Rect());
       
   333 		}
       
   334 	DEBUG( - CLocSUPLSettingsContainer::SizeChanged );	
       
   335 	}
       
   336 	
       
   337 // ---------------------------------------------------------------------------
       
   338 // void CLocSUPLSettingsContainer::MakeTitleL
       
   339 // Sets the Title text
       
   340 //
       
   341 // @param aResourceText Resource to create title
       
   342 // ---------------------------------------------------------------------------
       
   343 //
       
   344 void CLocSUPLSettingsContainer::MakeTitleL( TInt aResourceText )
       
   345 	{
       
   346 	DEBUG( + CLocSUPLSettingsContainer::MakeTitleL );	
       
   347 	// Obtain the title from the Status Pane
       
   348 	CAknTitlePane* title = static_cast<CAknTitlePane*>( StatusPane()->
       
   349         ControlL( TUid::Uid( EEikStatusPaneUidTitle ) ) );
       
   350        
       
   351     // Set the Title's buffer    
       
   352     HBufC* buf = StringLoader::LoadL( aResourceText );
       
   353     title->SetText( buf ); // Takes ownership of buf
       
   354 	DEBUG( - CLocSUPLSettingsContainer::MakeTitleL );	
       
   355 	}
       
   356 
       
   357 // ---------------------------------------------------------------------------
       
   358 // void CLocSUPLSettingsContainer::StatusPane
       
   359 // Returns the Appui's status pane
       
   360 //
       
   361 // @return CEikStatusPane* Statuspane pointer
       
   362 // ---------------------------------------------------------------------------
       
   363 //
       
   364 CEikStatusPane* CLocSUPLSettingsContainer::StatusPane()
       
   365 	{
       
   366 	return iEikonEnv->AppUiFactory()->StatusPane();	
       
   367 	}
       
   368 
       
   369 // ---------------------------------------------------------------------------
       
   370 // void CLocSUPLSettingsContainer::CreateListboxL
       
   371 // Creates the List box and the Listbox model. Associates the list box model 
       
   372 // with the list box
       
   373 //
       
   374 // @param aEngine                       Reference to the SUPL Settings
       
   375 //                                      engine 
       
   376 // ---------------------------------------------------------------------------	
       
   377 //
       
   378 void CLocSUPLSettingsContainer::CreateListboxL( 
       
   379                                     CLocSUPLSettingsUiEngine&     aEngine )
       
   380 	{
       
   381 	DEBUG( + CLocSUPLSettingsContainer::CreateListboxL );	
       
   382 	// Create the Listbox model
       
   383     iListBoxModel = CLocSUPLSettingsLBModel::NewL( aEngine );
       
   384 	
       
   385 	// Create the List box
       
   386 	iListBox = new ( ELeave ) CAknSettingStyleListBox;
       
   387     iListBox->ConstructL( this, EAknListBoxSelectionList );
       
   388     iListBox->SetContainerWindowL( *this ); 
       
   389     iListBox->SetListBoxObserver( this );
       
   390     iListBox->CreateScrollBarFrameL( ETrue );
       
   391     iListBox->ScrollBarFrame()->SetScrollBarVisibilityL( CEikScrollBarFrame::EOff,
       
   392     													 CEikScrollBarFrame::EAuto ); 
       
   393     													 
       
   394     // The ownership of the list box model is retained with the Container.
       
   395     // This is because the model contains the additional functionality of
       
   396     // changing the settings values in addition to retreiving it.    													 
       
   397     iListBox->Model()->SetItemTextArray( iListBoxModel );	
       
   398     iListBox->Model()->SetOwnershipType( ELbmDoesNotOwnItemArray );									
       
   399     iListBox->ActivateL();
       
   400 	DEBUG( - CLocSUPLSettingsContainer::CreateListboxL );	
       
   401 	}
       
   402 
       
   403 // ---------------------------------------------------------------------------
       
   404 // void CLocSUPLSettingsContainer::FocusToItemL
       
   405 // Focus move to server detail setting item
       
   406 //
       
   407 // ---------------------------------------------------------------------------
       
   408 //
       
   409 void CLocSUPLSettingsContainer::FocusToItemL( TInt aIndex )
       
   410 	{
       
   411 		iListBox->SetCurrentItemIndex( aIndex );
       
   412 	}
       
   413     
       
   414 // ---------------------------------------------------------------------------
       
   415 // TInt CLocSUPLSettingsLBModel::ActiveSessionCount()
       
   416 // Returns the number of Active sessions.
       
   417 //
       
   418 // @return  TInt Returns the number of Active sessions count.
       
   419 // ---------------------------------------------------------------------------
       
   420 //	
       
   421 TInt CLocSUPLSettingsContainer::ActiveSessionCount( ) const
       
   422     {
       
   423 	if( iListBoxModel )
       
   424 		{
       
   425 		return iListBoxModel->ActiveSessionCount();
       
   426 		}
       
   427 	else
       
   428 		{
       
   429 		return 0;
       
   430 		}
       
   431 	}
       
   432 
       
   433 // End of file