29 |
29 |
30 #include "MAknFileSelectionObserver.h" |
30 #include "MAknFileSelectionObserver.h" |
31 #include "MAknFileFilter.h" |
31 #include "MAknFileFilter.h" |
32 #include "AknCFDUtility.h" |
32 #include "AknCFDUtility.h" |
33 #include "CAknDataCagingFilter.h" |
33 #include "CAknDataCagingFilter.h" |
34 |
34 #include "commondialogsdata.hrh" |
35 // CONSTANTS |
35 // CONSTANTS |
|
36 _LIT( KImageHeader, "%d\t" ); |
|
37 const TInt KFileExtNameSize = 10; |
36 const TInt KEntryArrayGranularity( 10 ); |
38 const TInt KEntryArrayGranularity( 10 ); |
37 const TInt KFilterArrayGranularity( 2 ); |
39 const TInt KFilterArrayGranularity( 2 ); |
38 |
40 const TInt KIndexDataLen = 6; |
39 _LIT( KCFDMimeTypeImage, "image/*" ); |
41 |
40 _LIT( KCFDMimeTypeImageGms, "image/x-ota-bitmap" ); |
42 // Store file ext name and right icon index |
41 _LIT( KCFDMimeTypeRam, "audio/x-pn-realaudio-plugin" ); // = link |
43 class TCFDFileTypes |
42 _LIT( KCFDMimeTypeAudioVoiceRec, "audio/amr*" ); |
44 { |
43 _LIT( KCFDMimeTypeAudioVoiceRec2, "application/vnd.nokia.ringing-tone" ); |
45 public: |
44 _LIT( KCFDMimeTypeAudio, "audio/*" ); // = other sound files |
46 TBuf<KFileExtNameSize> iFileType; |
45 _LIT( KCFDMimeTypePlaylist, "audio/*mpegurl*" ); |
47 TInt iIconIndex; |
46 _LIT( KCFDMimeTypeVideo, "video/*" ); |
48 }; |
47 _LIT( KCFDMimeTypeVideoRealMedia, "application/*n-realmedia" ); |
|
48 _LIT( KCFDMimeTypeVideoSdp, "application/sdp" ); |
|
49 _LIT( KCFDMimeTypeGame, "application/*game*" ); |
|
50 _LIT( KCFDMimeTypeNote, "text/*" ); |
|
51 _LIT( KCFDMimeTypeJava, "application/java-archive" ); |
|
52 _LIT( KCFDMimeTypeFlash, "application/x-shockwave-flash" ); |
|
53 |
|
54 _LIT( KCFDMimeTypeJad, "text/vnd.sun.j2me.app-descriptor" ); |
|
55 _LIT( KCFDMimeTypePdf, "application/pdf" ); |
|
56 _LIT( KCFDMimeTypeZip, "application/*zip*"); |
|
57 _LIT( KCFDMimeTypeDoc, "application/vnd.ms-word"); |
|
58 _LIT( KCFDMimeTypePpt, "application/vnd.ms-powerpoint"); |
|
59 _LIT( KCFDMimeTypeXls, "application/vnd.ms-excel"); |
|
60 |
|
61 _LIT( KCFDFileExtSis, ".sis" ); |
|
62 _LIT( KCFDFileExtSisx, ".sisx"); |
|
63 _LIT( KCFDFileExtMid, ".mid" ); |
|
64 |
49 |
65 // ============================ MEMBER FUNCTIONS =============================== |
50 // ============================ MEMBER FUNCTIONS =============================== |
66 |
51 |
67 // ----------------------------------------------------------------------------- |
52 // ----------------------------------------------------------------------------- |
68 // CAknFileSelectionModel::CAknFileSelectionModel |
53 // CAknFileSelectionModel::CAknFileSelectionModel |
84 // |
68 // |
85 // ----------------------------------------------------------------------------- |
69 // ----------------------------------------------------------------------------- |
86 // |
70 // |
87 void CAknFileSelectionModel::ConstructL() |
71 void CAknFileSelectionModel::ConstructL() |
88 { |
72 { |
89 User::LeaveIfError( iApaSession.Connect() ); |
|
90 iLocalizer = CDirectoryLocalizer::NewL(); |
73 iLocalizer = CDirectoryLocalizer::NewL(); |
91 iEntryArray = new( ELeave ) CArrayPakFlat<TEntry>( KEntryArrayGranularity ); |
74 iEntryArray = new( ELeave ) CArrayPakFlat<TEntry>( KEntryArrayGranularity ); |
92 iFilterArray = new( ELeave ) CArrayPtrSeg<MAknFileFilter>( KFilterArrayGranularity ); |
75 iFilterArray = new( ELeave ) CArrayPtrSeg<MAknFileFilter>( KFilterArrayGranularity ); |
93 iItemWithImageIndex = HBufC::NewL(KMaxPath); |
76 iFileTypeArray = new ( ELeave ) CArrayFixFlat<TCFDFileTypes>( KEntryArrayGranularity ); |
|
77 |
|
78 // Directories should be shown in front of files in list, |
|
79 // create two arrays to save it respectively |
|
80 iLocalFileNameArray = new ( ELeave ) CDesC16ArraySeg( KEntryArrayGranularity ); |
|
81 iLocalDirNameArray = new ( ELeave ) CDesC16ArraySeg( KEntryArrayGranularity ); |
|
82 |
|
83 TResourceReader reader; |
|
84 iCoeEnv.CreateResourceReaderLC( reader, R_CDF_FILE_TYPE_ICON_SET ); |
|
85 ReadFileExtNameAndIconIndexL( reader ); |
|
86 CleanupStack::PopAndDestroy();//reader |
|
87 |
|
88 iStringBuf = HBufC::NewL(KMaxPath); |
|
89 |
94 User::LeaveIfError( iFs.Connect() ); |
90 User::LeaveIfError( iFs.Connect() ); |
95 iRootFolderText = iCoeEnv.AllocReadResourceL( R_CFD_QTN_FLDR_ROOT_LEVEL ); |
91 iRootFolderText = iCoeEnv.AllocReadResourceL( R_CFD_QTN_FLDR_ROOT_LEVEL ); |
96 |
|
97 AddFilterL( CAknDataCagingFilter::NewLC() ); |
92 AddFilterL( CAknDataCagingFilter::NewLC() ); |
98 CleanupStack::Pop(); //caging filter |
93 CleanupStack::Pop(); //caging filter |
99 } |
94 } |
100 |
95 |
|
96 // ----------------------------------------------------------------------------- |
|
97 // CAknFileSelectionModel::ReadFileExtNameAndIconIndexL |
|
98 // |
|
99 // ----------------------------------------------------------------------------- |
|
100 // |
|
101 void CAknFileSelectionModel::ReadFileExtNameAndIconIndexL( TResourceReader& aReader ) |
|
102 { |
|
103 // File icon will be selected by file extname. |
|
104 TInt count( aReader.ReadInt16() ); |
|
105 for ( TInt i = 0; i < count; i++ ) |
|
106 { |
|
107 TCFDFileTypes type; |
|
108 type.iFileType.Copy( aReader.ReadTPtrC() ); |
|
109 type.iIconIndex = aReader.ReadInt32(); |
|
110 iFileTypeArray->AppendL( type ); |
|
111 } |
|
112 } |
101 // ----------------------------------------------------------------------------- |
113 // ----------------------------------------------------------------------------- |
102 // CAknFileSelectionModel::NewL |
114 // CAknFileSelectionModel::NewL |
103 // |
115 // |
104 // ----------------------------------------------------------------------------- |
116 // ----------------------------------------------------------------------------- |
105 // |
117 // |
275 // CAknFileSelectionModel::UpdateItemListL |
293 // CAknFileSelectionModel::UpdateItemListL |
276 // ----------------------------------------------------------------------------- |
294 // ----------------------------------------------------------------------------- |
277 // |
295 // |
278 TInt CAknFileSelectionModel::UpdateItemListL() |
296 TInt CAknFileSelectionModel::UpdateItemListL() |
279 { |
297 { |
|
298 // Clear array contents |
280 iEntryArray->Reset(); |
299 iEntryArray->Reset(); |
281 iImageIndexArray.Reset(); |
300 iLocalDirNameArray->Reset(); |
282 |
301 iLocalFileNameArray->Reset(); |
|
302 |
283 CDir* entryArray = ReadDirectory( iCurrentPath.DriveAndPath() ); |
303 CDir* entryArray = ReadDirectory( iCurrentPath.DriveAndPath() ); |
284 if ( !entryArray ) |
304 if ( !entryArray ) |
285 { |
305 { |
286 return KErrNotFound; |
306 return KErrNotFound; |
287 } |
307 } |
288 CleanupStack::PushL( entryArray ); |
308 CleanupStack::PushL( entryArray ); |
289 |
309 |
290 TInt itemCount( entryArray->Count() ); |
310 TInt itemCount( entryArray->Count() ); |
291 if ( itemCount > 0 ) |
311 // entry index in iEntryArray |
292 { |
312 TInt entryIndex = 0; |
293 TInt filterCount( iFilterArray->Count() ); |
313 for ( TInt i( 0 ); i < itemCount; i++ ) // Add entry or not |
294 TInt filterIndex; |
314 { |
295 TBool accepted; |
315 const TEntry& entry = ( *entryArray )[i]; |
296 CDesC16Array* desC16FoldersArray = new ( ELeave ) |
316 if ( EntryIsAccepted( entry ) ) |
297 CDesC16ArrayFlat( KEntryArrayGranularity ); |
317 { |
298 CleanupStack::PushL( desC16FoldersArray ); |
318 // Add entry |
299 CDesC16Array* desC16FilesArray = new ( ELeave ) |
319 if ( entry.IsDir() ) |
300 CDesC16ArrayFlat( KEntryArrayGranularity ); |
|
301 CleanupStack::PushL( desC16FilesArray ); |
|
302 CArrayPakFlat<TEntry>* tmpFoldersArray = new( ELeave ) |
|
303 CArrayPakFlat<TEntry>( KEntryArrayGranularity ); |
|
304 CleanupStack::PushL( tmpFoldersArray ); |
|
305 CArrayPakFlat<TEntry>* tmpFilesArray = new( ELeave ) |
|
306 CArrayPakFlat<TEntry>( KEntryArrayGranularity ); |
|
307 CleanupStack::PushL( tmpFilesArray ); |
|
308 |
|
309 tmpFoldersArray->Reset(); |
|
310 desC16FoldersArray->Reset(); |
|
311 tmpFilesArray->Reset(); |
|
312 desC16FilesArray->Reset(); |
|
313 |
|
314 for ( TInt i( 0 ); i < itemCount; i++ ) // Generate filtered list |
|
315 { |
|
316 accepted = ETrue; // If there are no filters, accept the entry |
|
317 TEntry entry = ( *entryArray )[i]; |
|
318 filterIndex = 0; |
|
319 // Go thru the filters while the entry is accepted |
|
320 while( ( filterIndex < filterCount ) && ( accepted ) ) |
|
321 { |
320 { |
322 accepted = iFilterArray->At( filterIndex )->Accept( |
321 // Entry is a directory |
323 iCurrentPath.DriveAndPath(), entry ); |
322 TFileTypeIcon folderIcon( EFolderIcon ); |
324 filterIndex++; |
323 |
|
324 if( !AknCFDUtility::IsRemoteDrive( iCurrentPath.Drive() ) ) |
|
325 { |
|
326 if ( ContainsSubfolders( entry.iName ) ) |
|
327 { |
|
328 folderIcon = ESubFolderIcon; |
|
329 } |
|
330 else if ( !ContainsFiles( entry.iName ) ) |
|
331 { |
|
332 folderIcon = EFolderEmptyIcon; |
|
333 } |
|
334 } |
|
335 // List item uses localized name and icon index to show itself, |
|
336 // common dialogs need to give user the entry's iName, list item |
|
337 // need to bind unique entry. For sorting list and binding entry, |
|
338 // save icon index, localized name and right entry index of iEntryArray |
|
339 // in the element of iLocalDirNameArray and iLocalFileNameArray |
|
340 TFileName name( GetLocalizedName( entry.iName ) ); |
|
341 // Append icon index number at the end of entry's localized name |
|
342 name.AppendNumFixedWidth( folderIcon, EDecimal, KIndexDataLen ); |
|
343 // Append entry index number of iEntryArray in the end |
|
344 name.AppendNumFixedWidth( entryIndex, EDecimal, KIndexDataLen ); |
|
345 iLocalDirNameArray->AppendL( name ); |
325 } |
346 } |
326 if ( accepted ) // Directory entry has passed all filters |
347 else |
327 { |
348 { |
328 // Add filename to filtered list |
349 TInt icon(EUnknowTypeIcon); |
329 if ( entry.IsDir() ) |
350 icon = GetIconForFileL( entry.iName ); |
330 { |
351 TFileName name( GetLocalizedName( entry.iName ) ); |
331 desC16FoldersArray->AppendL( GetLocalizedName( entry.iName ) ); |
352 name.AppendNumFixedWidth( icon, EDecimal, KIndexDataLen ); |
332 tmpFoldersArray->AppendL( entry, sizeof( TEntry ) ); |
353 name.AppendNumFixedWidth( entryIndex, EDecimal, KIndexDataLen ); |
333 } |
354 iLocalFileNameArray->AppendL( name ); |
334 else |
|
335 { |
|
336 desC16FilesArray->AppendL( GetLocalizedName( entry.iName ) ); |
|
337 tmpFilesArray->AppendL( entry, sizeof( TEntry ) ); |
|
338 } |
|
339 } |
355 } |
340 } |
356 entryIndex++; |
341 |
357 iEntryArray->AppendL( entry, sizeof( TEntry ) ); |
342 TInt entryCount = 0; |
358 } |
343 TInt index; |
359 } |
344 TKeyArrayPak key( _FOFF( TEntry, iName ), ECmpCollated ); |
360 |
345 |
361 CleanupStack::PopAndDestroy( entryArray ); |
346 // Add folder entries |
362 // Sort list item to show |
347 desC16FoldersArray->Sort( ECmpCollated ); |
363 iLocalDirNameArray->Sort( ECmpCollated ); |
348 entryCount = desC16FoldersArray->MdcaCount(); |
364 iLocalFileNameArray->Sort( ECmpCollated ); |
349 for( TInt j( 0 ); j < entryCount; j++ ) |
365 if ( AknCFDUtility::DirectoriesOnly( iDialogType ) ) |
350 { |
366 { |
351 for( TInt k( 0 ); k < entryCount; k++ ) |
367 // Set the current folder name as first item. |
|
368 TPtr folder = iStringBuf->Des(); |
|
369 folder = iCurrentPath.DriveAndPath(); |
|
370 AknCFDUtility::RemoveTrailingBackslash( folder ); // ignore error |
|
371 TParsePtr parsedFolder(folder); |
|
372 folder = parsedFolder.NameAndExt(); |
|
373 TFileName name(folder); |
|
374 TEntry folderEntry; |
|
375 folderEntry.iName = name; |
|
376 if ( iDirectoryLevel == 0 ) |
|
377 { |
|
378 name = iRootFolderText->Des(); |
|
379 } |
|
380 else |
|
381 { |
|
382 folder = iCurrentPath.DriveAndPath(); |
|
383 iLocalizer->SetFullPath( folder ); |
|
384 if( iLocalizer->IsLocalized() ) |
352 { |
385 { |
353 if( ( *desC16FoldersArray )[j] == |
386 name = iLocalizer->LocalizedName(); |
354 GetLocalizedName( ( *tmpFoldersArray )[k].iName ) && |
|
355 iEntryArray->Find( ( *tmpFoldersArray )[k], key, index ) != 0 ) |
|
356 { |
|
357 TEntry tmpEntry = ( *tmpFoldersArray )[k]; |
|
358 |
|
359 iEntryArray->AppendL( tmpEntry, sizeof( TEntry ) ); |
|
360 |
|
361 // Entry is a directory |
|
362 TFileTypeIcon folderIcon( EFolderIcon ); |
|
363 |
|
364 if( !AknCFDUtility::IsRemoteDrive( iCurrentPath.Drive() ) ) |
|
365 { |
|
366 if ( ContainsSubfolders( tmpEntry.iName ) ) |
|
367 { |
|
368 folderIcon = ESubFolderIcon; |
|
369 } |
|
370 else if ( !ContainsFiles( tmpEntry.iName ) ) |
|
371 { |
|
372 folderIcon = EFolderEmptyIcon; |
|
373 } |
|
374 } |
|
375 iImageIndexArray.Append( folderIcon ); |
|
376 |
|
377 break; |
|
378 } |
|
379 } |
387 } |
380 } |
388 } |
381 |
389 name.AppendNumFixedWidth( EThisFolderIcon, EDecimal, KIndexDataLen ); |
382 // Add file entries |
390 name.AppendNumFixedWidth( entryIndex, EDecimal, KIndexDataLen ); |
383 desC16FilesArray->Sort( ECmpCollated ); |
391 iLocalDirNameArray->InsertL( 0, name ); |
384 entryCount = desC16FilesArray->MdcaCount(); |
392 iEntryArray->AppendL( folderEntry, sizeof(TEntry) ); |
385 for( TInt j( 0 ); j < entryCount; j++ ) |
393 } |
386 { |
|
387 for( TInt k( 0 ); k < entryCount; k++ ) |
|
388 { |
|
389 if( ( *desC16FilesArray )[j] == |
|
390 GetLocalizedName( ( *tmpFilesArray )[k].iName ) && |
|
391 iEntryArray->Find( ( *tmpFilesArray )[k], key, index ) != 0 ) |
|
392 { |
|
393 TEntry tmpFile = ( *tmpFilesArray )[k]; |
|
394 |
|
395 iEntryArray->AppendL( tmpFile, sizeof( TEntry ) ); |
|
396 |
|
397 // Entry is a file |
|
398 AppendIconForFileL( tmpFile.iName ); |
|
399 |
|
400 break; |
|
401 } |
|
402 } |
|
403 } |
|
404 |
|
405 CleanupStack::PopAndDestroy( tmpFilesArray ); |
|
406 CleanupStack::PopAndDestroy( tmpFoldersArray ); |
|
407 CleanupStack::Pop( desC16FilesArray ); |
|
408 desC16FilesArray->Reset(); |
|
409 delete desC16FilesArray; |
|
410 CleanupStack::Pop( desC16FoldersArray ); |
|
411 desC16FoldersArray->Reset(); |
|
412 delete desC16FoldersArray; |
|
413 } |
|
414 |
|
415 CleanupStack::PopAndDestroy( entryArray ); |
|
416 |
|
417 if ( AknCFDUtility::DirectoriesOnly( iDialogType ) ) |
|
418 { |
|
419 // Set the current folder name as first item. |
|
420 // Current folder is for example "E:\Images\Holiday\" |
|
421 // Remove trailing backslash, we get "E:\Images\Holiday" |
|
422 // Parse the path with TParse and ask for NameAndExt(). |
|
423 // TParse interpretes "Holiday" as file name and returns it. |
|
424 |
|
425 HBufC * bufFolder = HBufC::NewLC(KMaxPath); |
|
426 * bufFolder = iCurrentPath.DriveAndPath() ; |
|
427 TPtr folder = bufFolder->Des(); |
|
428 |
|
429 AknCFDUtility::RemoveTrailingBackslash( folder ); // ignore error |
|
430 |
|
431 TParsePtr parsedFolder(folder); |
|
432 |
|
433 folder = parsedFolder.NameAndExt(); |
|
434 iFolderEntry.iName = folder; |
|
435 iEntryArray->InsertL( 0, iFolderEntry, sizeof( TEntry ) ); |
|
436 iImageIndexArray.Insert( EThisFolderIcon, 0 ); |
|
437 |
|
438 CleanupStack::PopAndDestroy(); //bufFolder |
|
439 } |
|
440 |
|
441 return iEntryArray->Count(); |
394 return iEntryArray->Count(); |
442 } |
395 } |
443 |
396 |
444 // ----------------------------------------------------------------------------- |
397 // ----------------------------------------------------------------------------- |
|
398 // CAknFileSelectionModel::EntryIsAccepted |
|
399 // ----------------------------------------------------------------------------- |
|
400 // |
|
401 TBool CAknFileSelectionModel::EntryIsAccepted( const TEntry& aEntry ) const |
|
402 { |
|
403 TInt filterCount( iFilterArray->Count() ); |
|
404 // Go through the filters while the entry is accepted |
|
405 for ( TInt i = 0 ; i < filterCount ; ++i ) |
|
406 { |
|
407 if ( !( iFilterArray->At( i )->Accept( |
|
408 iCurrentPath.DriveAndPath(), aEntry ) ) ) |
|
409 { |
|
410 // Some filter does not accept this entry |
|
411 return EFalse; |
|
412 } |
|
413 } |
|
414 return ETrue; |
|
415 } |
|
416 |
|
417 // ----------------------------------------------------------------------------- |
445 // CAknFileSelectionModel::Entry |
418 // CAknFileSelectionModel::Entry |
446 // |
419 // |
447 // |
420 // |
448 // ----------------------------------------------------------------------------- |
421 // ----------------------------------------------------------------------------- |
449 // |
422 // |
450 const TEntry& CAknFileSelectionModel::Entry( const TInt& aIndex ) const |
423 const TEntry& CAknFileSelectionModel::Entry( const TInt& aIndex ) const |
451 { |
424 { |
452 return iEntryArray->At( aIndex ); |
425 TInt index = aIndex; |
|
426 // List item sequence is arranged in MdcaPoint() |
|
427 if ( aIndex < iLocalDirNameArray->Count() ) |
|
428 { |
|
429 // Get right entry index of iEntryArray |
|
430 TLex lex((*iLocalDirNameArray)[aIndex].Right(KIndexDataLen)); |
|
431 lex.Val( index ); |
|
432 } |
|
433 else |
|
434 { |
|
435 TLex lex((*iLocalFileNameArray)[aIndex - iLocalDirNameArray->Count()].Right(KIndexDataLen)); |
|
436 lex.Val( index ); |
|
437 } |
|
438 return iEntryArray->At( index ); |
453 } |
439 } |
454 |
440 |
455 // ----------------------------------------------------------------------------- |
441 // ----------------------------------------------------------------------------- |
456 // CAknFileSelectionModel::GetCurrentPath |
442 // CAknFileSelectionModel::GetCurrentPath |
457 // |
443 // |
524 // |
510 // |
525 // ----------------------------------------------------------------------------- |
511 // ----------------------------------------------------------------------------- |
526 // |
512 // |
527 TPtrC CAknFileSelectionModel::MdcaPoint( TInt aIndex ) const |
513 TPtrC CAknFileSelectionModel::MdcaPoint( TInt aIndex ) const |
528 { |
514 { |
529 TEntry entry = iEntryArray->At( aIndex ); // reference |
515 // List items sequence follows the sequence of sorted array |
530 TParsePtrC parsedEntry( entry.iName ); |
516 TPtr listItem = iStringBuf->Des(); |
531 TPtrC fileName( parsedEntry.NameAndExt() ); |
517 TInt icon(0); |
532 TInt entryType( iImageIndexArray[ aIndex ] ); |
518 if ( aIndex < iLocalDirNameArray->Count() ) |
533 |
519 { |
534 TPtr itemWithImageIndex = iItemWithImageIndex->Des(); |
520 // Directories need to arrange at ahead of files |
535 |
521 TInt len = (*iLocalDirNameArray)[aIndex].Length(); |
536 switch( entryType ) |
522 TLex lex( (*iLocalDirNameArray)[aIndex].Mid( |
537 { |
523 len - KIndexDataLen - KIndexDataLen, KIndexDataLen) ); |
538 case EThisFolderIcon: |
524 // Get icon index for the item |
539 { |
525 lex.Val( icon ); |
540 if ( iDirectoryLevel == 0 ) |
526 listItem.Format( KImageHeader, icon ); |
541 { |
527 // Append localized name as list item name |
542 // Root folder |
528 listItem.Append((*iLocalDirNameArray)[aIndex].Left( |
543 fileName.Set( iRootFolderText->Des() ); |
529 len - KIndexDataLen - KIndexDataLen ) ); |
544 } |
530 } |
545 else |
531 else |
546 { |
532 { |
547 // Not the root folder |
533 TInt len = (*iLocalFileNameArray)[aIndex - iLocalDirNameArray->Count()].Length(); |
548 iLocalizer->SetFullPath( iCurrentPath.DriveAndPath() ); |
534 TLex lex( (*iLocalFileNameArray)[aIndex - iLocalDirNameArray->Count()].Mid( |
549 if ( iLocalizer->IsLocalized() ) // Localized? |
535 len - KIndexDataLen - KIndexDataLen, KIndexDataLen) ); |
550 { |
536 lex.Val( icon ); |
551 // Folder name is localized |
537 listItem.Format( KImageHeader, icon ); |
552 fileName.Set( iLocalizer->LocalizedName() ); |
538 listItem.Append((*iLocalFileNameArray)[aIndex - iLocalDirNameArray->Count()].Left( |
553 } |
539 len - KIndexDataLen - KIndexDataLen ) ); |
554 } |
540 } |
555 break; |
541 return listItem; |
556 } |
|
557 case EFolderIcon: // fall through |
|
558 case ESubFolderIcon: |
|
559 case EFolderEmptyIcon: |
|
560 { |
|
561 itemWithImageIndex = iCurrentPath.DriveAndPath(); |
|
562 itemWithImageIndex.Append( entry.iName ); |
|
563 // ignore error: |
|
564 AknCFDUtility::AddTrailingBackslash( itemWithImageIndex ); |
|
565 iLocalizer->SetFullPath( itemWithImageIndex ); |
|
566 if( iLocalizer->IsLocalized() ) |
|
567 { |
|
568 fileName.Set( iLocalizer->LocalizedName() ); |
|
569 } |
|
570 break; |
|
571 } |
|
572 default: // EFileIcon |
|
573 { |
|
574 break; |
|
575 } |
|
576 } |
|
577 |
|
578 _LIT( KImageHeader, "%d\t" ); |
|
579 itemWithImageIndex.Format( KImageHeader, entryType ); |
|
580 itemWithImageIndex.Append( fileName ); |
|
581 |
|
582 return itemWithImageIndex; |
|
583 } |
542 } |
584 |
543 |
585 // ----------------------------------------------------------------------------- |
544 // ----------------------------------------------------------------------------- |
586 // CAknFileSelectionModel::ReadDirectory |
545 // CAknFileSelectionModel::ReadDirectory |
587 // |
546 // |
658 ret = ETrue; |
625 ret = ETrue; |
659 } |
626 } |
660 dir.Close(); |
627 dir.Close(); |
661 return ret; |
628 return ret; |
662 } |
629 } |
663 |
630 // ----------------------------------------------------------------------------- |
664 void CAknFileSelectionModel::AppendIconForFileL(const TDesC& aFileName) |
631 // CAknFileSelectionModel::AppendIconForFileL |
665 { |
632 // |
666 //TFileName absFileName( iCurrentPath.DriveAndPath() ); |
633 // ----------------------------------------------------------------------------- |
667 HBufC *bufAbsFileName = HBufC::NewLC(KMaxPath); |
634 // |
668 *bufAbsFileName = iCurrentPath.DriveAndPath(); |
635 TInt CAknFileSelectionModel::GetIconForFileL(const TDesC& aFileName ) const |
669 TPtr absFileName = bufAbsFileName->Des(); |
636 { |
670 |
637 TParsePtrC ptr( aFileName ); |
671 absFileName.Append( aFileName ); |
638 TPtrC ptrc = ptr.Ext(); |
672 TUid uidIgnore; |
639 for ( TInt i = 0; i < iFileTypeArray->Count(); i++ ) |
673 TDataType dataType; |
640 { |
674 TInt err = iApaSession.AppForDocument( absFileName, uidIgnore, dataType ); |
641 if ( ptrc.MatchF( (*iFileTypeArray)[i].iFileType ) == 0 ) |
675 TInt iconIndex = EUnknowTypeIcon; |
642 { |
676 CleanupStack::PopAndDestroy(); //bufAbsFileName |
643 return (*iFileTypeArray)[i].iIconIndex; |
677 |
644 } |
678 if( err != KErrNone ) |
645 } |
679 { |
646 return EUnknowTypeIcon; |
680 // Couldn't find out the data type, use generic file icon: |
|
681 iconIndex = EUnknowTypeIcon; |
|
682 } |
|
683 else |
|
684 { |
|
685 HBufC *bufDataTypeBuf = HBufC::NewLC(KMaxDataTypeLength); |
|
686 *bufDataTypeBuf = dataType.Des(); |
|
687 TPtr dataTypeBuf = bufDataTypeBuf->Des(); |
|
688 |
|
689 if( dataTypeBuf.MatchF( KCFDMimeTypeAudioVoiceRec ) == 0 || |
|
690 dataTypeBuf.MatchF( KCFDMimeTypeAudioVoiceRec2 ) == 0 ) |
|
691 { |
|
692 iconIndex = EVoiceRecFileIcon; |
|
693 } |
|
694 else if( dataTypeBuf.MatchF( KCFDMimeTypePlaylist ) == 0 ) |
|
695 { |
|
696 iconIndex = EPlaylistFileIcon; |
|
697 } |
|
698 else if( dataTypeBuf.MatchF( KCFDMimeTypeRam ) == 0 ) |
|
699 { |
|
700 iconIndex = ELinkFileIcon; |
|
701 } |
|
702 else if( dataTypeBuf.MatchF( KCFDMimeTypeAudio ) == 0 ) |
|
703 { |
|
704 iconIndex = ESoundFileIcon; |
|
705 } |
|
706 else if( dataTypeBuf.MatchF( KCFDMimeTypeImageGms ) == 0 ) |
|
707 { |
|
708 iconIndex = EGmsFileIcon; |
|
709 } |
|
710 else if( dataTypeBuf.MatchF( KCFDMimeTypeImage ) == 0 ) |
|
711 { |
|
712 iconIndex = EImageFileIcon; |
|
713 } |
|
714 else if( dataTypeBuf.MatchF( KCFDMimeTypeVideo ) == 0 || |
|
715 dataTypeBuf.MatchF( KCFDMimeTypeVideoRealMedia ) == 0 || |
|
716 dataTypeBuf.MatchF( KCFDMimeTypeVideoSdp ) == 0 ) |
|
717 { |
|
718 iconIndex = EVideoFileIcon; |
|
719 } |
|
720 else if( dataTypeBuf.MatchF( KCFDMimeTypeGame ) == 0 ) |
|
721 { |
|
722 iconIndex = EGameFileIcon; |
|
723 } |
|
724 else if( dataTypeBuf.MatchF( KCFDMimeTypeJava ) == 0 |
|
725 || dataTypeBuf.MatchF( KCFDMimeTypeJad ) == 0 ) |
|
726 { |
|
727 iconIndex = EAppFileIcon; |
|
728 } |
|
729 else if ( dataTypeBuf.MatchF( KCFDMimeTypeFlash ) == 0 ) |
|
730 { |
|
731 iconIndex = EFlashFileIcon; |
|
732 } |
|
733 else if ( dataTypeBuf.MatchF( KCFDMimeTypeZip ) == 0 ) |
|
734 { |
|
735 iconIndex = EAppFileIcon; |
|
736 } |
|
737 else if ( dataTypeBuf.MatchF( KCFDMimeTypePdf ) == 0 |
|
738 || dataTypeBuf.MatchF( KCFDMimeTypeDoc ) == 0 |
|
739 || dataTypeBuf.MatchF( KCFDMimeTypePpt ) == 0 |
|
740 || dataTypeBuf.MatchF( KCFDMimeTypeXls ) == 0 |
|
741 || dataTypeBuf.MatchF( KCFDMimeTypeNote ) == 0 ) |
|
742 { |
|
743 iconIndex = ENoteFileIcon; |
|
744 } |
|
745 else |
|
746 { |
|
747 // Check from the file name extension, if it's a SIS file: |
|
748 //TParse fileName; |
|
749 //fileName.Set( aFileName, NULL, NULL ); |
|
750 |
|
751 HBufC * bufFileName = aFileName.AllocLC(); |
|
752 TPtr ptrFileName = bufFileName->Des(); |
|
753 TParsePtr fileName(ptrFileName); |
|
754 |
|
755 TPtrC ext( fileName.Ext() ); |
|
756 if( ext.CompareF( KCFDFileExtSis ) == 0 |
|
757 || ext.CompareF( KCFDFileExtSisx ) == 0 ) |
|
758 { |
|
759 iconIndex = EAppFileIcon; |
|
760 } |
|
761 // RApaLsSession does not recognize .mid's: |
|
762 else if( ext.CompareF( KCFDFileExtMid ) == 0 ) |
|
763 { |
|
764 iconIndex = ESoundFileIcon; |
|
765 } |
|
766 else |
|
767 { |
|
768 iconIndex = EUnknowTypeIcon; |
|
769 } |
|
770 CleanupStack::PopAndDestroy(); //bufFileName |
|
771 |
|
772 } |
|
773 |
|
774 CleanupStack::PopAndDestroy(); //bufDataTypeBuf |
|
775 } |
|
776 iImageIndexArray.Append( iconIndex ); |
|
777 } |
647 } |
778 |
648 |
779 TPtrC CAknFileSelectionModel::GetLocalizedName(const TDesC& aFileName) |
649 TPtrC CAknFileSelectionModel::GetLocalizedName(const TDesC& aFileName) |
780 { |
650 { |
781 TParsePtrC parsedEntry( aFileName ); |
651 TParsePtrC parsedEntry( aFileName ); |
782 TPtrC fileName( parsedEntry.NameAndExt() ); |
652 TPtrC fileName( parsedEntry.NameAndExt() ); |
783 |
653 |
784 TPtr itemWithImageIndex = iItemWithImageIndex->Des(); |
654 TPtr itemWithImageIndex = iStringBuf->Des(); |
785 |
655 |
786 itemWithImageIndex = iCurrentPath.DriveAndPath(); |
656 itemWithImageIndex = iCurrentPath.DriveAndPath(); |
787 itemWithImageIndex.Append( aFileName); |
657 itemWithImageIndex.Append( aFileName); |
788 // ignore error: |
658 // ignore error: |
789 AknCFDUtility::AddTrailingBackslash( itemWithImageIndex ); |
659 AknCFDUtility::AddTrailingBackslash( itemWithImageIndex ); |