summaryrefslogtreecommitdiff
authordrw <drw>2002-03-09 21:58:30 (UTC)
committer drw <drw>2002-03-09 21:58:30 (UTC)
commita07cd819c6ce288e6b4426ce1668e57bb629c868 (patch) (unidiff)
treea4b7418180eb56f22529e0471bfce9cae6cbe833
parent80be7dabb1e1390e4d412c785d9f44e2293b2d5d (diff)
downloadopie-a07cd819c6ce288e6b4426ce1668e57bb629c868.zip
opie-a07cd819c6ce288e6b4426ce1668e57bb629c868.tar.gz
opie-a07cd819c6ce288e6b4426ce1668e57bb629c868.tar.bz2
drw: Code enhancements to reduce executable size.
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/sysinfo/processdetail.cpp22
-rw-r--r--noncore/settings/sysinfo/processdetail.h6
-rw-r--r--noncore/settings/sysinfo/processinfo.cpp41
-rw-r--r--noncore/settings/sysinfo/processinfo.h3
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
@@ -30,17 +30,14 @@
30#include <qmessagebox.h> 30#include <qmessagebox.h>
31 31
32ProcessDetail::ProcessDetail( QWidget* parent, const char* name, bool modal, WFlags fl ) 32ProcessDetail::ProcessDetail( QWidget* parent, const char* name, WFlags fl )
33 : QDialog( parent, name, modal, fl ) 33 : QWidget( parent, name, fl )
34{ 34{
35 pid = 0; 35 pid = 0;
36 36
37 QGridLayout *layout = new QGridLayout( this ); 37 QGridLayout *layout = new QGridLayout( this );
38 layout->setSpacing( 6 ); 38 layout->setSpacing( 4 );
39 layout->setMargin( 11 ); 39 layout->setMargin( 4 );
40 40
41 SignalCB = new QComboBox( FALSE, this, "SignalCB" ); 41 SignalCB = new QComboBox( FALSE, this, "SignalCB" );
42 SignalCB->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)1, (QSizePolicy::SizeType)7, SignalCB->sizePolicy().hasHeightForWidth() ) );
43 SignalCB->setMinimumSize( QSize( 50, 24 ) );
44 SignalCB->setMaximumSize( QSize( 600, 24 ) );
45 SignalCB->insertItem( " 1: SIGHUP" ); 42 SignalCB->insertItem( " 1: SIGHUP" );
46 SignalCB->insertItem( " 2: SIGINT" ); 43 SignalCB->insertItem( " 2: SIGINT" );
@@ -52,9 +49,7 @@ ProcessDetail::ProcessDetail( QWidget* parent, const char* name, bool modal, WF
52 49
53 ProcessView = new QTextView( this, "ProcessView" ); 50 ProcessView = new QTextView( this, "ProcessView" );
54 ProcessView->setFrameShadow( QTextView::Plain );
55 layout->addMultiCellWidget( ProcessView, 0, 0, 0, 1 ); 51 layout->addMultiCellWidget( ProcessView, 0, 0, 0, 1 );
56 52
57 SendButton = new QPushButton( this, "SendButton" ); 53 SendButton = new QPushButton( this, "SendButton" );
58 SendButton->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, SendButton->sizePolicy().hasHeightForWidth() ) );
59 SendButton->setMinimumSize( QSize( 50, 24 ) ); 54 SendButton->setMinimumSize( QSize( 50, 24 ) );
60 SendButton->setMaximumSize( QSize( 50, 24 ) ); 55 SendButton->setMaximumSize( QSize( 50, 24 ) );
@@ -74,11 +69,12 @@ void ProcessDetail::slotSendClicked()
74 int sigid = sigstr.toUInt(); 69 int sigid = sigstr.toUInt();
75 70
76 if ( !QMessageBox::information( this, caption(), 71 if ( QMessageBox::warning( this, caption(),
77 ( tr( "You really want to send\n" + SignalCB->currentText() + "\nto this process?") ), 72 tr( "You really want to send\n" + SignalCB->currentText() + "\nto this process?"),
78 ( tr( "Yes" ) ), ( tr( "No" ) ), 0 ) ) 73 QMessageBox::Yes | QMessageBox::Default, QMessageBox::No | QMessageBox::Escape )
74 == QMessageBox::Yes )
79 { 75 {
80 if ( kill( pid, sigid ) == 0 ) 76 if ( kill( pid, sigid ) == 0 )
81 { 77 {
82 accept(); 78 hide();
83 } 79 }
84 } 80 }
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
@@ -21,5 +21,5 @@
21#define PROCESSDETAIL_H 21#define PROCESSDETAIL_H
22 22
23#include <qdialog.h> 23#include <qwidget.h>
24#include <qcombo.h> 24#include <qcombo.h>
25#include <qtextview.h> 25#include <qtextview.h>
@@ -27,10 +27,10 @@
27#include <qlistview.h> 27#include <qlistview.h>
28 28
29class ProcessDetail : public QDialog 29class ProcessDetail : public QWidget
30{ 30{
31 Q_OBJECT 31 Q_OBJECT
32 32
33public: 33public:
34 ProcessDetail( QWidget* parent, const char* name, bool modal, WFlags fl ); 34 ProcessDetail( QWidget* parent, const char* name, WFlags fl );
35 ~ProcessDetail(); 35 ~ProcessDetail();
36 36
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
@@ -26,5 +26,4 @@
26 26
27#include "processinfo.h" 27#include "processinfo.h"
28#include "processdetail.h"
29 28
30ProcessInfo::ProcessInfo( QWidget* parent, const char* name, WFlags fl ) 29ProcessInfo::ProcessInfo( QWidget* parent, const char* name, WFlags fl )
@@ -50,4 +49,7 @@ ProcessInfo::ProcessInfo( QWidget* parent, const char* name, WFlags fl )
50 49
51 updateData(); 50 updateData();
51
52 ProcessDtl = new ProcessDetail( 0, 0, 0 );
53 ProcessDtl->ProcessView->setTextFormat( RichText );
52} 54}
53 55
@@ -58,8 +60,4 @@ ProcessInfo::~ProcessInfo()
58void ProcessInfo::updateData() 60void ProcessInfo::updateData()
59{ 61{
60 QString processnum("");
61 QString processcmd("");
62 QString processstatus("");
63 QString processtime("");
64 int pid, ppid, pgrp, session, tty, tpgid, utime, stime, cutime, cstime, counter, priority, starttime, 62 int pid, ppid, pgrp, session, tty, tpgid, utime, stime, cutime, cstime, counter, priority, starttime,
65 signal, blocked, sigignore, sigcatch; 63 signal, blocked, sigignore, sigcatch;
@@ -67,11 +65,9 @@ void ProcessInfo::updateData()
67 endcode, startstack, kstkesp, kstkeip, wchan; 65 endcode, startstack, kstkesp, kstkeip, wchan;
68 char state; 66 char state;
69 char comm[255]; 67 char comm[64];
70 68
71 ProcessView->clear(); 69 ProcessView->clear();
72 70
73 QDir *procdir = new QDir("/proc"); 71 QDir *procdir = new QDir("/proc", 0, QDir::Name, QDir::Dirs);
74 procdir->setFilter(QDir::Dirs);
75 procdir->setSorting(QDir::Name);
76 QFileInfoList *proclist = new QFileInfoList(*(procdir->entryInfoList())); 72 QFileInfoList *proclist = new QFileInfoList(*(procdir->entryInfoList()));
77 if ( proclist ) 73 if ( proclist )
@@ -82,6 +78,6 @@ void ProcessInfo::updateData()
82 { 78 {
83 ++it; 79 ++it;
84 processnum = f->fileName(); 80 QString processnum = f->fileName();
85 if ( processnum >= "0" && processnum <= "99999" ) 81 if ( processnum >= "1" && processnum <= "99999" )
86 { 82 {
87 FILE *procfile = fopen( ( QString ) ( "/proc/" + processnum + "/stat"), "r"); 83 FILE *procfile = fopen( ( QString ) ( "/proc/" + processnum + "/stat"), "r");
@@ -96,8 +92,7 @@ void ProcessInfo::updateData()
96 &kstkesp, &kstkeip, &signal, &blocked, &sigignore, &sigcatch, &wchan ); 92 &kstkesp, &kstkeip, &signal, &blocked, &sigignore, &sigcatch, &wchan );
97 processnum = processnum.rightJustify( 5, ' ' ); 93 processnum = processnum.rightJustify( 5, ' ' );
98 processcmd = QString( comm ).replace( QRegExp( "(" ), "" ); 94 QString processcmd = QString( comm ).replace( QRegExp( "[()]" ), "" );
99 processcmd = processcmd.replace( QRegExp( ")" ), "" ); 95 QString processstatus = QChar(state);
100 processstatus = state; 96 QString processtime = QString::number( ( utime + stime ) / 100 );
101 processtime.setNum( ( utime + stime ) / 100 );
102 processtime = processtime.rightJustify( 9, ' ' ); 97 processtime = processtime.rightJustify( 9, ' ' );
103 fclose( procfile ); 98 fclose( procfile );
@@ -115,10 +110,8 @@ void ProcessInfo::updateData()
115void ProcessInfo::viewProcess(QListViewItem *process) 110void ProcessInfo::viewProcess(QListViewItem *process)
116{ 111{
117 QString pid= process->text(0).stripWhiteSpace(); 112 QString pid= process->text( 0 ).stripWhiteSpace();
118 QString command = process->text(1); 113 QString command = process->text( 1 );
119 ProcessDetail *processdtl = new ProcessDetail( this, 0, TRUE, 0); 114 ProcessDtl->setCaption( pid + " - " + command );
120 processdtl->setCaption( pid + " - " + command ); 115 ProcessDtl->pid = pid.toUInt();
121 processdtl->pid = pid.toUInt();
122 processdtl->ProcessView->setTextFormat( RichText );
123 FILE *statfile = fopen( ( QString ) ( "/proc/" + pid + "/status"), "r"); 116 FILE *statfile = fopen( ( QString ) ( "/proc/" + pid + "/status"), "r");
124 if ( statfile ) 117 if ( statfile )
@@ -126,12 +119,12 @@ void ProcessInfo::viewProcess(QListViewItem *process)
126 char line[81]; 119 char line[81];
127 fgets( line, 81, statfile ); 120 fgets( line, 81, statfile );
128 processdtl->ProcessView->setText( line ); 121 ProcessDtl->ProcessView->setText( line );
129 while ( fgets( line, 81, statfile ) ) 122 while ( fgets( line, 81, statfile ) )
130 { 123 {
131 processdtl->ProcessView->append( line ); 124 ProcessDtl->ProcessView->append( line );
132 } 125 }
133 fclose( statfile ); 126 fclose( statfile );
134 } 127 }
135 128
136 processdtl->showMaximized(); 129 ProcessDtl->showMaximized();
137} 130}
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
@@ -24,4 +24,6 @@
24#include <qlistview.h> 24#include <qlistview.h>
25 25
26#include "processdetail.h"
27
26class ProcessInfo : public QWidget 28class ProcessInfo : public QWidget
27{ 29{
@@ -37,4 +39,5 @@ private slots:
37private: 39private:
38 QListView* ProcessView; 40 QListView* ProcessView;
41 ProcessDetail *ProcessDtl;
39}; 42};
40 43