Diffstat (limited to 'noncore/settings/sysinfo/devicesinfo.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/settings/sysinfo/devicesinfo.cpp | 140 |
1 files changed, 109 insertions, 31 deletions
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 @@ -29,3 +29,2 @@ _;:, .> :=|. This program is free software; you can #include "devicesinfo.h" - /* OPIE */ @@ -40,2 +39,3 @@ using namespace Opie::Ui; /* QT */ +#include <qobjectlist.h> #include <qlistview.h> @@ -75,2 +75,4 @@ void DevicesView::selectionChanged( QListViewItem* item ) odebug << "DevicesView::selectionChanged to '" << item->text( 0 ) << "'" << oendl; + if ( item->parent() ) + { QWidget* details = ( static_cast<Device*>( item ) )->detailsWidget(); @@ -78,2 +80,7 @@ void DevicesView::selectionChanged( QListViewItem* item ) } + else + { + odebug << "DevicesView::not a device node." << oendl; + } +} @@ -85,6 +92,8 @@ DevicesInfo::DevicesInfo( QWidget* parent, const char* name, WFlags fl ) 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 ); } @@ -99,5 +108,10 @@ 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 ); } @@ -117,18 +131,2 @@ 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 ) @@ -148,3 +146,3 @@ void CpuCategory::populate() { - new OListViewItem( this, "ERROR: /proc/cpuinfo not found or unaccessible" ); + new CpuDevice( this, "ERROR: /proc/cpuinfo not found or unaccessible" ); return; @@ -154,2 +152,4 @@ void CpuCategory::populate() int cpucount = 0; + CpuDevice* dev = 0; + while ( !cpuinfo.atEnd() ) @@ -160,3 +160,4 @@ void CpuCategory::populate() { - new OListViewItem( this, QString( "CPU #%1" ).arg( cpucount++ ) ); + dev = new CpuDevice( this, QString( "CPU #%1" ).arg( cpucount++ ) ); + dev->addInfo( line ); } @@ -164,3 +165,3 @@ void CpuCategory::populate() { - continue; + if ( dev ) dev->addInfo( line ); } @@ -187,3 +188,3 @@ void InputCategory::populate() OInputDevice* dev = it.current(); - new OListViewItem( this, dev->identity() ); + new InputDevice( this, dev->identity() ); ++it; @@ -212,3 +213,3 @@ void CardsCategory::populate() { - new OListViewItem( this, "ERROR: pcmcia info file not found or unaccessible" ); + new CardDevice( this, "ERROR: pcmcia info file not found or unaccessible" ); return; @@ -222,3 +223,3 @@ void CardsCategory::populate() { - new OListViewItem( this, line ); + new CardDevice( this, line ); } @@ -247,3 +248,3 @@ void UsbCategory::populate() { - 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; @@ -265,3 +266,3 @@ void UsbCategory::populate() - new OListViewItem( this, QString( "USB Device #%1" ).arg( usbcount++ ) ); + new UsbDevice( this, QString( "USB Device #%1" ).arg( usbcount++ ) ); } @@ -274 +275,78 @@ void UsbCategory::populate() + +//================================================================================================= +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() +{ +} |