-rw-r--r-- | noncore/settings/sysinfo/config.in | 3 | ||||
-rw-r--r-- | noncore/settings/sysinfo/devicesinfo.cpp | 148 | ||||
-rw-r--r-- | noncore/settings/sysinfo/devicesinfo.h | 66 |
3 files changed, 172 insertions, 45 deletions
diff --git a/noncore/settings/sysinfo/config.in b/noncore/settings/sysinfo/config.in index 349dbdc..0c558dd 100644 --- a/noncore/settings/sysinfo/config.in +++ b/noncore/settings/sysinfo/config.in @@ -1,4 +1,7 @@ config SYSINFO boolean "opie-sysinfo (System Information dialog)" default "y" depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE2CORE && LIBOPIE2UI + comment "opie-sysinfo needs a libqpe, libopie2core, libopie2ui" + depends !( ( LIBQPE || LIBQPE-X11 ) && LIBOPIE2CORE && LIBOPIE2UI ) + diff --git a/noncore/settings/sysinfo/devicesinfo.cpp b/noncore/settings/sysinfo/devicesinfo.cpp index f1efb33..6508d3c 100644 --- a/noncore/settings/sysinfo/devicesinfo.cpp +++ b/noncore/settings/sysinfo/devicesinfo.cpp @@ -24,23 +24,23 @@ _;:, .> :=|. This program is free software; you can If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "devicesinfo.h" - /* OPIE */ #include <opie2/odebug.h> #include <opie2/oinputsystem.h> #include <opie2/olayout.h> #include <opie2/olistview.h> #include <qpe/qpeapplication.h> using namespace Opie::Core; using namespace Opie::Ui; /* QT */ +#include <qobjectlist.h> #include <qlistview.h> #include <qcombobox.h> #include <qfile.h> #include <qpushbutton.h> #include <qtextstream.h> #include <qtextview.h> @@ -70,39 +70,53 @@ DevicesView::~DevicesView() } void DevicesView::selectionChanged( QListViewItem* item ) { odebug << "DevicesView::selectionChanged to '" << item->text( 0 ) << "'" << oendl; - QWidget* details = ( static_cast<Device*>( item ) )->detailsWidget(); - ( static_cast<DevicesInfo*>( parent() ) )->setDetailsWidget( details ); + if ( item->parent() ) + { + QWidget* details = ( static_cast<Device*>( item ) )->detailsWidget(); + ( static_cast<DevicesInfo*>( parent() ) )->setDetailsWidget( details ); + } + else + { + odebug << "DevicesView::not a device node." << oendl; + } } //================================================================================================= DevicesInfo::DevicesInfo( QWidget* parent, const char* name, WFlags fl ) :QWidget( parent, name, fl ), details( 0 ) { layout = new OAutoBoxLayout( this ); - layout->setSpacing( 4 ); - layout->setMargin( 4 ); + layout->setSpacing( 2 ); + layout->setMargin( 2 ); view = new DevicesView( this ); - layout->addWidget( view ); + layout->addWidget( view, 100 ); + stack = new QWidgetStack( this ); + layout->addWidget( stack, 70 ); } DevicesInfo::~DevicesInfo() { } void DevicesInfo::setDetailsWidget( QWidget* w ) { - if ( details ) delete( details ); - layout->addWidget( w ); - w->show(); + if ( details ) + { + qDebug( "hiding widget '%s' ('%s')", details->name(), details->className() ); + stack->removeWidget( w ); + } + + stack->addWidget( details = w, 40 ); + stack->raiseWidget( details ); } //================================================================================================= Category::Category( DevicesView* parent, const QString& name ) :OListViewItem( parent, name ) @@ -112,28 +126,12 @@ Category::Category( DevicesView* parent, const QString& name ) Category::~Category() { } //================================================================================================= -Device::Device( Category* parent, const QString& name ) - :OListViewItem( parent, name ) -{ -} - -Device::~Device() -{ -} - -QWidget* Device::detailsWidget() -{ - return new QPushButton( static_cast<QWidget*>( listView()->parent() ), "Press Button to self-destruct" ); -} - - -//================================================================================================= CpuCategory::CpuCategory( DevicesView* parent ) :Category( parent, "1. Central Processing Unit" ) { } CpuCategory::~CpuCategory() @@ -143,29 +141,32 @@ CpuCategory::~CpuCategory() void CpuCategory::populate() { odebug << "CpuCategory::populate()" << oendl; QFile cpuinfofile( "/proc/cpuinfo" ); if ( !cpuinfofile.exists() || !cpuinfofile.open( IO_ReadOnly ) ) { - new OListViewItem( this, "ERROR: /proc/cpuinfo not found or unaccessible" ); + new CpuDevice( this, "ERROR: /proc/cpuinfo not found or unaccessible" ); return; } QTextStream cpuinfo( &cpuinfofile ); int cpucount = 0; + CpuDevice* dev = 0; + while ( !cpuinfo.atEnd() ) { QString line = cpuinfo.readLine(); odebug << "got line '" << line << "'" << oendl; if ( line.startsWith( "processor" ) ) { - new OListViewItem( this, QString( "CPU #%1" ).arg( cpucount++ ) ); + dev = new CpuDevice( this, QString( "CPU #%1" ).arg( cpucount++ ) ); + dev->addInfo( line ); } else { - continue; + if ( dev ) dev->addInfo( line ); } } } //================================================================================================= InputCategory::InputCategory( DevicesView* parent ) @@ -182,13 +183,13 @@ void InputCategory::populate() odebug << "InputCategory::populate()" << oendl; OInputSystem* sys = OInputSystem::instance(); OInputSystem::DeviceIterator it = sys->iterator(); while ( it.current() ) { OInputDevice* dev = it.current(); - new OListViewItem( this, dev->identity() ); + new InputDevice( this, dev->identity() ); ++it; } } //================================================================================================= CardsCategory::CardsCategory( DevicesView* parent ) @@ -207,23 +208,23 @@ void CardsCategory::populate() if ( QFile::exists( "/var/run/stab" ) ) { fileName = "/var/run/stab"; } else if ( QFile::exists( "/var/state/pcmcia/stab" ) ) { fileName = "/var/state/pcmcia/stab"; } else { fileName = "/var/lib/pcmcia/stab"; } QFile cardinfofile( fileName ); if ( !cardinfofile.exists() || !cardinfofile.open( IO_ReadOnly ) ) { - new OListViewItem( this, "ERROR: pcmcia info file not found or unaccessible" ); + new CardDevice( this, "ERROR: pcmcia info file not found or unaccessible" ); return; } QTextStream cardinfo( &cardinfofile ); while ( !cardinfo.atEnd() ) { QString line = cardinfo.readLine(); odebug << "got line '" << line << "'" << oendl; - if ( line.startsWith("Socket") ) + if ( line.startsWith( "Socket" ) ) { - new OListViewItem( this, line ); + new CardDevice( this, line ); } else { continue; } } @@ -242,13 +243,13 @@ UsbCategory::~UsbCategory() void UsbCategory::populate() { odebug << "UsbCategory::populate()" << oendl; QFile usbinfofile( "/proc/bus/usb/devices" ); if ( !usbinfofile.exists() || !usbinfofile.open( IO_ReadOnly ) ) { - new OListViewItem( this, "ERROR: /proc/bus/usb/devices not found or unaccessible" ); + new UsbDevice( this, "ERROR: /proc/bus/usb/devices not found or unaccessible" ); return; } QTextStream usbinfo( &usbinfofile ); int _bus, _level, _parent, _port, _count, _device, _channels, _power; float _speed; @@ -256,19 +257,96 @@ void UsbCategory::populate() int usbcount = 0; while ( !usbinfo.atEnd() ) { QString line = usbinfo.readLine(); odebug << "got line '" << line << "'" << oendl; - if ( line.startsWith("T:") ) + if ( line.startsWith( "T:" ) ) { sscanf(line.local8Bit().data(), "T: Bus=%2d Lev=%2d Prnt=%2d Port=%d Cnt=%2d Dev#=%3d Spd=%3f MxCh=%2d", &_bus, &_level, &_parent, &_port, &_count, &_device, &_speed, &_channels); - new OListViewItem( this, QString( "USB Device #%1" ).arg( usbcount++ ) ); + new UsbDevice( this, QString( "USB Device #%1" ).arg( usbcount++ ) ); } else { continue; } } } + +//================================================================================================= +Device::Device( Category* parent, const QString& name ) + :OListViewItem( parent, name ) +{ + devinfo = static_cast<QWidget*>( listView()->parent() ); +} + +Device::~Device() +{ +} + + +QWidget* Device::detailsWidget() +{ + return details; +} + +//================================================================================================= +CpuDevice::CpuDevice( Category* parent, const QString& name ) + :Device( parent, name ) +{ + OListView* w = new OListView( devinfo ); + details = w; + w->addColumn( "Info" ); + w->addColumn( "Value" ); + w->hide(); +} + +CpuDevice::~CpuDevice() +{ +} + +void CpuDevice::addInfo( const QString& info ) +{ + int dp = info.find( ':' ); + if ( dp != -1 ) + { + new OListViewItem( (OListView*) details, info.left( dp ), info.right( info.length()-dp ) ); + } +} + +//================================================================================================= +CardDevice::CardDevice( Category* parent, const QString& name ) + :Device( parent, name ) +{ + details = new QPushButton( name, devinfo ); + details->hide(); +} + +CardDevice::~CardDevice() +{ +} + +//================================================================================================= +InputDevice::InputDevice( Category* parent, const QString& name ) + :Device( parent, name ) +{ + details = new QPushButton( name, devinfo ); + details->hide(); +} + +InputDevice::~InputDevice() +{ +} + +//================================================================================================= +UsbDevice::UsbDevice( Category* parent, const QString& name ) + :Device( parent, name ) +{ + details = new QPushButton( name, devinfo ); + details->hide(); +} + +UsbDevice::~UsbDevice() +{ +} diff --git a/noncore/settings/sysinfo/devicesinfo.h b/noncore/settings/sysinfo/devicesinfo.h index b065f40..586d204 100644 --- a/noncore/settings/sysinfo/devicesinfo.h +++ b/noncore/settings/sysinfo/devicesinfo.h @@ -32,12 +32,13 @@ _;:, .> :=|. This program is free software; you can /* OPIE */ #include <opie2/olistview.h> #include <opie2/olayout.h> /* QT */ #include <qwidget.h> +#include <qwidgetstack.h> //================================================================================================= class DevicesView : public Opie::Ui::OListView { Q_OBJECT public: @@ -58,12 +59,13 @@ public: void setDetailsWidget( QWidget* w = 0 ); private: Opie::Ui::OAutoBoxLayout* layout; Opie::Ui::OListView* view; QWidget* details; + QWidgetStack* stack; private slots: }; //================================================================================================= class Category : public Opie::Ui::OListViewItem { @@ -72,22 +74,12 @@ public: virtual ~Category(); virtual void populate() = 0; }; //================================================================================================= -class Device : public Opie::Ui::OListViewItem -{ -public: - Device( Category* parent, const QString& name ); - ~Device(); - - QWidget* detailsWidget(); -}; - -//================================================================================================= class CpuCategory : public Category { public: CpuCategory( DevicesView* parent ); virtual ~CpuCategory(); @@ -121,8 +113,62 @@ public: UsbCategory( DevicesView* parent ); virtual ~UsbCategory(); virtual void populate(); }; +//================================================================================================= +class Device : public Opie::Ui::OListViewItem +{ +public: + Device( Category* parent, const QString& name ); + ~Device(); + + QWidget* devinfo; + QWidget* details; + + virtual QWidget* detailsWidget(); +}; + +//================================================================================================= +class CpuDevice : public Device +{ +public: + CpuDevice( Category* parent, const QString& name ); + ~CpuDevice(); + + void addInfo( const QString& line ); + +// virtual QWidget* detailsWidget(); +}; + +//================================================================================================= +class InputDevice : public Device +{ +public: + InputDevice( Category* parent, const QString& name ); + ~InputDevice(); + +// virtual QWidget* detailsWidget(); +}; + +//================================================================================================= +class CardDevice : public Device +{ +public: + CardDevice( Category* parent, const QString& name ); + ~CardDevice(); + +// virtual QWidget* detailsWidget(); +}; + +//================================================================================================= +class UsbDevice : public Device +{ +public: + UsbDevice( Category* parent, const QString& name ); + ~UsbDevice(); + +// virtual QWidget* detailsWidget(); +}; #endif |