|
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: |
|
15 * |
|
16 */ |
|
17 |
|
18 #ifndef FMDRIVEMODEL_H |
|
19 #define FMDRIVEMODEL_H |
|
20 |
|
21 #include <QAbstractItemModel> |
|
22 #include <QStringList> |
|
23 #include <QModelIndex> |
|
24 |
|
25 class FmFileIconProvider; |
|
26 |
|
27 /*! |
|
28 \class FmDriveListProvider |
|
29 \brief The class FmDriveListProvider provide drive list which is used in FmDriveModel |
|
30 */ |
|
31 class FmDriveListProvider |
|
32 { |
|
33 public: |
|
34 FmDriveListProvider() |
|
35 { |
|
36 } |
|
37 |
|
38 virtual ~FmDriveListProvider() |
|
39 { |
|
40 } |
|
41 |
|
42 /*! |
|
43 implement this function to provide drive list. |
|
44 */ |
|
45 virtual void getDriveList( QStringList &driveList ) = 0; |
|
46 }; |
|
47 |
|
48 class FmDriveModel : public QAbstractListModel |
|
49 { |
|
50 Q_OBJECT |
|
51 public: |
|
52 enum Option |
|
53 { |
|
54 FillWithVolume = 0x00000001, // add volume behind disname |
|
55 FillWithDefaultVolume = 0x00000002, // add default diskname while enable FillWithVolume and volume is empty |
|
56 HideUnAvailableDrive = 0x00000004, // for example: drive F when no MMC card inserted. |
|
57 FillWithTotalSize = 0x00000008, // show the drive's total size. |
|
58 FillWithFreeSize = 0x00000010 //show the drive's free size. |
|
59 }; |
|
60 Q_DECLARE_FLAGS(Options, Option) |
|
61 |
|
62 explicit FmDriveModel( QObject *parent = 0, Options options = 0, |
|
63 FmDriveListProvider *driveListProvider = 0 ); |
|
64 virtual ~FmDriveModel(); |
|
65 |
|
66 void refresh(); |
|
67 int rowCount( const QModelIndex &parent = QModelIndex() ) const; |
|
68 int columnCount( const QModelIndex &parent = QModelIndex() ) const; |
|
69 QVariant data( const QModelIndex &index, int role = Qt::DisplayRole ) const; |
|
70 QVariant headerData( int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const; |
|
71 bool indexValid( const QModelIndex &index ) const; |
|
72 QString driveName( const QModelIndex &index ) const; |
|
73 QVariant displayString( const QModelIndex &index ) const; |
|
74 |
|
75 private: |
|
76 QStringList mFindResult; |
|
77 FmFileIconProvider *mIconProvider; |
|
78 QStringList mDriveList; |
|
79 Options mOptions; |
|
80 |
|
81 // DriveListProvider will ignore HideUnAvailableDrive option. |
|
82 // DriveListProvide can be set by others to provide special drive list |
|
83 FmDriveListProvider *mDriveListProvider; |
|
84 }; |
|
85 |
|
86 Q_DECLARE_OPERATORS_FOR_FLAGS(FmDriveModel::Options) |
|
87 |
|
88 #endif |