|
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 "MemSpyViewChunkList.h" |
|
19 |
|
20 // System includes |
|
21 #include <memspyui.rsg> |
|
22 |
|
23 // Engine includes |
|
24 #include <memspy/engine/memspyengine.h> |
|
25 #include <memspy/engine/memspyengineobjectprocess.h> |
|
26 #include <memspy/engine/memspyengineobjectthread.h> |
|
27 #include <memspy/engine/memspyengineobjectcontainer.h> |
|
28 #include <memspy/engine/memspyengineobjectthreadinfoobjects.h> |
|
29 #include <memspy/engine/memspyengineobjectthreadinfocontainer.h> |
|
30 #include <memspy/engine/memspyenginehelperprocess.h> |
|
31 #include <memspy/engine/memspyenginehelperchunk.h> |
|
32 |
|
33 // User includes |
|
34 #include "MemSpyUiUtils.h" |
|
35 #include "MemSpyViewMainMenu.h" |
|
36 |
|
37 |
|
38 |
|
39 CMemSpyViewChunkBase::CMemSpyViewChunkBase( CMemSpyEngine& aEngine, MMemSpyViewObserver& aObserver, CMemSpyEngineChunkList* aList ) |
|
40 : CMemSpyViewBase( aEngine, aObserver ), iList( aList ) |
|
41 { |
|
42 } |
|
43 |
|
44 |
|
45 CMemSpyViewChunkBase::~CMemSpyViewChunkBase() |
|
46 { |
|
47 delete iList; |
|
48 } |
|
49 |
|
50 |
|
51 TBool CMemSpyViewChunkBase::HandleCommandL( TInt aCommand ) |
|
52 { |
|
53 TBool handled = ETrue; |
|
54 // |
|
55 switch ( aCommand ) |
|
56 { |
|
57 case EMemSpyCmdChunkSortByName: |
|
58 iList->SortByNameL(); |
|
59 CMemSpyViewBase::RefreshL(); |
|
60 break; |
|
61 case EMemSpyCmdChunkSortBySize: |
|
62 iList->SortBySizeL(); |
|
63 CMemSpyViewBase::RefreshL(); |
|
64 break; |
|
65 case EMemSpyCmdChunkListing: |
|
66 OnCmdListingL(); |
|
67 break; |
|
68 default: |
|
69 handled = CMemSpyViewBase::HandleCommandL( aCommand ); |
|
70 break; |
|
71 } |
|
72 // |
|
73 return handled; |
|
74 } |
|
75 |
|
76 |
|
77 void CMemSpyViewChunkBase::OnCmdListingL() |
|
78 { |
|
79 // Begin a new data stream |
|
80 _LIT( KMemSpyContext, "Chunk List" ); |
|
81 _LIT( KMemSpyFolder, "Chunks" ); |
|
82 iEngine.Sink().DataStreamBeginL( KMemSpyContext, KMemSpyFolder ); |
|
83 |
|
84 // Set prefix for overall listing |
|
85 _LIT( KOverallPrefix, "Chunk List - " ); |
|
86 iEngine.Sink().OutputPrefixSetLC( KOverallPrefix ); |
|
87 |
|
88 // Create header |
|
89 CMemSpyEngineChunkList::OutputDataColumnsL( iEngine ); |
|
90 |
|
91 // List items |
|
92 const TInt count = iList->Count(); |
|
93 for(TInt i=0; i<count; i++) |
|
94 { |
|
95 const CMemSpyEngineChunkEntry& entry = iList->At( i ); |
|
96 // |
|
97 entry.OutputDataL( iEngine.HelperChunk() ); |
|
98 } |
|
99 |
|
100 // Tidy up |
|
101 CleanupStack::PopAndDestroy(); // prefix |
|
102 |
|
103 // End data stream |
|
104 iEngine.Sink().DataStreamEndL(); |
|
105 } |
|
106 |
|
107 |
|
108 |
|
109 |
|
110 |
|
111 |
|
112 |
|
113 |
|
114 |
|
115 |
|
116 |
|
117 |
|
118 |
|
119 |
|
120 |
|
121 |
|
122 |
|
123 |
|
124 |
|
125 |
|
126 |
|
127 |
|
128 |
|
129 |
|
130 |
|
131 |
|
132 |
|
133 |
|
134 |
|
135 |
|
136 CMemSpyViewChunkList::CMemSpyViewChunkList( CMemSpyEngine& aEngine, MMemSpyViewObserver& aObserver ) |
|
137 : CMemSpyViewChunkBase( aEngine, aObserver, NULL ) |
|
138 { |
|
139 } |
|
140 |
|
141 |
|
142 CMemSpyViewChunkList::CMemSpyViewChunkList( CMemSpyEngine& aEngine, MMemSpyViewObserver& aObserver, CMemSpyEngineChunkList& aList ) |
|
143 : CMemSpyViewChunkBase( aEngine, aObserver, &aList ) |
|
144 { |
|
145 } |
|
146 |
|
147 |
|
148 void CMemSpyViewChunkList::ConstructL( const TRect& aRect, CCoeControl& aContainer, TAny* aSelectionRune ) |
|
149 { |
|
150 _LIT( KTitle, "Chunks" ); |
|
151 SetTitleL( KTitle ); |
|
152 |
|
153 if ( iList == NULL ) |
|
154 { |
|
155 // Prepare code segment list |
|
156 iList = iEngine.HelperChunk().ListL(); |
|
157 } |
|
158 |
|
159 // Finish construction |
|
160 CMemSpyViewBase::ConstructL( aRect, aContainer, aSelectionRune ); |
|
161 |
|
162 if ( aSelectionRune != NULL ) |
|
163 { |
|
164 iCurrentChunk = reinterpret_cast< CMemSpyEngineChunkEntry* >( aSelectionRune ); |
|
165 const TInt index = iList->ItemIndex( *iCurrentChunk ); |
|
166 iListBox->SetCurrentItemIndex( index ); |
|
167 HandleListBoxItemSelectedL( index ); |
|
168 } |
|
169 |
|
170 iListBox->DrawDeferred(); |
|
171 } |
|
172 |
|
173 |
|
174 TMemSpyViewType CMemSpyViewChunkList::ViewType() const |
|
175 { |
|
176 return EMemSpyViewTypeChunkList; |
|
177 } |
|
178 |
|
179 |
|
180 CMemSpyViewBase* CMemSpyViewChunkList::PrepareParentViewL() |
|
181 { |
|
182 CMemSpyViewMainMenu* parent = new(ELeave) CMemSpyViewMainMenu( iEngine, iObserver ); |
|
183 CleanupStack::PushL( parent ); |
|
184 parent->ConstructL( Rect(), *Parent(), (TAny*) ViewType() ); |
|
185 CleanupStack::Pop( parent ); |
|
186 return parent; |
|
187 } |
|
188 |
|
189 |
|
190 CMemSpyViewBase* CMemSpyViewChunkList::PrepareChildViewL() |
|
191 { |
|
192 CMemSpyViewBase* child = new(ELeave) CMemSpyViewChunkDetails( iEngine, iObserver, *iList, *iCurrentChunk ); |
|
193 |
|
194 // Ownership is transferred to child. Cleanupstack guarantees it will be destroyed now. |
|
195 // This object is about to die in any case. |
|
196 iList = NULL; |
|
197 |
|
198 CleanupStack::PushL( child ); |
|
199 child->ConstructL( Rect(), *Parent() ); |
|
200 CleanupStack::Pop( child ); |
|
201 return child; |
|
202 } |
|
203 |
|
204 |
|
205 void CMemSpyViewChunkList::SetListBoxModelL() |
|
206 { |
|
207 CAknSettingStyleListBox* listbox = static_cast< CAknSettingStyleListBox* >( iListBox ); |
|
208 listbox->Model()->SetItemTextArray( iList ); |
|
209 listbox->Model()->SetOwnershipType( ELbmDoesNotOwnItemArray ); |
|
210 } |
|
211 |
|
212 |
|
213 void CMemSpyViewChunkList::HandleListBoxItemActionedL( TInt aIndex ) |
|
214 { |
|
215 const TInt count = iList->Count(); |
|
216 if ( aIndex >= 0 && aIndex < count ) |
|
217 { |
|
218 CMemSpyEngineChunkEntry& chunk = iList->At( aIndex ); |
|
219 iCurrentChunk = &chunk; |
|
220 } |
|
221 else |
|
222 { |
|
223 iCurrentChunk = NULL; |
|
224 } |
|
225 |
|
226 // Notify observer about item selection |
|
227 ReportEventL( MMemSpyViewObserver::EEventItemActioned ); |
|
228 } |
|
229 |
|
230 |
|
231 void CMemSpyViewChunkList::HandleListBoxItemSelectedL( TInt aIndex ) |
|
232 { |
|
233 const TInt count = iList->Count(); |
|
234 if ( aIndex >= 0 && aIndex < count ) |
|
235 { |
|
236 CMemSpyEngineChunkEntry& chunk = iList->At( aIndex ); |
|
237 iCurrentChunk = &chunk; |
|
238 } |
|
239 else |
|
240 { |
|
241 iCurrentChunk = NULL; |
|
242 } |
|
243 |
|
244 // Notify observer about item selection |
|
245 ReportEventL( MMemSpyViewObserver::EEventItemSelected ); |
|
246 } |
|
247 |
|
248 |
|
249 |
|
250 |
|
251 |
|
252 |
|
253 |
|
254 |
|
255 |
|
256 |
|
257 |
|
258 |
|
259 |
|
260 |
|
261 |
|
262 |
|
263 |
|
264 |
|
265 |
|
266 |
|
267 |
|
268 |
|
269 |
|
270 |
|
271 |
|
272 |
|
273 |
|
274 |
|
275 |
|
276 |
|
277 |
|
278 |
|
279 |
|
280 |
|
281 |
|
282 CMemSpyViewChunkDetails::CMemSpyViewChunkDetails( CMemSpyEngine& aEngine, MMemSpyViewObserver& aObserver, CMemSpyEngineChunkList& aList, CMemSpyEngineChunkEntry& aSelectedChunk ) |
|
283 : CMemSpyViewChunkBase( aEngine, aObserver, &aList ), iChunk( aSelectedChunk ) |
|
284 { |
|
285 } |
|
286 |
|
287 |
|
288 void CMemSpyViewChunkDetails::ConstructL( const TRect& aRect, CCoeControl& aContainer, TAny* aSelectionRune ) |
|
289 { |
|
290 _LIT( KTitle, "Chunk Details" ); |
|
291 SetTitleL( KTitle ); |
|
292 |
|
293 // Finish construction |
|
294 CMemSpyViewBase::ConstructL( aRect, aContainer, aSelectionRune ); |
|
295 } |
|
296 |
|
297 |
|
298 void CMemSpyViewChunkDetails::RefreshL() |
|
299 { |
|
300 SetListBoxModelL(); |
|
301 CMemSpyViewBase::RefreshL(); |
|
302 } |
|
303 |
|
304 |
|
305 TMemSpyViewType CMemSpyViewChunkDetails::ViewType() const |
|
306 { |
|
307 return EMemSpyViewTypeChunkDetails; |
|
308 } |
|
309 |
|
310 |
|
311 CMemSpyViewBase* CMemSpyViewChunkDetails::PrepareParentViewL() |
|
312 { |
|
313 CMemSpyViewChunkList* parent = new(ELeave) CMemSpyViewChunkList( iEngine, iObserver, *iList ); |
|
314 |
|
315 // Ownership is transferred to child. Cleanupstack guarantees it will be destroyed now. |
|
316 // This object is about to die in any case. |
|
317 iList = NULL; |
|
318 |
|
319 CleanupStack::PushL( parent ); |
|
320 parent->ConstructL( Rect(), *Parent(), &iChunk ); |
|
321 CleanupStack::Pop( parent ); |
|
322 return parent; |
|
323 } |
|
324 |
|
325 |
|
326 void CMemSpyViewChunkDetails::SetListBoxModelL() |
|
327 { |
|
328 CAknSettingStyleListBox* listbox = static_cast< CAknSettingStyleListBox* >( iListBox ); |
|
329 listbox->Model()->SetItemTextArray( &iChunk ); |
|
330 listbox->Model()->SetOwnershipType( ELbmDoesNotOwnItemArray ); |
|
331 } |
|
332 |
|
333 |
|
334 |
|
335 |
|
336 |
|
337 |
|
338 |
|
339 |
|
340 |
|
341 |
|
342 |
|
343 |
|
344 |
|
345 |
|
346 |