diff -r ada7962b4308 -r 15bc28c9dd51 filemanager/src/inc/fmdrivemodel.h --- a/filemanager/src/inc/fmdrivemodel.h Mon May 03 12:24:39 2010 +0300 +++ b/filemanager/src/inc/fmdrivemodel.h Tue Aug 24 10:24:14 2010 +0800 @@ -20,22 +20,47 @@ #include #include -#include #include +class FmFileIconProvider; + +/*! + \class FmDriveListProvider + \brief The class FmDriveListProvider provide drive list which is used in FmDriveModel + */ +class FmDriveListProvider +{ +public: + FmDriveListProvider() + { + } + + virtual ~FmDriveListProvider() + { + } + + /*! + implement this function to provide drive list. + */ + virtual void getDriveList( QStringList &driveList ) = 0; +}; + class FmDriveModel : public QAbstractListModel { Q_OBJECT public: enum Option { - FillWithVolume = 0x00000001, // add volume behind disname - FillWithDefaultVolume = 0x00000002, // add default diskname while enable FillWithVolume and volume is empty - HideUnAvailableDrive = 0x00000004 // for example: drive F when no MMC card inserted. + FillWithVolume = 0x00000001, // add volume behind disname + FillWithDefaultVolume = 0x00000002, // add default diskname while enable FillWithVolume and volume is empty + HideUnAvailableDrive = 0x00000004, // for example: drive F when no MMC card inserted. + FillWithTotalSize = 0x00000008, // show the drive's total size. + FillWithFreeSize = 0x00000010 //show the drive's free size. }; Q_DECLARE_FLAGS(Options, Option) - explicit FmDriveModel( QObject *parent = 0, Options options = 0 ); + explicit FmDriveModel( QObject *parent = 0, Options options = 0, + FmDriveListProvider *driveListProvider = 0 ); virtual ~FmDriveModel(); void refresh(); @@ -45,13 +70,17 @@ QVariant headerData( int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const; bool indexValid( const QModelIndex &index ) const; QString driveName( const QModelIndex &index ) const; - QString displayString( const QModelIndex &index ) const; + QVariant displayString( const QModelIndex &index ) const; private: QStringList mFindResult; - QFileIconProvider *mIconProvider; + FmFileIconProvider *mIconProvider; QStringList mDriveList; Options mOptions; + + // DriveListProvider will ignore HideUnAvailableDrive option. + // DriveListProvide can be set by others to provide special drive list + FmDriveListProvider *mDriveListProvider; }; Q_DECLARE_OPERATORS_FOR_FLAGS(FmDriveModel::Options)