author | zecke <zecke> | 2004-03-14 16:01:52 (UTC) |
---|---|---|
committer | zecke <zecke> | 2004-03-14 16:01:52 (UTC) |
commit | f12af18557c8f376f0c6c30e80a85737ff6c592e (patch) (side-by-side diff) | |
tree | d60806f34f4ff6af82491579e80c9ef72cd4071e /noncore/settings/sysinfo | |
parent | 13aeeabab5f2a6262b33de83cc9559a49365e325 (diff) | |
download | opie-f12af18557c8f376f0c6c30e80a85737ff6c592e.zip opie-f12af18557c8f376f0c6c30e80a85737ff6c592e.tar.gz opie-f12af18557c8f376f0c6c30e80a85737ff6c592e.tar.bz2 |
Make use of ODP
-rw-r--r-- | noncore/settings/sysinfo/benchmarkinfo.cpp | 21 | ||||
-rw-r--r-- | noncore/settings/sysinfo/benchmarkinfo.h | 22 | ||||
-rw-r--r-- | noncore/settings/sysinfo/main.cpp | 1 | ||||
-rw-r--r-- | noncore/settings/sysinfo/modulesinfo.cpp | 10 | ||||
-rw-r--r-- | noncore/settings/sysinfo/modulesinfo.h | 10 | ||||
-rw-r--r-- | noncore/settings/sysinfo/processinfo.cpp | 11 | ||||
-rw-r--r-- | noncore/settings/sysinfo/processinfo.h | 10 | ||||
-rw-r--r-- | noncore/settings/sysinfo/sysinfo.cpp | 1 | ||||
-rw-r--r-- | noncore/settings/sysinfo/versioninfo.cpp | 2 |
9 files changed, 55 insertions, 33 deletions
diff --git a/noncore/settings/sysinfo/benchmarkinfo.cpp b/noncore/settings/sysinfo/benchmarkinfo.cpp index 3c2c15f..2a52b00 100644 --- a/noncore/settings/sysinfo/benchmarkinfo.cpp +++ b/noncore/settings/sysinfo/benchmarkinfo.cpp @@ -42,25 +42,28 @@ #include <qtimer.h> #include <qwhatsthis.h> /* STD */ #include <time.h> #include <stdio.h> #include <stdlib.h> #include <math.h> #if defined (__GNUC__) && (__GNUC__ < 3) extern double round(double); #endif +using namespace Opie::Ui; +using namespace Opie::Core; extern "C" + { void BenchFFT( void ); double dhry_main( int ); } #define DHRYSTONE_RUNS 20000000 #define TEST_DURATION 3 #define BUFF_SIZE 8192 #define FILE_SIZE 1024 * 1024 // 1Mb //=========================================================================== @@ -166,30 +169,30 @@ BenchmarkInfo::~BenchmarkInfo() void BenchmarkInfo::machineActivated( int index ) { QStringList* results = machines[ machineCombo->text( index ) ]; if ( !results ) { qDebug( "sysinfo: no results available." ); return; } QStringList::Iterator it = results->begin(); test_alu->setText( 2, *(it++) ); - test_fpu->setText( 2, *(it++) ); + test_fpu->setText( 2, *(it++) ); test_txt->setText( 2, *(it++) ); test_gfx->setText( 2, *(it++) ); test_ram->setText( 2, *(it++) ); test_sd->setText( 2, *(it++) ); - test_cf->setText( 2, *(it++) ); + test_cf->setText( 2, *(it++) ); } void BenchmarkInfo::run() { startButton->setText( "> Don't touch! Running Tests! Don't touch! <" ); qApp->processEvents(); QTime t; if ( test_alu->isOn() ) { int d = round( dhry_main( DHRYSTONE_RUNS ) ); @@ -250,100 +253,100 @@ int BenchmarkInfo::textRendering( int seconds ) int gg[] = { 0, 255, 0, 0, 255, 255, 0, 128, 128 }; int bb[] = { 0, 0, 255, 0, 0, 255, 255, 128, 0 }; const QString text( "Opie Benchmark Test" ); int w = QApplication::desktop()->width(); int h = QApplication::desktop()->height(); srand( time( NULL ) ); BenchmarkPaintWidget bpw; int loops = 0; - + while ( t.elapsed() < stop ) { int k = rand() % 9; int s = rand() % 100; bpw.p.setPen( QColor( rr[ k ], gg[ k ], bb[ k ] ) ); bpw.p.setFont( QFont( "Vera", s ) ); bpw.p.drawText( rand() % w, rand() % h, text, text.length() ); ++loops; } - + return loops * text.length(); } int BenchmarkInfo::gfxRendering( int seconds ) { int rr[] = { 255, 255, 255, 0, 0, 0, 0, 128, 128 }; int gg[] = { 0, 255, 0, 0, 255, 255, 0, 128, 128 }; int bb[] = { 0, 0, 255, 0, 0, 255, 255, 128, 0 }; int w = QApplication::desktop()->width(); int h = QApplication::desktop()->height(); srand( time( NULL ) ); BenchmarkPaintWidget bpw; QTime t; t.start(); int stop = t.elapsed() + seconds*1000; int loops = 0; - + while ( t.elapsed() < stop ) { int k = rand() % 9; bpw.p.setPen( QColor( rr[ k ], gg[ k ], bb[ k ] ) ); bpw.p.drawLine( rand()%w, rand()%h, rand()%w, rand()%h ); ++loops; } t.restart(); stop = t.elapsed() + seconds*1000; - + while ( t.elapsed() < stop ) { int k = rand() % 9; bpw.p.setPen( QColor( rr[ k ], gg[ k ], bb[ k ] ) ); bpw.p.drawArc( rand()%w, rand()%h, rand()%w, rand()%h, 360 * 16, 360 * 16 ); ++loops; } QBrush br1; br1.setStyle( SolidPattern ); t.restart(); stop = t.elapsed() + seconds*1000; - + while ( t.elapsed() < stop ) { int k = rand() % 9; br1.setColor( QColor( rr[ k ], gg[ k ], bb[ k ] ) ); bpw.p.fillRect( rand()%w, rand()%h, rand()%w, rand()%h, br1 ); ++loops; } QPixmap p = Resource::loadPixmap( "sysinfo/pattern" ); t.restart(); stop = t.elapsed() + seconds*1000; - + while ( t.elapsed() < stop ) { bpw.p.drawPixmap( rand()%w, rand()%h, p ); ++loops; } return loops; - + } void BenchmarkInfo::performFileTest( const QString& fname, OCheckListItem* item ) { QTime time; time.start(); if ( writeFile( fname ) && readFile( fname ) ) { QFile::remove( fname ); item->setText( 1, QString( "%1 kb/sec" ).arg( QString::number( 1024.0 / ( time.elapsed() / 1000.0 ) ) ) ); item->setOn( false ); diff --git a/noncore/settings/sysinfo/benchmarkinfo.h b/noncore/settings/sysinfo/benchmarkinfo.h index c3d44ec..0a61134 100644 --- a/noncore/settings/sysinfo/benchmarkinfo.h +++ b/noncore/settings/sysinfo/benchmarkinfo.h @@ -14,56 +14,56 @@ ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** **********************************************************************/ #include <qwidget.h> #include <qdialog.h> #include <qdict.h> #include <qstringlist.h> class QClipboard; class QComboBox; -class OCheckListItem; +namespace Opie {namespace Ui {class OCheckListItem;}} class QPushButton; -class OListView; +namespace Opie {namespace Ui {class OListView;}} class BenchmarkInfo : public QWidget { Q_OBJECT public: BenchmarkInfo( QWidget *parent = 0, const char *name = 0, int wFlags = 0 ); ~BenchmarkInfo(); - OCheckListItem* test_alu; - OCheckListItem* test_fpu; - OCheckListItem* test_txt; - OCheckListItem* test_gfx; - OCheckListItem* test_ram; - OCheckListItem* test_sd; - OCheckListItem* test_cf; + Opie::Ui::OCheckListItem* test_alu; + Opie::Ui::OCheckListItem* test_fpu; + Opie::Ui::OCheckListItem* test_txt; + Opie::Ui::OCheckListItem* test_gfx; + Opie::Ui::OCheckListItem* test_ram; + Opie::Ui::OCheckListItem* test_sd; + Opie::Ui::OCheckListItem* test_cf; bool main_rd; bool main_wt; bool sd_rd; bool sd_wt; bool cf_rd; bool cf_wt; QClipboard* clb; QComboBox* machineCombo; - OListView* tests; + Opie::Ui::OListView* tests; QPushButton* startButton; QDict <QStringList> machines; int textRendering( int ); int gfxRendering( int ); - void performFileTest( const QString& fname, OCheckListItem* item ); + void performFileTest( const QString& fname, Opie::Ui::OCheckListItem* item ); private slots: bool writeFile( const QString& ); bool readFile( const QString& ); void run(); void machineActivated( int ); }; diff --git a/noncore/settings/sysinfo/main.cpp b/noncore/settings/sysinfo/main.cpp index 3a7b1b1..8ebac20 100644 --- a/noncore/settings/sysinfo/main.cpp +++ b/noncore/settings/sysinfo/main.cpp @@ -14,13 +14,14 @@ ** See http://www.trolltech.com/gpl/ for GPL licensing information. ** ** Contact info@trolltech.com if any conditions of this licensing are ** not clear to you. ** **********************************************************************/ #include "sysinfo.h" #include <opie2/oapplicationfactory.h> +using namespace Opie::Core; OPIE_EXPORT_APP( OApplicationFactory<SystemInfo> ) diff --git a/noncore/settings/sysinfo/modulesinfo.cpp b/noncore/settings/sysinfo/modulesinfo.cpp index dfe48e1..71cefcb 100644 --- a/noncore/settings/sysinfo/modulesinfo.cpp +++ b/noncore/settings/sysinfo/modulesinfo.cpp @@ -27,48 +27,49 @@ #include <qpe/qpeapplication.h> /* QT */ #include <qcombobox.h> #include <qfile.h> #include <qlayout.h> #include <qmessagebox.h> #include <qpushbutton.h> #include <qtextview.h> #include <qtimer.h> #include <qwhatsthis.h> +using namespace Opie::Ui; ModulesInfo::ModulesInfo( QWidget* parent, const char* name, WFlags fl ) : QWidget( parent, name, fl ) { QGridLayout *layout = new QGridLayout( this ); layout->setSpacing( 4 ); layout->setMargin( 4 ); ModulesView = new OListView( this ); int colnum = ModulesView->addColumn( tr( "Module" ) ); colnum = ModulesView->addColumn( tr( "Size" ) ); ModulesView->setColumnAlignment( colnum, Qt::AlignRight ); colnum = ModulesView->addColumn( tr( "Use#" ) ); ModulesView->setColumnAlignment( colnum, Qt::AlignRight ); colnum = ModulesView->addColumn( tr( "Used by" ) ); ModulesView->setAllColumnsShowFocus( TRUE ); layout->addMultiCellWidget( ModulesView, 0, 0, 0, 1 ); QWhatsThis::add( ModulesView, tr( "This is a list of all the kernel modules currently loaded on this handheld device.\n\nClick and hold on a module to see additional information about the module, or to unload it." ) ); // Test if we have /sbin/modinfo, and if so, allow module detail window if ( QFile::exists( "/sbin/modinfo" ) ) { QPEApplication::setStylusOperation( ModulesView->viewport(), QPEApplication::RightOnHold ); - connect( ModulesView, SIGNAL( rightButtonPressed(OListViewItem*,const QPoint&,int) ), - this, SLOT( viewModules(OListViewItem*) ) ); + connect( ModulesView, SIGNAL( rightButtonPressed(QListViewItem*,const QPoint&,int) ), + this, SLOT( viewModules(QListViewItem*) ) ); } CommandCB = new QComboBox( FALSE, this ); CommandCB->insertItem( "modprobe -r" ); CommandCB->insertItem( "rmmod" ); // I can't think of other useful commands yet. Anyone? layout->addWidget( CommandCB, 1, 0 ); QWhatsThis::add( CommandCB, tr( "Select a command here and then click the Send button to the right to send the command to module selected above." ) ); QPushButton *btn = new QPushButton( this ); btn->setMinimumSize( QSize( 50, 24 ) ); btn->setMaximumSize( QSize( 50, 24 ) ); @@ -154,24 +155,29 @@ void ModulesInfo::slotSendClicked() QString command = "/sbin/"; command.append( CommandCB->currentText() ); command.append( " " ); command.append( modname ); FILE* stream = popen( command, "r" ); if ( stream ) pclose( stream ); } } +void ModulesInfo::viewModules( QListViewItem *module ) { + if ( !module ) + return; + viewModules( static_cast<OListViewItem*>( module ) ); +} void ModulesInfo::viewModules( OListViewItem *modules ) { QString modname = modules->text( 0 ); QString capstr = "Module: "; capstr.append( modname ); ModulesDtl->setCaption( capstr ); QString command = "/sbin/modinfo "; command.append( modname ); FILE* modinfo = popen( command, "r" ); if ( modinfo ) { diff --git a/noncore/settings/sysinfo/modulesinfo.h b/noncore/settings/sysinfo/modulesinfo.h index 78dce73..b816b41 100644 --- a/noncore/settings/sysinfo/modulesinfo.h +++ b/noncore/settings/sysinfo/modulesinfo.h @@ -17,35 +17,37 @@ ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** **********************************************************************/ #ifndef MODULESINFO_H #define MODULESINFO_H #include <qwidget.h> class Detail; class QComboBox; -class OListView; -class OListViewItem; +class QListViewItem; +namespace Opie {namespace Ui {class OListView;}} +namespace Opie {namespace Ui {class OListViewItem;}} class ModulesInfo : public QWidget { Q_OBJECT public: ModulesInfo( QWidget *parent = 0, const char *name = 0, WFlags f = 0 ); ~ModulesInfo(); private: - OListView* ModulesView; + Opie::Ui::OListView* ModulesView; QComboBox* CommandCB; Detail* ModulesDtl; private slots: void updateData(); void slotSendClicked(); - void viewModules( OListViewItem * ); + void viewModules( QListViewItem* ); + void viewModules( Opie::Ui::OListViewItem * ); }; #endif diff --git a/noncore/settings/sysinfo/processinfo.cpp b/noncore/settings/sysinfo/processinfo.cpp index dd9a05d..e887267 100644 --- a/noncore/settings/sysinfo/processinfo.cpp +++ b/noncore/settings/sysinfo/processinfo.cpp @@ -29,43 +29,44 @@ #include <qdir.h> #include <qlayout.h> #include <qmessagebox.h> #include <qpushbutton.h> #include <qtextview.h> #include <qtimer.h> #include <qwhatsthis.h> /* STD */ #include <sys/types.h> #include <signal.h> +using namespace Opie::Ui; ProcessInfo::ProcessInfo( QWidget* parent, const char* name, WFlags fl ) : QWidget( parent, name, fl ) { QGridLayout *layout = new QGridLayout( this ); layout->setSpacing( 4 ); layout->setMargin( 4 ); ProcessView = new OListView( this, "ProcessView" ); int colnum = ProcessView->addColumn( tr( "PID" ) ); ProcessView->setColumnAlignment( colnum, Qt::AlignRight ); colnum = ProcessView->addColumn( tr( "Command" ),96 ); colnum = ProcessView->addColumn( tr( "Status" ) ); colnum = ProcessView->addColumn( tr( "Time" ) ); ProcessView->setColumnAlignment( colnum, Qt::AlignRight ); ProcessView->setAllColumnsShowFocus( TRUE ); QPEApplication::setStylusOperation( ProcessView->viewport(), QPEApplication::RightOnHold ); - connect( ProcessView, SIGNAL( rightButtonPressed(OListViewItem*,const QPoint&,int) ), - this, SLOT( viewProcess(OListViewItem*) ) ); + connect( ProcessView, SIGNAL( rightButtonPressed(QListViewItem*,const QPoint&,int) ), + this, SLOT( viewProcess(QListViewItem*) ) ); layout->addMultiCellWidget( ProcessView, 0, 0, 0, 1 ); QWhatsThis::add( ProcessView, tr( "This is a list of all the processes on this handheld device.\n\nClick and hold on a process to see additional information about the process, or to send a signal to it." ) ); SignalCB = new QComboBox( FALSE, this, "SignalCB" ); SignalCB->insertItem( " 1: SIGHUP" ); SignalCB->insertItem( " 2: SIGINT" ); SignalCB->insertItem( " 3: SIGQUIT" ); SignalCB->insertItem( " 5: SIGTRAP" ); SignalCB->insertItem( " 6: SIGABRT" ); SignalCB->insertItem( " 9: SIGKILL" ); SignalCB->insertItem( "14: SIGALRM" ); SignalCB->insertItem( "15: SIGTERM" ); @@ -176,24 +177,30 @@ void ProcessInfo::slotSendClicked() currprocess = static_cast<OListViewItem*>( ProcessView->currentItem() ); if ( currprocess ) { QString sigstr = SignalCB->currentText(); sigstr.truncate(2); int sigid = sigstr.toUInt(); kill( currprocess->text( 0 ).stripWhiteSpace().toUInt(), sigid ); } } } +void ProcessInfo::viewProcess( QListViewItem* process ) { + if ( !process ) + return; + viewProcess( static_cast<OListViewItem*>( process ) ); +} + void ProcessInfo::viewProcess( OListViewItem *process ) { QString pid= process->text( 0 ).stripWhiteSpace(); QString command = process->text( 1 ); ProcessDtl->setCaption( pid + " - " + command ); FILE *statfile = fopen( ( QString ) ( "/proc/" + pid + "/status"), "r"); if ( statfile ) { char line[81]; fgets( line, 81, statfile ); ProcessDtl->detailView->setText( line ); while ( fgets( line, 81, statfile ) ) diff --git a/noncore/settings/sysinfo/processinfo.h b/noncore/settings/sysinfo/processinfo.h index 6e7acd5..0a1682b 100644 --- a/noncore/settings/sysinfo/processinfo.h +++ b/noncore/settings/sysinfo/processinfo.h @@ -15,36 +15,38 @@ ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** **********************************************************************/ #ifndef PROCESSINFO_H #define PROCESSINFO_H #include <qwidget.h> class Detail; class QComboBox; -class OListView; -class OListViewItem; +class QListViewItem; +namespace Opie {namespace Ui {class OListView;}} +namespace Opie {namespace Ui {class OListViewItem;}} class ProcessInfo : public QWidget { Q_OBJECT public: ProcessInfo( QWidget *parent = 0, const char *name = 0, WFlags f = 0 ); ~ProcessInfo(); private: - OListView* ProcessView; + Opie::Ui::OListView* ProcessView; QComboBox* SignalCB; QPushButton* SendButton; Detail *ProcessDtl; private slots: void updateData(); void slotSendClicked(); - void viewProcess( OListViewItem * ); + void viewProcess( QListViewItem* ); + void viewProcess( Opie::Ui::OListViewItem * ); }; #endif diff --git a/noncore/settings/sysinfo/sysinfo.cpp b/noncore/settings/sysinfo/sysinfo.cpp index fda6352..4c58999 100644 --- a/noncore/settings/sysinfo/sysinfo.cpp +++ b/noncore/settings/sysinfo/sysinfo.cpp @@ -29,24 +29,25 @@ #include "modulesinfo.h" #include "benchmarkinfo.h" #include "versioninfo.h" #include "sysinfo.h" #include <opie2/otabwidget.h> #include <qpe/config.h> #include <qpe/resource.h> #include <qlayout.h> +using namespace Opie::Ui; SystemInfo::SystemInfo( QWidget *parent, const char *name, WFlags ) : QWidget( parent, name, WStyle_ContextHelp ) { setIcon( Resource::loadPixmap( "system_icon" ) ); setCaption( tr("System Info") ); resize( 220, 180 ); Config config( "qpe" ); config.setGroup( "Appearance" ); bool advanced = config.readBoolEntry( "Advanced", TRUE ); diff --git a/noncore/settings/sysinfo/versioninfo.cpp b/noncore/settings/sysinfo/versioninfo.cpp index 4bebd06..6764aa6 100644 --- a/noncore/settings/sysinfo/versioninfo.cpp +++ b/noncore/settings/sysinfo/versioninfo.cpp @@ -24,25 +24,25 @@ #include <opie2/odevice.h> #include <qpe/resource.h> #include <qpe/version.h> /* QT */ #include <qfile.h> #include <qlabel.h> #include <qlayout.h> #include <qscrollview.h> #include <qtextstream.h> #include <qwhatsthis.h> -using namespace Opie; +using namespace Opie::Core; VersionInfo::VersionInfo( QWidget *parent, const char *name, WFlags f ) : QWidget( parent, name, f ) { setMinimumSize( 200, 150 ); QVBoxLayout *tmpvb = new QVBoxLayout( this ); QScrollView *sv = new QScrollView( this ); tmpvb->addWidget( sv, 0, 0 ); sv->setResizePolicy( QScrollView::AutoOneFit ); sv->setFrameStyle( QFrame::NoFrame ); QWidget *container = new QWidget( sv->viewport() ); |