sipplugins/sippsipsettingsui/src/sipsettlistsipprofsetcontainer.cpp
changeset 0 307788aac0a8
child 4 dd3853b8dc3f
child 15 8248b03a2669
equal deleted inserted replaced
-1:000000000000 0:307788aac0a8
       
     1 /*
       
     2 * Copyright (c) 2005 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:  The control container (view) of the profile setting view
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include    <eikappui.h>
       
    21 #include    <eikenv.h>
       
    22 #include    <csxhelp/cp.hlp.hrh>
       
    23 #include    <gsfwviewuids.h>
       
    24 #include    <aknsettingitemlist.h>
       
    25 #include    "sipsettlistsipprofsetcontainer.h"
       
    26 #include    "sipsettlistsipprofsetmodel.h"
       
    27 #include    "sipsettlistsipprofsetview.h"
       
    28 #include    "sipsettlistsipprofsetitemlist.h"
       
    29 #include     "sipsettingsplugin.h"
       
    30 #include    "gssippluginlogger.h"
       
    31 
       
    32 // LOCAL CONSTANTS AND MACROS
       
    33 
       
    34 const TInt KNumberOfControls = 1;
       
    35 const TInt KControlItemList = 0;
       
    36 
       
    37 // ============================ MEMBER FUNCTIONS ==============================
       
    38 
       
    39 // ----------------------------------------------------------------------------
       
    40 // CSIPSettListSIPProfSetContainer::CSIPSettListSIPProfSetContainer
       
    41 // C++ default constructor can NOT contain any code, that
       
    42 // might leave.
       
    43 // ----------------------------------------------------------------------------
       
    44 //
       
    45 CSIPSettListSIPProfSetContainer::CSIPSettListSIPProfSetContainer()
       
    46     {
       
    47     __GSLOGSTRING("CSIPSettListSIPProfSetContainer::CSIPSettListSIPProfSetContainer" )
       
    48     }
       
    49 
       
    50 // ----------------------------------------------------------------------------
       
    51 // CSIPSettListSIPProfSetContainer::ConstructL
       
    52 // Symbian 2nd phase constructor can leave.
       
    53 // ----------------------------------------------------------------------------
       
    54 //
       
    55 void CSIPSettListSIPProfSetContainer::ConstructL(
       
    56     TInt aIndex,
       
    57     CAknTitlePane* aPane,
       
    58     const TRect& aRect,    
       
    59     CSIPSettListSIPProfSetModel& aModel )
       
    60     {
       
    61     __GSLOGSTRING("CSIPSettListSIPProfSetContainer::ConstructL" )
       
    62     CreateWindowL();
       
    63 
       
    64     // Initialize item list
       
    65     iItemList = CSIPSettListSIPProfSetItemList::NewL( this, &aModel, aPane );
       
    66 
       
    67     // Set limits to the view & activate it
       
    68     SetRect( aRect );
       
    69     ActivateL();
       
    70     CAknSettingItemArray * array = iItemList->SettingItemArray();
       
    71     TInt Uiindex = 0;
       
    72     for( TInt i = 0; i < array->Count(); i ++ )
       
    73         {
       
    74         if( aIndex == array->ItemIndexFromVisibleIndex(i) )
       
    75             {
       
    76             Uiindex = i;
       
    77             break;
       
    78             }
       
    79         }
       
    80     
       
    81     iItemList->ListBox()->SetCurrentItemIndex( Uiindex );    
       
    82     DrawNow();
       
    83     
       
    84     iTimer = CGSSIPTimer::NewL( *this, *(iItemList->ListBox()->View()->ItemDrawer()) );
       
    85     }
       
    86 
       
    87 // -----------------------------------------------------------------------------
       
    88 // CSIPSettListSIPProfSetContainer::NewL
       
    89 // Two-phased constructor.
       
    90 // -----------------------------------------------------------------------------
       
    91 //
       
    92 CSIPSettListSIPProfSetContainer* CSIPSettListSIPProfSetContainer::NewL( 
       
    93     TInt aIndex,
       
    94     CAknTitlePane* aPane,
       
    95     MObjectProvider* aProvider,
       
    96     const TRect& aRect,        
       
    97     CSIPSettListSIPProfSetModel& aModel )
       
    98     {
       
    99     __GSLOGSTRING("CSIPSettListSIPProfSetContainer::NewL" )
       
   100     CSIPSettListSIPProfSetContainer* self = 
       
   101         new ( ELeave ) CSIPSettListSIPProfSetContainer();
       
   102     
       
   103     CleanupStack::PushL( self );
       
   104     self->SetMopParent( aProvider );
       
   105     self->ConstructL( aIndex, aPane, aRect, aModel );
       
   106     CleanupStack::Pop( self );
       
   107 
       
   108     return self;
       
   109     }
       
   110    
       
   111 // Destructor
       
   112 CSIPSettListSIPProfSetContainer::~CSIPSettListSIPProfSetContainer()
       
   113     {
       
   114     __GSLOGSTRING("CSIPSettListSIPProfSetContainer::~CSIPSettListSIPProfSetContainer" )  
       
   115     delete iItemList;
       
   116     delete iTimer;
       
   117     iTimer = NULL;
       
   118     }
       
   119 
       
   120 // -----------------------------------------------------------------------------
       
   121 // CSIPSettListSIPProfSetContainer::EditCurrentListItemL
       
   122 // Edits the current list item by simulating the enter key press
       
   123 // -----------------------------------------------------------------------------
       
   124 //
       
   125 void CSIPSettListSIPProfSetContainer::EditCurrentListItemL( TInt aCommand )
       
   126     { 
       
   127     __GSLOGSTRING("CSIPSettListSIPProfSetContainer::EditCurrentListItemL" ) 
       
   128     const TInt index = iItemList->ListBox()->CurrentItemIndex();
       
   129     if ( aCommand == EGSMSKCmdAppChange &&
       
   130         ( index == EGSItemServiceProfile ||
       
   131             index == EGSItemCompression ||
       
   132             index == EGSItemRegistration ||
       
   133             index == EGSItemSecurity ) )
       
   134         {
       
   135         iItemList->HandleListBoxEventL( iItemList->ListBox(),
       
   136             MEikListBoxObserver::EEventEnterKeyPressed );
       
   137         }
       
   138     else
       
   139         {
       
   140         iItemList->EditItemL( iItemList->ListBox()->CurrentItemIndex(), ETrue );
       
   141         }
       
   142         
       
   143     TKeyEvent event;
       
   144     event.iCode = EStdKeyEnter;
       
   145     event.iScanCode = EKeyEnter;
       
   146     OfferKeyEventL( event, EEventKey );                    
       
   147     }
       
   148 
       
   149 // -----------------------------------------------------------------------------
       
   150 // CSIPSettListSIPProfSetContainer::StoreSettingsL()
       
   151 // Stores settings to actual variables from item list
       
   152 // -----------------------------------------------------------------------------
       
   153 //
       
   154 void CSIPSettListSIPProfSetContainer::StoreSettingsL()
       
   155     {
       
   156     iItemList->StoreSettingsL();
       
   157     }
       
   158 
       
   159 // -----------------------------------------------------------------------------
       
   160 // CSIPSettListSIPProfSetContainer::CountComponentControls
       
   161 // Returns the amount of controls on the view
       
   162 // -----------------------------------------------------------------------------
       
   163 //
       
   164 TInt CSIPSettListSIPProfSetContainer::CountComponentControls() const
       
   165     {
       
   166     return KNumberOfControls;
       
   167     }
       
   168 
       
   169 // -----------------------------------------------------------------------------
       
   170 // CSIPSettListSIPProfSetContainer::ComponentControl
       
   171 // Returns list box
       
   172 // -----------------------------------------------------------------------------
       
   173 //
       
   174 CCoeControl* CSIPSettListSIPProfSetContainer::ComponentControl( 
       
   175     TInt aIndex ) const
       
   176     {
       
   177     __GSLOGSTRING("CSIPSettListSIPProfSetContainer::ComponentControl" ) 
       
   178     CCoeControl* cntrl = NULL;
       
   179 
       
   180     if ( aIndex == KControlItemList )
       
   181         {
       
   182         cntrl = iItemList->ListBox();
       
   183         }
       
   184                                                                   
       
   185     return cntrl;
       
   186     }
       
   187 
       
   188 // -----------------------------------------------------------------------------
       
   189 // CSIPSettListSIPProfSetContainer::SizeChanged
       
   190 // Sets new size for the item list
       
   191 // -----------------------------------------------------------------------------
       
   192 //
       
   193 void CSIPSettListSIPProfSetContainer::SizeChanged()
       
   194     {
       
   195     iItemList->ListBox()->SetRect( Rect() );
       
   196     }
       
   197 
       
   198 // -----------------------------------------------------------------------------
       
   199 // CSIPSettListSIPProfSetContainer::OfferKeyEventL
       
   200 // Handles the key events, pushes them to item list
       
   201 // -----------------------------------------------------------------------------
       
   202 //
       
   203 TKeyResponse CSIPSettListSIPProfSetContainer::OfferKeyEventL( 
       
   204     const TKeyEvent& aKeyEvent,
       
   205     TEventCode aType )
       
   206     {
       
   207     __GSLOGSTRING("CSIPSettListSIPProfSetContainer::OfferKeyEventL" ) 
       
   208     // Pass the key event to list box
       
   209     if ( aKeyEvent.iCode == EKeyUpArrow || aKeyEvent.iCode == EKeyDownArrow )
       
   210         {
       
   211         iItemList->ListBox()->View()->ItemDrawer()->ClearFlags( CTextListItemDrawer::EDisableHighlight );
       
   212 
       
   213         iTimer->StartTimer();
       
   214 
       
   215         }
       
   216     
       
   217     return iItemList->OfferKeyEventL( aKeyEvent, aType );
       
   218     }
       
   219     
       
   220 // -----------------------------------------------------------------------------
       
   221 // CSIPSettListSIPProfSetContainer::FocusChanged()
       
   222 // Responds to a change in focus
       
   223 // -----------------------------------------------------------------------------
       
   224 //
       
   225 void CSIPSettListSIPProfSetContainer::FocusChanged( TDrawNow aDrawNow )
       
   226     {
       
   227     __GSLOGSTRING("CSIPSettListSIPProfSetContainer::FocusChanged" ) 
       
   228     CCoeControl::FocusChanged( aDrawNow );
       
   229     if( iItemList )
       
   230         {
       
   231       iItemList->SetFocus( IsFocused(), aDrawNow );
       
   232         }
       
   233         iTimer->StopTimer();
       
   234 
       
   235     }
       
   236 
       
   237 // ---------------------------------------------------------------------------
       
   238 // CSIPSettListSIPProfSetContainer::HandleResourceChange
       
   239 // Resource change handling
       
   240 // ---------------------------------------------------------------------------
       
   241 // 
       
   242 void CSIPSettListSIPProfSetContainer::HandleResourceChange( TInt aType )
       
   243     {
       
   244     __GSLOGSTRING("CSIPSettListSIPProfSetContainer::HandleResourceChange" ) 
       
   245     CCoeControl::HandleResourceChange( aType );
       
   246     if ( aType == KEikDynamicLayoutVariantSwitch )
       
   247         {
       
   248         TRect mainPaneRect;
       
   249         AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EMainPane,
       
   250                                            mainPaneRect);
       
   251         SetRect( mainPaneRect );
       
   252         }
       
   253     }
       
   254 
       
   255 // ---------------------------------------------------------------------------
       
   256 // CSIPSettListSIPProfSetContainer::GetHelpContext(TCoeHelpContext& aContext) const
       
   257 // Gets Help 
       
   258 //  
       
   259 // ---------------------------------------------------------------------------
       
   260 //
       
   261 void CSIPSettListSIPProfSetContainer::GetHelpContext(TCoeHelpContext& aContext) const
       
   262     {
       
   263     __GSLOGSTRING("CSIPSettListSIPProfSetContainer::GetHelpContext" )
       
   264     aContext.iMajor = KUidGS;
       
   265     aContext.iContext = KSIP_HLP_PROF_PARAMS;
       
   266     }
       
   267 
       
   268 // -----------------------------------------------------------------------------
       
   269 // CSIPSettListSIPProfSetContainer::HandlePointerEventL()
       
   270 // Responds to a Pointer Event.
       
   271 // -----------------------------------------------------------------------------
       
   272 //
       
   273 void CSIPSettListSIPProfSetContainer::HandlePointerEventL( const TPointerEvent& aPointerEvent )
       
   274     {
       
   275     __GSLOGSTRING("CSIPSettListSIPProfSetContainer::HandlePointerEventL" )
       
   276      iItemList->ListBox()->View()->ItemDrawer()->ClearFlags( CTextListItemDrawer::EDisableHighlight );
       
   277      DrawNow();    
       
   278      CCoeControl::HandlePointerEventL( aPointerEvent );
       
   279     }
       
   280 
       
   281 // -----------------------------------------------------------------------------
       
   282 // CSIPSettListSIPProfSetContainer::IfPointerEvent()
       
   283 // Check if it is Pointer Event.
       
   284 // -----------------------------------------------------------------------------
       
   285 //
       
   286 TBool CSIPSettListSIPProfSetContainer::IfPointerEvent()
       
   287     {
       
   288      return !( iTimer->IsStarted() );
       
   289     }
       
   290 
       
   291 //Second
       
   292 //  End of File