logsui/LogsPlugin/CLogsSettingsControlContainer.cpp
changeset 0 e686773b3f54
child 68 9da50d567e3c
equal deleted inserted replaced
-1:000000000000 0:e686773b3f54
       
     1 /*
       
     2 * Copyright (c) 2002 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: 
       
    15 *     Logs "Settings" view container control class implementation
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 #include <aknnavide.h>
       
    22 #include <AknUtils.h>
       
    23 #include <Logs.rsg>
       
    24 
       
    25 #include "CLogsSettingsControlContainer.h"
       
    26 #include "CLogsSettingsView.h"
       
    27 #include "CLogsEngine.h"
       
    28 #include "MLogsSharedData.h"
       
    29 
       
    30 #include "LogsConstants.hrh"
       
    31 
       
    32 #include "LogsUID.h"
       
    33 #include <csxhelp/log.hlp.hrh>
       
    34 
       
    35 // EXTERNAL DATA STRUCTURES
       
    36 
       
    37 // EXTERNAL FUNCTION PROTOTYPES  
       
    38 
       
    39 // CONSTANTS
       
    40 
       
    41 // MACROS
       
    42 
       
    43 // LOCAL CONSTANTS AND MACROS
       
    44 
       
    45 // MODULE DATA STRUCTURES
       
    46 
       
    47 // LOCAL FUNCTION PROTOTYPES
       
    48 
       
    49 // ==================== LOCAL FUNCTIONS ====================
       
    50 
       
    51 // ================= MEMBER FUNCTIONS =======================
       
    52 
       
    53 // ----------------------------------------------------------------------------
       
    54 // CLogsSettingsControlContainer::NewL
       
    55 // ----------------------------------------------------------------------------
       
    56 //
       
    57 CLogsSettingsControlContainer* CLogsSettingsControlContainer::NewL(
       
    58     CLogsSettingsView* aSettingsView,
       
    59     const TRect& aRect,
       
    60     TBool aForGs )  
       
    61     {
       
    62     CLogsSettingsControlContainer* self = new( ELeave ) 
       
    63                         CLogsSettingsControlContainer( aSettingsView );
       
    64     CleanupStack::PushL( self );
       
    65     self->ConstructL( aRect, aForGs );
       
    66     CleanupStack::Pop();  // self
       
    67     return self;
       
    68     }
       
    69 
       
    70 // ----------------------------------------------------------------------------
       
    71 // CLogsSettingsControlContainer::ConstructL
       
    72 // ----------------------------------------------------------------------------
       
    73 //
       
    74 void CLogsSettingsControlContainer::ConstructL( 
       
    75     const TRect& aRect,
       
    76     TBool aForGs )  
       
    77     {
       
    78     BaseConstructL();
       
    79     CreateListBoxL();        //Creates empty iListBox  
       
    80     
       
    81     if( aForGs )
       
    82         {
       
    83         MakeTitleL( R_LOGS_SETTINGS_TITLE_FOR_GS );
       
    84         }
       
    85     else
       
    86         {
       
    87         MakeTitleL( R_LOGS_SETTINGS_TITLE_FOR_LOGS );
       
    88         }
       
    89     
       
    90     MakeEmptyTextListBoxL( iListBox, R_LOGS_EVENTVIEW_FETCHING_TEXT );    
       
    91     NaviPaneL()->PushDefaultL();
       
    92     MakeScrollArrowsL( iListBox ); 
       
    93     SetRect( aRect );
       
    94     ActivateL();    
       
    95     }
       
    96 
       
    97 
       
    98 // ----------------------------------------------------------------------------
       
    99 // CLogsSettingsControlContainer::CLogsSettingsControlContainer
       
   100 // ----------------------------------------------------------------------------
       
   101 //
       
   102 CLogsSettingsControlContainer::CLogsSettingsControlContainer(
       
   103     CLogsSettingsView* aSettingsView ) :
       
   104         CLogsBaseControlContainer( aSettingsView ),
       
   105         iSettingsView( aSettingsView )
       
   106     {
       
   107     }
       
   108 
       
   109 // ----------------------------------------------------------------------------
       
   110 // CLogsSettingsControlContainer::~CLogsSettingsControlContainer
       
   111 // ----------------------------------------------------------------------------
       
   112 //
       
   113 CLogsSettingsControlContainer::~CLogsSettingsControlContainer()
       
   114     {
       
   115     delete iListBox;   
       
   116     }
       
   117 
       
   118 // ----------------------------------------------------------------------------
       
   119 // CLogsSettingsControlContainer::OfferKeyEventL
       
   120 // ----------------------------------------------------------------------------
       
   121 //
       
   122 TKeyResponse CLogsSettingsControlContainer::OfferKeyEventL(
       
   123     const TKeyEvent& aKeyEvent,
       
   124     TEventCode aType
       
   125     )
       
   126     {
       
   127     TKeyResponse res = CLogsBaseControlContainer::
       
   128                                     OfferKeyEventL(aKeyEvent, aType );
       
   129     iCurrentListBoxTopIndex = iListBox->TopItemIndex();
       
   130     iCurrentListBoxIndex = iListBox->CurrentItemIndex();
       
   131     return res;
       
   132     }
       
   133 
       
   134 
       
   135 // ----------------------------------------------------------------------------
       
   136 // CLogsSettingsControlContainer::ComponentControl
       
   137 // ----------------------------------------------------------------------------
       
   138 //
       
   139 CCoeControl* CLogsSettingsControlContainer::ComponentControl(
       
   140     TInt /*aIndex*/) const
       
   141     {
       
   142     return iListBox;
       
   143     }
       
   144 
       
   145 // ----------------------------------------------------------------------------
       
   146 // CLogsSettingsControlContainer::SizeChanged
       
   147 // ----------------------------------------------------------------------------
       
   148 //
       
   149 void CLogsSettingsControlContainer::SizeChanged()
       
   150     {
       
   151     if( iListBox )
       
   152         {
       
   153         iListBox->SetRect( Rect() );
       
   154         }
       
   155     }
       
   156 
       
   157 
       
   158 // ----------------------------------------------------------------------------
       
   159 // CLogsSettingsControlContainer::ListBox
       
   160 // ----------------------------------------------------------------------------
       
   161 //
       
   162 CAknSettingStyleListBox* CLogsSettingsControlContainer::ListBox()
       
   163     {
       
   164     return iListBox;
       
   165     }
       
   166 
       
   167 // ----------------------------------------------------------------------------
       
   168 // CLogsSettingsControlContainer::CreateListBoxL
       
   169 // ----------------------------------------------------------------------------
       
   170 //
       
   171 void CLogsSettingsControlContainer::CreateListBoxL()
       
   172     {
       
   173     if( iListBox )
       
   174         {
       
   175         delete iListBox;
       
   176         iListBox = NULL;
       
   177         }
       
   178 
       
   179     iListBox = new( ELeave ) CAknSettingStyleListBox;
       
   180     iListBox->ConstructL( this, EAknListBoxSelectionListWithShortcuts );
       
   181     SizeChanged();
       
   182     }
       
   183 
       
   184 // ----------------------------------------------------------------------------
       
   185 // CLogsSettingsControlContainer::AddOneListBoxTextLineL
       
   186 // ----------------------------------------------------------------------------
       
   187 //
       
   188 void CLogsSettingsControlContainer::AddOneListBoxTextLineL(
       
   189     CDesCArrayFlat* aItems,
       
   190     TInt aFirstResourceText,
       
   191     TInt aSecondResourceText )
       
   192     {
       
   193     // temporary place for the resource texts
       
   194     HBufC* textFromResourceFile;
       
   195     // Place where to put text to display
       
   196     HBufC* textBuf = HBufC::NewLC( KLogsBuff128 ); 
       
   197     TPtr ptr = textBuf->Des();
       
   198     ptr.Format( KEmptySpaceAndTabulator );
       
   199 
       
   200     textFromResourceFile = iCoeEnv->AllocReadResourceLC( aFirstResourceText );
       
   201     TPtr ptr2 = textFromResourceFile->Des();
       
   202     AknTextUtils::LanguageSpecificNumberConversion( ptr2 );
       
   203     ptr .AppendFormat( *textFromResourceFile );
       
   204     CleanupStack::PopAndDestroy();  // textFromResourceFile
       
   205 
       
   206     ptr .AppendFormat( KTabulatorTwice );
       
   207 
       
   208     textFromResourceFile = iCoeEnv->AllocReadResourceLC( aSecondResourceText );
       
   209     TPtr ptr3 = textFromResourceFile->Des();
       
   210     AknTextUtils::LanguageSpecificNumberConversion( ptr3 );
       
   211     ptr .AppendFormat( *textFromResourceFile );
       
   212 
       
   213     aItems->AppendL( *textBuf );
       
   214     CleanupStack::PopAndDestroy( 2 );  // textFromResourceFile, textBuf
       
   215     }
       
   216 
       
   217 // ----------------------------------------------------------------------------
       
   218 // CLogsSettingsControlContainer::UpdateListBoxContentL
       
   219 // ----------------------------------------------------------------------------
       
   220 //
       
   221 void CLogsSettingsControlContainer::UpdateListBoxContentL()
       
   222     {
       
   223     // Create item array for listbox
       
   224     CDesCArrayFlat* items = new( ELeave ) CDesCArrayFlat( 2 );  // for number of lines, see number of AddOneListBoxTextLineL calls
       
   225     CleanupStack::PushL( items );
       
   226 
       
   227     //  First line: Log Length ( 0 / 1 / 10 / 30 days )
       
   228     switch( iSettingsView->LogAge() )
       
   229         {
       
   230         case ELogsConfigAgeNoLog:
       
   231             AddOneListBoxTextLineL( items, R_LOGS_SETTINGS_LOG_LENGTH_TEXT,
       
   232                                        R_LOGS_SV_LOG_LENGTH_0_TEXT );
       
   233             break;
       
   234         
       
   235         case ELogsConfigAge1Days:
       
   236             AddOneListBoxTextLineL( items, R_LOGS_SETTINGS_LOG_LENGTH_TEXT,
       
   237                                        R_LOGS_SV_LOG_LENGTH_1_TEXT );
       
   238             break;
       
   239 
       
   240         case ELogsConfigAge10Days:
       
   241             AddOneListBoxTextLineL( items, R_LOGS_SETTINGS_LOG_LENGTH_TEXT,
       
   242                                        R_LOGS_SV_LOG_LENGTH_10_TEXT );
       
   243             break;
       
   244 
       
   245         case ELogsConfigAge30Days:
       
   246             AddOneListBoxTextLineL( items, R_LOGS_SETTINGS_LOG_LENGTH_TEXT,
       
   247                                        R_LOGS_SV_LOG_LENGTH_30_TEXT );
       
   248             break;
       
   249 
       
   250         default:
       
   251             AddOneListBoxTextLineL( items, R_LOGS_SETTINGS_LOG_LENGTH_TEXT,
       
   252                                        R_LOGS_SV_LOG_LENGTH_30_TEXT );
       
   253             break;
       
   254         }
       
   255     /************************************************
       
   256     "Show Call Duration" moved General Settings application, not in use any more in Logs 
       
   257     //  Second line: Show Call Duration in Phone application ( ON / OFF )
       
   258     if( iSettingsView->Engine()->SharedDataL()->ShowCallDurationPhone() )
       
   259         {
       
   260         AddOneListBoxTextLineL( items, 
       
   261                                 R_LOGS_SETTINGS_SHOW_CALL_DURATION_TEXT,
       
   262                                 R_QTN_LOGS_LDV3_TIMER_ON_TEXT );
       
   263         }
       
   264     else
       
   265         {
       
   266         AddOneListBoxTextLineL( items, 
       
   267                                 R_LOGS_SETTINGS_SHOW_CALL_DURATION_TEXT,
       
   268                                 R_QTN_LOGS_LDV3_TIMER_OFF_TEXT );
       
   269         }
       
   270     ************************************************/
       
   271 
       
   272     //  Creation of the model, which handles the text items
       
   273     CTextListBoxModel* model = iListBox->Model();
       
   274     model->SetItemTextArray( items );
       
   275     model->SetOwnershipType( ELbmOwnsItemArray );       //Ownership of items transferred 
       
   276     CleanupStack::Pop( items );                         
       
   277 
       
   278     if( iCurrentListBoxIndex != KErrNotFound )
       
   279         {
       
   280         iListBox->SetCurrentItemIndex( iCurrentListBoxIndex );
       
   281         }
       
   282 
       
   283     iListBox->SetTopItemIndex( iCurrentListBoxTopIndex );
       
   284 
       
   285     //MakeScrollArrowsL( iListBox );    --> moved to ConstructL to avoid flickering, fix for: SMEA-75MEVX 
       
   286     iListBox->HandleItemAdditionL(); 
       
   287     
       
   288     // Remember to hand focus to the newly created list if the container
       
   289     // already has the focus.
       
   290     iListBox->SetFocus( IsFocused() );    
       
   291     }
       
   292 
       
   293 // ----------------------------------------------------------------------------
       
   294 // CLogsSettingsControlContainer::GetHelpContext
       
   295 // ----------------------------------------------------------------------------
       
   296 //
       
   297 void CLogsSettingsControlContainer::GetHelpContext( TCoeHelpContext& aContext ) const
       
   298 	{
       
   299     aContext.iMajor = TUid::Uid( KLogsAppUID3 );
       
   300     aContext.iContext = KLOGS_HLP_SETTING;
       
   301     }
       
   302 
       
   303 // ----------------------------------------------------------------------------
       
   304 // CLogsSettingsControlContainer::FocusChanged
       
   305 //
       
   306 // This is needed to hand focus changes to list. Otherwise animations are not displayed.
       
   307 // ----------------------------------------------------------------------------
       
   308 //
       
   309 void CLogsSettingsControlContainer::FocusChanged(TDrawNow /* aDrawNow */ )
       
   310     {
       
   311     if( iListBox )
       
   312         {
       
   313         iListBox->SetFocus( IsFocused() );
       
   314         }
       
   315     }
       
   316 
       
   317 //  End of File