equal
deleted
inserted
replaced
21 #include <QAbstractItemModel> |
21 #include <QAbstractItemModel> |
22 #include <QStringList> |
22 #include <QStringList> |
23 #include <QFileIconProvider> |
23 #include <QFileIconProvider> |
24 #include <QModelIndex> |
24 #include <QModelIndex> |
25 |
25 |
|
26 /*! |
|
27 \class FmDriveListProvider |
|
28 \brief The class FmDriveListProvider provide drive list which is used in FmDriveModel |
|
29 */ |
|
30 class FmDriveListProvider |
|
31 { |
|
32 public: |
|
33 FmDriveListProvider() |
|
34 { |
|
35 } |
|
36 |
|
37 virtual ~FmDriveListProvider() |
|
38 { |
|
39 } |
|
40 |
|
41 /*! |
|
42 implement this function to provide drive list. |
|
43 */ |
|
44 virtual void getDriveList( QStringList &driveList ) = 0; |
|
45 }; |
|
46 |
26 class FmDriveModel : public QAbstractListModel |
47 class FmDriveModel : public QAbstractListModel |
27 { |
48 { |
28 Q_OBJECT |
49 Q_OBJECT |
29 public: |
50 public: |
30 enum Option |
51 enum Option |
33 FillWithDefaultVolume = 0x00000002, // add default diskname while enable FillWithVolume and volume is empty |
54 FillWithDefaultVolume = 0x00000002, // add default diskname while enable FillWithVolume and volume is empty |
34 HideUnAvailableDrive = 0x00000004 // for example: drive F when no MMC card inserted. |
55 HideUnAvailableDrive = 0x00000004 // for example: drive F when no MMC card inserted. |
35 }; |
56 }; |
36 Q_DECLARE_FLAGS(Options, Option) |
57 Q_DECLARE_FLAGS(Options, Option) |
37 |
58 |
38 explicit FmDriveModel( QObject *parent = 0, Options options = 0 ); |
59 explicit FmDriveModel( QObject *parent = 0, Options options = 0, |
|
60 FmDriveListProvider *driveListProvider = 0 ); |
39 virtual ~FmDriveModel(); |
61 virtual ~FmDriveModel(); |
40 |
62 |
41 void refresh(); |
63 void refresh(); |
42 int rowCount( const QModelIndex &parent = QModelIndex() ) const; |
64 int rowCount( const QModelIndex &parent = QModelIndex() ) const; |
43 int columnCount( const QModelIndex &parent = QModelIndex() ) const; |
65 int columnCount( const QModelIndex &parent = QModelIndex() ) const; |
50 private: |
72 private: |
51 QStringList mFindResult; |
73 QStringList mFindResult; |
52 QFileIconProvider *mIconProvider; |
74 QFileIconProvider *mIconProvider; |
53 QStringList mDriveList; |
75 QStringList mDriveList; |
54 Options mOptions; |
76 Options mOptions; |
|
77 |
|
78 // DriveListProvider will ignore HideUnAvailableDrive option. |
|
79 // DriveListProvide can be set by others to provide special drive list |
|
80 FmDriveListProvider *mDriveListProvider; |
55 }; |
81 }; |
56 |
82 |
57 Q_DECLARE_OPERATORS_FOR_FLAGS(FmDriveModel::Options) |
83 Q_DECLARE_OPERATORS_FOR_FLAGS(FmDriveModel::Options) |
58 |
84 |
59 #endif |
85 #endif |