summaryrefslogtreecommitdiff
authordrw <drw>2002-03-15 16:25:53 (UTC)
committer drw <drw>2002-03-15 16:25:53 (UTC)
commiteb338502c03edbfc8b9b9f00bd95c0c0d4317003 (patch) (unidiff)
tree36a0a6fb3a193a526bc0f7f748c404b621ea2224
parenta0d6c8fdac4e8644c31d1b2e2a321131be4b57c2 (diff)
downloadopie-eb338502c03edbfc8b9b9f00bd95c0c0d4317003.zip
opie-eb338502c03edbfc8b9b9f00bd95c0c0d4317003.tar.gz
opie-eb338502c03edbfc8b9b9f00bd95c0c0d4317003.tar.bz2
Click & hold, not double click, to bring up detail
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/sysinfo/processinfo.cpp9
-rw-r--r--noncore/settings/sysinfo/processinfo.h2
2 files changed, 7 insertions, 4 deletions
diff --git a/noncore/settings/sysinfo/processinfo.cpp b/noncore/settings/sysinfo/processinfo.cpp
index ad81d7b..0512141 100644
--- a/noncore/settings/sysinfo/processinfo.cpp
+++ b/noncore/settings/sysinfo/processinfo.cpp
@@ -4,55 +4,59 @@
4** Display process information 4** Display process information
5** 5**
6** Copyright (C) 2002, Dan Williams 6** Copyright (C) 2002, Dan Williams
7** williamsdr@acm.org 7** williamsdr@acm.org
8** http://draknor.net 8** http://draknor.net
9** 9**
10** This file may be distributed and/or modified under the terms of the 10** This file may be distributed and/or modified under the terms of the
11** GNU General Public License version 2 as published by the Free Software 11** GNU General Public License version 2 as published by the Free Software
12** Foundation and appearing in the file LICENSE.GPL included in the 12** Foundation and appearing in the file LICENSE.GPL included in the
13** packaging of this file. 13** packaging of this file.
14** 14**
15** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 15** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
16** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 16** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
17** 17**
18**********************************************************************/ 18**********************************************************************/
19 19
20#include <qpe/qpeapplication.h>
21
20#include <qheader.h> 22#include <qheader.h>
21#include <qlistview.h> 23#include <qlistview.h>
22#include <qlayout.h> 24#include <qlayout.h>
23#include <qtimer.h> 25#include <qtimer.h>
24#include <qfile.h> 26#include <qfile.h>
25#include <qdir.h> 27#include <qdir.h>
26 28
27#include "processinfo.h" 29#include "processinfo.h"
28 30
29ProcessInfo::ProcessInfo( QWidget* parent, const char* name, WFlags fl ) 31ProcessInfo::ProcessInfo( QWidget* parent, const char* name, WFlags fl )
30 : QWidget( parent, name, fl ) 32 : QWidget( parent, name, fl )
31{ 33{
32 QVBoxLayout *layout = new QVBoxLayout( this, 5 ); 34 QVBoxLayout *layout = new QVBoxLayout( this, 5 );
33 35
34 ProcessView = new QListView( this, "ProcessView" ); 36 ProcessView = new QListView( this, "ProcessView" );
35 int colnum = ProcessView->addColumn( tr( "PID" ) ); 37 int colnum = ProcessView->addColumn( tr( "PID" ) );
36 ProcessView->setColumnAlignment( colnum, Qt::AlignRight ); 38 ProcessView->setColumnAlignment( colnum, Qt::AlignRight );
37 colnum = ProcessView->addColumn( tr( "Command" ),96 ); 39 colnum = ProcessView->addColumn( tr( "Command" ),96 );
38 colnum = ProcessView->addColumn( tr( "Status" ) ); 40 colnum = ProcessView->addColumn( tr( "Status" ) );
39 colnum = ProcessView->addColumn( tr( "Time" ) ); 41 colnum = ProcessView->addColumn( tr( "Time" ) );
40 ProcessView->setColumnAlignment( colnum, Qt::AlignRight ); 42 ProcessView->setColumnAlignment( colnum, Qt::AlignRight );
41 ProcessView->setAllColumnsShowFocus( TRUE ); 43 ProcessView->setAllColumnsShowFocus( TRUE );
42 connect( ProcessView, SIGNAL( doubleClicked(QListViewItem *) ), this, SLOT( viewProcess(QListViewItem *) ) ); 44 QPEApplication::setStylusOperation( ProcessView->viewport(), QPEApplication::RightOnHold );
45 connect( ProcessView, SIGNAL( rightButtonPressed( QListViewItem *, const QPoint &, int ) ),
46 this, SLOT( viewProcess( QListViewItem * ) ) );
43 47
44 layout->addWidget( ProcessView ); 48 layout->addWidget( ProcessView );
45 49
46 QTimer *t = new QTimer( this ); 50 QTimer *t = new QTimer( this );
47 connect( t, SIGNAL( timeout() ), this, SLOT( updateData() ) ); 51 connect( t, SIGNAL( timeout() ), this, SLOT( updateData() ) );
48 t->start( 5000 ); 52 t->start( 5000 );
49 53
50 updateData(); 54 updateData();
51 55
52 ProcessDtl = new ProcessDetail( 0, 0, 0 ); 56 ProcessDtl = new ProcessDetail( 0, 0, 0 );
53 ProcessDtl->ProcessView->setTextFormat( RichText ); 57 ProcessDtl->ProcessView->setTextFormat( RichText );
54} 58}
55 59
56ProcessInfo::~ProcessInfo() 60ProcessInfo::~ProcessInfo()
57{ 61{
58} 62}
@@ -94,37 +98,36 @@ void ProcessInfo::updateData()
94 QString processcmd = QString( comm ).replace( QRegExp( "[()]" ), "" ); 98 QString processcmd = QString( comm ).replace( QRegExp( "[()]" ), "" );
95 QString processstatus = QChar(state); 99 QString processstatus = QChar(state);
96 QString processtime = QString::number( ( utime + stime ) / 100 ); 100 QString processtime = QString::number( ( utime + stime ) / 100 );
97 processtime = processtime.rightJustify( 9, ' ' ); 101 processtime = processtime.rightJustify( 9, ' ' );
98 fclose( procfile ); 102 fclose( procfile );
99 103
100 ( void ) new QListViewItem( ProcessView, processnum, processcmd, processstatus, processtime ); 104 ( void ) new QListViewItem( ProcessView, processnum, processcmd, processstatus, processtime );
101 } 105 }
102 } 106 }
103 } 107 }
104 } 108 }
105 109
106 delete proclist; 110 delete proclist;
107 delete procdir; 111 delete procdir;
108} 112}
109 113
110void ProcessInfo::viewProcess(QListViewItem *process) 114void ProcessInfo::viewProcess( QListViewItem *process )
111{ 115{
112 QString pid= process->text( 0 ).stripWhiteSpace(); 116 QString pid= process->text( 0 ).stripWhiteSpace();
113 QString command = process->text( 1 ); 117 QString command = process->text( 1 );
114 ProcessDtl->setCaption( pid + " - " + command ); 118 ProcessDtl->setCaption( pid + " - " + command );
115 ProcessDtl->pid = pid.toUInt(); 119 ProcessDtl->pid = pid.toUInt();
116 FILE *statfile = fopen( ( QString ) ( "/proc/" + pid + "/status"), "r"); 120 FILE *statfile = fopen( ( QString ) ( "/proc/" + pid + "/status"), "r");
117 if ( statfile ) 121 if ( statfile )
118 { 122 {
119 char line[81]; 123 char line[81];
120 fgets( line, 81, statfile ); 124 fgets( line, 81, statfile );
121 ProcessDtl->ProcessView->setText( line ); 125 ProcessDtl->ProcessView->setText( line );
122 while ( fgets( line, 81, statfile ) ) 126 while ( fgets( line, 81, statfile ) )
123 { 127 {
124 ProcessDtl->ProcessView->append( line ); 128 ProcessDtl->ProcessView->append( line );
125 } 129 }
126 fclose( statfile ); 130 fclose( statfile );
127 } 131 }
128
129 ProcessDtl->showMaximized(); 132 ProcessDtl->showMaximized();
130} 133}
diff --git a/noncore/settings/sysinfo/processinfo.h b/noncore/settings/sysinfo/processinfo.h
index 89d1a93..24b190e 100644
--- a/noncore/settings/sysinfo/processinfo.h
+++ b/noncore/settings/sysinfo/processinfo.h
@@ -21,24 +21,24 @@
21#define PROCESSINFO_H 21#define PROCESSINFO_H
22 22
23#include <qwidget.h> 23#include <qwidget.h>
24#include <qlistview.h> 24#include <qlistview.h>
25 25
26#include "processdetail.h" 26#include "processdetail.h"
27 27
28class ProcessInfo : public QWidget 28class ProcessInfo : public QWidget
29{ 29{
30 Q_OBJECT 30 Q_OBJECT
31public: 31public:
32 ProcessInfo( QWidget *parent = 0, const char *name = 0, WFlags f = 0 ); 32 ProcessInfo( QWidget *parent = 0, const char *name = 0, WFlags f = 0 );
33 ~ProcessInfo(); 33 ~ProcessInfo();
34 34
35private slots: 35private slots:
36 void updateData(); 36 void updateData();
37 void viewProcess(QListViewItem *); 37 void viewProcess( QListViewItem * );
38 38
39private: 39private:
40 QListView* ProcessView; 40 QListView* ProcessView;
41 ProcessDetail *ProcessDtl; 41 ProcessDetail *ProcessDtl;
42}; 42};
43 43
44#endif 44#endif