perfmon/src/perfmon_settingsviewdlg.cpp
branchRCL_3
changeset 22 fad26422216a
equal deleted inserted replaced
21:b3cee849fa46 22:fad26422216a
       
     1 /*
       
     2 * Copyright (c) 2009 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 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include "perfmon_settingsviewdlg.h"
       
    21 #include "perfmon_model.h"
       
    22 #include "perfmon.hrh"
       
    23 #include "perfmon_std.h"
       
    24 #include <perfmon.rsg>
       
    25 
       
    26 #include <aknsettingitemlist.h>
       
    27 #include <CAknMemorySelectionSettingItem.h> 
       
    28 #include <aknlists.h>
       
    29 #include <akntitle.h>
       
    30 #include <aknnavi.h>
       
    31 #include <aknnavide.h>
       
    32 #include <StringLoader.h>
       
    33 #include <aknnotewrappers.h> 
       
    34 
       
    35 // ===================================== MEMBER FUNCTIONS =====================================
       
    36 
       
    37 CPerfMonSettingsViewDlg* CPerfMonSettingsViewDlg::NewL(TPerfMonSettings& aSettings)
       
    38     {
       
    39     CPerfMonSettingsViewDlg* self = new(ELeave) CPerfMonSettingsViewDlg(aSettings);
       
    40     CleanupStack::PushL(self);
       
    41     self->ConstructL();
       
    42     CleanupStack::Pop(self);
       
    43     return self;    
       
    44     }
       
    45 
       
    46 // --------------------------------------------------------------------------------------------
       
    47 
       
    48 CPerfMonSettingsViewDlg::~CPerfMonSettingsViewDlg()
       
    49     {
       
    50     // restore default navi pane by popping the tab group from stack
       
    51     if (iNaviContainer)
       
    52         iNaviContainer->Pop();
       
    53     
       
    54     if (iSettingItemArray)
       
    55         {
       
    56         iSettingItemArray->ResetAndDestroy();
       
    57         delete iSettingItemArray; 
       
    58         }
       
    59     
       
    60     delete iDecoratedTabGroup;   
       
    61     }
       
    62 
       
    63 // --------------------------------------------------------------------------------------------
       
    64 
       
    65 CPerfMonSettingsViewDlg::CPerfMonSettingsViewDlg(TPerfMonSettings& aSettings) : iSettings(aSettings)
       
    66     {
       
    67     }
       
    68 
       
    69 // --------------------------------------------------------------------------------------------
       
    70 
       
    71 void CPerfMonSettingsViewDlg::ConstructL()
       
    72     {
       
    73     // construct a menu bar
       
    74     CAknDialog::ConstructL(R_PERFMON_SETTINGS_MENUBAR);
       
    75 
       
    76     // get pointer to status pane   
       
    77     CEikStatusPane* sp = iEikonEnv->AppUiFactory()->StatusPane();
       
    78     
       
    79     // set title text
       
    80     CAknTitlePane* tp = static_cast<CAknTitlePane*>( sp->ControlL( TUid::Uid( EEikStatusPaneUidTitle ) ) );
       
    81     tp->SetTextL( _L("Settings") );
       
    82     
       
    83     // create a new tab group
       
    84     iNaviContainer = static_cast<CAknNavigationControlContainer*>(sp->ControlL(TUid::Uid(EEikStatusPaneUidNavi)));
       
    85     iDecoratedTabGroup = iNaviContainer->CreateTabGroupL(this);
       
    86     iTabGroup = static_cast<CAknTabGroup*>(iDecoratedTabGroup->DecoratedControl());
       
    87     iTabGroup->SetTabFixedWidthL(KTabWidthWithTwoLongTabs); 
       
    88     
       
    89     // add tabs
       
    90     iTabGroup->AddTabL(ETabSettingsGeneral, _L("General"));
       
    91     iTabGroup->AddTabL(ETabSettingsDataPopup, _L("Data popup"));
       
    92     iTabGroup->AddTabL(ETabSettingsGraphs, _L("Graphs"));
       
    93     iTabGroup->AddTabL(ETabSettingsLogging, _L("Logging"));
       
    94     iTabGroup->SetActiveTabByIndex(ETabSettingsGeneral);
       
    95     
       
    96     // add new tab group to stack
       
    97     iNaviContainer->PushL( *iDecoratedTabGroup );
       
    98     }
       
    99 
       
   100 // --------------------------------------------------------------------------------------------
       
   101 
       
   102 void CPerfMonSettingsViewDlg::HandleListBoxEventL(CEikListBox* /*aListBox*/, TListBoxEvent aEventType)
       
   103     {
       
   104     switch (aEventType)
       
   105         {
       
   106         case EEventEnterKeyPressed:
       
   107         case EEventItemDoubleClicked:
       
   108             ShowSettingPageL(EFalse);
       
   109             break;
       
   110         default:
       
   111             break;
       
   112         }
       
   113     }
       
   114 
       
   115 // --------------------------------------------------------------------------------------------
       
   116 
       
   117 void CPerfMonSettingsViewDlg::TabChangedL(TInt /*aIndex*/)
       
   118     {
       
   119     iListBox->SetCurrentItemIndex(0);
       
   120 
       
   121     SetVisibilitiesOfSettingItemsL();   
       
   122     }
       
   123 
       
   124 // --------------------------------------------------------------------------------------------
       
   125 
       
   126 void CPerfMonSettingsViewDlg::ProcessCommandL(TInt aCommandId)
       
   127     {
       
   128     CAknDialog::ProcessCommandL(aCommandId);
       
   129 
       
   130     switch (aCommandId)
       
   131         {
       
   132         case EPerfMonCmdSettingsChange:
       
   133             ShowSettingPageL(ETrue);
       
   134             break;
       
   135         case EPerfMonCmdSettingsExit:
       
   136             TryExitL(EAknCmdExit);
       
   137             break;
       
   138         default:
       
   139             break;
       
   140         }
       
   141     }
       
   142 
       
   143 // --------------------------------------------------------------------------------------------
       
   144 
       
   145 TKeyResponse CPerfMonSettingsViewDlg::OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType)
       
   146     {
       
   147     if (iTabGroup == NULL)
       
   148         {
       
   149         return EKeyWasNotConsumed;
       
   150         }
       
   151 
       
   152     TInt active = iTabGroup->ActiveTabIndex();
       
   153     TInt count = iTabGroup->TabCount();
       
   154 
       
   155     switch ( aKeyEvent.iCode )
       
   156         {
       
   157         case EKeyLeftArrow:
       
   158             if (active > 0)
       
   159                 {
       
   160                 active--;
       
   161                 iTabGroup->SetActiveTabByIndex(active);
       
   162                 TabChangedL(active); 
       
   163                 }
       
   164             break;
       
   165         
       
   166         case EKeyRightArrow:
       
   167             if((active + 1) < count)
       
   168                 {
       
   169                 active++;
       
   170                 iTabGroup->SetActiveTabByIndex(active);
       
   171                 TabChangedL(active); 
       
   172                 }
       
   173             break;
       
   174         }
       
   175 
       
   176     return CAknDialog::OfferKeyEventL(aKeyEvent, aType);
       
   177     }    
       
   178 
       
   179 // --------------------------------------------------------------------------------------------
       
   180 
       
   181 void CPerfMonSettingsViewDlg::PreLayoutDynInitL()
       
   182     {
       
   183     iListBox = static_cast<CAknSettingStyleListBox*>( Control(EPerfMonSettingItemList) );
       
   184     iListBox->SetMopParent(this);
       
   185     iListBox->CreateScrollBarFrameL(ETrue);
       
   186     iListBox->ScrollBarFrame()->SetScrollBarVisibilityL(CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto);
       
   187     iListBox->SetListBoxObserver(this);
       
   188 
       
   189     iSettingItemArray = new(ELeave) CAknSettingItemArray(16, EFalse, 0);
       
   190 
       
   191     CTextListBoxModel* model = iListBox->Model();
       
   192     model->SetItemTextArray(iSettingItemArray);
       
   193     model->SetOwnershipType(ELbmDoesNotOwnItemArray);
       
   194 
       
   195     UpdateListBoxL();    
       
   196     }
       
   197 
       
   198 // --------------------------------------------------------------------------------------------
       
   199 
       
   200 TBool CPerfMonSettingsViewDlg::OkToExitL(TInt aButtonId)
       
   201     {
       
   202     return CAknDialog::OkToExitL(aButtonId);
       
   203     }
       
   204 
       
   205 // --------------------------------------------------------------------------------------------
       
   206 
       
   207 void CPerfMonSettingsViewDlg::ShowSettingPageL(TInt aCalledFromMenu)
       
   208     {
       
   209     TInt listIndex = iListBox->CurrentItemIndex();
       
   210     TInt realIndex = iSettingItemArray->ItemIndexFromVisibleIndex(listIndex);
       
   211     CAknSettingItem* item = iSettingItemArray->At(realIndex);
       
   212     item->EditItemL(aCalledFromMenu);
       
   213     item->StoreL();
       
   214     SetVisibilitiesOfSettingItemsL();
       
   215     DrawNow();
       
   216     }
       
   217 
       
   218 // --------------------------------------------------------------------------------------------
       
   219 
       
   220 void CPerfMonSettingsViewDlg::SetVisibilitiesOfSettingItemsL()
       
   221     {
       
   222     if (iSettingItemArray->Count() > 0)
       
   223         {
       
   224         switch (iTabGroup->ActiveTabIndex())
       
   225             {
       
   226             case ETabSettingsGeneral:
       
   227                 {
       
   228                 ((*iSettingItemArray)[ESettingListItemHeartBeat])->SetHidden(EFalse);
       
   229                 ((*iSettingItemArray)[ESettingListItemMaxSamples])->SetHidden(EFalse);
       
   230                 ((*iSettingItemArray)[ESettingListItemPriority])->SetHidden(EFalse);
       
   231                 ((*iSettingItemArray)[ESettingListItemCPUMode])->SetHidden(EFalse);
       
   232                 ((*iSettingItemArray)[ESettingListItemKeepBackLightOn])->SetHidden(EFalse);
       
   233 
       
   234                 ((*iSettingItemArray)[ESettingListItemDataPopupVisbility])->SetHidden(ETrue);
       
   235                 ((*iSettingItemArray)[ESettingListItemDataPopupLocation])->SetHidden(ETrue);
       
   236                 ((*iSettingItemArray)[ESettingListItemDataPopupSources])->SetHidden(ETrue);
       
   237 
       
   238                 ((*iSettingItemArray)[ESettingListItemGraphsVerticalBarPeriod])->SetHidden(ETrue);
       
   239                 ((*iSettingItemArray)[ESettingListItemGraphsSources])->SetHidden(ETrue);
       
   240 
       
   241                 ((*iSettingItemArray)[ESettingListItemLoggingMode])->SetHidden(ETrue);
       
   242                 ((*iSettingItemArray)[ESettingListItemLoggingFilePath])->SetHidden(ETrue);
       
   243                 ((*iSettingItemArray)[ESettingListItemLoggingSources])->SetHidden(ETrue);
       
   244 
       
   245                 break;
       
   246                 }
       
   247             
       
   248             case ETabSettingsDataPopup:
       
   249                 {
       
   250                 ((*iSettingItemArray)[ESettingListItemHeartBeat])->SetHidden(ETrue);
       
   251                 ((*iSettingItemArray)[ESettingListItemMaxSamples])->SetHidden(ETrue);
       
   252                 ((*iSettingItemArray)[ESettingListItemPriority])->SetHidden(ETrue);
       
   253                 ((*iSettingItemArray)[ESettingListItemCPUMode])->SetHidden(ETrue);
       
   254                 ((*iSettingItemArray)[ESettingListItemKeepBackLightOn])->SetHidden(ETrue);
       
   255 
       
   256                 ((*iSettingItemArray)[ESettingListItemDataPopupVisbility])->SetHidden(EFalse);
       
   257                 ((*iSettingItemArray)[ESettingListItemDataPopupLocation])->SetHidden(EFalse);
       
   258                 ((*iSettingItemArray)[ESettingListItemDataPopupSources])->SetHidden(EFalse);
       
   259 
       
   260                 ((*iSettingItemArray)[ESettingListItemGraphsVerticalBarPeriod])->SetHidden(ETrue);
       
   261                 ((*iSettingItemArray)[ESettingListItemGraphsSources])->SetHidden(ETrue);
       
   262 
       
   263                 ((*iSettingItemArray)[ESettingListItemLoggingMode])->SetHidden(ETrue);
       
   264                 ((*iSettingItemArray)[ESettingListItemLoggingFilePath])->SetHidden(ETrue);
       
   265                 ((*iSettingItemArray)[ESettingListItemLoggingSources])->SetHidden(ETrue);
       
   266 
       
   267                 break;
       
   268                 }
       
   269 
       
   270             case ETabSettingsGraphs:
       
   271                 {
       
   272                 ((*iSettingItemArray)[ESettingListItemHeartBeat])->SetHidden(ETrue);
       
   273                 ((*iSettingItemArray)[ESettingListItemMaxSamples])->SetHidden(ETrue);
       
   274                 ((*iSettingItemArray)[ESettingListItemPriority])->SetHidden(ETrue);
       
   275                 ((*iSettingItemArray)[ESettingListItemCPUMode])->SetHidden(ETrue);
       
   276                 ((*iSettingItemArray)[ESettingListItemKeepBackLightOn])->SetHidden(ETrue);
       
   277 
       
   278                 ((*iSettingItemArray)[ESettingListItemDataPopupVisbility])->SetHidden(ETrue);
       
   279                 ((*iSettingItemArray)[ESettingListItemDataPopupLocation])->SetHidden(ETrue);
       
   280                 ((*iSettingItemArray)[ESettingListItemDataPopupSources])->SetHidden(ETrue);
       
   281 
       
   282                 ((*iSettingItemArray)[ESettingListItemGraphsVerticalBarPeriod])->SetHidden(EFalse);
       
   283                 ((*iSettingItemArray)[ESettingListItemGraphsSources])->SetHidden(EFalse);
       
   284 
       
   285                 ((*iSettingItemArray)[ESettingListItemLoggingMode])->SetHidden(ETrue);
       
   286                 ((*iSettingItemArray)[ESettingListItemLoggingFilePath])->SetHidden(ETrue);
       
   287                 ((*iSettingItemArray)[ESettingListItemLoggingSources])->SetHidden(ETrue);
       
   288 
       
   289                 break;
       
   290                 }
       
   291 
       
   292             case ETabSettingsLogging:
       
   293                 {
       
   294                 ((*iSettingItemArray)[ESettingListItemHeartBeat])->SetHidden(ETrue);
       
   295                 ((*iSettingItemArray)[ESettingListItemMaxSamples])->SetHidden(ETrue);
       
   296                 ((*iSettingItemArray)[ESettingListItemPriority])->SetHidden(ETrue);
       
   297                 ((*iSettingItemArray)[ESettingListItemCPUMode])->SetHidden(ETrue);
       
   298                 ((*iSettingItemArray)[ESettingListItemKeepBackLightOn])->SetHidden(ETrue);
       
   299 
       
   300                 ((*iSettingItemArray)[ESettingListItemDataPopupVisbility])->SetHidden(ETrue);
       
   301                 ((*iSettingItemArray)[ESettingListItemDataPopupLocation])->SetHidden(ETrue);
       
   302                 ((*iSettingItemArray)[ESettingListItemDataPopupSources])->SetHidden(ETrue);
       
   303 
       
   304                 ((*iSettingItemArray)[ESettingListItemGraphsVerticalBarPeriod])->SetHidden(ETrue);
       
   305                 ((*iSettingItemArray)[ESettingListItemGraphsSources])->SetHidden(ETrue);
       
   306 
       
   307                 ((*iSettingItemArray)[ESettingListItemLoggingMode])->SetHidden(EFalse);
       
   308                 
       
   309                 if (iSettings.iLoggingMode == ELoggingModeLogFile || iSettings.iLoggingMode == ELoggingModeRDebugLogFile)
       
   310                     ((*iSettingItemArray)[ESettingListItemLoggingFilePath])->SetHidden(EFalse);
       
   311                 else
       
   312                     ((*iSettingItemArray)[ESettingListItemLoggingFilePath])->SetHidden(ETrue);
       
   313                 
       
   314                 ((*iSettingItemArray)[ESettingListItemLoggingSources])->SetHidden(EFalse);
       
   315 
       
   316                 break;
       
   317                 }                
       
   318 
       
   319             default:
       
   320                 User::Panic(_L("TabIOOB"), 50);
       
   321                 break;
       
   322             }
       
   323 
       
   324         iSettingItemArray->RecalculateVisibleIndicesL();
       
   325         iListBox->HandleItemAdditionL();
       
   326         iListBox->UpdateScrollBarsL();
       
   327         }
       
   328     }   
       
   329 
       
   330 // --------------------------------------------------------------------------------------------
       
   331 
       
   332 void CPerfMonSettingsViewDlg::UpdateListBoxL()
       
   333     {
       
   334     iSettingItemArray->ResetAndDestroy();
       
   335 
       
   336     // create items
       
   337     TInt ordinal(0);
       
   338 
       
   339     AddSettingItemL(ESettingListItemHeartBeat,
       
   340                     R_HEARTBEAT_SETTING_TITLE,
       
   341                     R_HEARTBEAT_SETTING_PAGE,
       
   342                     NULL,
       
   343                     ordinal++);    
       
   344     
       
   345     AddSettingItemL(ESettingListItemMaxSamples,
       
   346                     R_MAXSAMPLES_SETTING_TITLE,
       
   347                     R_MAXSAMPLES_SETTING_PAGE,
       
   348                     NULL,
       
   349                     ordinal++);
       
   350 
       
   351     AddSettingItemL(ESettingListItemPriority,
       
   352                     R_PRIORITY_SETTING_TITLE,
       
   353                     R_PRIORITY_SETTING_PAGE,
       
   354                     R_PRIORITY_SETTING_TEXTS,
       
   355                     ordinal++);
       
   356 
       
   357     AddSettingItemL(ESettingListItemCPUMode,
       
   358                     R_CPUMODE_SETTING_TITLE,
       
   359                     R_CPUMODE_SETTING_PAGE,
       
   360                     R_CPUMODE_SETTING_TEXTS,
       
   361                     ordinal++);
       
   362 
       
   363     AddSettingItemL(ESettingListItemKeepBackLightOn,
       
   364                     R_KEEPBACKLIGHTON_SETTING_TITLE,
       
   365                     R_BINARY_SETTING_PAGE,
       
   366                     R_YESNO_BINARYSELECTION_TEXTS,
       
   367                     ordinal++);
       
   368 //
       
   369     AddSettingItemL(ESettingListItemDataPopupVisbility,
       
   370                     R_DATAPOPUPVISIBILITY_SETTING_TITLE,
       
   371                     R_DATAPOPUPVISIBILITY_SETTING_PAGE,
       
   372                     R_DATAPOPUPVISIBILITY_SETTING_TEXTS,
       
   373                     ordinal++);
       
   374 
       
   375     AddSettingItemL(ESettingListItemDataPopupLocation,
       
   376                     R_DATAPOPUPLOCATION_SETTING_TITLE,
       
   377                     R_DATAPOPUPLOCATION_SETTING_PAGE,
       
   378                     R_DATAPOPUPLOCATION_SETTING_TEXTS,
       
   379                     ordinal++);
       
   380 
       
   381     AddSettingItemL(ESettingListItemDataPopupSources,
       
   382                     R_SOURCES_SETTING_TITLE,
       
   383                     R_SOURCES_SETTING_PAGE,
       
   384                     NULL,
       
   385                     ordinal++);                    
       
   386 //
       
   387     AddSettingItemL(ESettingListItemGraphsVerticalBarPeriod,
       
   388                     R_GRAPHSVERTICALBAR_SETTING_TITLE,
       
   389                     R_GRAPHSVERTICALBAR_SETTING_PAGE,
       
   390                     NULL,
       
   391                     ordinal++);
       
   392     
       
   393     AddSettingItemL(ESettingListItemGraphsSources,
       
   394                     R_SOURCES_SETTING_TITLE,
       
   395                     R_SOURCES_SETTING_PAGE,
       
   396                     NULL,
       
   397                     ordinal++);                    
       
   398 //
       
   399     AddSettingItemL(ESettingListItemLoggingMode,
       
   400                     R_LOGGINGMODE_SETTING_TITLE,
       
   401                     R_LOGGINGMODE_SETTING_PAGE,
       
   402                     R_LOGGINGMODE_SETTING_TEXTS,
       
   403                     ordinal++);
       
   404 
       
   405      AddSettingItemL(ESettingListItemLoggingFilePath,
       
   406                     R_LOGGINGFILEPATH_SETTING_TITLE,
       
   407                     R_LOGGINGFILEPATH_SETTING_PAGE,
       
   408                     NULL,
       
   409                     ordinal++);
       
   410     
       
   411     AddSettingItemL(ESettingListItemLoggingSources,
       
   412                     R_SOURCES_SETTING_TITLE,
       
   413                     R_SOURCES_SETTING_PAGE,
       
   414                     NULL,
       
   415                     ordinal++);                    
       
   416                                                              
       
   417     SetVisibilitiesOfSettingItemsL(); 
       
   418     }
       
   419 
       
   420 // --------------------------------------------------------------------------------------------
       
   421 
       
   422 void CPerfMonSettingsViewDlg::AddSettingItemL(TInt aId,
       
   423                                                  TInt aTitleResource,
       
   424                                                  TInt aSettingPageResource,
       
   425                                                  TInt aAssociatedResource,
       
   426                                                  TInt aOrdinal)
       
   427     {
       
   428     // create a setting item
       
   429     CAknSettingItem* settingItem = NULL;
       
   430     
       
   431     switch (aId)
       
   432         {
       
   433         case ESettingListItemHeartBeat:
       
   434             settingItem = new(ELeave) CAknIntegerEdwinSettingItem(aId, iSettings.iHeartBeat);
       
   435             break;
       
   436 
       
   437         case ESettingListItemMaxSamples:
       
   438             settingItem = new(ELeave) CAknIntegerEdwinSettingItem(aId, iSettings.iMaxSamples);
       
   439             break;
       
   440 
       
   441         case ESettingListItemPriority:
       
   442             settingItem = new(ELeave) CAknEnumeratedTextPopupSettingItem(aId, iSettings.iPriority);
       
   443             break;
       
   444 
       
   445         case ESettingListItemCPUMode:
       
   446             settingItem = new(ELeave) CAknEnumeratedTextPopupSettingItem(aId, iSettings.iCPUMode);
       
   447             break;
       
   448 
       
   449         case ESettingListItemKeepBackLightOn:
       
   450             settingItem = new(ELeave) CAknBinaryPopupSettingItem(aId, iSettings.iKeepBacklightOn);
       
   451             break;
       
   452 
       
   453         case ESettingListItemDataPopupVisbility:
       
   454             settingItem = new(ELeave) CAknEnumeratedTextPopupSettingItem(aId, iSettings.iDataPopupVisibility);
       
   455             break;
       
   456 
       
   457         case ESettingListItemDataPopupLocation:
       
   458             settingItem = new(ELeave) CAknEnumeratedTextPopupSettingItem(aId, iSettings.iDataPopupLocation);
       
   459             break;
       
   460 
       
   461         case ESettingListItemDataPopupSources:
       
   462             settingItem = new(ELeave) CSourceSelectionCheckBoxSettingItem(aId, iSettings.iDataPopupSources);
       
   463             break;
       
   464 
       
   465         case ESettingListItemGraphsVerticalBarPeriod:
       
   466             settingItem = new(ELeave) CAknIntegerEdwinSettingItem(aId, iSettings.iGraphsVerticalBarPeriod);
       
   467             break;
       
   468 
       
   469         case ESettingListItemGraphsSources:
       
   470             settingItem = new(ELeave) CSourceSelectionCheckBoxSettingItem(aId, iSettings.iGraphsSources);
       
   471             break;
       
   472 
       
   473         case ESettingListItemLoggingMode:
       
   474             settingItem = new(ELeave) CAknEnumeratedTextPopupSettingItem(aId, iSettings.iLoggingMode);
       
   475             break;
       
   476 
       
   477         case ESettingListItemLoggingFilePath:
       
   478             settingItem = new(ELeave) CAknTextSettingItem(aId, iSettings.iLoggingFilePath);
       
   479             break;
       
   480 
       
   481         case ESettingListItemLoggingSources:
       
   482             settingItem = new(ELeave) CSourceSelectionCheckBoxSettingItem(aId, iSettings.iLoggingSources);
       
   483             break;
       
   484 
       
   485         default:
       
   486             User::Panic(_L("NotSetItem"), 50);
       
   487             break;
       
   488         }
       
   489         
       
   490     CleanupStack::PushL(settingItem);
       
   491 
       
   492     // get title text
       
   493     HBufC* itemTitle = StringLoader::LoadLC(aTitleResource);
       
   494 
       
   495     // construct the setting item
       
   496     settingItem->ConstructL(EFalse, aOrdinal, *itemTitle, NULL, aSettingPageResource,
       
   497                             EAknCtPopupSettingList, NULL, aAssociatedResource);
       
   498 
       
   499     // append the setting item to settingitem array
       
   500     iSettingItemArray->InsertL(aOrdinal, settingItem);
       
   501 
       
   502     CleanupStack::PopAndDestroy(); //itemTitle
       
   503     CleanupStack::Pop(); //settingItem
       
   504     }
       
   505 
       
   506 
       
   507 // --------------------------------------------------------------------------------------------
       
   508 // --------------------------------------------------------------------------------------------
       
   509 	
       
   510 CSourceSelectionCheckBoxSettingItem::CSourceSelectionCheckBoxSettingItem( TInt aIdentifier, TPerfMonSources& aMemoryInUse ): 
       
   511 	CAknSettingItem(aIdentifier), iExternalSources( aMemoryInUse ) 
       
   512 	{
       
   513 	}	
       
   514 
       
   515 CSourceSelectionCheckBoxSettingItem::~CSourceSelectionCheckBoxSettingItem()
       
   516 	{
       
   517 	delete iSettingText;
       
   518 
       
   519     if( iItemArray )
       
   520         {
       
   521         iItemArray->ResetAndDestroy();
       
   522         delete iItemArray;
       
   523         }
       
   524 	}
       
   525 
       
   526 void CSourceSelectionCheckBoxSettingItem::AddNewItemToArrayL(const TDesC& aLabel)
       
   527 	{
       
   528 	TBuf<64> buf;
       
   529 	buf.Copy(aLabel);
       
   530 	
       
   531     CSelectableItem* item = new(ELeave) CSelectableItem(buf, EFalse);
       
   532     CleanupStack::PushL(item);
       
   533     item->ConstructL();
       
   534     iItemArray->AppendL(item); // Ownership is transferred
       
   535     CleanupStack::Pop(); // item	
       
   536 	}
       
   537 	
       
   538 void CSourceSelectionCheckBoxSettingItem::CompleteConstructionL()
       
   539 	{
       
   540     SetEmptyItemTextL(_L("Nothing selected"));
       
   541 
       
   542     iItemArray = new(ELeave) CSelectionItemList(16);
       
   543     AddNewItemToArrayL(_L("CPU"));
       
   544     AddNewItemToArrayL(_L("RAM"));
       
   545     AddNewItemToArrayL(_L("C:"));
       
   546     AddNewItemToArrayL(_L("D:"));
       
   547     AddNewItemToArrayL(_L("E:"));
       
   548     AddNewItemToArrayL(_L("F:"));
       
   549     AddNewItemToArrayL(_L("G:"));
       
   550     AddNewItemToArrayL(_L("H:"));
       
   551     AddNewItemToArrayL(_L("I:"));
       
   552 
       
   553 	__ASSERT_ALWAYS(ESourcesLength==iItemArray->Count(), User::Panic(_L("Src.mismatch"),443));
       
   554     }
       
   555 
       
   556 // transfer settings to the variables defined in the constructor    	
       
   557 void CSourceSelectionCheckBoxSettingItem::StoreL()
       
   558 	{
       
   559 	for (TInt i=0; i<ESourcesLength; i++)
       
   560 	    {
       
   561         iExternalSources.iSrcEnabled[i] = iItemArray->At(i)->SelectionStatus();
       
   562 	    }
       
   563 	}
       
   564 
       
   565 // load settings from the variables defined in the constructor to our internal variables
       
   566 void CSourceSelectionCheckBoxSettingItem::LoadL()
       
   567 	{
       
   568 	for (TInt i=0; i<ESourcesLength; i++)
       
   569 	    {
       
   570         iItemArray->At(i)->SetSelectionStatus( iExternalSources.iSrcEnabled[i] );
       
   571 	    }
       
   572 	}
       
   573 
       
   574 // returns the text shown in the setting item list
       
   575 const TDesC& CSourceSelectionCheckBoxSettingItem::SettingTextL()
       
   576 	{
       
   577     TBuf<32> settingText;
       
   578 
       
   579     if (iItemArray->At(ESourceCPU)->SelectionStatus())
       
   580         settingText.Append(_L("CPU "));
       
   581     if (iItemArray->At(ESourceRAM)->SelectionStatus())
       
   582         settingText.Append(_L("RAM "));
       
   583     if (iItemArray->At(ESourceC)->SelectionStatus())
       
   584         settingText.Append(_L("C: "));
       
   585     if (iItemArray->At(ESourceD)->SelectionStatus())
       
   586         settingText.Append(_L("D: "));
       
   587     if (iItemArray->At(ESourceE)->SelectionStatus())
       
   588         settingText.Append(_L("E: "));
       
   589     if (iItemArray->At(ESourceF)->SelectionStatus())
       
   590         settingText.Append(_L("F: "));
       
   591     if (iItemArray->At(ESourceG)->SelectionStatus())
       
   592         settingText.Append(_L("G: "));
       
   593     if (iItemArray->At(ESourceH)->SelectionStatus())
       
   594         settingText.Append(_L("H: "));
       
   595     if (iItemArray->At(ESourceI)->SelectionStatus())
       
   596         settingText.Append(_L("I: "));
       
   597     settingText.TrimAll();
       
   598 
       
   599     if (iSettingText)
       
   600         {
       
   601         delete iSettingText;
       
   602         iSettingText = NULL;
       
   603         }
       
   604 
       
   605     iSettingText = HBufC::NewL(settingText.Length());
       
   606     iSettingText->Des().Copy(settingText);
       
   607 
       
   608 	if ( iSettingText->Length() > 0 )
       
   609 		return *iSettingText;
       
   610 	else
       
   611 		return EmptyItemText();
       
   612 	}
       
   613 
       
   614 
       
   615 // launches the setting page
       
   616 void CSourceSelectionCheckBoxSettingItem::EditItemL(TBool /*aCalledFromMenu*/)
       
   617 	{
       
   618 	CSourceSelectionCheckBoxSettingPage* dlg = new(ELeave) CSourceSelectionCheckBoxSettingPage(SettingPageResourceId(), iItemArray);
       
   619 
       
   620 	SetSettingPage( dlg );
       
   621 	SettingPage()->SetSettingPageObserver(this);
       
   622 
       
   623 	SettingPage()->ExecuteLD(CAknSettingPage::EUpdateWhenChanged);
       
   624 	SetSettingPage(0); // it is deleted now
       
   625 	}
       
   626 
       
   627 
       
   628 // handles setting page events
       
   629 void CSourceSelectionCheckBoxSettingItem::HandleSettingPageEventL( CAknSettingPage* aSettingPage, TAknSettingPageEvent aEventType )
       
   630     {
       
   631     switch( aEventType )
       
   632         {
       
   633         case EEventSettingCancelled:
       
   634             {
       
   635             // If setting is cancelled, load old values
       
   636             LoadL();
       
   637             break;
       
   638             }
       
   639         case EEventSettingChanged:
       
   640             {
       
   641             // If setting has changed, update CBA visibility
       
   642             static_cast<CSourceSelectionCheckBoxSettingPage*>( aSettingPage )->UpdateCba();
       
   643             break;
       
   644             }
       
   645         default:
       
   646             {
       
   647             break;
       
   648             }
       
   649         }
       
   650     CAknSettingItem::HandleSettingPageEventL( aSettingPage, aEventType );
       
   651     }
       
   652 
       
   653 // --------------------------------------------------------------------------------------------
       
   654 // --------------------------------------------------------------------------------------------
       
   655 
       
   656 CSourceSelectionCheckBoxSettingPage::CSourceSelectionCheckBoxSettingPage(TInt aResourceID, CSelectionItemList* aItemArray )
       
   657     : CAknCheckBoxSettingPage( aResourceID, aItemArray )
       
   658 	{
       
   659 	}
       
   660 
       
   661 void CSourceSelectionCheckBoxSettingPage::UpdateCba()
       
   662 	{
       
   663 	// Cache the pointer to button group container
       
   664 	CEikButtonGroupContainer* cba = Cba();
       
   665 	// Left softkey should be visible if there are items selected,
       
   666 	// i.e. the selection index array has items.
       
   667 	TBool visible( ListBoxControl()->View()->SelectionIndexes()->Count() > 0 );
       
   668 	// Resolve left softkey command id
       
   669 	TInt leftId( cba->ButtonGroup()->CommandId( 0 ) );
       
   670 	// Check if left softkey visibility has changed
       
   671 	if( visible != cba->IsCommandVisible( leftId ) )
       
   672 		{
       
   673 		// Left softkey visibility has changed, update it
       
   674 		cba->MakeCommandVisible( leftId, visible );
       
   675 		}
       
   676 	}
       
   677 
       
   678 // --------------------------------------------------------------------------------------------
       
   679 // --------------------------------------------------------------------------------------------
       
   680     
       
   681 // End of File