-rw-r--r-- | noncore/settings/sysinfo/devicesinfo.cpp | 22 | ||||
-rw-r--r-- | noncore/settings/sysinfo/devicesinfo.h | 8 |
2 files changed, 27 insertions, 3 deletions
diff --git a/noncore/settings/sysinfo/devicesinfo.cpp b/noncore/settings/sysinfo/devicesinfo.cpp index 4bce65f..f1efb33 100644 --- a/noncore/settings/sysinfo/devicesinfo.cpp +++ b/noncore/settings/sysinfo/devicesinfo.cpp @@ -68,35 +68,47 @@ DevicesView::DevicesView( QWidget* parent, const char* name, WFlags fl ) 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 ); } //================================================================================================= DevicesInfo::DevicesInfo( QWidget* parent, const char* name, WFlags fl ) - :QWidget( parent, name, fl ) + :QWidget( parent, name, fl ), details( 0 ) { - OAutoBoxLayout *layout = new OAutoBoxLayout( this ); + layout = new OAutoBoxLayout( this ); layout->setSpacing( 4 ); layout->setMargin( 4 ); view = new DevicesView( this ); layout->addWidget( view ); } + DevicesInfo::~DevicesInfo() { } +void DevicesInfo::setDetailsWidget( QWidget* w ) +{ + if ( details ) delete( details ); + layout->addWidget( w ); + w->show(); +} + + +//================================================================================================= Category::Category( DevicesView* parent, const QString& name ) :OListViewItem( parent, name ) { odebug << "Category '" << name << "' inserted. Scanning for devices..." << oendl; } Category::~Category() { @@ -107,16 +119,22 @@ 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() { diff --git a/noncore/settings/sysinfo/devicesinfo.h b/noncore/settings/sysinfo/devicesinfo.h index 262af31..b065f40 100644 --- a/noncore/settings/sysinfo/devicesinfo.h +++ b/noncore/settings/sysinfo/devicesinfo.h @@ -26,16 +26,17 @@ _;:, .> :=|. This program is free software; you can Boston, MA 02111-1307, USA. */ #ifndef DEVICESINFO_H #define DEVICESINFO_H /* OPIE */ #include <opie2/olistview.h> +#include <opie2/olayout.h> /* QT */ #include <qwidget.h> //================================================================================================= class DevicesView : public Opie::Ui::OListView { Q_OBJECT @@ -49,19 +50,22 @@ public slots: //================================================================================================= class DevicesInfo : public QWidget { Q_OBJECT public: DevicesInfo( QWidget *parent = 0, const char *name = 0, WFlags f = 0 ); ~DevicesInfo(); + void setDetailsWidget( QWidget* w = 0 ); + private: + Opie::Ui::OAutoBoxLayout* layout; Opie::Ui::OListView* view; - + QWidget* details; private slots: }; //================================================================================================= class Category : public Opie::Ui::OListViewItem { public: Category( DevicesView* parent, const QString& name ); @@ -71,16 +75,18 @@ public: }; //================================================================================================= 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(); |