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
@@ -29,19 +29,16 @@
29#include <qlistview.h> 29#include <qlistview.h>
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" );
47 SignalCB->insertItem( " 9: SIGKILL" ); 44 SignalCB->insertItem( " 9: SIGKILL" );
@@ -51,11 +48,9 @@ ProcessDetail::ProcessDetail( QWidget* parent, const char* name, bool modal, WF
51 layout->addWidget( SignalCB, 1, 0 ); 48 layout->addWidget( SignalCB, 1, 0 );
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 ) );
61 SendButton->setText( tr( "Send" ) ); 56 SendButton->setText( tr( "Send" ) );
@@ -73,13 +68,14 @@ void ProcessDetail::slotSendClicked()
73 sigstr.truncate(2); 68 sigstr.truncate(2);
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 }
85 81
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
@@ -20,18 +20,18 @@
20#ifndef PROCESSDETAIL_H 20#ifndef PROCESSDETAIL_H
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>
26#include <qpushbutton.h> 26#include <qpushbutton.h>
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
37 QComboBox* SignalCB; 37 QComboBox* SignalCB;
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
@@ -25,7 +25,6 @@
25#include <qdir.h> 25#include <qdir.h>
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 )
31 : QWidget( parent, name, fl ) 30 : QWidget( parent, name, fl )
@@ -49,6 +48,9 @@ ProcessInfo::ProcessInfo( QWidget* parent, const char* name, WFlags fl )
49 t->start( 5000 ); 48 t->start( 5000 );
50 49
51 updateData(); 50 updateData();
51
52 ProcessDtl = new ProcessDetail( 0, 0, 0 );
53 ProcessDtl->ProcessView->setTextFormat( RichText );
52} 54}
53 55
54ProcessInfo::~ProcessInfo() 56ProcessInfo::~ProcessInfo()
@@ -57,22 +59,16 @@ ProcessInfo::~ProcessInfo()
57 59
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;
66 uint flags, minflt, cminflt, majflt, cmajflt, timeout, itrealvalue, vsize, rss, rlim, startcode, 64 uint flags, minflt, cminflt, majflt, cmajflt, timeout, itrealvalue, vsize, rss, rlim, startcode,
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 )
78 { 74 {
@@ -81,8 +77,8 @@ void ProcessInfo::updateData()
81 while ( ( f = it.current() ) != 0 ) 77 while ( ( f = it.current() ) != 0 )
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");
88 84
@@ -95,10 +91,9 @@ void ProcessInfo::updateData()
95 &itrealvalue, &starttime, &vsize, &rss, &rlim, &startcode, &endcode, &startstack, 91 &itrealvalue, &starttime, &vsize, &rss, &rlim, &startcode, &endcode, &startstack,
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 );
104 99
@@ -114,24 +109,22 @@ void ProcessInfo::updateData()
114 109
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 )
125 { 118 {
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
@@ -23,6 +23,8 @@
23#include <qwidget.h> 23#include <qwidget.h>
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{
28 Q_OBJECT 30 Q_OBJECT
@@ -36,6 +38,7 @@ private slots:
36 38
37private: 39private:
38 QListView* ProcessView; 40 QListView* ProcessView;
41 ProcessDetail *ProcessDtl;
39}; 42};
40 43
41#endif 44#endif