summaryrefslogtreecommitdiff
path: root/noncore/settings/sysinfo/storage.cpp
Unidiff
Diffstat (limited to 'noncore/settings/sysinfo/storage.cpp') (more/less context) (show whitespace changes)
-rw-r--r--noncore/settings/sysinfo/storage.cpp11
1 files changed, 1 insertions, 10 deletions
diff --git a/noncore/settings/sysinfo/storage.cpp b/noncore/settings/sysinfo/storage.cpp
index c4474d5..4ef7122 100644
--- a/noncore/settings/sysinfo/storage.cpp
+++ b/noncore/settings/sysinfo/storage.cpp
@@ -49,44 +49,36 @@ FileSysInfo::FileSysInfo( QWidget *parent, const char *name )
49 vb = 0x0; 49 vb = 0x0;
50 50
51 storage = new StorageInfo( this ); 51 storage = new StorageInfo( this );
52 connect( storage, SIGNAL( disksChanged() ), this, SLOT( disksChanged() ) ); 52 connect( storage, SIGNAL( disksChanged() ), this, SLOT( disksChanged() ) );
53 53
54 lines.setAutoDelete(TRUE); 54 lines.setAutoDelete(TRUE);
55 55
56 rebuildDisks = TRUE; 56 rebuildDisks = TRUE;
57 updateMounts(); 57 updateMounts();
58 startTimer( 5000 ); 58 startTimer( 5000 );
59} 59}
60 60
61
61void FileSysInfo::timerEvent(QTimerEvent*) 62void FileSysInfo::timerEvent(QTimerEvent*)
62{ 63{
63 updateMounts(); 64 updateMounts();
64} 65}
65 66
66void FileSysInfo::updateMounts() 67void FileSysInfo::updateMounts()
67{ 68{
68 storage->update(); 69 storage->update();
69 70
70 if ( rebuildDisks ) 71 if ( rebuildDisks )
71 { 72 {
72 // Cannot auto delete QDict<MountInfo> disks because it seems to delete
73 // the filesystem object as well causing a segfault
74 MountInfo *mi;
75 for ( QDictIterator<MountInfo> delit(disks); delit.current(); ++delit )
76 {
77 mi = delit.current();
78 mi->fs = 0x0;
79 delete mi;
80 }
81 disks.clear(); 73 disks.clear();
82 lines.clear(); 74 lines.clear();
83 75
84 delete vb; 76 delete vb;
85 vb = new QVBoxLayout( container/*, n > 3 ? 1 : 5*/ ); 77 vb = new QVBoxLayout( container/*, n > 3 ? 1 : 5*/ );
86 78
87 bool frst=TRUE; 79 bool frst=TRUE;
88 80
89 FileSystem *fs; 81 FileSystem *fs;
90 for ( QListIterator<FileSystem> it(storage->fileSystems()); it.current(); ++it ) 82 for ( QListIterator<FileSystem> it(storage->fileSystems()); it.current(); ++it )
91 { 83 {
92 fs = it.current(); 84 fs = it.current();
@@ -154,25 +146,24 @@ MountInfo::MountInfo( FileSystem *filesys, QWidget *parent, const char *name )
154 146
155 legend = new GraphLegend( this ); 147 legend = new GraphLegend( this );
156 legend->setOrientation(Horizontal); 148 legend->setOrientation(Horizontal);
157 vb->addWidget( legend ); 149 vb->addWidget( legend );
158 legend->setData( data ); 150 legend->setData( data );
159 151
160 updateData(); 152 updateData();
161} 153}
162 154
163MountInfo::~MountInfo() 155MountInfo::~MountInfo()
164{ 156{
165 delete data; 157 delete data;
166 delete fs;
167} 158}
168 159
169void MountInfo::updateData() 160void MountInfo::updateData()
170{ 161{
171 long mult = fs->blockSize() / 1024; 162 long mult = fs->blockSize() / 1024;
172 long div = 1024 / fs->blockSize(); 163 long div = 1024 / fs->blockSize();
173 if ( !mult ) mult = 1; 164 if ( !mult ) mult = 1;
174 if ( !div ) div = 1; 165 if ( !div ) div = 1;
175 long total = fs->totalBlocks() * mult / div; 166 long total = fs->totalBlocks() * mult / div;
176 long avail = fs->availBlocks() * mult / div; 167 long avail = fs->availBlocks() * mult / div;
177 long used = total - avail; 168 long used = total - avail;
178 totalSize->setText( title + tr(" : %1 kB").arg( total ) ); 169 totalSize->setText( title + tr(" : %1 kB").arg( total ) );