summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/sysinfo/storage.cpp26
1 files changed, 10 insertions, 16 deletions
diff --git a/noncore/settings/sysinfo/storage.cpp b/noncore/settings/sysinfo/storage.cpp
index f76fbdb..b369ff1 100644
--- a/noncore/settings/sysinfo/storage.cpp
+++ b/noncore/settings/sysinfo/storage.cpp
@@ -126,115 +126,109 @@ void StorageInfo::updateMounts()
126 humanname = tr("CF Card: "+*fsmount+" "+*fsTit+" "); 126 humanname = tr("CF Card: "+*fsmount+" "+*fsTit+" ");
127 else if ( humanname == "/dev/hda1" ) 127 else if ( humanname == "/dev/hda1" )
128 humanname = tr("Hard Disk "+*fsmount+" "+*fsTit+" "); 128 humanname = tr("Hard Disk "+*fsmount+" "+*fsTit+" ");
129 else if ( humanname.left(9) == "/dev/mmcd" ) 129 else if ( humanname.left(9) == "/dev/mmcd" )
130 humanname = tr("SD Card "+*fsmount+" "+*fsTit+" "); 130 humanname = tr("SD Card "+*fsmount+" "+*fsTit+" ");
131 else if ( humanname.left(7) == "/dev/hd" ) 131 else if ( humanname.left(7) == "/dev/hd" )
132 humanname = tr("Hard Disk") + " " + humanname.mid(7)+" "+*fsmount+" "+*fsTit+" "; 132 humanname = tr("Hard Disk") + " " + humanname.mid(7)+" "+*fsmount+" "+*fsTit+" ";
133 else if ( humanname.left(7) == "/dev/sd" ) 133 else if ( humanname.left(7) == "/dev/sd" )
134 humanname = tr("SCSI Hard Disk") + " " + humanname.mid(7)+" "+*fsmount+" "+*fsTit+" "; 134 humanname = tr("SCSI Hard Disk") + " " + humanname.mid(7)+" "+*fsmount+" "+*fsTit+" ";
135 else if ( humanname == "/dev/mtdblock1" || humanname == "/dev/mtdblock/1" ) 135 else if ( humanname == "/dev/mtdblock1" || humanname == "/dev/mtdblock/1" )
136 humanname = tr("Int. Storage "+*fsmount+" "+*fsTit+"\n"); 136 humanname = tr("Int. Storage "+*fsmount+" "+*fsTit+"\n");
137 else if ( humanname.left(14) == "/dev/mtdblock/" ) 137 else if ( humanname.left(14) == "/dev/mtdblock/" )
138 humanname = tr("Int. Storage") + " " + humanname.mid(14)+" "+*fsmount+" "+*fsTit+" "; 138 humanname = tr("Int. Storage") + " " + humanname.mid(14)+" "+*fsmount+" "+*fsTit+" ";
139 else if ( humanname.left(13) == "/dev/mtdblock" ) 139 else if ( humanname.left(13) == "/dev/mtdblock" )
140 humanname = tr("Int. Storage") + " " + humanname.mid(13)+" "+*fsmount+" "+*fsTit+" "; 140 humanname = tr("Int. Storage") + " " + humanname.mid(13)+" "+*fsmount+" "+*fsTit+" ";
141 else if ( humanname.left(9) == "/dev/root" ) 141 else if ( humanname.left(9) == "/dev/root" )
142 humanname = tr("Int. Storage "+*fsmount+" "+*fsTit+" "); 142 humanname = tr("Int. Storage "+*fsmount+" "+*fsTit+" ");
143 // etc. 143 // etc.
144 MountInfo* mi = new MountInfo( *fsit, humanname, this ); 144 MountInfo* mi = new MountInfo( *fsit, humanname, this );
145 vb->addWidget(mi); 145 vb->addWidget(mi);
146 disks.insert(*fsit,mi); 146 disks.insert(*fsit,mi);
147 mi->show(); 147 mi->show();
148 fsmount++;fsTit++; 148 fsmount++;fsTit++;
149 } 149 }
150 vb->addStretch(); 150 vb->addStretch();
151 } else { 151 } else {
152 // just update them 152 // just update them
153 for (QDictIterator<MountInfo> i(disks); i.current(); ++i) 153 for (QDictIterator<MountInfo> i(disks); i.current(); ++i)
154 i.current()->updateData(); 154 i.current()->updateData();
155 } 155 }
156#endif 156#endif
157} 157}
158 158
159 159
160MountInfo::MountInfo( const QString &path, const QString &ttl, QWidget *parent, const char *name ) 160MountInfo::MountInfo( const QString &path, const QString &ttl, QWidget *parent, const char *name )
161 : QWidget( parent, name ), title(ttl) 161 : QWidget( parent, name ), title(ttl)
162{ 162{
163 qDebug("new path is "+path); 163 qDebug("new path is "+path);
164 fs = new FileSystem( path ); 164 fs = new FileSystem( path );
165 QVBoxLayout *vb = new QVBoxLayout( this, 3 ); 165 QVBoxLayout *vb = new QVBoxLayout( this, 3 );
166 166
167 totalSize = new QLabel( this ); 167 totalSize = new QLabel( this );
168 vb->addWidget( totalSize ); 168 vb->addWidget( totalSize );
169 169
170 data = new GraphData(); 170 data = new GraphData();
171 graph = new BarGraph( this ); 171 graph = new BarGraph( this );
172 graph->setFrameStyle( QFrame::Panel | QFrame::Sunken ); 172 graph->setFrameStyle( QFrame::Panel | QFrame::Sunken );
173 vb->addWidget( graph, 1 ); 173 vb->addWidget( graph, 1 );
174 graph->setData( data ); 174 graph->setData( data );
175 175
176 legend = new GraphLegend( this ); 176 legend = new GraphLegend( this );
177 legend->setOrientation(Horizontal); 177 legend->setOrientation(Horizontal);
178 vb->addWidget( legend ); 178 vb->addWidget( legend );
179 legend->setData( data ); 179 legend->setData( data );
180 180
181 updateData(); 181 updateData();
182} 182}
183 183
184MountInfo::~MountInfo() 184MountInfo::~MountInfo()
185{ 185{
186 delete data; 186 delete data;
187 delete fs; 187 delete fs;
188} 188}
189 189
190void MountInfo::updateData() 190void MountInfo::updateData()
191{ 191{
192 fs->update(); 192 fs->update();
193 193
194 long mult = fs->blockSize() / 1024; 194 long mult = fs->blockSize() / 1024;
195 long div = 1024 / fs->blockSize(); 195 long div = 1024 / fs->blockSize();
196 if ( !mult ) mult = 1; 196 if ( !mult ) mult = 1;
197 if ( !div ) div = 1; 197 if ( !div ) div = 1;
198 long total = fs->totalBlocks() * mult / div; 198 long total = fs->totalBlocks() * mult / div;
199 long avail = fs->availBlocks() * mult / div; 199 long avail = fs->availBlocks() * mult / div;
200 long used = total - avail; 200 long used = total - avail;
201 totalSize->setText( title + tr(" : %1 kB").arg( total ) ); 201 totalSize->setText( title + tr(" : %1 kB").arg( total ) );
202 data->clear(); 202 data->clear();
203 data->addItem( tr("Used (%1 kB)").arg(used), used ); 203 data->addItem( tr("Used (%1 kB)").arg(used), used );
204 data->addItem( tr("Available (%1 kB)").arg(avail), avail ); 204 data->addItem( tr("Available (%1 kB)").arg(avail), avail );
205 graph->repaint( FALSE ); 205 graph->repaint( FALSE );
206 legend->update(); 206 legend->update();
207 graph->show(); 207 graph->show();
208 legend->show(); 208 legend->show();
209} 209}
210 210
211//--------------------------------------------------------------------------- 211//---------------------------------------------------------------------------
212 212
213FileSystem::FileSystem( const QString &p ) 213FileSystem::FileSystem( const QString &p )
214 : fspath( p ), blkSize(512), totalBlks(0), availBlks(0) 214 : fspath( p ), blkSize(512), totalBlks(0), availBlks(0)
215{ 215{
216 update(); 216 update();
217} 217}
218 218
219void FileSystem::update() 219void FileSystem::update()
220{ 220{
221#if defined(_OS_LINUX_) || defined(Q_OS_LINUX) 221#if defined(_OS_LINUX_) || defined(Q_OS_LINUX)
222 struct statfs fs; 222 struct statfs fs;
223 if ( !statfs( fspath.latin1(), &fs ) ) { 223 if ( !statfs( fspath.latin1(), &fs ) ) {
224 if( fspath.left(8) == "/mnt/ram") { //ugly hack openzaurus 224 blkSize = fs.f_bsize;
225 blkSize = fs.f_bsize; 225 totalBlks = fs.f_blocks;
226 totalBlks = fs.f_blocks; 226 availBlks = fs.f_bavail;
227 availBlks = fs.f_ffree; 227 } else {
228 } else { 228 blkSize = 0;
229 blkSize = fs.f_bsize; 229 totalBlks = 0;
230 totalBlks = fs.f_blocks; 230 availBlks = 0;
231 availBlks = fs.f_bavail; 231 }
232 }
233 } else {
234 blkSize = 0;
235 totalBlks = 0;
236 availBlks = 0;
237 }
238#endif 232#endif
239} 233}
240 234