summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2002-07-20 19:24:20 (UTC)
committer llornkcor <llornkcor>2002-07-20 19:24:20 (UTC)
commit2ba2f7293e6b7b7b54e733ff84e0b57f0dbc3dfc (patch) (side-by-side diff)
tree54721319a2e07ebda9def3f139f7302c64fef886
parent8c335cfdfffede8b7a864566ec4d9507a2978684 (diff)
downloadopie-2ba2f7293e6b7b7b54e733ff84e0b57f0dbc3dfc.zip
opie-2ba2f7293e6b7b7b54e733ff84e0b57f0dbc3dfc.tar.gz
opie-2ba2f7293e6b7b7b54e733ff84e0b57f0dbc3dfc.tar.bz2
ok, here ya go.
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
@@ -158,83 +158,77 @@ void StorageInfo::updateMounts()
MountInfo::MountInfo( const QString &path, const QString &ttl, QWidget *parent, const char *name )
: QWidget( parent, name ), title(ttl)
{
qDebug("new path is "+path);
fs = new FileSystem( path );
QVBoxLayout *vb = new QVBoxLayout( this, 3 );
totalSize = new QLabel( this );
vb->addWidget( totalSize );
data = new GraphData();
graph = new BarGraph( this );
graph->setFrameStyle( QFrame::Panel | QFrame::Sunken );
vb->addWidget( graph, 1 );
graph->setData( data );
legend = new GraphLegend( this );
legend->setOrientation(Horizontal);
vb->addWidget( legend );
legend->setData( data );
updateData();
}
MountInfo::~MountInfo()
{
delete data;
delete fs;
}
void MountInfo::updateData()
{
fs->update();
long mult = fs->blockSize() / 1024;
long div = 1024 / fs->blockSize();
if ( !mult ) mult = 1;
if ( !div ) div = 1;
long total = fs->totalBlocks() * mult / div;
long avail = fs->availBlocks() * mult / div;
long used = total - avail;
totalSize->setText( title + tr(" : %1 kB").arg( total ) );
data->clear();
data->addItem( tr("Used (%1 kB)").arg(used), used );
data->addItem( tr("Available (%1 kB)").arg(avail), avail );
graph->repaint( FALSE );
legend->update();
graph->show();
legend->show();
}
//---------------------------------------------------------------------------
FileSystem::FileSystem( const QString &p )
: fspath( p ), blkSize(512), totalBlks(0), availBlks(0)
{
update();
}
void FileSystem::update()
{
#if defined(_OS_LINUX_) || defined(Q_OS_LINUX)
- struct statfs fs;
- if ( !statfs( fspath.latin1(), &fs ) ) {
- if( fspath.left(8) == "/mnt/ram") { //ugly hack openzaurus
- blkSize = fs.f_bsize;
- totalBlks = fs.f_blocks;
- availBlks = fs.f_ffree;
- } else {
- blkSize = fs.f_bsize;
- totalBlks = fs.f_blocks;
- availBlks = fs.f_bavail;
- }
- } else {
- blkSize = 0;
- totalBlks = 0;
- availBlks = 0;
- }
+ struct statfs fs;
+ if ( !statfs( fspath.latin1(), &fs ) ) {
+ blkSize = fs.f_bsize;
+ totalBlks = fs.f_blocks;
+ availBlks = fs.f_bavail;
+ } else {
+ blkSize = 0;
+ totalBlks = 0;
+ availBlks = 0;
+ }
#endif
}