summaryrefslogtreecommitdiff
authormickeyl <mickeyl>2005-05-04 15:31:32 (UTC)
committer mickeyl <mickeyl>2005-05-04 15:31:32 (UTC)
commitbdc113a8b37e3fa2f65903d043798d33d2f9f907 (patch) (unidiff)
tree7af09b3bc1ceb52414aab972f1b4c4e16afe3441
parent1f412e211a7d5759d2ca51aa4e14c6292984f124 (diff)
downloadopie-bdc113a8b37e3fa2f65903d043798d33d2f9f907.zip
opie-bdc113a8b37e3fa2f65903d043798d33d2f9f907.tar.gz
opie-bdc113a8b37e3fa2f65903d043798d33d2f9f907.tar.bz2
start with details window
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/sysinfo/devicesinfo.cpp22
-rw-r--r--noncore/settings/sysinfo/devicesinfo.h8
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
@@ -12,167 +12,185 @@ _;:,     .>    :=|. This program is free software; you can
12   .%`+i>       _;_. 12   .%`+i>       _;_.
13   .i_,=:_.      -<s. This program is distributed in the hope that 13   .i_,=:_.      -<s. This program is distributed in the hope that
14    +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 14    +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
15   : ..    .:,     . . . without even the implied warranty of 15   : ..    .:,     . . . without even the implied warranty of
16   =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 16   =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
17 _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 17 _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
18..}^=.=       =       ; General Public License for more 18..}^=.=       =       ; General Public License for more
19++=   -.     .`     .: details. 19++=   -.     .`     .: details.
20:     =  ...= . :.=- 20:     =  ...= . :.=-
21-.   .:....=;==+<; You should have received a copy of the GNU 21-.   .:....=;==+<; You should have received a copy of the GNU
22 -_. . .   )=.  = General Public License along with 22 -_. . .   )=.  = General Public License along with
23   --        :-=` this application; see the file LICENSE.GPL. 23   --        :-=` this application; see the file LICENSE.GPL.
24 If not, write to the Free Software Foundation, 24 If not, write to the Free Software Foundation,
25 Inc., 59 Temple Place - Suite 330, 25 Inc., 59 Temple Place - Suite 330,
26 Boston, MA 02111-1307, USA. 26 Boston, MA 02111-1307, USA.
27*/ 27*/
28 28
29#include "devicesinfo.h" 29#include "devicesinfo.h"
30 30
31/* OPIE */ 31/* OPIE */
32#include <opie2/odebug.h> 32#include <opie2/odebug.h>
33#include <opie2/oinputsystem.h> 33#include <opie2/oinputsystem.h>
34#include <opie2/olayout.h> 34#include <opie2/olayout.h>
35#include <opie2/olistview.h> 35#include <opie2/olistview.h>
36#include <qpe/qpeapplication.h> 36#include <qpe/qpeapplication.h>
37using namespace Opie::Core; 37using namespace Opie::Core;
38using namespace Opie::Ui; 38using namespace Opie::Ui;
39 39
40/* QT */ 40/* QT */
41#include <qlistview.h> 41#include <qlistview.h>
42#include <qcombobox.h> 42#include <qcombobox.h>
43#include <qfile.h> 43#include <qfile.h>
44#include <qpushbutton.h> 44#include <qpushbutton.h>
45#include <qtextstream.h> 45#include <qtextstream.h>
46#include <qtextview.h> 46#include <qtextview.h>
47#include <qtimer.h> 47#include <qtimer.h>
48#include <qwhatsthis.h> 48#include <qwhatsthis.h>
49 49
50//================================================================================================= 50//=================================================================================================
51DevicesView::DevicesView( QWidget* parent, const char* name, WFlags fl ) 51DevicesView::DevicesView( QWidget* parent, const char* name, WFlags fl )
52 :Opie::Ui::OListView( parent, name, fl ) 52 :Opie::Ui::OListView( parent, name, fl )
53{ 53{
54 addColumn( tr( "My Computer" ) ); 54 addColumn( tr( "My Computer" ) );
55 setAllColumnsShowFocus( true ); 55 setAllColumnsShowFocus( true );
56 setRootIsDecorated( true ); 56 setRootIsDecorated( true );
57 QWhatsThis::add( this, tr( "This is a list of all the devices currently recognized on this device." ) ); 57 QWhatsThis::add( this, tr( "This is a list of all the devices currently recognized on this device." ) );
58 58
59 DevicesView* root = this; 59 DevicesView* root = this;
60 ( new CpuCategory( root ) )->populate(); 60 ( new CpuCategory( root ) )->populate();
61 ( new InputCategory( root ) )->populate(); 61 ( new InputCategory( root ) )->populate();
62 ( new CardsCategory( root ) )->populate(); 62 ( new CardsCategory( root ) )->populate();
63 ( new UsbCategory( root ) )->populate(); 63 ( new UsbCategory( root ) )->populate();
64 64
65 connect( this, SIGNAL(selectionChanged(QListViewItem*)), this, SLOT(selectionChanged(QListViewItem*)) ); 65 connect( this, SIGNAL(selectionChanged(QListViewItem*)), this, SLOT(selectionChanged(QListViewItem*)) );
66} 66}
67 67
68DevicesView::~DevicesView() 68DevicesView::~DevicesView()
69{ 69{
70} 70}
71 71
72 72
73void DevicesView::selectionChanged( QListViewItem* item ) 73void DevicesView::selectionChanged( QListViewItem* item )
74{ 74{
75 odebug << "DevicesView::selectionChanged to '" << item->text( 0 ) << "'" << oendl; 75 odebug << "DevicesView::selectionChanged to '" << item->text( 0 ) << "'" << oendl;
76 QWidget* details = ( static_cast<Device*>( item ) )->detailsWidget();
77 ( static_cast<DevicesInfo*>( parent() ) )->setDetailsWidget( details );
76} 78}
77 79
78 80
79//================================================================================================= 81//=================================================================================================
80DevicesInfo::DevicesInfo( QWidget* parent, const char* name, WFlags fl ) 82DevicesInfo::DevicesInfo( QWidget* parent, const char* name, WFlags fl )
81 :QWidget( parent, name, fl ) 83 :QWidget( parent, name, fl ), details( 0 )
82{ 84{
83 OAutoBoxLayout *layout = new OAutoBoxLayout( this ); 85 layout = new OAutoBoxLayout( this );
84 layout->setSpacing( 4 ); 86 layout->setSpacing( 4 );
85 layout->setMargin( 4 ); 87 layout->setMargin( 4 );
86 view = new DevicesView( this ); 88 view = new DevicesView( this );
87 layout->addWidget( view ); 89 layout->addWidget( view );
88} 90}
89 91
92
90DevicesInfo::~DevicesInfo() 93DevicesInfo::~DevicesInfo()
91{ 94{
92} 95}
93 96
94 97
98void DevicesInfo::setDetailsWidget( QWidget* w )
99{
100 if ( details ) delete( details );
101 layout->addWidget( w );
102 w->show();
103}
104
105
106//=================================================================================================
95Category::Category( DevicesView* parent, const QString& name ) 107Category::Category( DevicesView* parent, const QString& name )
96 :OListViewItem( parent, name ) 108 :OListViewItem( parent, name )
97{ 109{
98 odebug << "Category '" << name << "' inserted. Scanning for devices..." << oendl; 110 odebug << "Category '" << name << "' inserted. Scanning for devices..." << oendl;
99} 111}
100 112
101Category::~Category() 113Category::~Category()
102{ 114{
103} 115}
104 116
105//================================================================================================= 117//=================================================================================================
106Device::Device( Category* parent, const QString& name ) 118Device::Device( Category* parent, const QString& name )
107 :OListViewItem( parent, name ) 119 :OListViewItem( parent, name )
108{ 120{
109} 121}
110 122
111Device::~Device() 123Device::~Device()
112{ 124{
113} 125}
114 126
127QWidget* Device::detailsWidget()
128{
129 return new QPushButton( static_cast<QWidget*>( listView()->parent() ), "Press Button to self-destruct" );
130}
131
132
115//================================================================================================= 133//=================================================================================================
116CpuCategory::CpuCategory( DevicesView* parent ) 134CpuCategory::CpuCategory( DevicesView* parent )
117 :Category( parent, "1. Central Processing Unit" ) 135 :Category( parent, "1. Central Processing Unit" )
118{ 136{
119} 137}
120 138
121CpuCategory::~CpuCategory() 139CpuCategory::~CpuCategory()
122{ 140{
123} 141}
124 142
125void CpuCategory::populate() 143void CpuCategory::populate()
126{ 144{
127 odebug << "CpuCategory::populate()" << oendl; 145 odebug << "CpuCategory::populate()" << oendl;
128 QFile cpuinfofile( "/proc/cpuinfo" ); 146 QFile cpuinfofile( "/proc/cpuinfo" );
129 if ( !cpuinfofile.exists() || !cpuinfofile.open( IO_ReadOnly ) ) 147 if ( !cpuinfofile.exists() || !cpuinfofile.open( IO_ReadOnly ) )
130 { 148 {
131 new OListViewItem( this, "ERROR: /proc/cpuinfo not found or unaccessible" ); 149 new OListViewItem( this, "ERROR: /proc/cpuinfo not found or unaccessible" );
132 return; 150 return;
133 } 151 }
134 QTextStream cpuinfo( &cpuinfofile ); 152 QTextStream cpuinfo( &cpuinfofile );
135 153
136 int cpucount = 0; 154 int cpucount = 0;
137 while ( !cpuinfo.atEnd() ) 155 while ( !cpuinfo.atEnd() )
138 { 156 {
139 QString line = cpuinfo.readLine(); 157 QString line = cpuinfo.readLine();
140 odebug << "got line '" << line << "'" << oendl; 158 odebug << "got line '" << line << "'" << oendl;
141 if ( line.startsWith( "processor" ) ) 159 if ( line.startsWith( "processor" ) )
142 { 160 {
143 new OListViewItem( this, QString( "CPU #%1" ).arg( cpucount++ ) ); 161 new OListViewItem( this, QString( "CPU #%1" ).arg( cpucount++ ) );
144 } 162 }
145 else 163 else
146 { 164 {
147 continue; 165 continue;
148 } 166 }
149 } 167 }
150} 168}
151 169
152//================================================================================================= 170//=================================================================================================
153InputCategory::InputCategory( DevicesView* parent ) 171InputCategory::InputCategory( DevicesView* parent )
154 :Category( parent, "2. Input Subsystem" ) 172 :Category( parent, "2. Input Subsystem" )
155{ 173{
156} 174}
157 175
158InputCategory::~InputCategory() 176InputCategory::~InputCategory()
159{ 177{
160} 178}
161 179
162void InputCategory::populate() 180void InputCategory::populate()
163{ 181{
164 odebug << "InputCategory::populate()" << oendl; 182 odebug << "InputCategory::populate()" << oendl;
165 OInputSystem* sys = OInputSystem::instance(); 183 OInputSystem* sys = OInputSystem::instance();
166 OInputSystem::DeviceIterator it = sys->iterator(); 184 OInputSystem::DeviceIterator it = sys->iterator();
167 while ( it.current() ) 185 while ( it.current() )
168 { 186 {
169 OInputDevice* dev = it.current(); 187 OInputDevice* dev = it.current();
170 new OListViewItem( this, dev->identity() ); 188 new OListViewItem( this, dev->identity() );
171 ++it; 189 ++it;
172 } 190 }
173} 191}
174 192
175//================================================================================================= 193//=================================================================================================
176CardsCategory::CardsCategory( DevicesView* parent ) 194CardsCategory::CardsCategory( DevicesView* parent )
177 :Category( parent, "3. Removable Cards" ) 195 :Category( parent, "3. Removable Cards" )
178{ 196{
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
@@ -1,122 +1,128 @@
1/* 1/*
2                This file is part of the Opie Project 2                This file is part of the Opie Project
3 =. Copyright (C) 2005 Michael 'Mickey' Lauer <mickey@Vanille.de> 3 =. Copyright (C) 2005 Michael 'Mickey' Lauer <mickey@Vanille.de>
4 .=l. Copyright (C) The Opie Team <opie-devel@handhelds.org> 4 .=l. Copyright (C) The Opie Team <opie-devel@handhelds.org>
5          .>+-= 5          .>+-=
6_;:,     .>    :=|. This program is free software; you can 6_;:,     .>    :=|. This program is free software; you can
7.> <`_,   >  .   <= redistribute it and/or modify it under 7.> <`_,   >  .   <= redistribute it and/or modify it under
8:`=1 )Y*s>-.--   : the terms of the GNU General Public 8:`=1 )Y*s>-.--   : the terms of the GNU General Public
9.="- .-=="i,     .._ License as published by the Free Software 9.="- .-=="i,     .._ License as published by the Free Software
10- .   .-<_>     .<> Foundation; version 2 of the License. 10- .   .-<_>     .<> Foundation; version 2 of the License.
11    ._= =}       : 11    ._= =}       :
12   .%`+i>       _;_. 12   .%`+i>       _;_.
13   .i_,=:_.      -<s. This program is distributed in the hope that 13   .i_,=:_.      -<s. This program is distributed in the hope that
14    +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 14    +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
15   : ..    .:,     . . . without even the implied warranty of 15   : ..    .:,     . . . without even the implied warranty of
16   =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 16   =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
17 _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 17 _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
18..}^=.=       =       ; General Public License for more 18..}^=.=       =       ; General Public License for more
19++=   -.     .`     .: details. 19++=   -.     .`     .: details.
20:     =  ...= . :.=- 20:     =  ...= . :.=-
21-.   .:....=;==+<; You should have received a copy of the GNU 21-.   .:....=;==+<; You should have received a copy of the GNU
22 -_. . .   )=.  = General Public License along with 22 -_. . .   )=.  = General Public License along with
23   --        :-=` this application; see the file LICENSE.GPL. 23   --        :-=` this application; see the file LICENSE.GPL.
24 If not, write to the Free Software Foundation, 24 If not, write to the Free Software Foundation,
25 Inc., 59 Temple Place - Suite 330, 25 Inc., 59 Temple Place - Suite 330,
26 Boston, MA 02111-1307, USA. 26 Boston, MA 02111-1307, USA.
27*/ 27*/
28 28
29#ifndef DEVICESINFO_H 29#ifndef DEVICESINFO_H
30#define DEVICESINFO_H 30#define DEVICESINFO_H
31 31
32/* OPIE */ 32/* OPIE */
33#include <opie2/olistview.h> 33#include <opie2/olistview.h>
34#include <opie2/olayout.h>
34 35
35/* QT */ 36/* QT */
36#include <qwidget.h> 37#include <qwidget.h>
37 38
38//================================================================================================= 39//=================================================================================================
39class DevicesView : public Opie::Ui::OListView 40class DevicesView : public Opie::Ui::OListView
40{ 41{
41 Q_OBJECT 42 Q_OBJECT
42public: 43public:
43 DevicesView( QWidget* parent = 0, const char* name = 0, WFlags f = 0 ); 44 DevicesView( QWidget* parent = 0, const char* name = 0, WFlags f = 0 );
44 ~DevicesView(); 45 ~DevicesView();
45public slots: 46public slots:
46 void selectionChanged( QListViewItem* item ); 47 void selectionChanged( QListViewItem* item );
47}; 48};
48 49
49//================================================================================================= 50//=================================================================================================
50class DevicesInfo : public QWidget 51class DevicesInfo : public QWidget
51{ 52{
52 Q_OBJECT 53 Q_OBJECT
53public: 54public:
54 DevicesInfo( QWidget *parent = 0, const char *name = 0, WFlags f = 0 ); 55 DevicesInfo( QWidget *parent = 0, const char *name = 0, WFlags f = 0 );
55 ~DevicesInfo(); 56 ~DevicesInfo();
56 57
58 void setDetailsWidget( QWidget* w = 0 );
59
57private: 60private:
61 Opie::Ui::OAutoBoxLayout* layout;
58 Opie::Ui::OListView* view; 62 Opie::Ui::OListView* view;
59 63 QWidget* details;
60private slots: 64private slots:
61}; 65};
62 66
63//================================================================================================= 67//=================================================================================================
64class Category : public Opie::Ui::OListViewItem 68class Category : public Opie::Ui::OListViewItem
65{ 69{
66public: 70public:
67 Category( DevicesView* parent, const QString& name ); 71 Category( DevicesView* parent, const QString& name );
68 virtual ~Category(); 72 virtual ~Category();
69 73
70 virtual void populate() = 0; 74 virtual void populate() = 0;
71}; 75};
72 76
73//================================================================================================= 77//=================================================================================================
74class Device : public Opie::Ui::OListViewItem 78class Device : public Opie::Ui::OListViewItem
75{ 79{
76public: 80public:
77 Device( Category* parent, const QString& name ); 81 Device( Category* parent, const QString& name );
78 ~Device(); 82 ~Device();
83
84 QWidget* detailsWidget();
79}; 85};
80 86
81//================================================================================================= 87//=================================================================================================
82class CpuCategory : public Category 88class CpuCategory : public Category
83{ 89{
84public: 90public:
85 CpuCategory( DevicesView* parent ); 91 CpuCategory( DevicesView* parent );
86 virtual ~CpuCategory(); 92 virtual ~CpuCategory();
87 93
88 virtual void populate(); 94 virtual void populate();
89}; 95};
90 96
91//================================================================================================= 97//=================================================================================================
92class InputCategory : public Category 98class InputCategory : public Category
93{ 99{
94public: 100public:
95 InputCategory( DevicesView* parent ); 101 InputCategory( DevicesView* parent );
96 virtual ~InputCategory(); 102 virtual ~InputCategory();
97 103
98 virtual void populate(); 104 virtual void populate();
99}; 105};
100 106
101//================================================================================================= 107//=================================================================================================
102class CardsCategory : public Category 108class CardsCategory : public Category
103{ 109{
104public: 110public:
105 CardsCategory( DevicesView* parent ); 111 CardsCategory( DevicesView* parent );
106 virtual ~CardsCategory(); 112 virtual ~CardsCategory();
107 113
108 virtual void populate(); 114 virtual void populate();
109}; 115};
110 116
111//================================================================================================= 117//=================================================================================================
112class UsbCategory : public Category 118class UsbCategory : public Category
113{ 119{
114public: 120public:
115 UsbCategory( DevicesView* parent ); 121 UsbCategory( DevicesView* parent );
116 virtual ~UsbCategory(); 122 virtual ~UsbCategory();
117 123
118 virtual void populate(); 124 virtual void populate();
119}; 125};
120 126
121 127
122#endif 128#endif