filemanager/src/inc/fmutils.h
changeset 33 328cf6fbe40c
parent 27 df183af6b92f
child 40 4167eb56f30d
equal deleted inserted replaced
32:39cf9ced4cc4 33:328cf6fbe40c
    24 #include <QString>
    24 #include <QString>
    25 
    25 
    26 class FmDriverInfo
    26 class FmDriverInfo
    27 {
    27 {
    28 public:
    28 public:
       
    29     /*!
       
    30         Used to get drive status for convenience.
       
    31         /sa DriveType is used to get drive type.
       
    32     */
    29     enum driveState
    33     enum driveState
    30     {
    34     {
    31         EDriveNotPresent = 0x1, // true when Drive have not inserted, for example, MMC Card
    35         EDriveNotPresent = 0x1, // true when Drive have not inserted, for example, MMC Card
    32         EDriveAvailable = 0x2,  // false when drive is locked or corrupted, for example MMC Card
    36         EDriveAvailable = 0x2,  // false when drive is locked or corrupted, for example MMC Card
    33         EDriveLocked = 0x4,
    37         EDriveLocked = 0x4,
    44         EDriveEjectable = 0x2000,
    48         EDriveEjectable = 0x2000,
    45         EDriveInUse = 0x4000,
    49         EDriveInUse = 0x4000,
    46         EDriveMassStorage = 0x8000,
    50         EDriveMassStorage = 0x8000,
    47         EDriveRam = 0x10000,
    51         EDriveRam = 0x10000,
    48         EDriveUsbMemory = 0x20000,
    52         EDriveUsbMemory = 0x20000,
       
    53         EDriveRemote = 0x40000,
    49      };
    54      };
       
    55     
       
    56     /*!
       
    57         Used to get drive type for convenience.
       
    58     */
       
    59     enum DriveType
       
    60     {
       
    61         EDriveTypeRom,
       
    62         EDriveTypeRam,
       
    63         EDriveTypePhoneMemory,
       
    64         EDriveTypeMassStorage,
       
    65         EDriveTypeMemoryCard,
       
    66         EDriveTypeUsbMemory,
       
    67         EDriveTypeRemote,
       
    68     };
       
    69     
    50     Q_DECLARE_FLAGS( DriveState, driveState )
    70     Q_DECLARE_FLAGS( DriveState, driveState )
    51     
    71     
    52     FmDriverInfo( quint64 s, quint64 f, const QString &n, const QString &vN, const quint32 driveState ) :
    72     FmDriverInfo( quint64 s, quint64 f, const QString &n, const QString &vN, const quint32 driveState ) :
    53         mSize( s ), mFreeSize( f ), mName( n ), mVolumeName( vN ), mDriveState( driveState ) {}
    73         mSize( s ), mFreeSize( f ), mName( n ), mVolumeName( vN ), mDriveState( driveState ) {}
    54     FmDriverInfo( const FmDriverInfo &other )
    74     FmDriverInfo( const FmDriverInfo &other )
    69     quint64 size() const { return mSize; }
    89     quint64 size() const { return mSize; }
    70     quint64 freeSize() const { return mFreeSize; }
    90     quint64 freeSize() const { return mFreeSize; }
    71     QString name() const { return mName; }
    91     QString name() const { return mName; }
    72     QString volumeName() const { return mVolumeName; }
    92     QString volumeName() const { return mVolumeName; }
    73     DriveState driveState() const { return mDriveState; }
    93     DriveState driveState() const { return mDriveState; }
       
    94     FmDriverInfo::DriveType driveType();
    74     
    95     
    75 private:
    96 private:
    76     quint64 mSize;
    97     quint64 mSize;
    77     quint64 mFreeSize;
    98     quint64 mFreeSize;
    78     QString mName;
    99     QString mName;
    79     QString mVolumeName;
   100     QString mVolumeName;
    80     DriveState mDriveState;
   101     DriveState mDriveState;
       
   102     DriveType mDriveType;
    81 };
   103 };
    82 Q_DECLARE_OPERATORS_FOR_FLAGS( FmDriverInfo::DriveState )
   104 Q_DECLARE_OPERATORS_FOR_FLAGS( FmDriverInfo::DriveState )
    83 
   105 
    84 class FmUtils
   106 class FmUtils
    85 {
   107 {
   140      * @param defaultName whether it is the default name.
   162      * @param defaultName whether it is the default name.
   141      * @return the volume name.
   163      * @return the volume name.
   142      */
   164      */
   143     static QString getVolumeNameWithDefaultNameIfNull( const QString &diskName, bool &defaultName );
   165     static QString getVolumeNameWithDefaultNameIfNull( const QString &diskName, bool &defaultName );
   144 
   166 
       
   167     static bool isSubLevelPath( const QString &src, const QString &dest );
       
   168 
       
   169 	static int setFileAttributes( const QString &srcFile, const QString &desFile ); 
   145 };
   170 };
   146 
   171 
   147 #endif
   172 #endif
   148 
   173