memspyui/ui/avkon/src/MemSpyViewThreadInfoItemGeneric.cpp
changeset 19 4b22a598b890
parent 17 4f2773374eff
child 31 e7a04a6385be
--- a/memspyui/ui/avkon/src/MemSpyViewThreadInfoItemGeneric.cpp	Fri May 14 15:53:02 2010 +0300
+++ b/memspyui/ui/avkon/src/MemSpyViewThreadInfoItemGeneric.cpp	Thu May 27 12:52:19 2010 +0300
@@ -29,49 +29,42 @@
 #include <memspy/engine/memspyengineobjectthreadinfoobjects.h>
 #include <memspy/engine/memspyengineobjectthreadinfocontainer.h>
 #include <memspy/engine/memspyenginehelperprocess.h>
+#include <memspysession.h>
 
 // User includes
 #include "MemSpyContainerObserver.h"
 #include "MemSpyViewThreadInfoItemList.h"
+#include "MemSpyUiUtils.h"
 
 // Constants
 const TInt KMemSpyConstructionCheckerTimerPeriod = 500000; // 1/2 second
 
-
-
-CMemSpyViewThreadInfoItemGeneric::CMemSpyViewThreadInfoItemGeneric( CMemSpyEngine& aEngine, MMemSpyViewObserver& aObserver, CMemSpyThreadInfoContainer& aInfoContainer, TMemSpyThreadInfoItemType aType )
-:   CMemSpyViewBase( aEngine, aObserver ), iContainer( aInfoContainer )
+CMemSpyViewThreadInfoItemGeneric::CMemSpyViewThreadInfoItemGeneric( RMemSpySession& aSession, MMemSpyViewObserver& aObserver, TProcessId aProcessId, TThreadId aId, TMemSpyThreadInfoItemType aType )
+:   CMemSpyViewBase( aSession, aObserver )//, iThreadId( aId ), iType( aType )		//iContainer( aInfoContainer )
     {
-    iContainer.Thread().Process().Open();
-    iContainer.Thread().Open();
-    iContainer.Open();
-    //
-    iInfoItem = &iContainer.Item( aType );
-    __ASSERT_ALWAYS( iInfoItem != NULL, User::Invariant() );
-    iInfoItem->Open();
+	iParentProcessId = aProcessId;
+	iThreadId = aId;
+	iType = aType;
     }
 
 
 CMemSpyViewThreadInfoItemGeneric::~CMemSpyViewThreadInfoItemGeneric()
