author | drw <drw> | 2002-03-09 21:58:30 (UTC) |
---|---|---|
committer | drw <drw> | 2002-03-09 21:58:30 (UTC) |
commit | a07cd819c6ce288e6b4426ce1668e57bb629c868 (patch) (side-by-side diff) | |
tree | a4b7418180eb56f22529e0471bfce9cae6cbe833 | |
parent | 80be7dabb1e1390e4d412c785d9f44e2293b2d5d (diff) | |
download | opie-a07cd819c6ce288e6b4426ce1668e57bb629c868.zip opie-a07cd819c6ce288e6b4426ce1668e57bb629c868.tar.gz opie-a07cd819c6ce288e6b4426ce1668e57bb629c868.tar.bz2 |
drw: Code enhancements to reduce executable size.
-rw-r--r-- | noncore/settings/sysinfo/processdetail.cpp | 22 | ||||
-rw-r--r-- | noncore/settings/sysinfo/processdetail.h | 6 | ||||
-rw-r--r-- | noncore/settings/sysinfo/processinfo.cpp | 41 | ||||
-rw-r--r-- | noncore/settings/sysinfo/processinfo.h | 3 |
4 files changed, 32 insertions, 40 deletions
diff --git a/noncore/settings/sysinfo/processdetail.cpp b/noncore/settings/sysinfo/processdetail.cpp index 06e5c0d..ef612e6 100644 --- a/noncore/settings/sysinfo/processdetail.cpp +++ b/noncore/settings/sysinfo/processdetail.cpp @@ -31,4 +31,4 @@ -ProcessDetail::ProcessDetail( QWidget* parent, const char* name, bool modal, WFlags fl ) - : QDialog( parent, name, modal, fl ) +ProcessDetail::ProcessDetail( QWidget* parent, const char* name, WFlags fl ) + : QWidget( parent, name, fl ) { @@ -37,9 +37,6 @@ ProcessDetail::ProcessDetail( QWidget* parent, const char* name, bool modal, WF QGridLayout *layout = new QGridLayout( this ); - layout->setSpacing( 6 ); - layout->setMargin( 11 ); + layout->setSpacing( 4 ); + layout->setMargin( 4 ); SignalCB = new QComboBox( FALSE, this, "SignalCB" ); - SignalCB->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)1, (QSizePolicy::SizeType)7, SignalCB->sizePolicy().hasHeightForWidth() ) ); - SignalCB->setMinimumSize( QSize( 50, 24 ) ); - SignalCB->setMaximumSize( QSize( 600, 24 ) ); SignalCB->insertItem( " 1: SIGHUP" ); @@ -53,3 +50,2 @@ ProcessDetail::ProcessDetail( QWidget* parent, const char* name, bool modal, WF ProcessView = new QTextView( this, "ProcessView" ); - ProcessView->setFrameShadow( QTextView::Plain ); layout->addMultiCellWidget( ProcessView, 0, 0, 0, 1 ); @@ -57,3 +53,2 @@ ProcessDetail::ProcessDetail( QWidget* parent, const char* name, bool modal, WF SendButton = new QPushButton( this, "SendButton" ); - SendButton->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, SendButton->sizePolicy().hasHeightForWidth() ) ); SendButton->setMinimumSize( QSize( 50, 24 ) ); @@ -75,5 +70,6 @@ void ProcessDetail::slotSendClicked() - if ( !QMessageBox::information( this, caption(), - ( tr( "You really want to send\n" + SignalCB->currentText() + "\nto this process?") ), - ( tr( "Yes" ) ), ( tr( "No" ) ), 0 ) ) + if ( QMessageBox::warning( this, caption(), + tr( "You really want to send\n" + SignalCB->currentText() + "\nto this process?"), + QMessageBox::Yes | QMessageBox::Default, QMessageBox::No | QMessageBox::Escape ) + == QMessageBox::Yes ) { @@ -81,3 +77,3 @@ void ProcessDetail::slotSendClicked() { - accept(); + hide(); } diff --git a/noncore/settings/sysinfo/processdetail.h b/noncore/settings/sysinfo/processdetail.h index 5d418ac..22e196f 100644 --- a/noncore/settings/sysinfo/processdetail.h +++ b/noncore/settings/sysinfo/processdetail.h @@ -22,3 +22,3 @@ -#include <qdialog.h> +#include <qwidget.h> #include <qcombo.h> @@ -28,3 +28,3 @@ -class ProcessDetail : public QDialog +class ProcessDetail : public QWidget { @@ -33,3 +33,3 @@ class ProcessDetail : public QDialog public: - ProcessDetail( QWidget* parent, const char* name, bool modal, WFlags fl ); + ProcessDetail( QWidget* parent, const char* name, WFlags fl ); ~ProcessDetail(); diff --git a/noncore/settings/sysinfo/processinfo.cpp b/noncore/settings/sysinfo/processinfo.cpp index 225da63..ad81d7b 100644 --- a/noncore/settings/sysinfo/processinfo.cpp +++ b/noncore/settings/sysinfo/processinfo.cpp @@ -27,3 +27,2 @@ #include "processinfo.h" -#include "processdetail.h" @@ -51,2 +50,5 @@ ProcessInfo::ProcessInfo( QWidget* parent, const char* name, WFlags fl ) updateData(); + + ProcessDtl = new ProcessDetail( 0, 0, 0 ); + ProcessDtl->ProcessView->setTextFormat( RichText ); } @@ -59,6 +61,2 @@ void ProcessInfo::updateData() { - QString processnum(""); - QString processcmd(""); - QString processstatus(""); - QString processtime(""); int pid, ppid, pgrp, session, tty, tpgid, utime, stime, cutime, cstime, counter, priority, starttime, @@ -68,3 +66,3 @@ void ProcessInfo::updateData() char state; - char comm[255]; + char comm[64]; @@ -72,5 +70,3 @@ void ProcessInfo::updateData() - QDir *procdir = new QDir("/proc"); - procdir->setFilter(QDir::Dirs); - procdir->setSorting(QDir::Name); + QDir *procdir = new QDir("/proc", 0, QDir::Name, QDir::Dirs); QFileInfoList *proclist = new QFileInfoList(*(procdir->entryInfoList())); @@ -83,4 +79,4 @@ void ProcessInfo::updateData() ++it; - processnum = f->fileName(); - if ( processnum >= "0" && processnum <= "99999" ) + QString processnum = f->fileName(); + if ( processnum >= "1" && processnum <= "99999" ) { @@ -97,6 +93,5 @@ void ProcessInfo::updateData() processnum = processnum.rightJustify( 5, ' ' ); - processcmd = QString( comm ).replace( QRegExp( "(" ), "" ); - processcmd = processcmd.replace( QRegExp( ")" ), "" ); - processstatus = state; - processtime.setNum( ( utime + stime ) / 100 ); + QString processcmd = QString( comm ).replace( QRegExp( "[()]" ), "" ); + QString processstatus = QChar(state); + QString processtime = QString::number( ( utime + stime ) / 100 ); processtime = processtime.rightJustify( 9, ' ' ); @@ -116,8 +111,6 @@ void ProcessInfo::viewProcess(QListViewItem *process) { - QString pid= process->text(0).stripWhiteSpace(); - QString command = process->text(1); - ProcessDetail *processdtl = new ProcessDetail( this, 0, TRUE, 0); - processdtl->setCaption( pid + " - " + command ); - processdtl->pid = pid.toUInt(); - processdtl->ProcessView->setTextFormat( RichText ); + QString pid= process->text( 0 ).stripWhiteSpace(); + QString command = process->text( 1 ); + ProcessDtl->setCaption( pid + " - " + command ); + ProcessDtl->pid = pid.toUInt(); FILE *statfile = fopen( ( QString ) ( "/proc/" + pid + "/status"), "r"); @@ -127,6 +120,6 @@ void ProcessInfo::viewProcess(QListViewItem *process) fgets( line, 81, statfile ); - processdtl->ProcessView->setText( line ); + ProcessDtl->ProcessView->setText( line ); while ( fgets( line, 81, statfile ) ) { - processdtl->ProcessView->append( line ); + ProcessDtl->ProcessView->append( line ); } @@ -135,3 +128,3 @@ void ProcessInfo::viewProcess(QListViewItem *process) - processdtl->showMaximized(); + ProcessDtl->showMaximized(); } diff --git a/noncore/settings/sysinfo/processinfo.h b/noncore/settings/sysinfo/processinfo.h index e5bacca..89d1a93 100644 --- a/noncore/settings/sysinfo/processinfo.h +++ b/noncore/settings/sysinfo/processinfo.h @@ -25,2 +25,4 @@ +#include "processdetail.h" + class ProcessInfo : public QWidget @@ -38,2 +40,3 @@ private: QListView* ProcessView; + ProcessDetail *ProcessDtl; }; |