Changeset View
Changeset View
Standalone View
Standalone View
src/summaryWidget.cpp
Show All 31 Lines | |||||
32 | 32 | | |||
33 | #include <QLabel> | 33 | #include <QLabel> | ||
34 | #include <QApplication> | 34 | #include <QApplication> | ||
35 | #include <QByteArray> | 35 | #include <QByteArray> | ||
36 | #include <QList> | 36 | #include <QList> | ||
37 | #include <QMouseEvent> | 37 | #include <QMouseEvent> | ||
38 | #include <QLayout> | 38 | #include <QLayout> | ||
39 | #include <QStorageInfo> | 39 | #include <QStorageInfo> | ||
40 | #include <QMap> | ||||
40 | 41 | | |||
41 | namespace Filelight | 42 | namespace Filelight | ||
42 | { | 43 | { | ||
43 | 44 | | |||
44 | struct Disk | 45 | struct Disk | ||
45 | { | 46 | { | ||
46 | QString mount; | 47 | QString mount; | ||
47 | QString name; | 48 | QString name; | ||
48 | 49 | | |||
49 | qint64 size; | 50 | qint64 size; | ||
50 | qint64 used; | 51 | qint64 used; | ||
51 | qint64 free; //NOTE used+avail != size (clustersize!) | 52 | qint64 free; //NOTE used+avail != size (clustersize!) | ||
52 | }; | 53 | }; | ||
53 | 54 | | |||
54 | 55 | | |||
55 | struct DiskList : QList<Disk> | 56 | struct DiskList : QMap<QString, Disk> | ||
56 | { | 57 | { | ||
57 | DiskList(); | 58 | DiskList(); | ||
58 | }; | 59 | }; | ||
59 | 60 | | |||
60 | 61 | | |||
61 | class MyRadialMap : public RadialMap::Widget | 62 | class MyRadialMap : public RadialMap::Widget | ||
62 | { | 63 | { | ||
63 | Q_OBJECT | 64 | Q_OBJECT | ||
Show All 38 Lines | |||||
102 | void SummaryWidget::createDiskMaps() | 103 | void SummaryWidget::createDiskMaps() | ||
103 | { | 104 | { | ||
104 | DiskList disks; | 105 | DiskList disks; | ||
105 | 106 | | |||
106 | QString text; | 107 | QString text; | ||
107 | 108 | | |||
108 | for (DiskList::ConstIterator it = disks.constBegin(), end = disks.constEnd(); it != end; ++it) | 109 | for (DiskList::ConstIterator it = disks.constBegin(), end = disks.constEnd(); it != end; ++it) | ||
109 | { | 110 | { | ||
110 | Disk const &disk = *it; | 111 | Disk const &disk = it.value(); | ||
111 | 112 | | |||
112 | if (disk.free == 0 && disk.used == 0) | 113 | if (disk.free == 0 && disk.used == 0) | ||
113 | continue; | 114 | continue; | ||
114 | 115 | | |||
115 | QWidget *volume = new QWidget(this); | 116 | QWidget *volume = new QWidget(this); | ||
116 | QVBoxLayout *volumeLayout = new QVBoxLayout(volume); | 117 | QVBoxLayout *volumeLayout = new QVBoxLayout(volume); | ||
117 | RadialMap::Widget *map = new MyRadialMap(this); | 118 | RadialMap::Widget *map = new MyRadialMap(this); | ||
118 | 119 | | |||
Show All 26 Lines | |||||
145 | map->create(tree); //must be done when visible | 146 | map->create(tree); //must be done when visible | ||
146 | 147 | | |||
147 | connect(map, &RadialMap::Widget::activated, this, &SummaryWidget::activated); | 148 | connect(map, &RadialMap::Widget::activated, this, &SummaryWidget::activated); | ||
148 | } | 149 | } | ||
149 | } | 150 | } | ||
150 | 151 | | |||
151 | DiskList::DiskList() | 152 | DiskList::DiskList() | ||
152 | { | 153 | { | ||
153 | static const QSet<QByteArray> ignoredFsTypes = { "tmpfs", "squashfs" }; | 154 | static const QSet<QByteArray> ignoredFsTypes = { "tmpfs", "squashfs", "autofs" }; | ||
154 | | ||||
155 | QStringList partitions; | | |||
156 | 155 | | |||
157 | for (const QStorageInfo &storage : QStorageInfo::mountedVolumes()) { | 156 | for (const QStorageInfo &storage : QStorageInfo::mountedVolumes()) { | ||
158 | if (!storage.isReady() || ignoredFsTypes.contains(storage.fileSystemType())) { | 157 | if (!storage.isReady() || ignoredFsTypes.contains(storage.fileSystemType())) { | ||
159 | continue; | 158 | continue; | ||
160 | } | 159 | } | ||
161 | 160 | | |||
162 | Disk disk; | 161 | Disk disk; | ||
163 | disk.mount = storage.rootPath(); | 162 | disk.mount = storage.rootPath(); | ||
164 | disk.name = storage.name(); | 163 | disk.name = storage.name(); | ||
165 | disk.size = storage.bytesTotal(); | 164 | disk.size = storage.bytesTotal(); | ||
166 | disk.free = storage.bytesFree(); | 165 | disk.free = storage.bytesFree(); | ||
167 | disk.used = disk.size - disk.free; | 166 | disk.used = disk.size - disk.free; | ||
168 | 167 | | |||
169 | *this += disk; | 168 | // if something is mounted over same path, last mounted point would be used since only it is currently reachable. | ||
169 | (*this)[disk.mount] = disk; | ||||
170 | } | 170 | } | ||
171 | } | 171 | } | ||
172 | 172 | | |||
173 | } | 173 | } | ||
174 | 174 | | |||
175 | #include "summaryWidget.moc" | 175 | #include "summaryWidget.moc" |