-    {
+    {/* TODO:
     if  ( iInfoItem )
         {
         iInfoItem->Close();
-        }
-    //
-    DestroyWaitNote();
-    //
-    iContainer.Close();
-    iContainer.Thread().Close();
-    iContainer.Thread().Process().Close();
+        }    
+    DestroyWaitNote();    
+    */
     }
 
 
 void CMemSpyViewThreadInfoItemGeneric::ConstructL( const TRect& aRect, CCoeControl& aContainer, TAny* aSelectionRune )
     {
-    const TPtrC pTitle( iInfoItem->Name().Mid( 1 ) );
-    SetTitleL( pTitle );
+	const TPtrC pTitle( MemSpyUiUtils::ThreadInfoItemNameByType( iType ) );
+	SetTitleL( pTitle );
     //
+    /* TODO:
     if  ( iInfoItem->IsReady() == EFalse )
         {
 #ifdef _DEBUG
@@ -81,39 +74,39 @@
         // Wait for engine data to be made ready... 
         ShowWaitNoteL();
         }
-
+	*/
     CMemSpyViewBase::ConstructL( aRect, aContainer, aSelectionRune );
     }
 
 
 CMemSpyProcess& CMemSpyViewThreadInfoItemGeneric::Process() const
     {
-    return iContainer.Thread().Process();
+  //  return iContainer.Thread().Process();
     }
 
 
 CMemSpyThread& CMemSpyViewThreadInfoItemGeneric::Thread() const
     {
-    return iContainer.Thread();
+  //  return iContainer.Thread();
     }
 
 
 CMemSpyThreadInfoContainer& CMemSpyViewThreadInfoItemGeneric::Container() const
     {
-    return iContainer;
+ //   return iContainer;
     }
 
 
 CMemSpyThreadInfoItemBase& CMemSpyViewThreadInfoItemGeneric::InfoItem() const
     {
-    __ASSERT_ALWAYS( iInfoItem != NULL, User::Invariant() );
-    return *iInfoItem;
+ //   __ASSERT_ALWAYS( iInfoItem != NULL, User::Invariant() );
+ //   return *iInfoItem;
     }
 
 
 void CMemSpyViewThreadInfoItemGeneric::RefreshL()
     {
-    iInfoItem->RebuildL();    
+ //   iInfoItem->RebuildL();     //TODO
     SetListBoxModelL();
     CMemSpyViewBase::RefreshL();
     }
@@ -123,7 +116,8 @@
     {
     TMemSpyViewType type = EMemSpyViewTypeNone;
     //
-    switch( iInfoItem->Type() )
+    //switch( iInfoItem->Type() )
+    switch( iType )
         {
     case EMemSpyThreadInfoItemTypeHeap:
         type = EMemSpyViewTypeThreadInfoItemHeap;
@@ -196,7 +190,7 @@
         break;
 
     default:
-        __ASSERT_DEBUG( EFalse, User::Invariant() );
+        //__ASSERT_DEBUG( EFalse, User::Invariant() );
         break;
         }
     //
@@ -206,9 +200,9 @@
 
 CMemSpyViewBase* CMemSpyViewThreadInfoItemGeneric::PrepareParentViewL()
     {
-    CMemSpyViewThreadInfoItemList* parent = new(ELeave) CMemSpyViewThreadInfoItemList( iEngine, iObserver, Thread() );
+    CMemSpyViewThreadInfoItemList* parent = new(ELeave) CMemSpyViewThreadInfoItemList( iMemSpySession, iObserver, iParentProcessId, iThreadId );
     CleanupStack::PushL( parent );
-    parent->ConstructL( Rect(), *Parent(), iInfoItem );
+    parent->ConstructL( Rect(), *Parent() ); //TODO: arguent removed: iInfoItem
     CleanupStack::Pop( parent );
     return parent;
     }
@@ -216,7 +210,7 @@
 
 CMemSpyViewBase* CMemSpyViewThreadInfoItemGeneric::PrepareChildViewL()
     {
-    __ASSERT_ALWAYS( iInfoItem != NULL, User::Invariant() );
+    //__ASSERT_ALWAYS( iInfoItem != NULL, User::Invariant() );
     CMemSpyViewBase* child = NULL;
     //
     return child;
@@ -232,8 +226,40 @@
 
 void CMemSpyViewThreadInfoItemGeneric::SetListBoxModelL()
     {
+	iMemSpySession.GetThreadInfoItems( iThreadInfoItems, iThreadId, iType );
+	
+	iModel = new (ELeave) CDesC16ArrayFlat( iThreadInfoItems.Count() + 10 );
+	
+	for( TInt i=0; i<iThreadInfoItems.Count(); i++)
+		{						
+		HBufC* iCombined = HBufC::NewL( iThreadInfoItems[i]->Caption().Length() + iThreadInfoItems[i]->Value().Length() + 30 );		
+			/*
+		else if ( iCombined->Des().MaxLength() < requiredLength )
+			{
+			iCombined = iCombined->ReAllocL( requiredLength );
+			}*/
+		
+		CleanupStack::PushL( iCombined );
+        
+		TPtr pCombined( iCombined->Des() );
+		pCombined.Zero();
+		pCombined.Copy( _L("\t") );
+		if( iThreadInfoItems[i]->Caption() != KNullDesC )
+			pCombined.Append( iThreadInfoItems[i]->Caption() );
+		if( iType != EMemSpyThreadInfoItemTypeChunk )
+			{
+			pCombined.Append( _L("\t\t") );
+			pCombined.Append( iThreadInfoItems[i]->Value() );
+			}					
+		
+		iModel->AppendL( pCombined );				
+		
+		CleanupStack::PopAndDestroy( iCombined );
+		}	
+	
     CAknSettingStyleListBox* listbox = static_cast< CAknSettingStyleListBox* >( iListBox );
-    listbox->Model()->SetItemTextArray( iInfoItem );
+    //listbox->Model()->SetItemTextArray( iInfoItem );
+    listbox->Model()->SetItemTextArray( iModel );
     listbox->Model()->SetOwnershipType( ELbmDoesNotOwnItemArray );
     }
 
@@ -256,7 +282,7 @@
 void CMemSpyViewThreadInfoItemGeneric::ShowWaitNoteL()
     {
     // Ugly, but I'm not adding an observer mechanism just for this wait dialog.
-    __ASSERT_ALWAYS( iWaitConstructionChecker == NULL, User::Invariant() );
+   // __ASSERT_ALWAYS( iWaitConstructionChecker == NULL, User::Invariant() );
     iWaitConstructionChecker = CPeriodic::NewL( CActive::EPriorityLow );
     iWaitConstructionChecker->Start( KMemSpyConstructionCheckerTimerPeriod, 
                                      KMemSpyConstructionCheckerTimerPeriod, 
@@ -293,12 +319,15 @@
 
 TInt CMemSpyViewThreadInfoItemGeneric::CheckForItemConstructionComplete( TAny* aSelf )
     {
+	/*
     CMemSpyViewThreadInfoItemGeneric& self = *reinterpret_cast< CMemSpyViewThreadInfoItemGeneric* >( aSelf );
+    */
     //
 #ifdef _DEBUG
-    RDebug::Printf( "CMemSpyViewThreadInfoItemGeneric::CheckForItemConstructionComplete() - ready status: %d, iType: %d", self.iInfoItem->IsReady(), self.iInfoItem->Type() );
+/*   RDebug::Printf( "CMemSpyViewThreadInfoItemGeneric::CheckForItemConstructionComplete() - ready status: %d, iType: %d", self.iInfoItem->IsReady(), self.iInfoItem->Type() );*/
 #endif
 	//
+    /*
     TBool callAgain = ETrue;
     if  ( self.iInfoItem->IsReady() )
         {
@@ -307,6 +336,7 @@
         }
     //
     return callAgain;
+    */
     }