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: This file contains CTestCaseListBoxModel class |
|
15 * definition. |
|
16 * |
|
17 */ |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include <aknlists.h> // ListBox |
|
21 #include <AknIconArray.h> // CAknIconArray |
|
22 #include <aknnotewrappers.h> |
|
23 |
|
24 #include <eikclbd.h> // CColumnListBoxData |
|
25 |
|
26 #include "Container.h" |
|
27 #include <Stifui.rsg> |
|
28 #include "Stifui.hrh" |
|
29 #include "AppUIAppUi.h" |
|
30 |
|
31 |
|
32 // ================= MEMBER FUNCTIONS ======================= |
|
33 // ---------------------------------------------------------------------------- |
|
34 // CTestCaseListBoxModel::NewL |
|
35 // |
|
36 // Two-phased constructor. |
|
37 // ---------------------------------------------------------------------------- |
|
38 // |
|
39 |
|
40 CTestCaseListBoxModel* CTestCaseListBoxModel::NewL(RPointerArray<CTestInfo>* aTestCasesInView) |
|
41 { |
|
42 CTestCaseListBoxModel* self = new ( ELeave ) CTestCaseListBoxModel(); |
|
43 CleanupStack::PushL( self ); |
|
44 self->iBuffer = HBufC::NewL( 130 ); |
|
45 self->iTestCasesInView = aTestCasesInView; |
|
46 CleanupStack::Pop(); |
|
47 return self; |
|
48 } |
|
49 |
|
50 // ---------------------------------------------------------------------------- |
|
51 // CTestCaseListBoxModel::ConstructL |
|
52 // |
|
53 // Symbian OS two phased constructor. |
|
54 // ---------------------------------------------------------------------------- |
|
55 // |
|
56 |
|
57 void CTestCaseListBoxModel::ConstructL() |
|
58 { |
|
59 //iBuffer = HBufC::NewLC( KMaxInfoName + KMaxName + 2 ); |
|
60 } |
|
61 |
|
62 // ---------------------------------------------------------------------------- |
|
63 // CTestCaseListBoxModel::~CTestCaseListBoxModel |
|
64 // |
|
65 // Destructor. |
|
66 // ---------------------------------------------------------------------------- |
|
67 // |
|
68 CTestCaseListBoxModel::~CTestCaseListBoxModel() |
|
69 { |
|
70 delete iBuffer; |
|
71 } |
|
72 |
|
73 // ---------------------------------------------------------------------------- |
|
74 // CTestCaseListBoxModel::MdcaCount |
|
75 // |
|
76 // Returns the number of descriptor elements in the array. |
|
77 // ---------------------------------------------------------------------------- |
|
78 // |
|
79 |
|
80 TInt CTestCaseListBoxModel::MdcaCount() const |
|
81 { |
|
82 return iTestCasesInView->Count(); |
|
83 } |
|
84 |
|
85 // ---------------------------------------------------------------------------- |
|
86 // CTestCaseListBoxModel::MdcaPoint |
|
87 // |
|
88 // Indexes into a descriptor array. |
|
89 // ---------------------------------------------------------------------------- |
|
90 // |
|
91 TPtrC CTestCaseListBoxModel::MdcaPoint(TInt aIndex) const |
|
92 { |
|
93 CTestInfo* testCasePtr = (*iTestCasesInView)[aIndex]; |
|
94 TPtr buffer( iBuffer->Des() ); |
|
95 buffer.Zero(); |
|
96 buffer.Append(_L("\t")); |
|
97 buffer.Append(testCasePtr->TestCaseTitle() ); |
|
98 return *iBuffer; |
|
99 } |
|
100 |
|
101 // ================= MEMBER FUNCTIONS ======================= |
|
102 // ---------------------------------------------------------------------------- |
|
103 // CContainer::ConstructL |
|
104 // |
|
105 // Symbian OS two phased constructor. |
|
106 // ---------------------------------------------------------------------------- |
|
107 // |
|
108 void CContainer::ConstructL() |
|
109 { |
|
110 } |
|
111 |
|
112 // ---------------------------------------------------------------------------- |
|
113 // CContainer::~CContainer |
|
114 // |
|
115 // Destructor. |
|
116 // ---------------------------------------------------------------------------- |
|
117 // |
|
118 CContainer::~CContainer() |
|
119 { |
|
120 iTestCasesInView.Close(); // does not delete objects whose pointers are contained in the array |
|
121 delete iListBox; |
|
122 } |
|
123 |
|
124 |
|
125 // ---------------------------------------------------------------------------- |
|
126 // CContainer::SetGraphicIconL |
|
127 // |
|
128 // Sets graphic icon using listbox as CEikColumnListBox. |
|
129 // ---------------------------------------------------------------------------- |
|
130 // |
|
131 void CContainer::SetGraphicIconL( CEikColumnListBox* aListBox ) |
|
132 { |
|
133 if ( aListBox ) |
|
134 { |
|
135 // Creates gul icon. |
|
136 CAknIconArray* iconArray = new(ELeave) CAknIconArray(1); |
|
137 CleanupStack::PushL( iconArray ); |
|
138 |
|
139 GraphicIconL( iconArray ); // Appends graphic data. |
|
140 |
|
141 // Sets graphics as ListBox icon. |
|
142 aListBox->ItemDrawer()->ColumnData()->SetIconArray( iconArray ); |
|
143 |
|
144 CleanupStack::Pop(); |
|
145 } |
|
146 } |
|
147 |
|
148 // ---------------------------------------------------------------------------- |
|
149 // CContainer::CurrentItemIndex |
|
150 // |
|
151 // Returns current item index in list box. |
|
152 // ---------------------------------------------------------------------------- |
|
153 // |
|
154 TInt CContainer::CurrentItemIndex() |
|
155 { |
|
156 return iListBox->CurrentItemIndex(); |
|
157 } |
|
158 |
|
159 // ---------------------------------------------------------------------------- |
|
160 // CContainer::SetCurrentItemIndex |
|
161 // |
|
162 // Sets current item index in list box. |
|
163 // ---------------------------------------------------------------------------- |
|
164 // |
|
165 void CContainer::SetCurrentItemIndex(TInt aCurrentTestCase) |
|
166 { |
|
167 iListBox->SetCurrentItemIndexAndDraw(aCurrentTestCase); |
|
168 } |
|
169 |
|
170 // ---------------------------------------------------------------------------- |
|
171 // CContainer::GraphicIconL |
|
172 // |
|
173 // Appends graphics data. |
|
174 // ---------------------------------------------------------------------------- |
|
175 // |
|
176 void CContainer::GraphicIconL( CArrayPtr<CGulIcon>* aIcons ) |
|
177 { |
|
178 if ( aIcons ) |
|
179 { |
|
180 CFbsBitmap* markBitmap = NULL; |
|
181 CFbsBitmap* markBitmapMask = NULL; |
|
182 |
|
183 TRgb defaultColor; |
|
184 defaultColor = CEikonEnv::Static()->Color(EColorControlText); |
|
185 |
|
186 AknsUtils::CreateColorIconL(AknsUtils::SkinInstance(), |
|
187 KAknsIIDQgnIndiMarkedAdd, |
|
188 KAknsIIDQsnIconColors, |
|
189 EAknsCIQsnIconColorsCG13, |
|
190 markBitmap, |
|
191 markBitmapMask, |
|
192 AknIconUtils::AvkonIconFileName(), |
|
193 EMbmAvkonQgn_indi_marked_add, |
|
194 EMbmAvkonQgn_indi_marked_add_mask, |
|
195 defaultColor ); |
|
196 |
|
197 CGulIcon* markIcon = CGulIcon::NewL(markBitmap,markBitmapMask); |
|
198 aIcons->AppendL(markIcon); |
|
199 } |
|
200 } |
|
201 |
|
202 |
|
203 // ---------------------------------------------------------------------------- |
|
204 // CContainer::SizeChanged |
|
205 // |
|
206 // Called by framework when the view size is changed. |
|
207 // ---------------------------------------------------------------------------- |
|
208 // |
|
209 void CContainer::SizeChanged() |
|
210 { |
|
211 if ( iListBox ) |
|
212 { |
|
213 iListBox->SetRect( Rect() ); // Sets rectangle of listbox. |
|
214 } |
|
215 } |
|
216 |
|
217 // ---------------------------------------------------------------------------- |
|
218 // CContainer::CountComponentControls |
|
219 // |
|
220 // Gets a count of the component controls of this list box control. |
|
221 // ---------------------------------------------------------------------------- |
|
222 // |
|
223 TInt CContainer::CountComponentControls() const |
|
224 { |
|
225 return 1; // return nbr of controls inside this container |
|
226 } |
|
227 |
|
228 // ---------------------------------------------------------------------------- |
|
229 // CContainer::ComponentControl |
|
230 // |
|
231 // Gets a pointer to the specified component control. |
|
232 // ---------------------------------------------------------------------------- |
|
233 // |
|
234 CCoeControl* CContainer::ComponentControl(TInt aIndex) const |
|
235 { |
|
236 switch ( aIndex ) |
|
237 { |
|
238 case 0: |
|
239 return iListBox; |
|
240 default: |
|
241 return NULL; |
|
242 } |
|
243 } |
|
244 |
|
245 // ---------------------------------------------------------------------------- |
|
246 // CContainer::Draw |
|
247 // |
|
248 // Draw a control, called by window server. |
|
249 // ---------------------------------------------------------------------------- |
|
250 // |
|
251 void CContainer::Draw(const TRect& /*aRect*/) const |
|
252 { |
|
253 // CWindowGc& gc = SystemGc(); |
|
254 } |
|
255 |
|
256 // ---------------------------------------------------------------------------- |
|
257 // CContainer::SelectedTestCases |
|
258 // |
|
259 // Returns pointers to selected test cases. |
|
260 // ---------------------------------------------------------------------------- |
|
261 // |
|
262 void CContainer::SelectedTestCases |
|
263 (RPointerArray<CTestInfo>& aSelectedTestCases) |
|
264 { |
|
265 TInt selectedItemIdx = iListBox->CurrentItemIndex(); |
|
266 if ( ( selectedItemIdx >= 0 ) && ( iTestCasesInView.Count() > selectedItemIdx ) ) |
|
267 { |
|
268 aSelectedTestCases.Append( iTestCasesInView[ selectedItemIdx ] ); |
|
269 } |
|
270 } |
|
271 |
|
272 // ---------------------------------------------------------------------------- |
|
273 // CContainer::SelectedTestCaseInfo |
|
274 // |
|
275 // Returns pointers to currently selected (in list box) test cases info. |
|
276 // ---------------------------------------------------------------------------- |
|
277 // |
|
278 CTestInfo* CContainer::SelectedTestCaseInfo() |
|
279 { |
|
280 TInt selectedItemIdx = iListBox->CurrentItemIndex(); |
|
281 if ( ( selectedItemIdx >= 0 ) && ( iTestCasesInView.Count() > selectedItemIdx ) ) |
|
282 { |
|
283 return iTestCasesInView[ selectedItemIdx ]; |
|
284 } |
|
285 return NULL; |
|
286 } |
|
287 |
|
288 // ---------------------------------------------------------------------------- |
|
289 // CContainer::TestCaseInfo |
|
290 // |
|
291 // Returns pointers to selected test cases info. |
|
292 // ---------------------------------------------------------------------------- |
|
293 // |
|
294 CTestInfo* CContainer::TestCaseInfo( TInt aIndex ) |
|
295 { |
|
296 if ( ( aIndex >=0 ) && ( iTestCasesInView.Count() > aIndex ) ) |
|
297 { |
|
298 return iTestCasesInView[ aIndex ]; |
|
299 } |
|
300 return NULL; |
|
301 } |
|
302 |
|
303 // ---------------------------------------------------------------------------- |
|
304 // CContainer::HandleMarkCommandL |
|
305 // |
|
306 // Handles mark commands. |
|
307 // ---------------------------------------------------------------------------- |
|
308 // |
|
309 void CContainer::HandleMarkCommandL( TInt aCommand ) |
|
310 { |
|
311 if (iListBox) |
|
312 { |
|
313 AknSelectionService::HandleMarkableListProcessCommandL( aCommand, iListBox ); |
|
314 } |
|
315 } |
|
316 |
|
317 // ---------------------------------------------------------------------------- |
|
318 // CContainer::ProcessCommandL |
|
319 // |
|
320 // Processes user commands. |
|
321 // ---------------------------------------------------------------------------- |
|
322 // |
|
323 void CContainer::ProcessCommandL( TInt aCommand ) |
|
324 { |
|
325 AknSelectionService::HandleMarkableListProcessCommandL( aCommand, iListBox ); |
|
326 } |
|
327 |
|
328 // ---------------------------------------------------------------------------- |
|
329 // CContainer::SelectionListProcessCommandL |
|
330 // |
|
331 // Processes user commands. |
|
332 // ---------------------------------------------------------------------------- |
|
333 // |
|
334 void CContainer::SelectionListProcessCommandL( TInt aCommand ) |
|
335 { |
|
336 AknSelectionService::HandleSelectionListProcessCommandL( aCommand, iListBox ); |
|
337 } |
|
338 |
|
339 // ---------------------------------------------------------------------------- |
|
340 // CContainer::FilterCasesByModuleL |
|
341 // |
|
342 // Show only testcases which are defined is specified module. |
|
343 // ---------------------------------------------------------------------------- |
|
344 // |
|
345 void CContainer::FilterCasesByModuleL( TName aModuleName ) |
|
346 { |
|
347 iTestCasesInView.Reset(); // Clear testCasesInView pointer array |
|
348 |
|
349 RRefArray<CTestInfo> allCases; |
|
350 TInt ret = iUIStore->TestCases( allCases ); |
|
351 if( KErrNone != ret ) |
|
352 { |
|
353 ((CAppUIAppUi*)iCoeEnv->AppUi())->iLogger->Log(_L("FilterCasesByModuleL(): iUIStore->TestCases() fails")); |
|
354 allCases.Reset(); |
|
355 allCases.Close(); |
|
356 User::Leave( ret ); |
|
357 } |
|
358 const TInt KTestCaseCount = allCases.Count(); |
|
359 for( TInt i=0; i < KTestCaseCount; i++ ) |
|
360 { |
|
361 if ( allCases[i].ModuleName() == aModuleName ) |
|
362 { |
|
363 iTestCasesInView.Append( &( allCases[i] ) ); |
|
364 } |
|
365 } |
|
366 allCases.Reset(); |
|
367 allCases.Close(); |
|
368 |
|
369 iListBox->Reset(); |
|
370 iListBox->DrawNow(); |
|
371 } |
|
372 |
|
373 // ---------------------------------------------------------------------------- |
|
374 // CContainer::FilterCasesByTCFileNameL |
|
375 // |
|
376 // Show only testcases which are defined is specified test case file. |
|
377 // ---------------------------------------------------------------------------- |
|
378 // |
|
379 void CContainer::FilterCasesByTCFileNameL( |
|
380 TFileName aTestCaseFileName ) |
|
381 { |
|
382 |
|
383 iTestCasesInView.Reset(); // Clear testCasesInView pointer array |
|
384 |
|
385 RRefArray<CTestInfo> allCases; |
|
386 TInt ret = iUIStore->TestCases( allCases ); |
|
387 if( KErrNone != ret ) |
|
388 { |
|
389 ((CAppUIAppUi*)iCoeEnv->AppUi())->iLogger->Log(_L("FilterCasesByModuleL(): iUIStore->TestCases() fails")); |
|
390 allCases.Reset(); |
|
391 allCases.Close(); |
|
392 User::Leave( ret ); |
|
393 } |
|
394 const TInt KTestCaseCount = allCases.Count(); |
|
395 for( TInt i=0; i < KTestCaseCount; i++ ) |
|
396 { |
|
397 if ( allCases[i].TestCaseFile() == aTestCaseFileName ) |
|
398 { |
|
399 iTestCasesInView.Append( &( allCases[i] ) ); |
|
400 } |
|
401 } |
|
402 |
|
403 allCases.Reset(); |
|
404 allCases.Close(); |
|
405 |
|
406 iListBox->Reset(); |
|
407 iListBox->DrawNow(); |
|
408 } |
|
409 |
|
410 // ---------------------------------------------------------------------------- |
|
411 // CContainer::NoFilteringL |
|
412 // |
|
413 // Remove possible filtering of test cases -> show all test cases. |
|
414 // ---------------------------------------------------------------------------- |
|
415 // |
|
416 void CContainer::NoFilteringL() |
|
417 { |
|
418 iTestCasesInView.Reset(); // Clear testCasesInView pointer array |
|
419 |
|
420 RRefArray<CTestInfo> allCases; |
|
421 TInt ret = iUIStore->TestCases( allCases ); |
|
422 if( KErrNone != ret ) |
|
423 { |
|
424 ((CAppUIAppUi*)iCoeEnv->AppUi())->iLogger->Log(_L("FilterCasesByModuleL(): iUIStore->TestCases() fails")); |
|
425 allCases.Reset(); |
|
426 allCases.Close(); |
|
427 User::Leave( ret ); |
|
428 } |
|
429 const TInt KTestCaseCount = allCases.Count(); |
|
430 |
|
431 // Add all cases to iTestCasesInView pointer array |
|
432 for( TInt i=0; i < KTestCaseCount; i++ ) |
|
433 { |
|
434 iTestCasesInView.Append( &( allCases[i] ) ); |
|
435 } |
|
436 |
|
437 allCases.Reset(); |
|
438 allCases.Close(); |
|
439 |
|
440 iListBox->Reset(); |
|
441 iListBox->DrawNow(); |
|
442 } |
|
443 |
|
444 // End of File |
|