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 | |||
@@ -27,7 +27,6 @@ _;:, .> :=|. This program is free software; you can | |||
27 | */ | 27 | */ |
28 | 28 | ||
29 | #include "devicesinfo.h" | 29 | #include "devicesinfo.h" |
30 | |||
31 | /* OPIE */ | 30 | /* OPIE */ |
32 | #include <opie2/odebug.h> | 31 | #include <opie2/odebug.h> |
33 | #include <opie2/oinputsystem.h> | 32 | #include <opie2/oinputsystem.h> |
@@ -38,6 +37,7 @@ using namespace Opie::Core; | |||
38 | using namespace Opie::Ui; | 37 | using namespace Opie::Ui; |
39 | 38 | ||
40 | /* QT */ | 39 | /* QT */ |
40 | #include <qobjectlist.h> | ||
41 | #include <qlistview.h> | 41 | #include <qlistview.h> |
42 | #include <qcombobox.h> | 42 | #include <qcombobox.h> |
43 | #include <qfile.h> | 43 | #include <qfile.h> |
@@ -73,9 +73,16 @@ DevicesView::~DevicesView() | |||
73 | void DevicesView::selectionChanged( QListViewItem* item ) | 73 | void 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 | if ( item->parent() ) | ||
77 | { | ||
76 | QWidget* details = ( static_cast<Device*>( item ) )->detailsWidget(); | 78 | QWidget* details = ( static_cast<Device*>( item ) )->detailsWidget(); |
77 | ( static_cast<DevicesInfo*>( parent() ) )->setDetailsWidget( details ); | 79 | ( static_cast<DevicesInfo*>( parent() ) )->setDetailsWidget( details ); |
78 | } | 80 | } |
81 | else | ||
82 | { | ||
83 | odebug << "DevicesView::not a device node." << oendl; | ||
84 | } | ||
85 | } | ||
79 | 86 | ||
80 | 87 | ||
81 | //================================================================================================= | 88 | //================================================================================================= |
@@ -83,10 +90,12 @@ DevicesInfo::DevicesInfo( QWidget* parent, const char* name, WFlags fl ) | |||
83 | :QWidget( parent, name, fl ), details( 0 ) | 90 | :QWidget( parent, name, fl ), details( 0 ) |
84 | { | 91 | { |
85 | layout = new OAutoBoxLayout( this ); | 92 | layout = new OAutoBoxLayout( this ); |
86 | layout->setSpacing( 4 ); | 93 | layout->setSpacing( 2 ); |
87 | layout->setMargin( 4 ); | 94 | layout->setMargin( 2 ); |
88 | view = new DevicesView( this ); | 95 | view = new DevicesView( this ); |
89 | layout->addWidget( view ); | 96 | layout->addWidget( view, 100 ); |
97 | stack = new QWidgetStack( this ); | ||
98 | layout->addWidget( stack, 70 ); | ||
90 | } | 99 | } |
91 | 100 | ||
92 | 101 | ||
@@ -97,9 +106,14 @@ DevicesInfo::~DevicesInfo() | |||
97 | 106 | ||
98 | void DevicesInfo::setDetailsWidget( QWidget* w ) | 107 | void DevicesInfo::setDetailsWidget( QWidget* w ) |
99 | { | 108 | { |
100 | if ( details ) delete( details ); | 109 | if ( details ) |
101 | layout->addWidget( w ); | 110 | { |
102 | w->show(); | 111 | qDebug( "hiding widget '%s' ('%s')", details->name(), details->className() ); |
112 | stack->removeWidget( w ); | ||
113 | } | ||
114 | |||
115 | stack->addWidget( details = w, 40 ); | ||
116 | stack->raiseWidget( details ); | ||
103 | } | 117 | } |
104 | 118 | ||
105 | 119 | ||
@@ -115,22 +129,6 @@ Category::~Category() | |||
115 | } | 129 | } |
116 | 130 | ||
117 | //================================================================================================= | 131 | //================================================================================================= |
118 | Device::Device( Category* parent, const QString& name ) | ||
119 | :OListViewItem( parent, name ) | ||
120 | { | ||
121 | } | ||
122 | |||
123 | Device::~Device() | ||
124 | { | ||
125 | } | ||
126 | |||
127 | QWidget* Device::detailsWidget() | ||
128 | { | ||
129 | return new QPushButton( static_cast<QWidget*>( listView()->parent() ), "Press Button to self-destruct" ); | ||
130 | } | ||
131 | |||
132 | |||
133 | //================================================================================================= | ||
134 | CpuCategory::CpuCategory( DevicesView* parent ) | 132 | CpuCategory::CpuCategory( DevicesView* parent ) |
135 | :Category( parent, "1. Central Processing Unit" ) | 133 | :Category( parent, "1. Central Processing Unit" ) |
136 | { | 134 | { |
@@ -146,23 +144,26 @@ void CpuCategory::populate() | |||
146 | QFile cpuinfofile( "/proc/cpuinfo" ); | 144 | QFile cpuinfofile( "/proc/cpuinfo" ); |
147 | if ( !cpuinfofile.exists() || !cpuinfofile.open( IO_ReadOnly ) ) | 145 | if ( !cpuinfofile.exists() || !cpuinfofile.open( IO_ReadOnly ) ) |
148 | { | 146 | { |
149 | new OListViewItem( this, "ERROR: /proc/cpuinfo not found or unaccessible" ); | 147 | new CpuDevice( this, "ERROR: /proc/cpuinfo not found or unaccessible" ); |
150 | return; | 148 | return; |
151 | } | 149 | } |
152 | QTextStream cpuinfo( &cpuinfofile ); | 150 | QTextStream cpuinfo( &cpuinfofile ); |
153 | 151 | ||
154 | int cpucount = 0; | 152 | int cpucount = 0; |
153 | CpuDevice* dev = 0; | ||
154 | |||
155 | while ( !cpuinfo.atEnd() ) | 155 | while ( !cpuinfo.atEnd() ) |
156 | { | 156 | { |
157 | QString line = cpuinfo.readLine(); | 157 | QString line = cpuinfo.readLine(); |
158 | odebug << "got line '" << line << "'" << oendl; | 158 | odebug << "got line '" << line << "'" << oendl; |
159 | if ( line.startsWith( "processor" ) ) | 159 | if ( line.startsWith( "processor" ) ) |
160 | { | 160 | { |
161 | new OListViewItem( this, QString( "CPU #%1" ).arg( cpucount++ ) ); | 161 | dev = new CpuDevice( this, QString( "CPU #%1" ).arg( cpucount++ ) ); |
162 | dev->addInfo( line ); | ||
162 | } | 163 | } |
163 | else | 164 | else |
164 | { | 165 | { |
165 | continue; | 166 | if ( dev ) dev->addInfo( line ); |
166 | } | 167 | } |
167 | } | 168 | } |
168 | } | 169 | } |
@@ -185,7 +186,7 @@ void InputCategory::populate() | |||
185 | while ( it.current() ) | 186 | while ( it.current() ) |
186 | { | 187 | { |
187 | OInputDevice* dev = it.current(); | 188 | OInputDevice* dev = it.current(); |
188 | new OListViewItem( this, dev->identity() ); | 189 | new InputDevice( this, dev->identity() ); |
189 | ++it; | 190 | ++it; |
190 | } | 191 | } |
191 | } | 192 | } |
@@ -210,7 +211,7 @@ void CardsCategory::populate() | |||
210 | QFile cardinfofile( fileName ); | 211 | QFile cardinfofile( fileName ); |
211 | if ( !cardinfofile.exists() || !cardinfofile.open( IO_ReadOnly ) ) | 212 | if ( !cardinfofile.exists() || !cardinfofile.open( IO_ReadOnly ) ) |
212 | { | 213 | { |
213 | new OListViewItem( this, "ERROR: pcmcia info file not found or unaccessible" ); | 214 | new CardDevice( this, "ERROR: pcmcia info file not found or unaccessible" ); |
214 | return; | 215 | return; |
215 | } | 216 | } |
216 | QTextStream cardinfo( &cardinfofile ); | 217 | QTextStream cardinfo( &cardinfofile ); |
@@ -220,7 +221,7 @@ void CardsCategory::populate() | |||
220 | odebug << "got line '" << line << "'" << oendl; | 221 | odebug << "got line '" << line << "'" << oendl; |
221 | if ( line.startsWith("Socket") ) | 222 | if ( line.startsWith("Socket") ) |
222 | { | 223 | { |
223 | new OListViewItem( this, line ); | 224 | new CardDevice( this, line ); |
224 | } | 225 | } |
225 | else | 226 | else |
226 | { | 227 | { |
@@ -245,7 +246,7 @@ void UsbCategory::populate() | |||
245 | QFile usbinfofile( "/proc/bus/usb/devices" ); | 246 | QFile usbinfofile( "/proc/bus/usb/devices" ); |
246 | if ( !usbinfofile.exists() || !usbinfofile.open( IO_ReadOnly ) ) | 247 | if ( !usbinfofile.exists() || !usbinfofile.open( IO_ReadOnly ) ) |
247 | { | 248 | { |
248 | new OListViewItem( this, "ERROR: /proc/bus/usb/devices not found or unaccessible" ); | 249 | new UsbDevice( this, "ERROR: /proc/bus/usb/devices not found or unaccessible" ); |
249 | return; | 250 | return; |
250 | } | 251 | } |
251 | QTextStream usbinfo( &usbinfofile ); | 252 | QTextStream usbinfo( &usbinfofile ); |
@@ -263,7 +264,7 @@ void UsbCategory::populate() | |||
263 | { | 264 | { |
264 | 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); | 265 | 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); |
265 | 266 | ||
266 | new OListViewItem( this, QString( "USB Device #%1" ).arg( usbcount++ ) ); | 267 | new UsbDevice( this, QString( "USB Device #%1" ).arg( usbcount++ ) ); |
267 | } | 268 | } |
268 | else | 269 | else |
269 | { | 270 | { |
@@ -272,3 +273,80 @@ void UsbCategory::populate() | |||
272 | } | 273 | } |
273 | } | 274 | } |
274 | 275 | ||
276 | |||
277 | //================================================================================================= | ||
278 | Device::Device( Category* parent, const QString& name ) | ||
279 | :OListViewItem( parent, name ) | ||
280 | { | ||
281 | devinfo = static_cast<QWidget*>( listView()->parent() ); | ||
282 | } | ||
283 | |||
284 | Device::~Device() | ||
285 | { | ||
286 | } | ||
287 | |||
288 | |||
289 | QWidget* Device::detailsWidget() | ||
290 | { | ||
291 | return details; | ||
292 | } | ||
293 | |||
294 | //================================================================================================= | ||
295 | CpuDevice::CpuDevice( Category* parent, const QString& name ) | ||
296 | :Device( parent, name ) | ||
297 | { | ||
298 | OListView* w = new OListView( devinfo ); | ||
299 | details = w; | ||
300 | w->addColumn( "Info" ); | ||
301 | w->addColumn( "Value" ); | ||
302 | w->hide(); | ||
303 | } | ||
304 | |||
305 | CpuDevice::~CpuDevice() | ||
306 | { | ||
307 | } | ||
308 | |||
309 | void CpuDevice::addInfo( const QString& info ) | ||
310 | { | ||
311 | int dp = info.find( ':' ); | ||
312 | if ( dp != -1 ) | ||
313 | { | ||
314 | new OListViewItem( (OListView*) details, info.left( dp ), info.right( info.length()-dp ) ); | ||
315 | } | ||
316 | } | ||
317 | |||
318 | //================================================================================================= | ||
319 | CardDevice::CardDevice( Category* parent, const QString& name ) | ||
320 | :Device( parent, name ) | ||
321 | { | ||
322 | details = new QPushButton( name, devinfo ); | ||
323 | details->hide(); | ||
324 | } | ||
325 | |||
326 | CardDevice::~CardDevice() | ||
327 | { | ||
328 | } | ||
329 | |||
330 | //================================================================================================= | ||
331 | InputDevice::InputDevice( Category* parent, const QString& name ) | ||
332 | :Device( parent, name ) | ||
333 | { | ||
334 | details = new QPushButton( name, devinfo ); | ||
335 | details->hide(); | ||
336 | } | ||
337 | |||
338 | InputDevice::~InputDevice() | ||
339 | { | ||
340 | } | ||
341 | |||
342 | //================================================================================================= | ||
343 | UsbDevice::UsbDevice( Category* parent, const QString& name ) | ||
344 | :Device( parent, name ) | ||
345 | { | ||
346 | details = new QPushButton( name, devinfo ); | ||
347 | details->hide(); | ||
348 | } | ||
349 | |||
350 | UsbDevice::~UsbDevice() | ||
351 | { | ||
352 | } | ||