memspyui/ui/avkon/src/MemSpyViewThreads.cpp
changeset 31 e7a04a6385be
parent 26 41ebde60981f
--- a/memspyui/ui/avkon/src/MemSpyViewThreads.cpp	Thu Jun 17 15:34:52 2010 +0300
+++ b/memspyui/ui/avkon/src/MemSpyViewThreads.cpp	Thu Jun 24 14:55:55 2010 +0300
@@ -38,15 +38,8 @@
 
 
 
-/*
-CMemSpyViewThreads::CMemSpyViewThreads( CMemSpyEngine& aEngine, MMemSpyViewObserver& aObserver, CMemSpyProcess& aProcess )
-:   CMemSpyViewBase( aEngine, aObserver ), iParentProcess( aProcess )
-    {
-    iParentProcess.Open();
-    }
-*/
-CMemSpyViewThreads::CMemSpyViewThreads( RMemSpySession& aSession, MMemSpyViewObserver& aObserver, TProcessId aId )
-:   CMemSpyViewBase( aSession, aObserver ), iParentProcessId( aId )
+CMemSpyViewThreads::CMemSpyViewThreads( RMemSpySession& aSession, MMemSpyViewObserver& aObserver, TProcessId aId, TThreadId aThreadId )
+:   CMemSpyViewBase( aSession, aObserver ), iParentProcessId( aId ), iCurrentThreadId( aThreadId )
     {    
     }
 
@@ -58,30 +51,33 @@
  
 void CMemSpyViewThreads::ConstructL( const TRect& aRect, CCoeControl& aContainer, TAny* aSelectionRune )
     {
+	iMemSpySession.GetThreadsL( iParentProcessId, iThreads );
+	
     _LIT( KTitle, "Threads" );
     SetTitleL( KTitle );
     //
     CMemSpyViewBase::ConstructL( aRect, aContainer, aSelectionRune );
-    //
-    if  ( aSelectionRune )
-        {
-		iListBox->SetCurrentItemIndex( 0 ); //for now
+    //    
+    if( iCurrentThreadId > 0 )
+        {		
+		for( TInt i = 0; i < iThreads.Count() ; i++ )
+			{
+			if( iThreads[i]->Id() == iCurrentThreadId )
+				{
+				const TInt index = i;
+				if  ( index >= 0 && index < iListBox->Model()->NumberOfItems() )
+					{
+					iListBox->SetCurrentItemIndex( index );
+					HandleListBoxItemSelectedL( index );
+					}
+				}			
+			}
+        }
+    else if( iThreads.Count() > 0 )
+    	{
+		iListBox->SetCurrentItemIndex( 0 );
 		HandleListBoxItemSelectedL( 0 );
-		/* TODO: 
-        CMemSpyThread* selectedItem = reinterpret_cast< CMemSpyThread* >( aSelectionRune );
-        const TInt index = iParentProcess.ThreadIndexById( selectedItem->Id() );
-        if  ( index >= 0 && index < iListBox->Model()->NumberOfItems() )
-            {
-            iListBox->SetCurrentItemIndex( index );
-            HandleListBoxItemSelectedL( index );
-            }
-        */		
-        }
-    //else if ( iParentProcess.Count() > 0 )
-    //    {
-        iListBox->SetCurrentItemIndex( 0 );
-        HandleListBoxItemSelectedL( 0 );
-    //    }
+    	}		
     }
 
 
@@ -125,7 +121,7 @@
     {	
     CMemSpyViewThreadInfoItemList* child = new(ELeave) CMemSpyViewThreadInfoItemList( iMemSpySession, iObserver, iParentProcessId, iCurrentThreadId );
     CleanupStack::PushL( child );
-    child->ConstructL( Rect(), *Parent() );
+    child->ConstructL( Rect(), *Parent(), EMemSpyThreadInfoItemTypeFirst );
     CleanupStack::Pop( child );
     return child;    
     }
@@ -331,16 +327,13 @@
 
 void CMemSpyViewThreads::OnCmdInfoHandlesL()
     {
-	/*
-    CMemSpyThread& thread = CurrentThread();
-    thread.InfoContainerForceSyncronousConstructionL().PrintL();
-    */
+	iMemSpySession.OutputThreadInfoHandlesL( iCurrentThreadId );	
     }
 
 
 void CMemSpyViewThreads::SetListBoxModelL()
     {
-	iMemSpySession.GetThreadsL( iParentProcessId, iThreads );
+	//iMemSpySession.GetThreadsL( iParentProcessId, iThreads );
 	
 	iModel = new (ELeave) CDesC16ArrayFlat( iThreads.Count() ); //array for formated items
 		
@@ -359,8 +352,7 @@
 	    	CleanupStack::PopAndDestroy( tempName ); 
 			}			
 	
-    CAknSettingStyleListBox* listbox = static_cast< CAknSettingStyleListBox* >( iListBox );
-    //listbox->Model()->SetItemTextArray( &iParentProcess );
+    CAknSettingStyleListBox* listbox = static_cast< CAknSettingStyleListBox* >( iListBox );    
     listbox->Model()->SetItemTextArray( iModel );
     listbox->Model()->SetOwnershipType( ELbmDoesNotOwnItemArray );
     }