author | mickeyl <mickeyl> | 2005-05-03 22:32:11 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2005-05-03 22:32:11 (UTC) |
commit | 1f412e211a7d5759d2ca51aa4e14c6292984f124 (patch) (side-by-side diff) | |
tree | 6a6634d76f633cd5e8f3c6fcdf82f0604cdbad64 | |
parent | 1daea169fcc0007727f0752251ca4546817999b7 (diff) | |
download | opie-1f412e211a7d5759d2ca51aa4e14c6292984f124.zip opie-1f412e211a7d5759d2ca51aa4e14c6292984f124.tar.gz opie-1f412e211a7d5759d2ca51aa4e14c6292984f124.tar.bz2 |
use OAutoBoxLayout for devices info
-rw-r--r-- | noncore/settings/sysinfo/devicesinfo.cpp | 16 | ||||
-rw-r--r-- | noncore/settings/sysinfo/devicesinfo.h | 16 |
2 files changed, 23 insertions, 9 deletions
diff --git a/noncore/settings/sysinfo/devicesinfo.cpp b/noncore/settings/sysinfo/devicesinfo.cpp index a1c9e0b..4bce65f 100644 --- a/noncore/settings/sysinfo/devicesinfo.cpp +++ b/noncore/settings/sysinfo/devicesinfo.cpp @@ -1,169 +1,179 @@ /* This file is part of the Opie Project =. Copyright (C) 2005 Michael 'Mickey' Lauer <mickey@Vanille.de> .=l. Copyright (C) The Opie Team <opie-devel@handhelds.org> .>+-= _;:, .> :=|. This program is free software; you can .> <`_, > . <= redistribute it and/or modify it under :`=1 )Y*s>-.-- : the terms of the GNU General Public .="- .-=="i, .._ License as published by the Free Software - . .-<_> .<> Foundation; version 2 of the License. ._= =} : .%`+i> _;_. .i_,=:_. -<s. This program is distributed in the hope that + . -:. = it will be useful, but WITHOUT ANY WARRANTY; : .. .:, . . . without even the implied warranty of =_ + =;=|` MERCHANTABILITY or FITNESS FOR A _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU ..}^=.= = ; General Public License for more ++= -. .` .: details. : = ...= . :.=- -. .:....=;==+<; You should have received a copy of the GNU -_. . . )=. = General Public License along with -- :-=` this application; see the file LICENSE.GPL. 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 <qlistview.h> #include <qcombobox.h> #include <qfile.h> -#include <qlayout.h> #include <qpushbutton.h> #include <qtextstream.h> #include <qtextview.h> #include <qtimer.h> #include <qwhatsthis.h> //================================================================================================= DevicesView::DevicesView( QWidget* parent, const char* name, WFlags fl ) - :OListView( parent, name, fl ) + :Opie::Ui::OListView( parent, name, fl ) { addColumn( tr( "My Computer" ) ); setAllColumnsShowFocus( true ); setRootIsDecorated( true ); QWhatsThis::add( this, tr( "This is a list of all the devices currently recognized on this device." ) ); DevicesView* root = this; ( new CpuCategory( root ) )->populate(); ( new InputCategory( root ) )->populate(); ( new CardsCategory( root ) )->populate(); ( new UsbCategory( root ) )->populate(); + + connect( this, SIGNAL(selectionChanged(QListViewItem*)), this, SLOT(selectionChanged(QListViewItem*)) ); } DevicesView::~DevicesView() { } + +void DevicesView::selectionChanged( QListViewItem* item ) +{ + odebug << "DevicesView::selectionChanged to '" << item->text( 0 ) << "'" << oendl; +} + + //================================================================================================= DevicesInfo::DevicesInfo( QWidget* parent, const char* name, WFlags fl ) :QWidget( parent, name, fl ) { - QVBoxLayout *layout = new QVBoxLayout( this ); + OAutoBoxLayout *layout = new OAutoBoxLayout( this ); layout->setSpacing( 4 ); layout->setMargin( 4 ); view = new DevicesView( this ); layout->addWidget( view ); } DevicesInfo::~DevicesInfo() { } Category::Category( DevicesView* parent, const QString& name ) :OListViewItem( parent, name ) { odebug << "Category '" << name << "' inserted. Scanning for devices..." << oendl; } Category::~Category() { } //================================================================================================= Device::Device( Category* parent, const QString& name ) :OListViewItem( parent, name ) { } Device::~Device() { } //================================================================================================= CpuCategory::CpuCategory( DevicesView* parent ) :Category( parent, "1. Central Processing Unit" ) { } 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" ); return; } QTextStream cpuinfo( &cpuinfofile ); int cpucount = 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++ ) ); } else { continue; } } } //================================================================================================= InputCategory::InputCategory( DevicesView* parent ) :Category( parent, "2. Input Subsystem" ) { } InputCategory::~InputCategory() { } 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() ); ++it; } } //================================================================================================= CardsCategory::CardsCategory( DevicesView* parent ) :Category( parent, "3. Removable Cards" ) { } diff --git a/noncore/settings/sysinfo/devicesinfo.h b/noncore/settings/sysinfo/devicesinfo.h index 60ec999..262af31 100644 --- a/noncore/settings/sysinfo/devicesinfo.h +++ b/noncore/settings/sysinfo/devicesinfo.h @@ -1,118 +1,122 @@ /* This file is part of the Opie Project =. Copyright (C) 2005 Michael 'Mickey' Lauer <mickey@Vanille.de> .=l. Copyright (C) The Opie Team <opie-devel@handhelds.org> .>+-= _;:, .> :=|. This program is free software; you can .> <`_, > . <= redistribute it and/or modify it under :`=1 )Y*s>-.-- : the terms of the GNU General Public .="- .-=="i, .._ License as published by the Free Software - . .-<_> .<> Foundation; version 2 of the License. ._= =} : .%`+i> _;_. .i_,=:_. -<s. This program is distributed in the hope that + . -:. = it will be useful, but WITHOUT ANY WARRANTY; : .. .:, . . . without even the implied warranty of =_ + =;=|` MERCHANTABILITY or FITNESS FOR A _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU ..}^=.= = ; General Public License for more ++= -. .` .: details. : = ...= . :.=- -. .:....=;==+<; You should have received a copy of the GNU -_. . . )=. = General Public License along with -- :-=` this application; see the file LICENSE.GPL. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef DEVICESINFO_H #define DEVICESINFO_H -#include <qwidget.h> +/* OPIE */ #include <opie2/olistview.h> -using namespace Opie::Ui; + +/* QT */ +#include <qwidget.h> //================================================================================================= -class DevicesView : public OListView +class DevicesView : public Opie::Ui::OListView { Q_OBJECT public: DevicesView( QWidget* parent = 0, const char* name = 0, WFlags f = 0 ); ~DevicesView(); +public slots: + void selectionChanged( QListViewItem* item ); }; //================================================================================================= class DevicesInfo : public QWidget { Q_OBJECT public: DevicesInfo( QWidget *parent = 0, const char *name = 0, WFlags f = 0 ); ~DevicesInfo(); private: - OListView* view; + Opie::Ui::OListView* view; private slots: }; //================================================================================================= -class Category : public OListViewItem +class Category : public Opie::Ui::OListViewItem { public: Category( DevicesView* parent, const QString& name ); virtual ~Category(); virtual void populate() = 0; }; //================================================================================================= -class Device : public OListViewItem +class Device : public Opie::Ui::OListViewItem { public: Device( Category* parent, const QString& name ); ~Device(); }; //================================================================================================= class CpuCategory : public Category { public: CpuCategory( DevicesView* parent ); virtual ~CpuCategory(); virtual void populate(); }; //================================================================================================= class InputCategory : public Category { public: InputCategory( DevicesView* parent ); virtual ~InputCategory(); virtual void populate(); }; //================================================================================================= class CardsCategory : public Category { public: CardsCategory( DevicesView* parent ); virtual ~CardsCategory(); virtual void populate(); }; //================================================================================================= class UsbCategory : public Category { public: UsbCategory( DevicesView* parent ); virtual ~UsbCategory(); virtual void populate(); }; #endif |