|
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 "fmutils.h" |
|
20 |
|
21 #include <QDir> |
|
22 #include <QFileInfo> |
|
23 |
|
24 #define mmcIcon ":image/qgn_prop_mmc_memc.svg" |
|
25 #define mmcNoneIcon ":image/qgn_prop_fmgr_mmc_no_sub.svg" |
|
26 #define mmcLockedIcon ":image/qgn_prop_mmc_locked.svg" |
|
27 #define phoneMemoryIcon ":image/qgn_prop_phone_memc.svg" |
|
28 #define usbMemoryIcon ":image/qgn_prop_usb_memc.svg" |
|
29 #define massMemoryIcon ":image/qgn_prop_fmgr_ms.svg" |
|
30 |
|
31 FmFileIconProvider::FmFileIconProvider() |
|
32 { |
|
33 |
|
34 } |
|
35 |
|
36 FmFileIconProvider::~FmFileIconProvider() |
|
37 { |
|
38 } |
|
39 |
|
40 QIcon FmFileIconProvider::icon(const QFileInfo &info) const |
|
41 { |
|
42 QString filePath( info.path() ); |
|
43 if( FmUtils::isDrive( filePath ) ) { |
|
44 FmDriverInfo::DriveState driveState = FmUtils::queryDriverInfo( filePath ).driveState(); |
|
45 if( driveState & FmDriverInfo::EDriveAvailable ){ |
|
46 if( driveState & FmDriverInfo::EDriveRemovable ) { |
|
47 if( driveState & FmDriverInfo::EDriveMassStorage ) { |
|
48 // Mass Storage |
|
49 return QIcon( massMemoryIcon ); |
|
50 } |
|
51 else{ |
|
52 //Memory Card |
|
53 return QIcon( mmcIcon ); |
|
54 } |
|
55 } else{ |
|
56 //Phone Memory |
|
57 return QIcon( phoneMemoryIcon ); |
|
58 } |
|
59 } else if( driveState & FmDriverInfo::EDriveLocked ) { |
|
60 return QIcon( mmcLockedIcon ); |
|
61 } else if( driveState & FmDriverInfo::EDriveCorrupted ) { |
|
62 return QIcon( mmcNoneIcon ); |
|
63 } else if( driveState & FmDriverInfo::EDriveNotPresent ){ |
|
64 return QIcon( mmcNoneIcon ); |
|
65 } else { |
|
66 return QIcon( mmcNoneIcon ); |
|
67 } |
|
68 } else { |
|
69 return QFileIconProvider::icon( info ); |
|
70 } |
|
71 } |