|
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 aSelectedTestCases.Append( iTestCasesInView[iListBox->CurrentItemIndex()] ); |
|
266 } |
|
267 |
|
268 |
|
269 // ---------------------------------------------------------------------------- |
|
270 // CContainer::HandleMarkCommandL |
|
271 // |
|
272 // Handles mark commands. |
|
273 // ---------------------------------------------------------------------------- |
|
274 // |
|
275 void CContainer::HandleMarkCommandL( TInt aCommand ) |
|
276 { |
|
277 if (iListBox) |
|
278 { |
|
279 AknSelectionService::HandleMarkableListProcessCommandL( aCommand, iListBox ); |
|
280 } |
|
281 } |
|
282 |
|
283 // ---------------------------------------------------------------------------- |
|
284 // CContainer::ProcessCommandL |
|
285 // |
|
286 // Processes user commands. |
|
287 // ---------------------------------------------------------------------------- |
|
288 // |
|
289 void CContainer::ProcessCommandL( TInt aCommand ) |
|
290 { |
|
291 AknSelectionService::HandleMarkableListProcessCommandL( aCommand, iListBox ); |
|
292 } |
|
293 |
|
294 // ---------------------------------------------------------------------------- |
|
295 // CContainer::SelectionListProcessCommandL |
|
296 // |
|
297 // Processes user commands. |
|
298 // ---------------------------------------------------------------------------- |
|
299 // |
|
300 void CContainer::SelectionListProcessCommandL( TInt aCommand ) |
|
301 { |
|
302 AknSelectionService::HandleSelectionListProcessCommandL( aCommand, iListBox ); |
|
303 } |
|
304 |
|
305 // ---------------------------------------------------------------------------- |
|
306 // CContainer::FilterCasesByModuleL |
|
307 // |
|
308 // Show only testcases which are defined is specified module. |
|
309 // ---------------------------------------------------------------------------- |
|
310 // |
|
311 void CContainer::FilterCasesByModuleL( TName aModuleName ) |
|
312 { |
|
313 iTestCasesInView.Reset(); // Clear testCasesInView pointer array |
|
314 |
|
315 RRefArray<CTestInfo> allCases; |
|
316 TInt ret = iUIStore->TestCases( allCases ); |
|
317 if( KErrNone != ret ) |
|
318 { |
|
319 ((CAppUIAppUi*)iCoeEnv->AppUi())->iLogger->Log(_L("FilterCasesByModuleL(): iUIStore->TestCases() fails")); |
|
320 allCases.Reset(); |
|
321 allCases.Close(); |
|
322 User::Leave( ret ); |
|
323 } |
|
324 const TInt KTestCaseCount = allCases.Count(); |
|
325 for( TInt i=0; i < KTestCaseCount; i++ ) |
|
326 { |
|
327 if ( allCases[i].ModuleName() == aModuleName ) |
|
328 { |
|
329 iTestCasesInView.Append( &( allCases[i] ) ); |
|
330 } |
|
331 } |
|
332 allCases.Reset(); |
|
333 allCases.Close(); |
|
334 |
|
335 iListBox->Reset(); |
|
336 iListBox->DrawNow(); |
|
337 } |
|
338 |
|
339 // ---------------------------------------------------------------------------- |
|
340 // CContainer::FilterCasesByTCFileNameL |
|
341 // |
|
342 // Show only testcases which are defined is specified test case file. |
|
343 // ---------------------------------------------------------------------------- |
|
344 // |
|
345 void CContainer::FilterCasesByTCFileNameL( |
|
346 TFileName aTestCaseFileName ) |
|
347 { |
|
348 |
|
349 iTestCasesInView.Reset(); // Clear testCasesInView pointer array |
|
350 |
|
351 RRefArray<CTestInfo> allCases; |
|
352 TInt ret = iUIStore->TestCases( allCases ); |
|
353 if( KErrNone != ret ) |
|
354 { |
|
355 ((CAppUIAppUi*)iCoeEnv->AppUi())->iLogger->Log(_L("FilterCasesByModuleL(): iUIStore->TestCases() fails")); |
|
356 allCases.Reset(); |
|
357 allCases.Close(); |
|
358 User::Leave( ret ); |
|
359 } |
|
360 const TInt KTestCaseCount = allCases.Count(); |
|
361 for( TInt i=0; i < KTestCaseCount; i++ ) |
|
362 { |
|
363 if ( allCases[i].TestCaseFile() == aTestCaseFileName ) |
|
364 { |
|
365 iTestCasesInView.Append( &( allCases[i] ) ); |
|
366 } |
|
367 } |
|
368 |
|
369 allCases.Reset(); |
|
370 allCases.Close(); |
|
371 |
|
372 iListBox->Reset(); |
|
373 iListBox->DrawNow(); |
|
374 } |
|
375 |
|
376 // ---------------------------------------------------------------------------- |
|
377 // CContainer::NoFilteringL |
|
378 // |
|
379 // Remove possible filtering of test cases -> show all test cases. |
|
380 // ---------------------------------------------------------------------------- |
|
381 // |
|
382 void CContainer::NoFilteringL() |
|
383 { |
|
384 iTestCasesInView.Reset(); // Clear testCasesInView pointer array |
|
385 |
|
386 RRefArray<CTestInfo> allCases; |
|
387 TInt ret = iUIStore->TestCases( allCases ); |
|
388 if( KErrNone != ret ) |
|
389 { |
|
390 ((CAppUIAppUi*)iCoeEnv->AppUi())->iLogger->Log(_L("FilterCasesByModuleL(): iUIStore->TestCases() fails")); |
|
391 allCases.Reset(); |
|
392 allCases.Close(); |
|
393 User::Leave( ret ); |
|
394 } |
|
395 const TInt KTestCaseCount = allCases.Count(); |
|
396 |
|
397 // Add all cases to iTestCasesInView pointer array |
|
398 for( TInt i=0; i < KTestCaseCount; i++ ) |
|
399 { |
|
400 iTestCasesInView.Append( &( allCases[i] ) ); |
|
401 } |
|
402 |
|
403 allCases.Reset(); |
|
404 allCases.Close(); |
|
405 |
|
406 iListBox->Reset(); |
|
407 iListBox->DrawNow(); |
|
408 } |
|
409 |
|
410 // End of File |