1 /* |
|
2 * Copyright (c) 2002-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: File list model |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include "CGflmFileListModel.h" |
|
22 #include "MGflmItemGroup.h" |
|
23 #include "CGflmItemGroupImpl.h" |
|
24 #include "CGflmDirectoryListingCache.h" |
|
25 #include "CGflmFileRecognizer.h" |
|
26 #include "CGflmDriveResolver.h" |
|
27 #include "CGflmItemLocalizer.h" |
|
28 #include "CGflmFileSystemItem.h" |
|
29 #include "CGflmGlobalActionItem.h" |
|
30 #include "CGflmFileFinder.h" |
|
31 #include "MGflmItemFilter.h" |
|
32 #include "GflmUtils.h" |
|
33 #include "GFLMConsts.h" |
|
34 #include "GFLM.hrh" |
|
35 #include <e32base.h> |
|
36 #include <e32std.h> |
|
37 #include <badesca.h> |
|
38 |
|
39 |
|
40 // CONSTANTS |
|
41 |
|
42 // Granularity of iGroups array |
|
43 const TInt KItemGroupArrayGranularity = 3; |
|
44 |
|
45 |
|
46 // ============================ MEMBER FUNCTIONS =============================== |
|
47 |
|
48 // ----------------------------------------------------------------------------- |
|
49 // CGflmFileListModel::CGflmFileListModel |
|
50 // C++ default constructor can NOT contain any code, that |
|
51 // might leave. |
|
52 // ----------------------------------------------------------------------------- |
|
53 // |
|
54 CGflmFileListModel::CGflmFileListModel( RFs& aFs ) : |
|
55 CActive( CActive::EPriorityStandard ), |
|
56 iFs( aFs ) |
|
57 { |
|
58 } |
|
59 |
|
60 // ----------------------------------------------------------------------------- |
|
61 // CGflmFileListModel::NewL |
|
62 // Two-phased constructor. |
|
63 // ----------------------------------------------------------------------------- |
|
64 // |
|
65 EXPORT_C CGflmFileListModel* CGflmFileListModel::NewL( RFs& aFs ) |
|
66 { |
|
67 CGflmFileListModel* self = new( ELeave ) CGflmFileListModel( aFs ); |
|
68 |
|
69 CleanupStack::PushL( self ); |
|
70 self->ConstructL(); |
|
71 CleanupStack::Pop( self ); |
|
72 |
|
73 return self; |
|
74 } |
|
75 |
|
76 // ----------------------------------------------------------------------------- |
|
77 // CGflmFileListModel::ConstructL |
|
78 // Symbian 2nd phase constructor can leave. |
|
79 // ----------------------------------------------------------------------------- |
|
80 // |
|
81 void CGflmFileListModel::ConstructL() |
|
82 { |
|
83 FUNC_LOG |
|
84 |
|
85 CActiveScheduler::Add( this ); |
|
86 |
|
87 iGroups = new( ELeave ) |
|
88 CArrayPtrSeg< CGflmItemGroupImpl > |
|
89 ( KItemGroupArrayGranularity ); |
|
90 iListingCache = CGflmDirectoryListingCache::NewL( iFs, iCanceled ); |
|
91 iDriveResolver = CGflmDriveResolver::NewL( iFs ); |
|
92 iFileRecognizer = CGflmFileRecognizer::NewL( |
|
93 iFs, KGFLMFileRecognizerCacheSize, iDriveResolver ); |
|
94 iItemLocalizer = CGflmItemLocalizer::NewL(); |
|
95 iFileFinder = CGflmFileFinder::NewL( |
|
96 iFs, *iItemLocalizer, *iDriveResolver, iCanceled ); |
|
97 } |
|
98 |
|
99 // ----------------------------------------------------------------------------- |
|
100 // CGflmFileListModel::~CGflmFileListModel |
|
101 // |
|
102 // ----------------------------------------------------------------------------- |
|
103 // |
|
104 CGflmFileListModel::~CGflmFileListModel() |
|
105 { |
|
106 FUNC_LOG |
|
107 |
|
108 Cancel(); |
|
109 if ( iGroups ) |
|
110 { |
|
111 iGroups->ResetAndDestroy(); |
|
112 delete iGroups; |
|
113 } |
|
114 delete iFileFinder; |
|
115 delete iListingCache; |
|
116 delete iFileRecognizer; |
|
117 delete iItemLocalizer; |
|
118 delete iDriveResolver; |
|
119 iSemaphore.Close(); |
|
120 } |
|
121 |
|
122 // ----------------------------------------------------------------------------- |
|
123 // CGflmFileListModel::RefreshListL() |
|
124 // Creates and starts the work thread that refreshes the model |
|
125 // (other items were commented in a header). |
|
126 // ----------------------------------------------------------------------------- |
|
127 // |
|
128 EXPORT_C void CGflmFileListModel::RefreshListL( |
|
129 TRequestStatus& aStatus, TGflmRefreshMode aRefreshMode ) |
|
130 { |
|
131 FUNC_LOG |
|
132 |
|
133 if ( aStatus == KRequestPending ) |
|
134 { |
|
135 return; |
|
136 } |
|
137 |
|
138 iCorrupt = ETrue; |
|
139 iClientStatus = &aStatus; |
|
140 *iClientStatus = KRequestPending; |
|
141 iClientId = RThread().Id(); |
|
142 |
|
143 if ( iShutdown ) |
|
144 { |
|
145 // Ensure client completion |
|
146 NotifyClient( KErrNone ); |
|
147 return; |
|
148 } |
|
149 |
|
150 iCanceled = EFalse; |
|
151 |
|
152 if ( !IsActive() ) |
|
153 { |
|
154 // Create the work thread to do refresh |
|
155 iSemaphore.Close(); |
|
156 User::LeaveIfError( iSemaphore.CreateLocal( 0 ) ); |
|
157 |
|
158 RThread workThread; |
|
159 TInt err( workThread.Create( |
|
160 KGFLMWorkThreadName, |
|
161 WorkThreadStart, |
|
162 KGFLMWorkThreadStackSize, |
|
163 NULL, |
|
164 this ) ); |
|
165 LOG_IF_ERROR1( err, "CGflmFileListModel::RefreshListL-err1=%d", err ) |
|
166 User::LeaveIfError( err ); |
|
167 workThread.SetPriority( EPriorityLess ); |
|
168 workThread.Logon( iStatus ); |
|
169 SetActive(); |
|
170 iRefreshMode = aRefreshMode; |
|
171 workThread.Resume(); |
|
172 workThread.Close(); |
|
173 } |
|
174 else |
|
175 { |
|
176 // Signal the work thread to do refresh |
|
177 iRefreshMode = aRefreshMode; |
|
178 iSemaphore.Signal(); |
|
179 } |
|
180 } |
|
181 |
|
182 // ----------------------------------------------------------------------------- |
|
183 // CGflmFileListModel::WorkThreadStart() |
|
184 // An entry point function for the work thread |
|
185 // (other items were commented in a header). |
|
186 // ----------------------------------------------------------------------------- |
|
187 // |
|
188 TInt CGflmFileListModel::WorkThreadStart( TAny* aPtr ) |
|
189 { |
|
190 FUNC_LOG |
|
191 |
|
192 CGflmFileListModel* self = static_cast< CGflmFileListModel* >( aPtr ); |
|
193 CTrapCleanup* cleanupStack = CTrapCleanup::New(); |
|
194 if ( !cleanupStack ) |
|
195 { |
|
196 ERROR_LOG1( |
|
197 "CGflmFileListModel::WorkThreadStart-err1=%d", KErrNoMemory ) |
|
198 return KErrNoMemory; |
|
199 } |
|
200 |
|
201 TRAPD( err, self->iItemLocalizer->SetupWorkThreadLocalizerL() ); |
|
202 LOG_IF_ERROR1( err, "CGflmFileListModel::WorkThreadStart-err2=%d", err ) |
|
203 |
|
204 self->WorkThread(); |
|
205 self->iItemLocalizer->ReleaseWorkThreadLocalizer(); |
|
206 delete cleanupStack; |
|
207 |
|
208 return err; |
|
209 } |
|
210 |
|
211 // ----------------------------------------------------------------------------- |
|
212 // CGflmFileListModel::WorkThread() |
|
213 // ----------------------------------------------------------------------------- |
|
214 // |
|
215 void CGflmFileListModel::WorkThread() |
|
216 { |
|
217 TInt err( KErrNone ); |
|
218 do |
|
219 { |
|
220 |
|
221 // Do refresh |
|
222 iCorrupt = ETrue; |
|
223 err = KErrNone; |
|
224 |
|
225 TRAP( err, DoRefreshL() ); |
|
226 if ( err == KErrNone ) |
|
227 { |
|
228 iCorrupt = EFalse; |
|
229 } |
|
230 |
|
231 LOG_IF_ERROR1( err, "CGflmFileListModel::WorkThread-err=%d", err ) |
|
232 |
|
233 NotifyClient( err ); |
|
234 |
|
235 iSemaphore.Wait(); // Wait for refresh signal from main thread |
|
236 |
|
237 } while ( !iShutdown ); |
|
238 |
|
239 if ( iShutdown ) |
|
240 { |
|
241 // Disable list usage and ensure client completion |
|
242 iCorrupt = ETrue; |
|
243 NotifyClient( err ); |
|
244 } |
|
245 } |
|
246 |
|
247 // ----------------------------------------------------------------------------- |
|
248 // CGflmFileListModel::NotifyClient() |
|
249 // ----------------------------------------------------------------------------- |
|
250 // |
|
251 void CGflmFileListModel::NotifyClient( TInt aErr ) |
|
252 { |
|
253 FUNC_LOG |
|
254 |
|
255 if ( iClientStatus ) |
|
256 { |
|
257 RThread client; |
|
258 if ( client.Open( iClientId ) == KErrNone ) |
|
259 { |
|
260 client.RequestComplete( iClientStatus, aErr ); |
|
261 client.Close(); |
|
262 } |
|
263 } |
|
264 } |
|
265 |
|
266 // ----------------------------------------------------------------------------- |
|
267 // CGflmFileListModel::DoRefreshL() |
|
268 // This method does the actual refreshing. It's not static so it can access |
|
269 // member data and it can leave as it's trap harnessed in RefreshAndNotify() |
|
270 // (other items were commented in a header). |
|
271 // ----------------------------------------------------------------------------- |
|
272 // |
|
273 void CGflmFileListModel::DoRefreshL() |
|
274 { |
|
275 TIMESTAMP( "GFLM refresh files and folders started: " ) |
|
276 |
|
277 INFO_LOG1( |
|
278 "CGflmFileListModel::DoRefreshL-iSearchEnabled=%d", |
|
279 iSearchEnabled ) |
|
280 |
|
281 if ( iSearchEnabled ) |
|
282 { |
|
283 User::LeaveIfError( iDriveResolver->RefreshDrives( iFilter ) ); |
|
284 iFileFinder->RefreshL( iFilter, iSearchSortMethod, iRefreshMode ); |
|
285 } |
|
286 else |
|
287 { |
|
288 if ( iRefreshMode == ERefreshItems ) |
|
289 { |
|
290 iListingCache->ClearCache(); |
|
291 } |
|
292 User::LeaveIfError( iDriveResolver->RefreshDrives( iFilter ) ); |
|
293 |
|
294 TInt groupCount( iGroups->Count() ); |
|
295 for ( TInt i( 0 ); i < groupCount; i++ ) |
|
296 { |
|
297 iGroups->At( i )->RefreshL( iFilter, iSortMethod, iRefreshMode ); |
|
298 } |
|
299 } |
|
300 |
|
301 TIMESTAMP( "GFLM refresh files and folders ended: " ) |
|
302 } |
|
303 |
|
304 // ----------------------------------------------------------------------------- |
|
305 // CGflmFileListModel::CancelRefresh() |
|
306 // (other items were commented in a header). |
|
307 // ----------------------------------------------------------------------------- |
|
308 // |
|
309 EXPORT_C void CGflmFileListModel::CancelRefresh() |
|
310 { |
|
311 FUNC_LOG |
|
312 |
|
313 iCanceled = ETrue; |
|
314 } |
|
315 |
|
316 // ----------------------------------------------------------------------------- |
|
317 // CGflmFileListModel::MdcaCount() |
|
318 // (other items were commented in a header). |
|
319 // ----------------------------------------------------------------------------- |
|
320 // |
|
321 TInt CGflmFileListModel::MdcaCount() const |
|
322 { |
|
323 if ( iCorrupt ) |
|
324 { |
|
325 return 0; |
|
326 } |
|
327 if ( iSearchEnabled ) |
|
328 { |
|
329 return iFileFinder->ItemCount(); |
|
330 } |
|
331 |
|
332 // Count the total number of items in groups |
|
333 TInt groupCount( iGroups->Count() ); |
|
334 TInt itemCount( 0 ); |
|
335 for( TInt i( 0 ); i < groupCount; i++ ) |
|
336 { |
|
337 itemCount += iGroups->At( i )->ItemCount(); |
|
338 } |
|
339 return itemCount; |
|
340 } |
|
341 |
|
342 // ----------------------------------------------------------------------------- |
|
343 // CGflmFileListModel::MdcaPoint() |
|
344 // (other items were commented in a header). |
|
345 // ----------------------------------------------------------------------------- |
|
346 // |
|
347 TPtrC CGflmFileListModel::MdcaPoint( TInt aIndex ) const |
|
348 { |
|
349 if ( iSearchEnabled ) |
|
350 { |
|
351 return iFileFinder->Item( aIndex )->Name(); |
|
352 } |
|
353 |
|
354 // Return the formatted presentation by global index |
|
355 MGflmItemGroup* group = NULL; |
|
356 TInt localIndex( 0 ); |
|
357 GetGroupAndLocalIndex( aIndex, localIndex, group ); |
|
358 return group->Item( localIndex )->Name(); |
|
359 } |
|
360 |
|
361 // ----------------------------------------------------------------------------- |
|
362 // CGflmFileListModel::GetGroupAndLocalIndex() |
|
363 // (other items were commented in a header). |
|
364 // ----------------------------------------------------------------------------- |
|
365 // |
|
366 void CGflmFileListModel::GetGroupAndLocalIndex( |
|
367 const TInt aGlobalIndex, |
|
368 TInt& aLocalIndex, |
|
369 MGflmItemGroup*& aGroup ) const |
|
370 { |
|
371 // Calculate the group and the requested item's local index |
|
372 // from a global index |
|
373 TInt groupCount( iGroups->Count() ); |
|
374 TInt offset( 0 ); |
|
375 for( TInt i( 0 ); i < groupCount; i++ ) |
|
376 { |
|
377 MGflmItemGroup* currentGroup = iGroups->At( i ); |
|
378 TInt itemsInGroup( currentGroup->ItemCount() ); |
|
379 if ( aGlobalIndex < itemsInGroup + offset ) |
|
380 { |
|
381 // The global index resides in this group |
|
382 aGroup = iGroups->At( i ); |
|
383 aLocalIndex = aGlobalIndex - offset; |
|
384 return; |
|
385 } |
|
386 offset += itemsInGroup; |
|
387 } |
|
388 |
|
389 // Group not found |
|
390 User::Panic( KGFLMPanicText, EGlobalIndexOutOfBounds ); |
|
391 } |
|
392 |
|
393 // ----------------------------------------------------------------------------- |
|
394 // CGflmFileListModel::Item() |
|
395 // (other items were commented in a header). |
|
396 // ----------------------------------------------------------------------------- |
|
397 // |
|
398 EXPORT_C CGflmGroupItem* CGflmFileListModel::Item( TInt aIndex ) const |
|
399 { |
|
400 if ( iSearchEnabled ) |
|
401 { |
|
402 return iFileFinder->Item( aIndex ); |
|
403 } |
|
404 // Return the formatted presentation by global index |
|
405 MGflmItemGroup* group = NULL; |
|
406 TInt localIndex( 0 ); |
|
407 GetGroupAndLocalIndex( aIndex, localIndex, group ); |
|
408 return group->Item( localIndex ); |
|
409 } |
|
410 |
|
411 // ----------------------------------------------------------------------------- |
|
412 // CGflmFileListModel::ResetModel() |
|
413 // (other items were commented in a header). |
|
414 // ----------------------------------------------------------------------------- |
|
415 // |
|
416 EXPORT_C void CGflmFileListModel::ResetModel() |
|
417 { |
|
418 iGroups->ResetAndDestroy(); |
|
419 iListingCache->ClearCache(); |
|
420 iDriveResolver->ClearDrives(); |
|
421 } |
|
422 |
|
423 // ----------------------------------------------------------------------------- |
|
424 // CGflmFileListModel::FindGroupById() |
|
425 // Used to provide clients with CGflmItemGroupImpl objects downcasted to |
|
426 // CGflmItemGroup. |
|
427 // (other items were commented in a header). |
|
428 // ----------------------------------------------------------------------------- |
|
429 // |
|
430 EXPORT_C MGflmItemGroup* CGflmFileListModel::FindGroupById( TInt aId ) |
|
431 { |
|
432 TInt groupCount( iGroups->Count() ); |
|
433 |
|
434 for( TInt i( 0 ); i < groupCount; i++ ) |
|
435 { |
|
436 CGflmItemGroupImpl* group = iGroups->At( i ); |
|
437 if ( aId == group->Id() ) |
|
438 { |
|
439 return group; |
|
440 } |
|
441 } |
|
442 |
|
443 // Group not found |
|
444 User::Panic( KGFLMPanicText, EInvalidGroupId ); |
|
445 |
|
446 // Execution never reaches this point |
|
447 // following line keeps the compiler happy |
|
448 return NULL; |
|
449 } |
|
450 |
|
451 // ----------------------------------------------------------------------------- |
|
452 // CGflmFileListModel::CreateGroupL() |
|
453 // (other items were commented in a header). |
|
454 // ----------------------------------------------------------------------------- |
|
455 EXPORT_C MGflmItemGroup* CGflmFileListModel::CreateGroupL( TInt aId ) |
|
456 { |
|
457 // Scan the list of groups for identical IDs |
|
458 TInt groupCount( iGroups->Count() ); |
|
459 for ( TInt i( 0 ); i < groupCount; i++ ) |
|
460 { |
|
461 if ( iGroups->At( i )->Id() == aId ) |
|
462 { |
|
463 User::Leave( KErrAlreadyExists ); |
|
464 } |
|
465 } |
|
466 |
|
467 CGflmItemGroupImpl* newGroup = CGflmItemGroupImpl::NewLC( |
|
468 aId, |
|
469 iFs, |
|
470 *iListingCache, |
|
471 *iItemLocalizer, |
|
472 *iDriveResolver ); |
|
473 |
|
474 iGroups->AppendL( newGroup ); |
|
475 CleanupStack::Pop( newGroup ); |
|
476 return newGroup; |
|
477 } |
|
478 |
|
479 // ----------------------------------------------------------------------------- |
|
480 // CGflmFileListModel::CreateGroupL() |
|
481 // (other items were commented in a header). |
|
482 // ----------------------------------------------------------------------------- |
|
483 EXPORT_C MGflmItemGroup* CGflmFileListModel::CreateGroupL( |
|
484 TInt aId, TUint aInclusion ) |
|
485 { |
|
486 MGflmItemGroup* newGroup = CreateGroupL( aId ); |
|
487 newGroup->SetInclusion( aInclusion ); |
|
488 return newGroup; |
|
489 } |
|
490 |
|
491 // ----------------------------------------------------------------------------- |
|
492 // CGflmFileListModel::SetCustomFilter() |
|
493 // (other items were commented in a header). |
|
494 // ----------------------------------------------------------------------------- |
|
495 EXPORT_C void CGflmFileListModel::SetCustomFilter( MGflmItemFilter* aFilter ) |
|
496 { |
|
497 iFilter = aFilter; |
|
498 } |
|
499 |
|
500 // ----------------------------------------------------------------------------- |
|
501 // CGflmFileListModel::ResolveMimeTypeL() |
|
502 // Uses the internal file recognition cache |
|
503 // (other items were commented in a header). |
|
504 // ----------------------------------------------------------------------------- |
|
505 EXPORT_C TPtrC CGflmFileListModel::ResolveMimeTypeL( const TDesC& aFilename ) |
|
506 { |
|
507 return iFileRecognizer->RecognizeL( aFilename ); |
|
508 } |
|
509 |
|
510 // ----------------------------------------------------------------------------- |
|
511 // CGflmFileListModel::IsCorrupt() |
|
512 // (other items were commented in a header). |
|
513 // ----------------------------------------------------------------------------- |
|
514 EXPORT_C TBool CGflmFileListModel::IsCorrupt() const |
|
515 { |
|
516 return iCorrupt; |
|
517 } |
|
518 |
|
519 // ----------------------------------------------------------------------------- |
|
520 // CGflmFileListModel::LocalizedName() |
|
521 // ----------------------------------------------------------------------------- |
|
522 // |
|
523 EXPORT_C TPtrC CGflmFileListModel::LocalizedName( const TDesC& aPath ) const |
|
524 { |
|
525 return iItemLocalizer->Localize( aPath ); |
|
526 } |
|
527 |
|
528 // ----------------------------------------------------------------------------- |
|
529 // CGflmFileListModel::ClearCache() |
|
530 // ----------------------------------------------------------------------------- |
|
531 // |
|
532 EXPORT_C void CGflmFileListModel::ClearCache() |
|
533 { |
|
534 iListingCache->ClearCache(); |
|
535 } |
|
536 |
|
537 // ----------------------------------------------------------------------------- |
|
538 // CGflmFileListModel::ClearDriveInfo() |
|
539 // ----------------------------------------------------------------------------- |
|
540 // |
|
541 EXPORT_C void CGflmFileListModel::ClearDriveInfo() |
|
542 { |
|
543 iDriveResolver->ClearDrives(); |
|
544 } |
|
545 |
|
546 // ----------------------------------------------------------------------------- |
|
547 // CGflmFileListModel::DriveFromPath() |
|
548 // ----------------------------------------------------------------------------- |
|
549 // |
|
550 EXPORT_C CGflmDriveItem* CGflmFileListModel::DriveFromPath( |
|
551 const TDesC& aPath ) const |
|
552 { |
|
553 if ( !iDriveResolver->DriveCount() ) |
|
554 { |
|
555 ERROR_LOG( "CGflmFileListModel::DriveFromPath-Forced drive refresh" ) |
|
556 iDriveResolver->RefreshDrives( iFilter ); |
|
557 } |
|
558 return iDriveResolver->DriveFromPath( aPath ); |
|
559 } |
|
560 |
|
561 // ----------------------------------------------------------------------------- |
|
562 // CGflmFileListModel::RunL() |
|
563 // ----------------------------------------------------------------------------- |
|
564 // |
|
565 void CGflmFileListModel::RunL() |
|
566 { |
|
567 FUNC_LOG |
|
568 |
|
569 NotifyClient( iStatus.Int() ); |
|
570 } |
|
571 |
|
572 // ----------------------------------------------------------------------------- |
|
573 // CGflmFileListModel::RunError |
|
574 // ----------------------------------------------------------------------------- |
|
575 // |
|
576 TInt CGflmFileListModel::RunError( TInt /*aError*/ ) |
|
577 { |
|
578 return KErrNone; |
|
579 } |
|
580 |
|
581 // ----------------------------------------------------------------------------- |
|
582 // CGflmFileListModel::DoCancel |
|
583 // ----------------------------------------------------------------------------- |
|
584 // |
|
585 void CGflmFileListModel::DoCancel() |
|
586 { |
|
587 FUNC_LOG |
|
588 |
|
589 iShutdown = ETrue; |
|
590 iSemaphore.Signal(); |
|
591 } |
|
592 |
|
593 // ----------------------------------------------------------------------------- |
|
594 // CGflmFileListModel::DriveFromId |
|
595 // ----------------------------------------------------------------------------- |
|
596 // |
|
597 EXPORT_C CGflmDriveItem* CGflmFileListModel::DriveFromId( |
|
598 const TInt aDrive ) const |
|
599 { |
|
600 if ( !iDriveResolver->DriveCount() ) |
|
601 { |
|
602 ERROR_LOG( "CGflmFileListModel::DriveFromId-Forced drive refresh" ) |
|
603 iDriveResolver->RefreshDrives( iFilter ); |
|
604 } |
|
605 return iDriveResolver->DriveFromId( aDrive ); |
|
606 } |
|
607 |
|
608 // ----------------------------------------------------------------------------- |
|
609 // CGflmFileListModel::EnableSearchMode |
|
610 // ----------------------------------------------------------------------------- |
|
611 // |
|
612 EXPORT_C void CGflmFileListModel::EnableSearchMode( const TBool aEnabled ) |
|
613 { |
|
614 iSearchEnabled = aEnabled; |
|
615 if ( iSearchEnabled ) |
|
616 { |
|
617 iSearchSortMethod = EByMatch; // Default for search |
|
618 } |
|
619 } |
|
620 |
|
621 // ----------------------------------------------------------------------------- |
|
622 // CGflmFileListModel::SearchMode |
|
623 // ----------------------------------------------------------------------------- |
|
624 // |
|
625 EXPORT_C TBool CGflmFileListModel::SearchMode() |
|
626 { |
|
627 return iSearchEnabled; |
|
628 } |
|
629 |
|
630 // ----------------------------------------------------------------------------- |
|
631 // CGflmFileListModel::SetSearchStringL |
|
632 // ----------------------------------------------------------------------------- |
|
633 // |
|
634 EXPORT_C void CGflmFileListModel::SetSearchStringL( const TDesC& aSearchString ) |
|
635 { |
|
636 iFileFinder->SetSearchStringL( aSearchString ); |
|
637 } |
|
638 |
|
639 // ----------------------------------------------------------------------------- |
|
640 // CGflmFileListModel::SetSearchFolderL |
|
641 // ----------------------------------------------------------------------------- |
|
642 // |
|
643 EXPORT_C void CGflmFileListModel::SetSearchFolderL( const TDesC& aSearchFolder ) |
|
644 { |
|
645 iFileFinder->SetSearchFolderL( aSearchFolder ); |
|
646 } |
|
647 |
|
648 // ----------------------------------------------------------------------------- |
|
649 // CGflmFileListModel::SetSortMethod |
|
650 // ----------------------------------------------------------------------------- |
|
651 // |
|
652 EXPORT_C void CGflmFileListModel::SetSortMethod( TGflmSortMethod aSortMethod ) |
|
653 { |
|
654 if ( iSearchEnabled ) |
|
655 { |
|
656 iSearchSortMethod = aSortMethod; |
|
657 } |
|
658 else if ( aSortMethod != EByMatch ) // EByMatch is allowed only for search |
|
659 { |
|
660 iSortMethod = aSortMethod; |
|
661 } |
|
662 } |
|
663 |
|
664 // ----------------------------------------------------------------------------- |
|
665 // CGflmFileListModel::SortMethod |
|
666 // ----------------------------------------------------------------------------- |
|
667 // |
|
668 EXPORT_C TGflmSortMethod CGflmFileListModel::SortMethod() const |
|
669 { |
|
670 if ( iSearchEnabled ) |
|
671 { |
|
672 return iSearchSortMethod; |
|
673 } |
|
674 return iSortMethod; |
|
675 } |
|
676 |
|
677 // ----------------------------------------------------------------------------- |
|
678 // CGflmFileListModel::FlushCache() |
|
679 // ----------------------------------------------------------------------------- |
|
680 // |
|
681 EXPORT_C void CGflmFileListModel::FlushCache() |
|
682 { |
|
683 iFileRecognizer->FlushCache(); |
|
684 } |
|
685 |
|
686 // End of File |
|