1 /* 2 * File name: FilesystemsWindow.h 3 * Summary: QDirStat "Mounted Filesystems" window 4 * License: GPL V2 - See file LICENSE for details. 5 * 6 * Author: Stefan Hundhammer <Stefan.Hundhammer@gmx.de> 7 */ 8 9 10 #ifndef FilesystemsWindow_h 11 #define FilesystemsWindow_h 12 13 #include <QDialog> 14 #include <QTreeWidgetItem> 15 16 #include "ui_filesystems-window.h" 17 #include "FileInfo.h" // FileSize 18 19 20 21 namespace QDirStat 22 { 23 class MountPoint; 24 25 /** 26 * Modeless dialog to display details about mounted filesystems: 27 * 28 * - device 29 * - mount point 30 * - filesystem type 31 * - used disk space 32 * - free disk space for nonprivileged users 33 * - free disk space for root 34 * 35 * The sizes may not be available on all platforms (no Qt 4 support!) or 36 * for some filesystem types. 37 **/ 38 class FilesystemsWindow: public QDialog 39 { 40 Q_OBJECT 41 42 public: 43 44 /** 45 * Constructor. 46 * 47 * Notice that this widget will destroy itself upon window close. 48 * 49 * It is advised to use a QPointer for storing a pointer to an instance 50 * of this class. The QPointer will keep track of this window 51 * auto-deleting itself when closed. 52 **/ 53 FilesystemsWindow( QWidget * parent = 0 ); 54 55 /** 56 * Destructor. 57 **/ 58 virtual ~FilesystemsWindow(); 59 60 /** 61 * Read the path of the currently selected filesystem or an empty 62 * string if there is none. 63 **/ 64 QString selectedPath() const; 65 66 67 signals: 68 69 void readFilesystem( const QString & path ); 70 71 72 public slots: 73 74 /** 75 * Populate the window with all normal filesystems. Bind mounts, 76 * filesystems mounted several times and Btrfs subvolumes are excluded. 77 **/ 78 void populate(); 79 80 /** 81 * Refresh (reload) all data. 82 **/ 83 void refresh(); 84 85 /** 86 * Reject the dialog contents, i.e. the user clicked the "Cancel" or 87 * WM_CLOSE button. This not only closes the dialog, it also deletes 88 * it. 89 * 90 * Reimplemented from QDialog. 91 **/ 92 virtual void reject() Q_DECL_OVERRIDE; 93 94 95 protected slots: 96 97 /** 98 * Enable or disable widgets such as the "Read" button. 99 **/ 100 void enableActions(); 101 102 /** 103 * Notification that the "Read" button was clicked: 104 * Emit the readFilesystem() signal. 105 **/ 106 void readSelectedFilesystem(); 107 108 109 protected: 110 111 /** 112 * Clear all data and widget contents. 113 **/ 114 void clear(); 115 116 /** 117 * One-time initialization of the widgets in this window. 118 **/ 119 void initWidgets(); 120 121 /** 122 * Show panel message warning about Btrfs and how it reports free sizes 123 **/ 124 void showBtrfsFreeSizeWarning(); 125 126 127 // 128 // Data members 129 // 130 131 Ui::FilesystemsWindow * _ui; 132 133 }; // class FilesystemsWindow 134 135 136 /** 137 * Column numbers for the filesystems tree widget 138 **/ 139 enum FilesystemColumns 140 { 141 FS_DeviceCol = 0, 142 FS_MountPathCol, 143 FS_TypeCol, 144 FS_TotalSizeCol, 145 FS_UsedSizeCol, 146 FS_ReservedSizeCol, 147 FS_FreeSizeCol, 148 FS_FreePercentCol 149 }; 150 151 152 /** 153 * Item class for the filesystems list (which is really a tree widget). 154 **/ 155 class FilesystemItem: public QTreeWidgetItem 156 { 157 public: 158 /** 159 * Constructor. 160 **/ 161 FilesystemItem( MountPoint * mountPoint, QTreeWidget * parent ); 162 163 // Getters 164 device()165 QString device() const { return _device; } mountPath()166 QString mountPath() const { return _mountPath; } fsType()167 QString fsType() const { return _fsType; } totalSize()168 FileSize totalSize() const { return _totalSize; } usedSize()169 FileSize usedSize() const { return _usedSize; } reservedSize()170 FileSize reservedSize() const { return _reservedSize; } freeSize()171 FileSize freeSize() const { return _freeSize; } isNetworkMount()172 bool isNetworkMount() const { return _isNetworkMount; } isReadOnly()173 bool isReadOnly() const { return _isReadOnly; } 174 175 /** 176 * Less-than operator for sorting. 177 **/ 178 bool operator<( const QTreeWidgetItem & rawOther ) const; 179 180 181 protected: 182 183 QString _device; 184 QString _mountPath; 185 QString _fsType; 186 FileSize _totalSize; 187 FileSize _usedSize; 188 FileSize _reservedSize; 189 FileSize _freeSize; 190 bool _isNetworkMount; 191 bool _isReadOnly; 192 }; 193 194 } 195 196 #endif // FilesystemsWindow_h 197