systemsettings/gssensorplugin/src/gssenturnctrlview.cpp
changeset 0 2e3d3ce01487
child 18 0818dd463d41
equal deleted inserted replaced
-1:000000000000 0:2e3d3ce01487
       
     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:  Sensors turn control view
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include "gssenturnctrlview.h"
       
    21 #include "gssenturnctrlcontainer.h"
       
    22 #include "gssensorplugin.hrh"
       
    23 #include "gssensorpluginlocalviewids.h"
       
    24 #include "gssenturnctrlcontainer.h"
       
    25 #include "gssensorpluginmodel.h"
       
    26 #include "gssensorplugin_debug.h"
       
    27 
       
    28 #include <aknViewAppUi.h>
       
    29 #include <gssensorpluginrsc.rsg>
       
    30 #include <gscommon.hrh>
       
    31 #include <eikbtgpc.h>
       
    32 
       
    33 
       
    34 // ========================= MEMBER FUNCTIONS ================================
       
    35 
       
    36 // ---------------------------------------------------------------------------
       
    37 // CGSSenTurnCtrlView::CGSSenTurnCtrlView
       
    38 // Default constructor
       
    39 // ---------------------------------------------------------------------------
       
    40 //
       
    41 CGSSenTurnCtrlView::CGSSenTurnCtrlView( CGSSensorPluginModel* aModel ) :
       
    42     iModel( aModel )
       
    43     {
       
    44     TRACE_( "[GSSensorPlugin] CGSSenTurnCtrlView::CGSSenTurnCtrlView()" );
       
    45     }
       
    46 
       
    47 // ---------------------------------------------------------------------------
       
    48 // CGSSenTurnCtrlView::NewL
       
    49 // Symbian OS two-phased constructor
       
    50 // ---------------------------------------------------------------------------
       
    51 CGSSenTurnCtrlView* CGSSenTurnCtrlView::NewL( CGSSensorPluginModel* aModel )
       
    52     {
       
    53     TRACE_( "[GSSensorPlugin] CGSSenTurnCtrlView::NewL()" );
       
    54     CGSSenTurnCtrlView* self = NewLC( aModel );
       
    55     CleanupStack::Pop( self );
       
    56     TRACE_( "[GSSensorPlugin] CGSSenTurnCtrlView::NewL() - return" );
       
    57     return self;
       
    58     }
       
    59 
       
    60 // ---------------------------------------------------------------------------
       
    61 // CGSSenTurnCtrlView::NewLC
       
    62 // Symbian OS two-phased constructor
       
    63 // ---------------------------------------------------------------------------
       
    64 CGSSenTurnCtrlView* CGSSenTurnCtrlView::NewLC( CGSSensorPluginModel* aModel )
       
    65     {
       
    66     TRACE_( "[GSSensorPlugin] CGSSenTurnCtrlView::NewLC()" );
       
    67     CGSSenTurnCtrlView* self = new( ELeave ) CGSSenTurnCtrlView( aModel );
       
    68     CleanupStack::PushL( self );
       
    69     self->ConstructL();
       
    70     TRACE_( "[GSSensorPlugin] CGSSenTurnCtrlView::NewLC() - return" );
       
    71     return self;
       
    72     }
       
    73 
       
    74 // ---------------------------------------------------------------------------
       
    75 // CGSSenTurnCtrlView::~CGSSenTurnCtrlView()
       
    76 // Destructor
       
    77 // ---------------------------------------------------------------------------
       
    78 CGSSenTurnCtrlView::~CGSSenTurnCtrlView()
       
    79     {
       
    80     TRACE_( "[GSSensorPlugin] CGSSenTurnCtrlView::~CGSSenTurnCtrlView()" );
       
    81     iModel = NULL;
       
    82     }
       
    83 
       
    84 // ---------------------------------------------------------------------------
       
    85 // CGSSenTurnCtrlView::ConstructL()
       
    86 // Symbian OS two-phased constructor
       
    87 // ---------------------------------------------------------------------------
       
    88 void CGSSenTurnCtrlView::ConstructL()
       
    89     {
       
    90     TRACE_( "[GSSensorPlugin] CGSSenTurnCtrlView::ConstructL()" );
       
    91     BaseConstructL( R_GS_CHECKBOX_VIEW );
       
    92     TRACE_( "[GSSensorPlugin] CGSSenTurnCtrlView::ConstructL() - return" );
       
    93     }
       
    94 
       
    95 // ---------------------------------------------------------------------------
       
    96 // TUid CGSSenTurnCtrlView::Id()
       
    97 // ---------------------------------------------------------------------------
       
    98 TUid CGSSenTurnCtrlView::Id() const
       
    99     {
       
   100     TRACE_1( "[GSSensorPlugin] CGSSenTurnCtrlView::Id() - ID: %i", KSenTurnCtrlViewId );
       
   101     return KSenTurnCtrlViewId;
       
   102     }
       
   103 
       
   104 // ---------------------------------------------------------------------------
       
   105 // CGSSenTurnCtrlView::HandleCommandL()
       
   106 // Command handling for sensor activation status view
       
   107 // ---------------------------------------------------------------------------
       
   108 void CGSSenTurnCtrlView::HandleCommandL( TInt aCommand )
       
   109     {   
       
   110     TRACE_1( "[GSSensorPlugin] CGSSenTurnCtrlView::HandleCommandL() - command: %i",
       
   111         aCommand );
       
   112 
       
   113     switch ( aCommand )
       
   114         {
       
   115         case EGSSenMskGeneral:
       
   116             {
       
   117             // Update checkbox and selections
       
   118             HandleListBoxSelectionL();
       
   119             // Update MSK label
       
   120             CheckMiddleSoftkeyLabelL();
       
   121             break;
       
   122             }
       
   123         case EGSCmdOk:
       
   124             // Check selections
       
   125             Container()->CheckSelections();
       
   126             // Store changes and show previous view
       
   127             Container()->StoreSelectionsL();
       
   128             // cont. to next case
       
   129         case EAknSoftkeyBack:
       
   130             {
       
   131             // activate previous view
       
   132             iAppUi->ActivateLocalViewL( KGSSensorPluginUid );
       
   133             break;
       
   134             }
       
   135         default:
       
   136             iAppUi->HandleCommandL( aCommand );
       
   137             break;
       
   138         }
       
   139     TRACE_( "[GSSensorPlugin] CGSSenTurnCtrlView::HandleCommandL() - return" );
       
   140     }
       
   141 
       
   142 // ---------------------------------------------------------------------------
       
   143 // CGSSenTurnCtrlView::Container
       
   144 // Returns call container item
       
   145 // ---------------------------------------------------------------------------
       
   146 //
       
   147 CGSSenTurnCtrlContainer* CGSSenTurnCtrlView::Container()
       
   148     {
       
   149     TRACE_( "[GSSensorPlugin] CGSSenTurnCtrlView::Container()" );
       
   150     return static_cast<CGSSenTurnCtrlContainer*>( iContainer );
       
   151     }
       
   152 
       
   153 // ---------------------------------------------------------------------------
       
   154 // CGSSenTurnCtrlView::NewContainerL()
       
   155 // Creates new iContainer.
       
   156 // ---------------------------------------------------------------------------
       
   157 //
       
   158 void CGSSenTurnCtrlView::NewContainerL()
       
   159     {
       
   160     TRACE_( "[GSSensorPlugin] CGSSenTurnCtrlView::NewContainerL()" );
       
   161     iContainer = new ( ELeave ) CGSSenTurnCtrlContainer( iModel, *this );
       
   162     TRACE_( "[GSSensorPlugin] CGSSenTurnCtrlView::NewContainerL() - return" );
       
   163     }
       
   164 
       
   165 // ---------------------------------------------------------------------------
       
   166 // CGSSenTurnCtrlView::HandleListBoxSelectionL()
       
   167 // ---------------------------------------------------------------------------
       
   168 void CGSSenTurnCtrlView::HandleListBoxSelectionL() 
       
   169     {
       
   170     TRACE_( "[GSSensorPlugin] CGSSenTurnCtrlView::HandleListBoxSelectionL()" );
       
   171     const TInt currentItem = Container()->CurrentFeatureId();
       
   172     Container()->ChangeSelectionStatus( currentItem );
       
   173     Container()->UpdateCheckboxIconL( currentItem );
       
   174     TRACE_( "[GSSensorPlugin] CGSSenTurnCtrlView::HandleListBoxSelectionL() - return" );
       
   175     }
       
   176 
       
   177 // ---------------------------------------------------------------------------
       
   178 // CGSSenTurnCtrlView::CheckMiddleSoftkeyLabelL
       
   179 // ---------------------------------------------------------------------------
       
   180 //
       
   181 void CGSSenTurnCtrlView::CheckMiddleSoftkeyLabelL() 
       
   182     {
       
   183     TRACE_( "[GSSensorPlugin] CGSSenTurnCtrlView::CheckMiddleSoftkeyLabelL()" );
       
   184     // First, resolve current item
       
   185     const TInt currentItem = Container()->CurrentFeatureId();
       
   186 
       
   187     // First, remove current label
       
   188     RemoveCommandFromMSK();
       
   189 
       
   190     // Resolve is currently selected item checked or unchecked and change MSK label accordingly
       
   191     if ( Container()->SelectionStatus( currentItem ) )
       
   192         {
       
   193         // Change MKS to 'Unmark'
       
   194         SetMiddleSoftKeyLabelL( R_GS_MKS_LABEL_UNMARK, EGSSenMskGeneral );
       
   195         }
       
   196     else
       
   197         {
       
   198         // Change MSK to 'Mark'
       
   199         SetMiddleSoftKeyLabelL( R_GS_MKS_LABEL_MARK, EGSSenMskGeneral );
       
   200         }  
       
   201 
       
   202     TRACE_( "[GSSensorPlugin] CGSSenTurnCtrlView::CheckMiddleSoftkeyLabelL() - return" );
       
   203     }