perfapps/memspyui/ui/avkon/src/MemSpyViewMainMenu.cpp
changeset 51 b048e15729d6
equal deleted inserted replaced
44:5db69f4c3d06 51:b048e15729d6
       
     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 #include "MemSpyViewMainMenu.h"
       
    19 
       
    20 // Engine includes
       
    21 #include <memspy/engine/memspyengine.h>
       
    22 #include <memspy/engine/memspyengineobjectprocess.h>
       
    23 #include <memspy/engine/memspyengineobjectthread.h>
       
    24 #include <memspy/engine/memspyengineobjectcontainer.h>
       
    25 #include <memspy/engine/memspyengineobjectthreadinfoobjects.h>
       
    26 #include <memspy/engine/memspyengineobjectthreadinfocontainer.h>
       
    27 #include <memspy/engine/memspyenginehelperprocess.h>
       
    28 
       
    29 // User includes
       
    30 #include "MemSpyContainerObserver.h"
       
    31 #include "MemSpyViewProcesses.h"
       
    32 #include "MemSpyViewRAMInfo.h"
       
    33 #include "MemSpyViewROMInfo.h"
       
    34 #include "MemSpyViewServerList.h"
       
    35 #include "MemSpyViewOpenFiles.h"
       
    36 #include "MemSpyViewFBServBitmaps.h"
       
    37 #include "MemSpyViewSystemConfig.h"
       
    38 #include "MemSpyViewCodeSegList.h"
       
    39 #include "MemSpyViewChunkList.h"
       
    40 #include "MemSpyViewKernel.h"
       
    41 #include "MemSpyViewHeapTracking.h"
       
    42 #include "MemSpyViewDriveInfo.h"
       
    43 #include "MemSpyViewECom.h"
       
    44 #include "MemSpyViewMemoryTrackingAutoStartConfig.h"
       
    45 #include "MemSpyViewWindowGroups.h"
       
    46 
       
    47 // System includes
       
    48 #include <aknnotewrappers.h>
       
    49 
       
    50 /*
       
    51 CMemSpyViewMainMenu::CMemSpyViewMainMenu( CMemSpyEngine& aEngine, MMemSpyViewObserver& aObserver )
       
    52 :   CMemSpyViewBase( aEngine, aObserver )
       
    53     {
       
    54     }
       
    55 */
       
    56 CMemSpyViewMainMenu::CMemSpyViewMainMenu( RMemSpySession& aSession, MMemSpyViewObserver& aObserver )
       
    57 :   CMemSpyViewBase( aSession, aObserver )
       
    58     {
       
    59     }
       
    60 
       
    61 void CMemSpyViewMainMenu::ConstructL( const TRect& aRect, CCoeControl& aContainer, TAny* aSelectionRune )
       
    62     {
       
    63     _LIT( KTitle, "MemSpy" );
       
    64     SetTitleL( KTitle );
       
    65     //
       
    66     CMemSpyViewBase::ConstructL( aRect, aContainer, aSelectionRune );
       
    67     
       
    68     // Make sure the correct item is selected
       
    69     const TMemSpyViewType viewType = (TMemSpyViewType) ((TInt) aSelectionRune);
       
    70     const TInt index = IndexByViewType( viewType );
       
    71     iListBox->SetCurrentItemIndex( index );
       
    72     HandleListBoxItemSelectedL( index );
       
    73     }
       
    74 
       
    75 
       
    76 void CMemSpyViewMainMenu::RefreshL()
       
    77     {
       
    78     SetListBoxModelL();
       
    79     CMemSpyViewBase::RefreshL();
       
    80     }
       
    81 
       
    82 
       
    83 TMemSpyViewType CMemSpyViewMainMenu::ViewType() const
       
    84     {
       
    85     return EMemSpyViewTypeMainMenu;
       
    86     }
       
    87 
       
    88 
       
    89 CMemSpyViewBase* CMemSpyViewMainMenu::PrepareChildViewL()
       
    90     {
       
    91     CMemSpyViewBase* child = NULL;
       
    92     const TInt index = iListBox->CurrentItemIndex();
       
    93     
       
    94 #ifdef __WINS__
       
    95     // threads & process view is not supported in the emulator environment    
       
    96     if  ( index == 0 )
       
    97         {
       
    98         CAknInformationNote* note = new (ELeave) CAknInformationNote;
       
    99         note->ExecuteLD(_L("Not supported in the emulator, try Kernel -> Objects view"));
       
   100         return NULL;
       
   101         }
       
   102 #endif
       
   103 
       
   104     if  ( index == 0 )
       
   105         {
       
   106         child = new(ELeave) CMemSpyViewProcesses( iMemSpySession, iObserver );		
       
   107         }
       
   108     else if ( index == 1 )
       
   109         {
       
   110         //child = new(ELeave) CMemSpyViewRAMInfo( iEngine, iObserver );
       
   111 		child = new(ELeave) CMemSpyViewKernel( iMemSpySession, iObserver );
       
   112         }
       
   113     else if ( index == 2 )
       
   114         {
       
   115 		child = new(ELeave) CMemSpyViewHeapTracking( iMemSpySession, iObserver );
       
   116         }
       
   117     else if ( index == 3 )
       
   118             {
       
   119             child = new(ELeave) CMemSpyViewServerList( iMemSpySession, iObserver );
       
   120             }
       
   121         
       
   122     /*
       
   123     else if ( index == 2 )
       
   124         {
       
   125         child = new(ELeave) CMemSpyViewROMInfo( iEngine, iObserver );
       
   126         }
       
   127     else if ( index == 3 )
       
   128         {
       
   129         child = new(ELeave) CMemSpyViewFBServBitmaps( iEngine, iObserver );
       
   130         }
       
   131     else if ( index == 4 )
       
   132         {
       
   133         child = new(ELeave) CMemSpyViewServerList( iEngine, iObserver );
       
   134         }
       
   135     else if ( index == 5 )
       
   136         {
       
   137         child = new(ELeave) CMemSpyViewChunkList( iEngine, iObserver );
       
   138         }
       
   139     else if ( index == 6 )
       
   140         {
       
   141         child = new(ELeave) CMemSpyViewCodeSegList( iEngine, iObserver );
       
   142         }
       
   143     else if ( index == 7 )
       
   144         {
       
   145         child = new(ELeave) CMemSpyViewOpenFiles( iEngine, iObserver );
       
   146         }
       
   147     else if ( index == 8 )
       
   148         {
       
   149         child = new(ELeave) CMemSpyViewSystemConfig( iEngine, iObserver );
       
   150         }    
       
   151     else if ( index == 9 )
       
   152         {
       
   153         child = new(ELeave) CMemSpyViewKernel( iEngine, iObserver );		       
       
   154         }       
       
   155     else if ( index == 10 )
       
   156         {
       
   157         child = new(ELeave) CMemSpyViewHeapTracking( iEngine, iObserver );
       
   158         }
       
   159      */    
       
   160     /*
       
   161     else if ( index == 11 )
       
   162         {
       
   163         child = new(ELeave) CMemSpyViewMemoryTrackingAutoStartConfig( iEngine, iObserver );
       
   164         }
       
   165     else if ( index == 12 )
       
   166         {
       
   167         child = new(ELeave) CMemSpyViewDriveList( iEngine, iObserver );
       
   168         }
       
   169     else if ( index == 13 )
       
   170         {
       
   171         child = new(ELeave) CMemSpyViewECom( iEngine, iObserver );
       
   172         }
       
   173     else if ( index == 14 )
       
   174         {
       
   175         child = new(ELeave) CMemSpyViewWindowGroups( iEngine, iObserver );
       
   176         }
       
   177         */
       
   178     CleanupStack::PushL( child );
       
   179     child->ConstructL( Rect(), *Parent() );
       
   180     CleanupStack::Pop( child );
       
   181     return child;
       
   182     }
       
   183 
       
   184 
       
   185 void CMemSpyViewMainMenu::SetListBoxModelL()
       
   186     {
       
   187     CDesCArrayFlat* model = new(ELeave) CDesCArrayFlat(5);
       
   188     CleanupStack::PushL( model );
       
   189 
       
   190     TBuf<KMaxFullName + 1> item;
       
   191 
       
   192     
       
   193     // 1st item = Processes
       
   194     _LIT(KItem1Format, "\tProcesses & Threads");
       
   195     item.Format( KItem1Format );
       
   196     model->AppendL( item );
       
   197 
       
   198     //some main view items temporary removed
       
   199     /*
       
   200     // 2nd item = RAM info
       
   201     _LIT(KItem2Format, "\tRAM Info");
       
   202     model->AppendL( KItem2Format );
       
   203 
       
   204     // 3rd item = ROM info
       
   205     _LIT(KItem3Format, "\tROM Info");
       
   206     model->AppendL( KItem3Format );
       
   207 
       
   208     // 4th item = FBServ Bitmaps
       
   209     _LIT(KItem4Format, "\tFont & Bitmap\nServer");
       
   210     model->AppendL( KItem4Format );
       
   211 	*/
       
   212 
       
   213     /*
       
   214     // 6th item = Chunks
       
   215     _LIT(KItem6Format, "\tChunks");
       
   216     model->AppendL( KItem6Format );
       
   217 
       
   218     // 7th item = Code Segments
       
   219     _LIT(KItem7Format, "\tCode Segments");
       
   220     model->AppendL( KItem7Format );
       
   221 
       
   222     // 8th item = Open Files
       
   223     _LIT(KItem8Format, "\tOpen Files");
       
   224     model->AppendL( KItem8Format );
       
   225 
       
   226     // 9th item = System Config
       
   227     _LIT(KItem9Format, "\tSystem\nConfiguration");
       
   228     model->AppendL( KItem9Format );
       
   229 	*/
       
   230     
       
   231     // 10th item = Kernel
       
   232     _LIT(KItem2Format, "\tKernel");
       
   233     model->AppendL( KItem2Format );    
       
   234 
       
   235     // 11th item = Heap Tracking
       
   236     _LIT(KItem3Format, "\tSystem-Wide Memory Tracking");
       
   237     model->AppendL( KItem3Format );
       
   238 
       
   239     // 5th item = Servers
       
   240     _LIT(KItem4Format, "\tServers");    
       
   241     model->AppendL( KItem4Format );
       
   242     /*
       
   243     // 12th item = Process-specific Tracking
       
   244     _LIT(KItem12Format, "\tProcess-Specific Memory Tracking");
       
   245     model->AppendL( KItem12Format );
       
   246 
       
   247     // 13th item = Drive Info
       
   248     _LIT(KItem13Format, "\tDrive Summary");
       
   249     model->AppendL( KItem13Format );
       
   250 
       
   251     // 14th item = ECOM
       
   252     _LIT(KItem14Format, "\tECom");
       
   253     model->AppendL( KItem14Format );
       
   254 
       
   255     // 15th item = Window Groups
       
   256     _LIT(KItem15Format, "\tWindow Groups");
       
   257     model->AppendL( KItem15Format );
       
   258     */
       
   259     // Set up list box
       
   260     CAknSettingStyleListBox* listbox = static_cast< CAknSettingStyleListBox* >( iListBox );
       
   261     listbox->Model()->SetItemTextArray( model );
       
   262     listbox->Model()->SetOwnershipType( ELbmOwnsItemArray );
       
   263     CleanupStack::Pop( model );
       
   264     }
       
   265 
       
   266 
       
   267 TInt CMemSpyViewMainMenu::IndexByViewType( TMemSpyViewType aType )
       
   268     {
       
   269     TInt index = 0;
       
   270     //
       
   271     switch( aType )
       
   272         {
       
   273     default:
       
   274     	
       
   275     case EMemSpyViewTypeProcesses:
       
   276         index = 0;
       
   277         break;
       
   278 /*  case EMemSpyViewTypeRAMInfo:
       
   279         index = 1;
       
   280         break;
       
   281     case EMemSpyViewTypeROMInfo:
       
   282         index = 2;
       
   283         break;
       
   284     case EMemSpyViewTypeFBServBitmaps:
       
   285         index = 3;
       
   286         break;
       
   287         */
       
   288        /*
       
   289     case EMemSpyViewTypeChunkList:
       
   290         index = 5;
       
   291         break;
       
   292     case EMemSpyViewTypeCodeSegmentList:
       
   293         index = 6;
       
   294         break;
       
   295     case EMemSpyViewTypeOpenFiles:
       
   296         index = 7;
       
   297         break;
       
   298     case EMemSpyViewTypeSystemConfig:
       
   299         index = 8;
       
   300         break;*/  
       
   301         
       
   302     case EMemSpyViewTypeKernel:
       
   303         index = 1 ;
       
   304         break;    
       
   305     case EMemSpyViewTypeHeapTracking:
       
   306         index = 2;
       
   307         break;
       
   308     case EMemSpyViewTypeServerList:
       
   309     	index = 3;
       
   310     	break;
       
   311         
       
   312         
       
   313     /*case EMemSpyViewTypeThreadInfoItemMemoryTrackingAutoStartConfig:
       
   314         index = 11;
       
   315         break;
       
   316     case EMemSpyViewTypeDriveSummary:
       
   317         index = 12;
       
   318         break;
       
   319     case EMemSpyViewTypeECom:
       
   320         index = 13;
       
   321         break;
       
   322     case EMemSpyViewTypeWindowGroups:
       
   323         index = 14;
       
   324         break;*/        
       
   325         }
       
   326     //
       
   327     return index;
       
   328     }
       
   329