filemanager/src/inc/fmdrivemodel.h
changeset 25 b7bfdea70ca2
parent 14 1957042d8c7e
child 40 4167eb56f30d
equal deleted inserted replaced
16:ada7962b4308 25:b7bfdea70ca2
    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:
    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.
    35     };
    57     };
    36     Q_DECLARE_FLAGS(Options, Option)
    58     Q_DECLARE_FLAGS(Options, Option)
    37 
    59 
    38     explicit FmDriveModel( QObject *parent = 0, Options options = 0 );
    60     explicit FmDriveModel( QObject *parent = 0, Options options = 0,
       
    61             FmDriveListProvider *driveListProvider = 0 );
    39     virtual ~FmDriveModel();
    62     virtual ~FmDriveModel();
    40 
    63 
    41     void refresh();
    64     void refresh();
    42     int rowCount( const QModelIndex &parent = QModelIndex() ) const;
    65     int rowCount( const QModelIndex &parent = QModelIndex() ) const;
    43     int columnCount( const QModelIndex &parent = QModelIndex() ) const;
    66     int columnCount( const QModelIndex &parent = QModelIndex() ) const;
    47     QString driveName( const QModelIndex &index ) const;
    70     QString driveName( const QModelIndex &index ) const;
    48     QString displayString( const QModelIndex &index ) const;
    71     QString displayString( const QModelIndex &index ) const;
    49     
    72     
    50 private:
    73 private:
    51     QStringList         mFindResult;
    74     QStringList         mFindResult;
    52     QFileIconProvider   *mIconProvider;
    75     FmFileIconProvider  *mIconProvider;
    53     QStringList         mDriveList;
    76     QStringList         mDriveList;
    54     Options             mOptions;
    77     Options             mOptions;
       
    78     
       
    79     // DriveListProvider will ignore HideUnAvailableDrive option.
       
    80     // DriveListProvide can be set by others to provide special drive list
       
    81     FmDriveListProvider *mDriveListProvider;
    55 };
    82 };
    56 
    83 
    57 Q_DECLARE_OPERATORS_FOR_FLAGS(FmDriveModel::Options)
    84 Q_DECLARE_OPERATORS_FOR_FLAGS(FmDriveModel::Options)
    58 
    85 
    59 #endif
    86 #endif