filemanager/src/inc/fmfileiconprovider.cpp
branchRCL_3
changeset 20 491b3ed49290
equal deleted inserted replaced
19:95243422089a 20:491b3ed49290
       
     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: filemanager file icon provider source file 
       
    15 *
       
    16 */
       
    17 
       
    18 #include "fmfileiconprovider.h"
       
    19 #include "fmfiletyperecognizer.h"
       
    20 #include "fmutils.h"
       
    21 
       
    22 #include <QDir>
       
    23 #include <QFileInfo>
       
    24 
       
    25 #include "hbicon.h"
       
    26 
       
    27 //#define mmcIcon         ":image/qgn_prop_mmc_memc.svg"
       
    28 //#define mmcNoneIcon     ":image/qgn_prop_fmgr_mmc_no_sub.svg"
       
    29 //#define mmcLockedIcon   ":image/qgn_prop_mmc_locked.svg"
       
    30 //#define phoneMemoryIcon ":image/qgn_prop_phone_memc.svg"
       
    31 //#define usbMemoryIcon   ":image/qgn_prop_usb_memc.svg"
       
    32 //#define massMemoryIcon  ":image/qgn_prop_fmgr_ms.svg"
       
    33 
       
    34 #define phoneMemoryIcon "qtg_large_mobile"
       
    35 #define massMemoryIcon  "qtg_large_mass_storage"
       
    36 #define mmcIcon         "qtg_large_mmc"
       
    37 #define mmcNoneIcon     "qtg_large_mmc_removed"
       
    38 #define usbMemoryIcon   "qtg_large_usb_memory"
       
    39 
       
    40 //TODO: UI_Update: mmcl locked icon have not provided in icon spec
       
    41 // Just use original custom-defined icon
       
    42 #define mmcLockedIcon   ":image/qgn_prop_mmc_locked.svg"
       
    43 
       
    44 
       
    45 #define folderIcon      "qtg_large_folder"
       
    46 
       
    47 #define imageIcon       "qtg_large_photos" 
       
    48 #define videoIcon       "qtg_large_video" 
       
    49 #define toneIcon        "qtg_large_tone"
       
    50 #define playlistIcon    "qtg_large_playlist" 
       
    51 #define textIcon        "qtg_large_text" 
       
    52 #define sisxIcon        "qtg_large_sisx" 
       
    53 #define javaIcon        "qtg_large_java" 
       
    54 #define flashIcon       "qtg_large_flash" 
       
    55 #define widgetIcon      "qtg_large_widget" 
       
    56 #define weblinkIcon     "qtg_large_web_link" 
       
    57 #define queryIcon       "qtg_large_query"
       
    58 
       
    59 FmFileIconProvider::FmFileIconProvider()
       
    60 {
       
    61     mFileTypeRecognizer = new FmFileTypeRecognizer();
       
    62 }
       
    63 
       
    64 FmFileIconProvider::~FmFileIconProvider()
       
    65 {
       
    66     delete mFileTypeRecognizer;
       
    67 }
       
    68         
       
    69 QIcon FmFileIconProvider::icon(const QFileInfo &info) const
       
    70 {
       
    71     QIcon retIcon;
       
    72     
       
    73     QString filePath( info.absoluteFilePath() );
       
    74     FmFileTypeRecognizer::FileType fileType = mFileTypeRecognizer->getType( filePath );
       
    75     switch( fileType )
       
    76         {
       
    77         case FmFileTypeRecognizer::FileTypeDrive:
       
    78             {
       
    79             FmDriverInfo driveInfo = FmUtils::queryDriverInfo( filePath );
       
    80             switch ( driveInfo.driveType() )
       
    81                 {
       
    82                 case FmDriverInfo::EDriveTypeMassStorage:
       
    83                     retIcon = HbIcon( massMemoryIcon ).qicon();
       
    84                     break;
       
    85                 case FmDriverInfo::EDriveTypeUsbMemory:
       
    86                     retIcon = HbIcon( usbMemoryIcon ).qicon();
       
    87                     break;
       
    88                 case FmDriverInfo::EDriveTypeMemoryCard:
       
    89                     if( !( driveInfo.driveState() & FmDriverInfo::EDriveNotPresent ) ) {
       
    90                         retIcon = HbIcon( mmcIcon ).qicon();
       
    91                     } else {
       
    92                         retIcon = HbIcon( mmcNoneIcon ).qicon();    
       
    93                     }
       
    94                     break;
       
    95                 case FmDriverInfo::EDriveTypePhoneMemory:
       
    96                     retIcon = HbIcon( phoneMemoryIcon ).qicon();
       
    97                     break;
       
    98                 case FmDriverInfo::EDriveTypeNotExist: // drive not exist, let QFileIconProvider to judge icon
       
    99                 default:  // filemanger do not provide icon for other drive types, let QFileIconProvider to judge icon
       
   100                     break;
       
   101                }
       
   102             break;
       
   103             }
       
   104         case FmFileTypeRecognizer::FileTypeFolder:
       
   105             {
       
   106             retIcon = HbIcon( folderIcon ).qicon();
       
   107             break;
       
   108             }
       
   109         case FmFileTypeRecognizer::FileTypeImage:
       
   110             {
       
   111             retIcon = HbIcon( imageIcon ).qicon();
       
   112             break;
       
   113             }
       
   114         case FmFileTypeRecognizer::FileTypeVideo:
       
   115             {
       
   116             retIcon = HbIcon( videoIcon ).qicon();
       
   117             break;
       
   118             }
       
   119         case FmFileTypeRecognizer::FileTypeTone:
       
   120             {
       
   121             retIcon = HbIcon( toneIcon ).qicon();
       
   122             break;
       
   123             }
       
   124         case FmFileTypeRecognizer::FileTypePlaylist:
       
   125             {
       
   126             retIcon = HbIcon( playlistIcon ).qicon();
       
   127             break;
       
   128             }
       
   129         case FmFileTypeRecognizer::FileTypeText:
       
   130             {
       
   131             retIcon = HbIcon( textIcon ).qicon();
       
   132             break;
       
   133             }
       
   134         case FmFileTypeRecognizer::FileTypeSisx:
       
   135             {
       
   136             retIcon = HbIcon( sisxIcon ).qicon();
       
   137             break;
       
   138             }
       
   139         case FmFileTypeRecognizer::FileTypeJava:
       
   140             {
       
   141             retIcon = HbIcon( javaIcon ).qicon();
       
   142             break;
       
   143             }
       
   144         case FmFileTypeRecognizer::FileTypeFlash:
       
   145             {
       
   146             retIcon = HbIcon( flashIcon ).qicon();
       
   147             break;
       
   148             }
       
   149         case FmFileTypeRecognizer::FileTypeWidget:
       
   150             {
       
   151             retIcon = HbIcon( widgetIcon ).qicon();
       
   152             break;
       
   153             }
       
   154         case FmFileTypeRecognizer::FileTypeWebLink:
       
   155             {
       
   156             retIcon = HbIcon( weblinkIcon ).qicon();
       
   157             break;
       
   158             }
       
   159         case FmFileTypeRecognizer::FileTypeUnKnown:
       
   160             {
       
   161             // currently filemanger icon doc is not unified with icon name.
       
   162             // for example, qtg_small_unknown  qtg_large_query both means for unknown type
       
   163 			// but the two icon name is not the same.
       
   164             retIcon = HbIcon( queryIcon ).qicon();
       
   165             break;
       
   166             }
       
   167         }
       
   168     
       
   169     // if cannot get icon, return icon from QFileIconProvider
       
   170     if( retIcon.isNull() ) {
       
   171         retIcon = QFileIconProvider::icon( info );
       
   172     }
       
   173     return retIcon;
       
   174 }