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 CTestSetInsertMenuView class |
|
15 * definition. |
|
16 * |
|
17 */ |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include <eikmenub.h> |
|
21 #include <aknViewAppUi.h> |
|
22 #include <aknlistquerydialog.h> |
|
23 #include <aknnotewrappers.h> |
|
24 #include <barsread.h> //TResourceReader |
|
25 #include <Stifui.rsg> |
|
26 #include "TestSetInsertMenuView.h" |
|
27 #include "TestSetInsertMenuContainer.h" |
|
28 #include "TestSetMenuView.h" |
|
29 #include "AppUIAppUi.h" |
|
30 #include "Stifui.hrh" |
|
31 |
|
32 |
|
33 // ================= MEMBER FUNCTIONS ======================= |
|
34 // ---------------------------------------------------------------------------- |
|
35 // CTestSetInsertMenuView::ConstructL |
|
36 // |
|
37 // Symbian OS two-phased constructor. |
|
38 // ---------------------------------------------------------------------------- |
|
39 // |
|
40 void CTestSetInsertMenuView::ConstructL() |
|
41 { |
|
42 CView::ConstructL(); |
|
43 BaseConstructL( R_INSERT_TESTCASES_VIEW ); |
|
44 iCurrentTestCase = 0; |
|
45 |
|
46 } |
|
47 |
|
48 // ---------------------------------------------------------------------------- |
|
49 // CTestSetInsertMenuView::~CTestSetInsertMenuView |
|
50 // |
|
51 // Destructor. |
|
52 // ---------------------------------------------------------------------------- |
|
53 // |
|
54 CTestSetInsertMenuView::~CTestSetInsertMenuView() |
|
55 { |
|
56 if ( iContainer ) |
|
57 { |
|
58 AppUi()->RemoveFromViewStack( *this, iContainer ); |
|
59 delete iContainer; |
|
60 } |
|
61 delete iNaviDecorator; |
|
62 iNaviDecorator = NULL; |
|
63 } |
|
64 |
|
65 // ---------------------------------------------------------------------------- |
|
66 // CTestSetInsertMenuView::Id |
|
67 // |
|
68 // Returns view´s id. |
|
69 // ---------------------------------------------------------------------------- |
|
70 // |
|
71 TUid CTestSetInsertMenuView::Id() const |
|
72 { |
|
73 return TUid::Uid(ETestSetInsertMenuViewId); |
|
74 |
|
75 } |
|
76 |
|
77 // ---------------------------------------------------------------------------- |
|
78 // CTestSetInsertMenuView::HandleCommandL |
|
79 // |
|
80 // Handles a command. |
|
81 // ---------------------------------------------------------------------------- |
|
82 // |
|
83 void CTestSetInsertMenuView::HandleCommandL(TInt aCommand) |
|
84 { |
|
85 if ( aCommand >= ECmdFilterByModule && aCommand < ECmdFilterByTestCaseFile ) // 0x1000 - 0x1FFF |
|
86 { |
|
87 TInt moduleNumber = aCommand - ECmdFilterByModule; |
|
88 RRefArray<TDesC> allModules; |
|
89 TInt ret = ((CAppUIAppUi*)AppUi())->UIStoreHandler()->Modules( allModules ); |
|
90 if( KErrNone != ret ) |
|
91 { |
|
92 allModules.Reset(); |
|
93 allModules.Close(); |
|
94 User::Leave( ret ); |
|
95 } |
|
96 TName moduleName = allModules[ moduleNumber ]; |
|
97 |
|
98 iContainer->FilterCasesByModuleL( moduleName ); |
|
99 |
|
100 allModules.Reset(); |
|
101 allModules.Close(); |
|
102 } |
|
103 else if ( aCommand >= ECmdFilterByTestCaseFile && aCommand < ECmdNOFiltering ) |
|
104 { |
|
105 TInt testCaseFileNumber = aCommand - ECmdFilterByTestCaseFile; |
|
106 RRefArray<TDesC> allTestCases; |
|
107 TInt ret = ((CAppUIAppUi*)AppUi())->UIStoreHandler()->TestCaseFiles( allTestCases ); |
|
108 if( KErrNone != ret ) |
|
109 { |
|
110 allTestCases.Reset(); |
|
111 allTestCases.Close(); |
|
112 User::Leave( ret ); |
|
113 } |
|
114 TFileName testCaseFileName = allTestCases[ testCaseFileNumber ]; |
|
115 |
|
116 iContainer->FilterCasesByTCFileNameL( testCaseFileName ); |
|
117 |
|
118 allTestCases.Reset(); |
|
119 allTestCases.Close(); |
|
120 } |
|
121 else if ( aCommand == ECmdNOFiltering ) |
|
122 { |
|
123 iContainer->NoFilteringL(); |
|
124 } |
|
125 else if ( aCommand == EAknCmdMark || aCommand == EAknCmdUnmark |
|
126 || aCommand == EAknMarkAll || aCommand == EAknUnmarkAll ) |
|
127 { |
|
128 iContainer->HandleMarkCommandL( aCommand ); |
|
129 } |
|
130 else |
|
131 { |
|
132 switch ( aCommand ) |
|
133 { |
|
134 case ECmdInsertSelectedCases: |
|
135 { |
|
136 ShowInsertCasesDialogL(); |
|
137 break; |
|
138 } |
|
139 case EAknSoftkeyCancel: |
|
140 { |
|
141 //iCurrentTestCase = 0; |
|
142 ( (CEikAppUi*)iCoeEnv->AppUi() )->HandleCommandL(EAppUIGoToTestSetsMenu); |
|
143 break; |
|
144 } |
|
145 default: |
|
146 { |
|
147 AppUi()->HandleCommandL( aCommand ); |
|
148 break; |
|
149 } |
|
150 } |
|
151 } |
|
152 |
|
153 } |
|
154 |
|
155 // ---------------------------------------------------------------------------- |
|
156 // CTestSetInsertMenuView::HandleClientRectChange |
|
157 // |
|
158 // Handles client rect changes. |
|
159 // ---------------------------------------------------------------------------- |
|
160 // |
|
161 void CTestSetInsertMenuView::HandleClientRectChange() |
|
162 { |
|
163 if ( iContainer ) |
|
164 { |
|
165 iContainer->SetRect( ClientRect() ); |
|
166 } |
|
167 |
|
168 } |
|
169 |
|
170 // ---------------------------------------------------------------------------- |
|
171 // CTestSetInsertMenuView::DoActivateL |
|
172 // |
|
173 // Initializes view when activated. |
|
174 // ---------------------------------------------------------------------------- |
|
175 // |
|
176 void CTestSetInsertMenuView::DoActivateL( |
|
177 const TVwsViewId& /*aPrevViewId*/,TUid /*aCustomMessageId*/, |
|
178 const TDesC8& /*aCustomMessage*/) |
|
179 { |
|
180 if (!iContainer) |
|
181 { |
|
182 ((CAppUIAppUi*)AppUi())->iLogger->Log(_L("TestSetInsertMenuView: DoActivateL")); |
|
183 //message = _L("eng.open ret:"); |
|
184 //message.AppendNum( ret , EDecimal ); |
|
185 //AppUi()->iLogger->Log( message ); |
|
186 iContainer = new (ELeave) CTestSetInsertMenuContainer; |
|
187 iContainer->SetMopParent(this); |
|
188 iContainer->ConstructL( ClientRect(), this ); |
|
189 ((CAppUIAppUi*)AppUi())->iLogger->Log(_L("TestSetInsertMenuView: container constructed")); |
|
190 AppUi()->AddToStackL( *this, iContainer ); |
|
191 } |
|
192 |
|
193 //testing |
|
194 iContainer->SetCurrentItemIndex(iCurrentTestCase); |
|
195 |
|
196 CEikStatusPane* sp=iEikonEnv->AppUiFactory()->StatusPane(); |
|
197 CAknNavigationControlContainer* np= (CAknNavigationControlContainer *)sp->ControlL(TUid::Uid(EEikStatusPaneUidNavi)); |
|
198 |
|
199 TResourceReader reader; |
|
200 iCoeEnv->CreateResourceReaderLC(reader,R_NAVITITLE_TESTSET_INSERT); |
|
201 iNaviDecorator = np->CreateNavigationLabelL( reader ); |
|
202 CleanupStack::PopAndDestroy(); // resource reader |
|
203 np->PushL(*iNaviDecorator); |
|
204 } |
|
205 |
|
206 // ---------------------------------------------------------------------------- |
|
207 // CTestSetInsertMenuView::DoDeactivate |
|
208 // |
|
209 // Deactivates view. |
|
210 // ---------------------------------------------------------------------------- |
|
211 // |
|
212 void CTestSetInsertMenuView::DoDeactivate() |
|
213 { |
|
214 if ( iContainer ) |
|
215 { |
|
216 iContainer->SaveActiveLine(); |
|
217 AppUi()->RemoveFromViewStack( *this, iContainer ); |
|
218 delete iContainer; |
|
219 iContainer = NULL; |
|
220 } |
|
221 delete iNaviDecorator; |
|
222 iNaviDecorator = NULL; |
|
223 } |
|
224 |
|
225 // ---------------------------------------------------------------------------- |
|
226 // CTestSetInsertMenuView::DynInitMenuPaneL |
|
227 // |
|
228 // Initializes menu pane. |
|
229 // ---------------------------------------------------------------------------- |
|
230 // |
|
231 void CTestSetInsertMenuView::DynInitMenuPaneL( |
|
232 TInt aResourceId, CEikMenuPane* aMenuPane) |
|
233 { |
|
234 |
|
235 // Test modules are added to filter by test module submenu if the submenu is opened |
|
236 if (R_APPUI_FILTERBYMODULES_MENU == aResourceId) |
|
237 { |
|
238 RRefArray<TDesC> modules; |
|
239 TInt ret = ((CAppUIAppUi*)AppUi())->UIStoreHandler()->Modules( modules ); |
|
240 if( KErrNone != ret ) |
|
241 { |
|
242 modules.Reset(); |
|
243 modules.Close(); |
|
244 User::Leave( ret ); |
|
245 } |
|
246 |
|
247 TInt moduleCount = modules.Count(); |
|
248 |
|
249 TInt i; |
|
250 CEikMenuPaneItem::SData item; |
|
251 |
|
252 item.iCommandId = ECmdFilterByModule; |
|
253 item.iFlags = 0; |
|
254 item.iCascadeId = 0; |
|
255 |
|
256 for (i = 0; i < moduleCount; i++) |
|
257 { |
|
258 //item.iText = modules[i].iModuleName; |
|
259 item.iText = modules[i]; |
|
260 aMenuPane->AddMenuItemL(item); |
|
261 item.iCommandId++; // command IDs 0x1000 - 0x1FFF are reserved for modules in hrh file |
|
262 } |
|
263 |
|
264 modules.Reset(); |
|
265 modules.Close(); |
|
266 |
|
267 } |
|
268 |
|
269 // Test case files are added to filter by test case file submenu if the submenu is opened |
|
270 if (R_APPUI_FILTER_BY_TESTCASEFILE_MENU == aResourceId) |
|
271 { |
|
272 RRefArray<TDesC> testCaseFiles; |
|
273 TInt ret = ((CAppUIAppUi*)AppUi())->UIStoreHandler()->TestCaseFiles( testCaseFiles ); |
|
274 if( KErrNone != ret ) |
|
275 { |
|
276 testCaseFiles.Reset(); |
|
277 testCaseFiles.Close(); |
|
278 User::Leave( ret ); |
|
279 } |
|
280 |
|
281 TInt testCaseFileCount = testCaseFiles.Count(); |
|
282 |
|
283 TInt i; |
|
284 CEikMenuPaneItem::SData item; |
|
285 |
|
286 item.iCommandId = ECmdFilterByTestCaseFile; |
|
287 item.iFlags = 0; |
|
288 item.iCascadeId = 0; |
|
289 |
|
290 for (i = 0; i < testCaseFileCount; i++) |
|
291 { |
|
292 item.iText = testCaseFiles[i]; |
|
293 aMenuPane->AddMenuItemL(item); |
|
294 item.iCommandId++; // command IDs 0x2000 - 0x2FFF are reserved for test case files in hrh file |
|
295 } |
|
296 } |
|
297 |
|
298 } |
|
299 |
|
300 // ---------------------------------------------------------------------------- |
|
301 // CTestSetInsertMenuView::HandleListBoxEventL |
|
302 // |
|
303 // Handles listbox events. |
|
304 // ---------------------------------------------------------------------------- |
|
305 // |
|
306 void CTestSetInsertMenuView::HandleListBoxEventL(CEikListBox* /*aListBox*/, TListBoxEvent aEventType) |
|
307 { |
|
308 |
|
309 if ( ( aEventType == EEventEnterKeyPressed ) || ( aEventType == EEventItemDoubleClicked ) ) |
|
310 { |
|
311 ShowInsertCasesDialogL(); |
|
312 } |
|
313 |
|
314 } |
|
315 |
|
316 // ---------------------------------------------------------------------------- |
|
317 // CTestSetInsertMenuView::ShowInsertCasesDialogL |
|
318 // |
|
319 // Show confirmation dialog for inserting test cases. |
|
320 // ---------------------------------------------------------------------------- |
|
321 // |
|
322 void CTestSetInsertMenuView::ShowInsertCasesDialogL() |
|
323 { |
|
324 TInt i(0); |
|
325 TBuf<50> message; |
|
326 CEikListBox* listBox = iContainer->ListBox(); |
|
327 TInt count = listBox->SelectionIndexes()->Count(); |
|
328 |
|
329 if ( count > 0 ) |
|
330 { |
|
331 CEikonEnv::Static()->ReadResource( message, R_INSERT_CONFIRMATION_QUESTION ); |
|
332 |
|
333 CAknQueryDialog * dlg = CAknQueryDialog::NewL(CAknQueryDialog::ENoTone); |
|
334 if ( dlg->ExecuteLD( R_GENERAL_CONFIRMATION_DIALOG, message ) ) |
|
335 { |
|
336 CEikListBox* newListBox = iContainer->ListBox(); |
|
337 TInt newCount = newListBox->SelectionIndexes()->Count(); |
|
338 RArray<TInt> selectedIndices; |
|
339 CleanupClosePushL( selectedIndices ); |
|
340 if ( newCount > 0 ) |
|
341 { |
|
342 for( i = 0; i < newCount; i++ ) |
|
343 { |
|
344 selectedIndices.InsertInOrder( (*newListBox->SelectionIndexes())[i] ); |
|
345 } |
|
346 |
|
347 AddCasesToTestSet( selectedIndices ); |
|
348 // Test cases added, set save needed flag to true. |
|
349 ((CTestSetMenuView*)AppUi()->View( |
|
350 TUid::Uid(ETestSetMenuViewId) ))->SetSaveNeeded(ETrue); |
|
351 } |
|
352 CleanupStack::PopAndDestroy(); |
|
353 |
|
354 // Test cases added -> go to test set menu |
|
355 AppUi()->HandleCommandL(EAppUIGoBack); |
|
356 } |
|
357 } |
|
358 else |
|
359 { |
|
360 CAknWarningNote* dialog = new(ELeave)CAknWarningNote(); |
|
361 CEikonEnv::Static()->ReadResource( message, R_INSERT_NOCASES_TEXT ); |
|
362 dialog->ExecuteLD(message); |
|
363 } |
|
364 |
|
365 } |
|
366 |
|
367 // ---------------------------------------------------------------------------- |
|
368 // CTestSetInsertMenuView::AddCasesToTestSet |
|
369 // |
|
370 // Adds selected test cases to the current test set. |
|
371 // ---------------------------------------------------------------------------- |
|
372 // |
|
373 void CTestSetInsertMenuView::AddCasesToTestSet( RArray<TInt> aSelectedIndexes ) |
|
374 { |
|
375 TInt ret(0); |
|
376 TInt i(0); |
|
377 RRefArray<CTestInfo> allCases; |
|
378 CTestSetMenuView* testSetMenuView = |
|
379 (CTestSetMenuView*)((CAppUIAppUi*)AppUi())->View( TUid::Uid(ETestSetMenuViewId) ); |
|
380 |
|
381 ret = ((CAppUIAppUi*)AppUi())->UIStoreHandler()->TestCases(allCases); |
|
382 |
|
383 for ( i = 0; i < aSelectedIndexes.Count(); i++ ) |
|
384 { |
|
385 ret = ((CAppUIAppUi*)AppUi())->UIStoreHandler()->AddToTestSet( |
|
386 testSetMenuView->CurrentTestSet(), |
|
387 allCases[ aSelectedIndexes[i] ] ); |
|
388 } |
|
389 if( ret != KErrNone ) |
|
390 { |
|
391 RDebug::Print( _L("AddCasesToTestSet failed with value: %d"), ret ); |
|
392 } |
|
393 |
|
394 allCases.Reset(); |
|
395 allCases.Close(); |
|
396 |
|
397 } |
|
398 |
|
399 // End of File |
|