summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--noncore/settings/sysinfo/storage.cpp174
-rw-r--r--noncore/settings/sysinfo/storage.h42
-rw-r--r--noncore/settings/sysinfo/sysinfo.cpp2
-rw-r--r--noncore/settings/sysinfo/versioninfo.cpp23
4 files changed, 82 insertions, 159 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
@@ -18,6 +18,9 @@
**
**********************************************************************/
// additions copyright 2002 by L.J. Potter
+
+#include <qpe/storage.h>
+
#include <qlabel.h>
#include <qlayout.h>
#include <qscrollview.h>
@@ -33,7 +36,7 @@
#include <mntent.h>
#endif
-StorageInfo::StorageInfo( QWidget *parent, const char *name )
+FileSysInfo::FileSysInfo( QWidget *parent, const char *name )
: QWidget( parent, name )
{
QVBoxLayout *tmpvb = new QVBoxLayout( this );
@@ -45,125 +48,64 @@ StorageInfo::StorageInfo( QWidget *parent, const char *name )
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)
+void FileSysInfo::updateMounts()
{
- 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;
-}
+ storage->update();
-void StorageInfo::updateMounts()
+ if ( rebuildDisks )
{
-#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;
- }
- }
- endmntent( mntfp );
+ // 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;
}
- 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 ) {
+ FileSystem *fs;
+ for ( QListIterator<FileSystem> it(storage->fileSystems()); it.current(); ++it )
+ {
+ fs = it.current();
+
+ if ( !frst )
+ {
QFrame *f = new QFrame( container );
vb->addWidget(f);
f->setFrameStyle( QFrame::HLine | QFrame::Sunken );
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( " " );
+ }
+ frst = FALSE;
- MountInfo* mi = new MountInfo( *fsit, humanname, container );
+ MountInfo *mi = new MountInfo( fs, container );
vb->addWidget(mi);
- disks.insert(*fsit,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." ) );
else if ( tempstr == tr( "Ha" ) )
@@ -178,24 +120,32 @@ void StorageInfo::updateMounts()
QWhatsThis::add( mi, tr( "This graph represents how much memory is currently used of the temporary RAM disk." ) );
}
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 );
totalSize = new QLabel( this );
vb->addWidget( totalSize );
+ fs = filesys;
+ title = fs->name();
+
data = new GraphData();
graph = new BarGraph( this );
graph->setFrameStyle( QFrame::Panel | QFrame::Sunken );
@@ -218,8 +168,6 @@ MountInfo::~MountInfo()
void MountInfo::updateData()
{
- fs->update();
-
long mult = fs->blockSize() / 1024;
long div = 1024 / fs->blockSize();
if ( !mult ) mult = 1;
@@ -237,27 +185,3 @@ void MountInfo::updateData()
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 ) ) {
- 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
@@ -30,60 +30,50 @@ class FileSystem;
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:
void timerEvent(QTimerEvent*);
private:
void updateMounts();
+
+ QWidget *container;
+ QVBoxLayout *vb;
+
+ StorageInfo *storage;
QDict<MountInfo> disks;
QList<QFrame> lines;
- QVBoxLayout *vb;
- QWidget *container;
+
+ bool rebuildDisks;
+
+private slots:
+ void disksChanged();
};
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;
Graph *graph;
GraphLegend *legend;
};
-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
@@ -54,7 +54,7 @@ SystemInfo::SystemInfo( QWidget *parent, const char *name, WFlags )
lay->addWidget( tab );
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") );
if ( advanced )
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
@@ -27,6 +27,7 @@
#include <qlayout.h>
#include <qpixmap.h>
#include <qpainter.h>
+#include <qscrollview.h>
#include <qtextstream.h>
#include <qtimer.h>
#include <qwhatsthis.h>
@@ -42,7 +43,15 @@ 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;
QFile file( "/proc/version" );
@@ -78,7 +87,7 @@ VersionInfo::VersionInfo( QWidget *parent, const char *name, WFlags f )
QHBoxLayout *hb1 = new QHBoxLayout( vb );
hb1->setSpacing( 2 );
- QLabel *palmtopLogo = new QLabel( this );
+ QLabel *palmtopLogo = new QLabel( container );
QImage logo1 = Resource::loadImage( "logo/opielogo" );
logo1 = logo1.smoothScale( 50, 55 );
QPixmap logo1Pixmap;
@@ -87,7 +96,7 @@ VersionInfo::VersionInfo( QWidget *parent, const char *name, WFlags f )
palmtopLogo->setFixedSize( 60, 60 );
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 );
@@ -95,7 +104,7 @@ VersionInfo::VersionInfo( QWidget *parent, const char *name, WFlags f )
QHBoxLayout *hb2 = new QHBoxLayout( vb );
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 );
QPixmap logo2Pixmap;
@@ -104,7 +113,7 @@ VersionInfo::VersionInfo( QWidget *parent, const char *name, WFlags f )
linuxLogo->setFixedSize( 60, 60 );
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 );
@@ -112,7 +121,7 @@ VersionInfo::VersionInfo( QWidget *parent, const char *name, WFlags f )
QHBoxLayout *hb3 = new QHBoxLayout( vb );
hb3->setSpacing( 2 );
- QLabel *palmtopLogo3 = new QLabel( this );
+ QLabel *palmtopLogo3 = new QLabel( container );
QImage logo3 = Resource::loadImage( "sysinfo/pda" );
logo3 = logo3.smoothScale( 50, 55 );
QPixmap logo3Pixmap;
@@ -131,7 +140,7 @@ VersionInfo::VersionInfo( QWidget *parent, const char *name, WFlags f )
systemString.append( tr( "<p>Vendor: " ) );
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 );