summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/sysinfo/storage.cpp198
-rw-r--r--noncore/settings/sysinfo/storage.h44
-rw-r--r--noncore/settings/sysinfo/sysinfo.cpp2
-rw-r--r--noncore/settings/sysinfo/versioninfo.cpp23
4 files changed, 95 insertions, 172 deletions
diff --git a/noncore/settings/sysinfo/storage.cpp b/noncore/settings/sysinfo/storage.cpp
index eb157ef..c4474d5 100644
--- a/noncore/settings/sysinfo/storage.cpp
+++ b/noncore/settings/sysinfo/storage.cpp
@@ -19,4 +19,7 @@
**********************************************************************/
// additions copyright 2002 by L.J. Potter
+
+#include <qpe/storage.h>
+
#include <qlabel.h>
#include <qlayout.h>
@@ -34,95 +37,61 @@
#endif
-StorageInfo::StorageInfo( QWidget *parent, const char *name )
+FileSysInfo::FileSysInfo( QWidget *parent, const char *name )
: QWidget( parent, name )
{
- QVBoxLayout *tmpvb = new QVBoxLayout( this );
- QScrollView *sv = new QScrollView( this );
- tmpvb->addWidget( sv, 0, 0 );
- sv->setResizePolicy( QScrollView::AutoOneFit );
- sv->setFrameStyle( QFrame::NoFrame );
- container = new QWidget( sv->viewport() );
- sv->addChild( container );
+ QVBoxLayout *tmpvb = new QVBoxLayout( this );
+ QScrollView *sv = new QScrollView( this );
+ tmpvb->addWidget( sv, 0, 0 );
+ sv->setResizePolicy( QScrollView::AutoOneFit );
+ sv->setFrameStyle( QFrame::NoFrame );
+ container = new QWidget( sv->viewport() );
+ sv->addChild( container );
vb = 0x0;
- disks.setAutoDelete(TRUE);
+ storage = new StorageInfo( this );
+ connect( storage, SIGNAL( disksChanged() ), this, SLOT( disksChanged() ) );
+
lines.setAutoDelete(TRUE);
+
+ rebuildDisks = TRUE;
updateMounts();
startTimer( 5000 );
}
-void StorageInfo::timerEvent(QTimerEvent*)
+void FileSysInfo::timerEvent(QTimerEvent*)
{
updateMounts();
}
-static bool isCF(const QString& m)
-{
- FILE* f = fopen("/var/run/stab", "r");
- if (!f) f = fopen("/var/state/pcmcia/stab", "r");
- if (!f) f = fopen("/var/lib/pcmcia/stab", "r");
- if ( f ) {
- char line[1024];
- char devtype[80];
- char devname[80];
- while ( fgets( line, 1024, f ) ) {
- // 0 ide ide-cs 0 hda 3 0
- if ( sscanf(line,"%*d %s %*s %*s %s", devtype, devname )==2 ) {
- if ( QString(devtype) == "ide" && m.find(devname)>0 ) {
- fclose(f);
- return TRUE;
- }
- }
- }
- fclose(f);
- }
- return FALSE;
-}
-
-void StorageInfo::updateMounts()
+void FileSysInfo::updateMounts()
{
-#if defined(_OS_LINUX_) || defined(Q_OS_LINUX)
- struct mntent *me;
- FILE *mntfp = setmntent( "/etc/mtab", "r" );
- QStringList curdisks;
- QStringList curfs;
- QStringList mountList;
- QStringList fsT;
- bool rebuild = FALSE;
- int n=0;
- if ( mntfp ) {
- while ( (me = getmntent( mntfp )) != 0 ) {
- QString fs = me->mnt_fsname;
- if ( fs.left(7)=="/dev/hd" || fs.left(7)=="/dev/sd"
- || fs.left(8)=="/dev/mtd" || fs.left(9) == "/dev/mmcd"
- || fs.left(9) == "/dev/root" || fs.left(5) == "/ramfs"
- || fs.left(5) == "tmpfs" ) {
- n++;
- curdisks.append(fs);
- QString d = me->mnt_dir;
- curfs.append(d);
- QString mount = me->mnt_dir;
- mountList.append(mount);
- QString t = me->mnt_type;
- fsT.append(t);
- if ( !disks.find(d) )
- rebuild = TRUE;
- }
+ storage->update();
+
+ if ( rebuildDisks )
+ {
+ // Cannot auto delete QDict<MountInfo> disks because it seems to delete
+ // the filesystem object as well causing a segfault
+ MountInfo *mi;
+ for ( QDictIterator<MountInfo> delit(disks); delit.current(); ++delit )
+ {
+ mi = delit.current();
+ mi->fs = 0x0;
+ delete mi;
}
- endmntent( mntfp );
- }
- if ( rebuild || n != (int)disks.count() ) {
disks.clear();
lines.clear();
+
delete vb;
vb = new QVBoxLayout( container/*, n > 3 ? 1 : 5*/ );
- bool frst=TRUE;
- QStringList::ConstIterator it = curdisks.begin();
- QStringList::ConstIterator fsit = curfs.begin();
- QStringList::ConstIterator fsmount = mountList.begin();
- QStringList::ConstIterator fsTit = fsT.begin();
- for (; it!=curdisks.end(); ++it, ++fsit) {
- if ( !frst ) {
+ bool frst=TRUE;
+
+ FileSystem *fs;
+ for ( QListIterator<FileSystem> it(storage->fileSystems()); it.current(); ++it )
+ {
+ fs = it.current();
+
+ if ( !frst )
+ {
QFrame *f = new QFrame( container );
vb->addWidget(f);
@@ -130,39 +99,12 @@ void StorageInfo::updateMounts()
lines.append(f);
f->show();
- } frst=FALSE;
- QString humanname=*it;
- if ( isCF(humanname) )
- humanname = tr( "CF Card: " );
- else if ( humanname == "/dev/hda1" )
- humanname = tr( "Hard Disk " );
-
- else if ( humanname.left(9) == "/dev/mmcd" )
- humanname = tr( "SD Card " );
-
- else if ( humanname.left(7) == "/dev/hd" )
- humanname = tr( "Hard Disk /dev/hd " );
-
- else if ( humanname.left(7) == "/dev/sd" )
- humanname = tr( "SCSI Hard Disk /dev/sd " );
-
- else if ( humanname == "/dev/mtdblock1"
- || humanname.left(13) == "/dev/mtdblock"
- || humanname.left(9) == "/dev/root")
- humanname = tr( "Int. Storage " );
-
- else if ( humanname.left(5) == "tmpfs" )
- humanname = tr( "RAM disk" );
- // etc.
- humanname.append( *fsmount );
- humanname.append( " " );
- humanname.append( *fsTit );
- humanname.append( " " );
-
- MountInfo* mi = new MountInfo( *fsit, humanname, container );
- vb->addWidget(mi);
- disks.insert(*fsit,mi);
+ }
+ frst = FALSE;
+
+ MountInfo *mi = new MountInfo( fs, container );
+ vb->addWidget( mi );
+ disks.insert( fs->path(), mi );
mi->show();
- fsmount++;fsTit++;
- QString tempstr = humanname.left( 2 );
+ QString tempstr = fs->name().left( 2 );
if ( tempstr == tr( "CF" ) )
QWhatsThis::add( mi, tr( "This graph represents how much memory is currently used on this Compact Flash memory card." ) );
@@ -179,17 +121,22 @@ void StorageInfo::updateMounts()
}
vb->addStretch();
- } else {
- // just update them
+ }
+ else
+ {
for (QDictIterator<MountInfo> i(disks); i.current(); ++i)
i.current()->updateData();
}
-#endif
+
+ rebuildDisks = FALSE;
}
+void FileSysInfo::disksChanged()
+{
+ rebuildDisks = TRUE;
+}
-MountInfo::MountInfo( const QString &path, const QString &ttl, QWidget *parent, const char *name )
- : QWidget( parent, name ), title(ttl)
+MountInfo::MountInfo( FileSystem *filesys, QWidget *parent, const char *name )
+ : QWidget( parent, name )
{
- fs = new FileSystem( path );
QVBoxLayout *vb = new QVBoxLayout( this, 3 );
@@ -197,4 +144,7 @@ MountInfo::MountInfo( const QString &path, const QString &ttl, QWidget *parent,
vb->addWidget( totalSize );
+ fs = filesys;
+ title = fs->name();
+
data = new GraphData();
graph = new BarGraph( this );
@@ -219,6 +169,4 @@ MountInfo::~MountInfo()
void MountInfo::updateData()
{
- fs->update();
-
long mult = fs->blockSize() / 1024;
long div = 1024 / fs->blockSize();
@@ -238,26 +186,2 @@ void MountInfo::updateData()
}
-//---------------------------------------------------------------------------
-
-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 ) ) {
- blkSize = fs.f_bsize;
- totalBlks = fs.f_blocks;
- availBlks = fs.f_bavail;
- } else {
- blkSize = 0;
- totalBlks = 0;
- availBlks = 0;
- }
-#endif
-}
-
diff --git a/noncore/settings/sysinfo/storage.h b/noncore/settings/sysinfo/storage.h
index 7e8b4e0..b8564af 100644
--- a/noncore/settings/sysinfo/storage.h
+++ b/noncore/settings/sysinfo/storage.h
@@ -31,11 +31,12 @@ class MountInfo;
class QVBoxLayout;
class QWidget;
+class StorageInfo;
-class StorageInfo : public QWidget
+class FileSysInfo : public QWidget
{
Q_OBJECT
public:
- StorageInfo( QWidget *parent=0, const char *name=0 );
+ FileSysInfo( QWidget *parent=0, const char *name=0 );
protected:
@@ -44,8 +45,16 @@ protected:
private:
void updateMounts();
- QDict<MountInfo> disks;
- QList<QFrame> lines;
+
+ QWidget *container;
QVBoxLayout *vb;
- QWidget *container;
+
+ StorageInfo *storage;
+ QDict<MountInfo> disks;
+ QList<QFrame> lines;
+
+ bool rebuildDisks;
+
+private slots:
+ void disksChanged();
};
@@ -54,12 +63,13 @@ class MountInfo : public QWidget
Q_OBJECT
public:
- MountInfo( const QString &path, const QString &ttl, QWidget *parent=0, const char *name=0 );
+ MountInfo( FileSystem *filesys=0, QWidget *parent=0, const char *name=0 );
~MountInfo();
void updateData();
+
+ FileSystem *fs;
private:
QString title;
- FileSystem *fs;
QLabel *totalSize;
GraphData *data;
@@ -68,22 +78,2 @@ private:
};
-class FileSystem
-{
-public:
- FileSystem( const QString &p );
-
- void update();
-
- const QString &path() const { return fspath; }
- long blockSize() const { return blkSize; }
- long totalBlocks() const { return totalBlks; }
- long availBlocks() const { return availBlks; }
-
-private:
- QString fspath;
- long blkSize;
- long totalBlks;
- long availBlks;
-};
-
-
diff --git a/noncore/settings/sysinfo/sysinfo.cpp b/noncore/settings/sysinfo/sysinfo.cpp
index c3bdae5..0c5a969 100644
--- a/noncore/settings/sysinfo/sysinfo.cpp
+++ b/noncore/settings/sysinfo/sysinfo.cpp
@@ -55,5 +55,5 @@ SystemInfo::SystemInfo( QWidget *parent, const char *name, WFlags )
tab->addTab( new MemoryInfo( tab ), "sysinfo/memorytabicon", tr("Memory") );
#if defined(_OS_LINUX_) || defined(Q_OS_LINUX)
- tab->addTab( new StorageInfo( tab ), "sysinfo/storagetabicon", tr("Storage") );
+ tab->addTab( new FileSysInfo( tab ), "sysinfo/storagetabicon", tr("Storage") );
#endif
tab->addTab( new LoadInfo( tab ), "sysinfo/cputabicon", tr("CPU") );
diff --git a/noncore/settings/sysinfo/versioninfo.cpp b/noncore/settings/sysinfo/versioninfo.cpp
index 9a444df..801af29 100644
--- a/noncore/settings/sysinfo/versioninfo.cpp
+++ b/noncore/settings/sysinfo/versioninfo.cpp
@@ -28,4 +28,5 @@
#include <qpixmap.h>
#include <qpainter.h>
+#include <qscrollview.h>
#include <qtextstream.h>
#include <qtimer.h>
@@ -43,5 +44,13 @@ VersionInfo::VersionInfo( QWidget *parent, const char *name, WFlags f )
setMinimumSize( 200, 150 );
- QVBoxLayout *vb = new QVBoxLayout( this, 4 );
+ QVBoxLayout *tmpvb = new QVBoxLayout( this );
+ QScrollView *sv = new QScrollView( this );
+ tmpvb->addWidget( sv, 0, 0 );
+ sv->setResizePolicy( QScrollView::AutoOneFit );
+ sv->setFrameStyle( QFrame::NoFrame );
+ QWidget *container = new QWidget( sv->viewport() );
+ sv->addChild( container );
+
+ QVBoxLayout *vb = new QVBoxLayout( container, 4 );
QString kernelVersionString;
@@ -79,5 +88,5 @@ VersionInfo::VersionInfo( QWidget *parent, const char *name, WFlags f )
hb1->setSpacing( 2 );
- QLabel *palmtopLogo = new QLabel( this );
+ QLabel *palmtopLogo = new QLabel( container );
QImage logo1 = Resource::loadImage( "logo/opielogo" );
logo1 = logo1.smoothScale( 50, 55 );
@@ -88,5 +97,5 @@ VersionInfo::VersionInfo( QWidget *parent, const char *name, WFlags f )
hb1->addWidget( palmtopLogo, 0, Qt::AlignTop + Qt::AlignLeft );
- QLabel *palmtopVersion = new QLabel( this );
+ QLabel *palmtopVersion = new QLabel( container );
palmtopVersion->setText( palmtopVersionString );
hb1->addWidget( palmtopVersion, 1, Qt::AlignTop + Qt::AlignLeft );
@@ -96,5 +105,5 @@ VersionInfo::VersionInfo( QWidget *parent, const char *name, WFlags f )
hb1->setSpacing( 2 );
- QLabel *linuxLogo = new QLabel( this );
+ QLabel *linuxLogo = new QLabel( container );
QImage logo2 = Resource::loadImage( "logo/tux-logo" );
logo2 = logo2.smoothScale( 55, 60 );
@@ -105,5 +114,5 @@ VersionInfo::VersionInfo( QWidget *parent, const char *name, WFlags f )
hb2->addWidget( linuxLogo, 0, Qt::AlignTop + Qt::AlignLeft );
- QLabel *kernelVersion = new QLabel( this );
+ QLabel *kernelVersion = new QLabel( container );
kernelVersion->setText( kernelVersionString );
hb2->addWidget( kernelVersion, 1, Qt::AlignTop + Qt::AlignLeft );
@@ -113,5 +122,5 @@ VersionInfo::VersionInfo( QWidget *parent, const char *name, WFlags f )
hb3->setSpacing( 2 );
- QLabel *palmtopLogo3 = new QLabel( this );
+ QLabel *palmtopLogo3 = new QLabel( container );
QImage logo3 = Resource::loadImage( "sysinfo/pda" );
logo3 = logo3.smoothScale( 50, 55 );
@@ -132,5 +141,5 @@ VersionInfo::VersionInfo( QWidget *parent, const char *name, WFlags f )
systemString.append( ODevice::inst()->vendorString() );
- QLabel *systemVersion = new QLabel( this );
+ QLabel *systemVersion = new QLabel( container );
systemVersion->setText( systemString );
hb3->addWidget( systemVersion, 1, Qt::AlignTop + Qt::AlignLeft );