|
1 /* |
|
2 * Copyright (c) 2006-2007 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: The grouped result view for all the searched contents. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 // System Includes |
|
24 #include <aknViewAppUi.h> |
|
25 #include <eikbtgpc.h> |
|
26 #include <eikmenup.h> |
|
27 #include <e32std.h> |
|
28 #include <AknGlobalNote.h> |
|
29 #include <StringLoader.h> |
|
30 #include <avkon.rsg> |
|
31 #include <srchui.rsg> |
|
32 #include "srchuifolderfileif.h" |
|
33 #include <hlplch.h> // help launcher |
|
34 #include <csxhelp/search.hlp.hrh> |
|
35 |
|
36 // User Includes |
|
37 #include "srchuiresfolder.h" |
|
38 #include "srchuigeneral.h" |
|
39 #include "srchuiresfolderview.h" |
|
40 #include "srchuiresfoldercontainer.h" |
|
41 #include "srchuiappuids.h" |
|
42 #include "srchui.hrh" |
|
43 #include "srchuidefines.h" |
|
44 |
|
45 const TInt KNaviStringLength = 20; |
|
46 |
|
47 // ====================================== MEMBER FUNCTIONS ========================================= |
|
48 |
|
49 // ------------------------------------------------------------------------------------------------- |
|
50 // CSrchUiResFolderView::NewL |
|
51 // Symbian OS 2 phased constructor. |
|
52 // ------------------------------------------------------------------------------------------------- |
|
53 // |
|
54 CSrchUiResFolderView* CSrchUiResFolderView::NewL(CSrchUiGeneral* aGeneralsrchUi, |
|
55 RPointerArray<CSrchUiResFolder>& aFolders) |
|
56 { |
|
57 CSrchUiResFolderView* self = CSrchUiResFolderView::NewLC(aGeneralsrchUi,aFolders ); |
|
58 CleanupStack::Pop(self); |
|
59 return self; |
|
60 } |
|
61 |
|
62 // ------------------------------------------------------------------------------------------------- |
|
63 // CSrchUiResFolderView::NewLC |
|
64 // Symbian OS 2 phased constructor. |
|
65 // ------------------------------------------------------------------------------------------------- |
|
66 // |
|
67 CSrchUiResFolderView* CSrchUiResFolderView::NewLC(CSrchUiGeneral* aGeneralsrchUi, |
|
68 RPointerArray<CSrchUiResFolder>& aFolders) |
|
69 { |
|
70 CSrchUiResFolderView* self = new (ELeave) CSrchUiResFolderView(); |
|
71 CleanupStack::PushL(self); |
|
72 self->ConstructL(aGeneralsrchUi, aFolders); |
|
73 return self; |
|
74 } |
|
75 |
|
76 // ------------------------------------------------------------------------------------------------- |
|
77 // CSrchUiResFolderView::~CSrchUiResFolderView |
|
78 // Destructor. |
|
79 // ------------------------------------------------------------------------------------------------- |
|
80 // |
|
81 CSrchUiResFolderView::~CSrchUiResFolderView() |
|
82 { |
|
83 DoDeactivate(); |
|
84 delete iContainer; |
|
85 } |
|
86 |
|
87 // ------------------------------------------------------------------------------------------------- |
|
88 // CSrchUiResFolderView::ResultsAddedL |
|
89 // Informs the control(listbox) that search results were added |
|
90 // ------------------------------------------------------------------------------------------------- |
|
91 // |
|
92 void CSrchUiResFolderView::ResultsAddedL() |
|
93 { |
|
94 if ( iContainer ) |
|
95 { |
|
96 iContainer->ResultsAddedL(); |
|
97 } |
|
98 } |
|
99 |
|
100 // ------------------------------------------------------------------------------------------------- |
|
101 // CSrchUiResFolderView::ResultsClearedL |
|
102 // Called from the application ui class when the previous results were deleted. |
|
103 // ------------------------------------------------------------------------------------------------- |
|
104 // |
|
105 void CSrchUiResFolderView::ResultsClearedL() |
|
106 { |
|
107 SetContainerListBoxIndex( KErrNotFound ); |
|
108 if ( iContainer ) |
|
109 { |
|
110 iContainer->ResultsClearedL(); |
|
111 } |
|
112 } |
|
113 |
|
114 // ------------------------------------------------------------------------------------------------- |
|
115 // CSrchUiResFolderView::SearchStatusChangedL |
|
116 // Called from the application ui class after some search status change. |
|
117 // ------------------------------------------------------------------------------------------------- |
|
118 // |
|
119 void CSrchUiResFolderView::SearchStatusChangedL() |
|
120 { |
|
121 if ( iContainer ) |
|
122 { |
|
123 iContainer->SearchStatusChangedL(); |
|
124 } |
|
125 } |
|
126 |
|
127 // ------------------------------------------------------------------------------------------------- |
|
128 // CSrchUiResFolderView::SearchFinishedL |
|
129 // Called from the application ui class after the search has finished. |
|
130 // ------------------------------------------------------------------------------------------------- |
|
131 // |
|
132 void CSrchUiResFolderView::SearchFinishedL(TInt aNumberOfFoundDocuments) |
|
133 { |
|
134 if ( Cba() ) |
|
135 { |
|
136 Cba()->SetCommandSetL( R_SOFTKEYS_OPTIONS_OPEN_BACK ); |
|
137 Cba()->DrawDeferred(); |
|
138 } |
|
139 iNumberOfFoundDocuments = aNumberOfFoundDocuments; |
|
140 if ( iContainer ) |
|
141 { |
|
142 // Stop the timer if it is active |
|
143 if ( iPeriodicTimer->IsActive() ) |
|
144 { |
|
145 iPeriodicTimer->Cancel(); |
|
146 } |
|
147 |
|
148 HBufC* naviStrFormat; |
|
149 TInt count = 0; |
|
150 RArray<TBool>& seltypes = iGeneralsrchUi->SelectedContentTypes(); |
|
151 for(TInt i =0; i<seltypes.Count();i++) |
|
152 { |
|
153 if(seltypes[i]) |
|
154 { |
|
155 count++; |
|
156 } |
|
157 } |
|
158 if((aNumberOfFoundDocuments == 0)&& (count == 1)) |
|
159 { |
|
160 naviStrFormat = KNullDesC().Alloc(); |
|
161 iContainer->SearchFinishedL(); |
|
162 iContainer->SetErrorNoteL(); |
|
163 iContainer->UpdateNaviPaneL(*naviStrFormat); |
|
164 } |
|
165 else |
|
166 { |
|
167 if(aNumberOfFoundDocuments == 1) |
|
168 { |
|
169 //load (%d result) from resource |
|
170 naviStrFormat = StringLoader::LoadL(R_QTN_SEARCH_ONE_RESULT); |
|
171 } |
|
172 else |
|
173 { |
|
174 //load (%d results) from resource |
|
175 naviStrFormat = StringLoader::LoadL( R_QTN_SEARCH_MULTIPLE_RESULTS, |
|
176 aNumberOfFoundDocuments ); |
|
177 } |
|
178 |
|
179 |
|
180 iContainer->UpdateNaviPaneL(*naviStrFormat ); |
|
181 //write code to display number of results in the Navi pane |
|
182 iContainer->SearchFinishedL(); |
|
183 delete naviStrFormat; |
|
184 } |
|
185 } |
|
186 } |
|
187 |
|
188 // ------------------------------------------------------------------------------------------------- |
|
189 // CSrchUiResFolderView::GetOpenFolder |
|
190 // Returns the pointer to opened folder |
|
191 // ------------------------------------------------------------------------------------------------- |
|
192 // |
|
193 MSrchUiFolder* CSrchUiResFolderView::GetOpenFolder() |
|
194 { |
|
195 return iContainer->GetOpenFolder(); |
|
196 } |
|
197 |
|
198 // ------------------------------------------------------------------------------------------------- |
|
199 // CSrchUiResFolderView::SetContainerListBoxIndex |
|
200 // Setter for iContainerListBoxIndex. |
|
201 // ------------------------------------------------------------------------------------------------- |
|
202 // |
|
203 void CSrchUiResFolderView::SetContainerListBoxIndex( TInt aIndex ) |
|
204 { |
|
205 iContainerListBoxIndex = aIndex; |
|
206 } |
|
207 |
|
208 // ------------------------------------------------------------------------------------------------- |
|
209 // CSrchUiResFolderView::ContainerListBoxIndex |
|
210 // Getter for iContainerListBoxIndex. |
|
211 // ------------------------------------------------------------------------------------------------- |
|
212 // |
|
213 TInt CSrchUiResFolderView::ContainerListBoxIndex() |
|
214 { |
|
215 return iContainerListBoxIndex; |
|
216 } |
|
217 |
|
218 // ----------------------------------------------------------------------------- |
|
219 // CSrchUiResFolderView::HandleItemAdditionL |
|
220 // Handles the addition of an item to the model. |
|
221 // ----------------------------------------------------------------------------- |
|
222 // |
|
223 void CSrchUiResFolderView::HandleItemAdditionL() |
|
224 { |
|
225 if(iContainer) |
|
226 { |
|
227 iContainer->HandleItemAdditionL(); |
|
228 } |
|
229 } |
|
230 |
|
231 // ------------------------------------------------------------------------------------------------- |
|
232 // CSrchUiResFolderView::UpdateNaviPaneL |
|
233 // Updates the navigation Pane. |
|
234 // ------------------------------------------------------------------------------------------------- |
|
235 // |
|
236 void CSrchUiResFolderView::UpdateNaviPaneL() |
|
237 { |
|
238 if(iGeneralsrchUi->IsSearchOngoing()) |
|
239 { |
|
240 SetNaviTextL(); |
|
241 } |
|
242 else |
|
243 { |
|
244 HBufC* naviStrFormat; |
|
245 if(iNumberOfFoundDocuments == 1) |
|
246 { |
|
247 //load (%d result) from resource |
|
248 naviStrFormat = StringLoader::LoadL(R_QTN_SEARCH_ONE_RESULT); |
|
249 } |
|
250 else |
|
251 { |
|
252 //load (%d results) from resource |
|
253 naviStrFormat = StringLoader::LoadL( R_QTN_SEARCH_MULTIPLE_RESULTS, |
|
254 iNumberOfFoundDocuments ); |
|
255 } |
|
256 |
|
257 iContainer->UpdateNaviPaneL( *naviStrFormat ); |
|
258 delete naviStrFormat; |
|
259 } |
|
260 } |
|
261 // ------------------------------------------------------------------------------------------------- |
|
262 // CSrchUiResFolderView::Id |
|
263 // Returns the unique id of the view. |
|
264 // ------------------------------------------------------------------------------------------------- |
|
265 // |
|
266 TUid CSrchUiResFolderView::Id() const |
|
267 { |
|
268 return KSearchResultFolderViewUid; |
|
269 } |
|
270 |
|
271 // ------------------------------------------------------------------------------------------------- |
|
272 // CSrchUiResFolderView::HandleCommandL |
|
273 // Handles the commands that are passed from softkey generated commands and |
|
274 // pop up's. |
|
275 // ------------------------------------------------------------------------------------------------- |
|
276 // |
|
277 void CSrchUiResFolderView::HandleCommandL( TInt aCommand ) |
|
278 { |
|
279 switch ( aCommand ) |
|
280 { |
|
281 case ESearchCmdOpen: |
|
282 { |
|
283 iContainer->HandleItemSelectionL(); |
|
284 } |
|
285 break; |
|
286 |
|
287 case ESearchCmdSearch: |
|
288 { |
|
289 _LIT(KEmptyString,""); |
|
290 TBufC<3> buf( KEmptyString ); |
|
291 HBufC* string = buf.AllocL(); |
|
292 CleanupStack::PushL(string); |
|
293 iGeneralsrchUi->SetSearchStringL( *string ); |
|
294 CleanupStack::PopAndDestroy(string); |
|
295 |
|
296 iGeneralsrchUi->StartNewSearchL(); |
|
297 } |
|
298 break; |
|
299 |
|
300 case ESearchCmdHelp: |
|
301 { |
|
302 TCoeHelpContext helpContext; |
|
303 helpContext.iMajor = KSearchAppUid ; |
|
304 helpContext.iContext = KSEARCH_HLP_GROUPED; // add correct help context when available |
|
305 |
|
306 CArrayFix<TCoeHelpContext>* hlpContextArray = |
|
307 new ( ELeave ) CArrayFixFlat<TCoeHelpContext> ( 1 ); |
|
308 |
|
309 CleanupStack::PushL( hlpContextArray ); |
|
310 hlpContextArray->AppendL( helpContext ); |
|
311 CleanupStack::Pop( hlpContextArray ); |
|
312 |
|
313 //Launch help - takes ownership of hlpContextArray |
|
314 HlpLauncher::LaunchHelpApplicationL( iEikonEnv->WsSession(), |
|
315 hlpContextArray ); |
|
316 } |
|
317 break; |
|
318 case EAknSoftkeyExit: |
|
319 iAvkonAppUi->ProcessCommandL(EAknCmdExit); |
|
320 break; |
|
321 |
|
322 case EAknSoftkeyBack: |
|
323 { |
|
324 iGeneralsrchUi->ActivatePreviousViewL(); |
|
325 } |
|
326 break; |
|
327 case ESearchCmdCancel: |
|
328 // Stop the timer if it is active |
|
329 if ( iPeriodicTimer->IsActive() ) |
|
330 { |
|
331 iPeriodicTimer->Cancel(); |
|
332 } |
|
333 iGeneralsrchUi->CancelSearch(); |
|
334 if ( Cba() ) |
|
335 { |
|
336 Cba()->SetCommandSetL( R_SOFTKEYS_OPTIONS_OPEN_BACK ); |
|
337 Cba()->DrawDeferred(); |
|
338 } |
|
339 break; |
|
340 default: |
|
341 break; |
|
342 } |
|
343 |
|
344 } |
|
345 |
|
346 // ------------------------------------------------------------------------------------------------- |
|
347 // CSrchUiResFolderView::DoActivateL |
|
348 // Called by the framework when the view is activated. |
|
349 // ------------------------------------------------------------------------------------------------- |
|
350 // |
|
351 void CSrchUiResFolderView::DoActivateL(const TVwsViewId& /*aPrevViewId*/,TUid /*aCustomMessageId*/, const TDesC8& /*aCustomMessage*/) |
|
352 { |
|
353 if ( !iContainer ) |
|
354 { |
|
355 iContainer = new( ELeave ) CSrchUiResFolderContainer( *this, iGeneralsrchUi ); |
|
356 iContainer->SetMopParent( this ); |
|
357 iContainer->ConstructL( ClientRect() ); |
|
358 iContainer->SetRoot( iGeneralsrchUi->SrchUiResRoot() ); |
|
359 |
|
360 AppUi()->AddToStackL( *this, iContainer ); |
|
361 iContainer->MakeVisible( ETrue ); |
|
362 |
|
363 if ( Cba() ) |
|
364 { |
|
365 if(iGeneralsrchUi->IsSearchOngoing()) |
|
366 { |
|
367 Cba()->SetCommandSetL( R_SOFTKEYS_OPTIONS_OPEN_CANCEL ); |
|
368 } |
|
369 else |
|
370 { |
|
371 Cba()->SetCommandSetL( R_SOFTKEYS_OPTIONS_OPEN_BACK ); |
|
372 } |
|
373 Cba()->DrawDeferred(); |
|
374 } |
|
375 } |
|
376 iContainer->UpdateTitlePaneL(); |
|
377 iPeriodicTimer = CPeriodic::NewL( CActive::EPriorityStandard ); |
|
378 if(iGeneralsrchUi->IsSearchOngoing()) |
|
379 { |
|
380 StartTimer(); |
|
381 } |
|
382 UpdateNaviPaneL(); |
|
383 } |
|
384 |
|
385 // ------------------------------------------------------------------------------------------------- |
|
386 // CSrchUiResView::DoDeactivate |
|
387 // Called by the framework when the view is de-activated. |
|
388 // ------------------------------------------------------------------------------------------------- |
|
389 // |
|
390 void CSrchUiResFolderView::DoDeactivate() |
|
391 { |
|
392 if ( iContainer ) |
|
393 { |
|
394 AppUi()->RemoveFromViewStack( *this, iContainer ); |
|
395 iContainer->MakeVisible( EFalse ); |
|
396 delete iContainer; |
|
397 iContainer = NULL; |
|
398 } |
|
399 if( iPeriodicTimer ) |
|
400 { |
|
401 delete iPeriodicTimer; |
|
402 iPeriodicTimer = NULL; |
|
403 } |
|
404 } |
|
405 |
|
406 // ------------------------------------------------------------------------------------------------- |
|
407 // CSrchUiResView::DynInitMenuPaneL |
|
408 // Called by the framework for dynamically initializing the menu pane. |
|
409 // ------------------------------------------------------------------------------------------------- |
|
410 // |
|
411 void CSrchUiResFolderView::DynInitMenuPaneL(TInt aResourceId, CEikMenuPane* aMenuPane) |
|
412 { |
|
413 if(!iContainer->IsElementValid()) |
|
414 { |
|
415 if ( aResourceId == R_SEARCH_RESULT_FOLDER_VIEW_MENU_PANE ) |
|
416 { |
|
417 aMenuPane->DeleteMenuItem( ESearchCmdOpen ); |
|
418 } |
|
419 } |
|
420 } |
|
421 |
|
422 // ------------------------------------------------------------------------------------------------- |
|
423 // CSrchUiResFolderView::CSrchUiResFolderView |
|
424 // Performs the first phase of two phase construction. |
|
425 // ------------------------------------------------------------------------------------------------- |
|
426 // |
|
427 CSrchUiResFolderView::CSrchUiResFolderView() |
|
428 { |
|
429 } |
|
430 |
|
431 // ------------------------------------------------------------------------------------------------- |
|
432 // CSrchUiResFolderView::ConstructL |
|
433 // Performs the second phase construction. |
|
434 // ------------------------------------------------------------------------------------------------- |
|
435 // |
|
436 void CSrchUiResFolderView::ConstructL(CSrchUiGeneral* aGeneralsrchUi, |
|
437 RPointerArray<CSrchUiResFolder>& aFolders) |
|
438 { |
|
439 iGeneralsrchUi = aGeneralsrchUi; |
|
440 iFolders = aFolders; |
|
441 iCount_val = 1; |
|
442 BaseConstructL( R_SEARCH_RESULT_FOLDER_VIEW ); |
|
443 } |
|
444 |
|
445 // ----------------------------------------------------------------------------- |
|
446 // CSrchUiResFolderView::PeriodL |
|
447 // This function is called by the periodic timer. |
|
448 // ----------------------------------------------------------------------------- |
|
449 // |
|
450 TInt CSrchUiResFolderView::PeriodL( TAny* aPtr ) |
|
451 { |
|
452 ( static_cast<CSrchUiResFolderView*>( aPtr ) )->SetNaviTextL(); |
|
453 // Returning a value of TRUE indicates the callback should be done again |
|
454 return ETrue; |
|
455 } |
|
456 |
|
457 // ----------------------------------------------------------------------------- |
|
458 // CSrchUiResFolderView::SetNaviTextL |
|
459 // Updates the navigation with the text about the staus. |
|
460 // ----------------------------------------------------------------------------- |
|
461 // |
|
462 void CSrchUiResFolderView::SetNaviTextL() |
|
463 { |
|
464 HBufC16 *pbuf; |
|
465 |
|
466 pbuf = StringLoader::LoadL(R_QTN_SEARCH_INPROGRESS); |
|
467 |
|
468 HBufC16* tmpbuf = HBufC::NewL( pbuf->Size() + 3 ); |
|
469 TPtr bufPtr = tmpbuf->Des(); |
|
470 bufPtr.Copy( *pbuf ); |
|
471 |
|
472 for ( TInt i = 0; i <= iCount_val % 3; i++ ) |
|
473 { |
|
474 _LIT ( KDot, "." ); |
|
475 bufPtr.Append( KDot ); |
|
476 } |
|
477 |
|
478 iCount_val++; |
|
479 iContainer->UpdateNaviPaneL(*tmpbuf ); |
|
480 delete pbuf; |
|
481 delete tmpbuf; |
|
482 } |
|
483 |
|
484 // ------------------------------------------------------------------------------------------------- |
|
485 // CSrchUiResFolderView::StartTimer |
|
486 // Starts the timer. |
|
487 // ------------------------------------------------------------------------------------------------- |
|
488 // |
|
489 void CSrchUiResFolderView::StartTimer() |
|
490 { |
|
491 // If the timer is not already running, start it |
|
492 if ( !iPeriodicTimer->IsActive() ) |
|
493 { |
|
494 iPeriodicTimer->Start( 10, 1000000, |
|
495 TCallBack( CSrchUiResFolderView::PeriodL, this ) ); |
|
496 } |
|
497 |
|
498 } |
|
499 |
|
500 /// End of File |