18 #ifndef FMDRIVEMODEL_H |
18 #ifndef FMDRIVEMODEL_H |
19 #define FMDRIVEMODEL_H |
19 #define FMDRIVEMODEL_H |
20 |
20 |
21 #include <QAbstractItemModel> |
21 #include <QAbstractItemModel> |
22 #include <QStringList> |
22 #include <QStringList> |
23 #include <QFileIconProvider> |
|
24 #include <QModelIndex> |
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 }; |
25 |
47 |
26 class FmDriveModel : public QAbstractListModel |
48 class FmDriveModel : public QAbstractListModel |
27 { |
49 { |
28 Q_OBJECT |
50 Q_OBJECT |
29 public: |
51 public: |
30 enum Option |
52 enum Option |
31 { |
53 { |
32 FillWithVolume = 0x00000001, // add volume behind disname |
54 FillWithVolume = 0x00000001, // add volume behind disname |
33 FillWithDefaultVolume = 0x00000002, // add default diskname while enable FillWithVolume and volume is empty |
55 FillWithDefaultVolume = 0x00000002, // add default diskname while enable FillWithVolume and volume is empty |
34 HideUnAvailableDrive = 0x00000004 // for example: drive F when no MMC card inserted. |
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. |
35 }; |
59 }; |
36 Q_DECLARE_FLAGS(Options, Option) |
60 Q_DECLARE_FLAGS(Options, Option) |
37 |
61 |
38 explicit FmDriveModel( QObject *parent = 0, Options options = 0 ); |
62 explicit FmDriveModel( QObject *parent = 0, Options options = 0, |
|
63 FmDriveListProvider *driveListProvider = 0 ); |
39 virtual ~FmDriveModel(); |
64 virtual ~FmDriveModel(); |
40 |
65 |
41 void refresh(); |
66 void refresh(); |
42 int rowCount( const QModelIndex &parent = QModelIndex() ) const; |
67 int rowCount( const QModelIndex &parent = QModelIndex() ) const; |
43 int columnCount( const QModelIndex &parent = QModelIndex() ) const; |
68 int columnCount( const QModelIndex &parent = QModelIndex() ) const; |
44 QVariant data( const QModelIndex &index, int role = Qt::DisplayRole ) const; |
69 QVariant data( const QModelIndex &index, int role = Qt::DisplayRole ) const; |
45 QVariant headerData( int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const; |
70 QVariant headerData( int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const; |
46 bool indexValid( const QModelIndex &index ) const; |
71 bool indexValid( const QModelIndex &index ) const; |
47 QString driveName( const QModelIndex &index ) const; |
72 QString driveName( const QModelIndex &index ) const; |
48 QString displayString( const QModelIndex &index ) const; |
73 QVariant displayString( const QModelIndex &index ) const; |
49 |
74 |
50 private: |
75 private: |
51 QStringList mFindResult; |
76 QStringList mFindResult; |
52 QFileIconProvider *mIconProvider; |
77 FmFileIconProvider *mIconProvider; |
53 QStringList mDriveList; |
78 QStringList mDriveList; |
54 Options mOptions; |
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; |
55 }; |
84 }; |
56 |
85 |
57 Q_DECLARE_OPERATORS_FOR_FLAGS(FmDriveModel::Options) |
86 Q_DECLARE_OPERATORS_FOR_FLAGS(FmDriveModel::Options) |
58 |
87 |
59 #endif |
88 #endif |