summaryrefslogtreecommitdiff
path: root/noncore/settings/sysinfo
authorbipolar <bipolar>2002-03-04 00:46:40 (UTC)
committer bipolar <bipolar>2002-03-04 00:46:40 (UTC)
commit01a9c4693d590ee210c5d6747c9fe7d982fb09df (patch) (side-by-side diff)
treead54d3f7cf506a8e61b7ce80ccaefd81e645051a /noncore/settings/sysinfo
parentdd1c6dda8ac16a1e506f441d6fa447930dffe9ee (diff)
downloadopie-01a9c4693d590ee210c5d6747c9fe7d982fb09df.zip
opie-01a9c4693d590ee210c5d6747c9fe7d982fb09df.tar.gz
opie-01a9c4693d590ee210c5d6747c9fe7d982fb09df.tar.bz2
committed by ljp (llornkcor): improvements by Dan Williams, and and alignment by me
Diffstat (limited to 'noncore/settings/sysinfo') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/sysinfo/processinfo.cpp119
-rw-r--r--noncore/settings/sysinfo/processinfo.h123
-rw-r--r--noncore/settings/sysinfo/sysinfo.cpp2
-rw-r--r--noncore/settings/sysinfo/sysinfo.pro40
4 files changed, 265 insertions, 19 deletions
diff --git a/noncore/settings/sysinfo/processinfo.cpp b/noncore/settings/sysinfo/processinfo.cpp
new file mode 100644
index 0000000..bd954c8
--- a/dev/null
+++ b/noncore/settings/sysinfo/processinfo.cpp
@@ -0,0 +1,119 @@
+/**********************************************************************
+** ProcessInfo
+**
+** Display process information
+**
+** Copyright (C) 2002, Dan Williams
+** williamsdr@acm.org
+** http://draknor.net
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU General Public License version 2 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file.
+**
+** 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 <qheader.h>
+#include <qlistview.h>
+#include <qlayout.h>
+#include <qtimer.h>
+#include <qfile.h>
+#include <qdir.h>
+
+#include "processinfo.h"
+
+ProcessInfo::ProcessInfo( QWidget* parent, const char* name, WFlags fl )
+ : QWidget( parent, name, fl )
+{
+ QVBoxLayout *vb = new QVBoxLayout( this, 5 );
+
+ ProcessView = new QListView( this, "ProcessView" );
+ int colnum = ProcessView->addColumn( tr( "PID" ) );
+ ProcessView->setColumnAlignment( colnum, Qt::AlignRight );
+ colnum = ProcessView->addColumn( tr( "Command" ),90 );
+ ProcessView->setColumnAlignment( colnum, Qt::AlignRight );
+ colnum = ProcessView->addColumn( tr( "Status" ) );
+ ProcessView->setColumnAlignment( colnum, Qt::AlignRight );
+ colnum = ProcessView->addColumn( tr( "Time" ) );
+ ProcessView->setColumnAlignment( colnum, Qt::AlignRight );
+ ProcessView->setAllColumnsShowFocus( TRUE );
+ connect( ProcessView, SIGNAL( doubleClicked(QListViewItem *) ), this, SLOT( viewProcess(QListViewItem *) ) );
+
+ vb->addWidget( ProcessView );
+
+ QTimer *t = new QTimer( this );
+ connect( t, SIGNAL( timeout() ), this, SLOT( updateData() ) );
+ t->start( 5000 );
+
+ updateData();
+}
+
+ProcessInfo::~ProcessInfo()
+{
+}
+
+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,
+ signal, blocked, sigignore, sigcatch;
+ uint flags, minflt, cminflt, majflt, cmajflt, timeout, itrealvalue, vsize, rss, rlim, startcode,
+ endcode, startstack, kstkesp, kstkeip, wchan;
+ char state;
+ char comm[255];
+
+ ProcessView->clear();
+
+ QDir *procdir = new QDir("/proc");
+ procdir->setFilter(QDir::Dirs);
+ procdir->setSorting(QDir::Name);
+ QFileInfoList *proclist = new QFileInfoList(*(procdir->entryInfoList()));
+ if ( proclist )
+ {
+ QFileInfoListIterator it(*proclist);
+ QFileInfo *f;
+ while ( ( f = it.current() ) != 0 )
+ {
+ ++it;
+ processnum = f->fileName();
+ if ( processnum >= "0" && processnum <= "99999" )
+ {
+ FILE *procfile = fopen( ( QString ) ( "/proc/" + processnum + "/stat"), "r");
+
+ if ( procfile )
+ {
+ fscanf( procfile,
+ "%d %s %c %d %d %d %d %d %u %u %u %u %u %d %d %d %d %d %d %u %u %d %u %u %u %u %u %u %u %u %d %d %d %d %u",
+ &pid, comm, &state, &ppid, &pgrp, &session,&tty, &tpgid, &flags, &minflt, &cminflt,
+ &majflt, &cmajflt, &utime, &stime, &cutime, &cstime, &counter, &priority, &timeout,
+ &itrealvalue, &starttime, &vsize, &rss, &rlim, &startcode, &endcode, &startstack,
+ &kstkesp, &kstkeip, &signal, &blocked, &sigignore, &sigcatch, &wchan );
+ processnum = processnum.rightJustify( 5, ' ' );
+ processcmd = QString( comm ).replace( QRegExp( "(" ), "" );
+ processcmd = processcmd.replace( QRegExp( ")" ), "" );
+ processstatus = state;
+ processtime.setNum( ( utime + stime ) / 100 );
+ processtime = processtime.rightJustify( 9, ' ' );
+ fclose( procfile );
+
+ ( void ) new QListViewItem( ProcessView, processnum, processcmd, processstatus, processtime );
+ }
+ }
+ }
+ }
+
+ delete proclist;
+ delete procdir;
+}
+
+void ProcessInfo::viewProcess(QListViewItem *process)
+{
+//printf("Double click for PID: %s\n", process->text(0).stripWhiteSpace().latin1());
+}
diff --git a/noncore/settings/sysinfo/processinfo.h b/noncore/settings/sysinfo/processinfo.h
new file mode 100644
index 0000000..f2eedc9
--- a/dev/null
+++ b/noncore/settings/sysinfo/processinfo.h
@@ -0,0 +1,123 @@
+/**********************************************************************
+** ProcessInfo
+**
+** Display process information
+**
+** Copyright (C) 2002, Dan Williams
+** williamsdr@acm.org
+** http://draknor.net
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU General Public License version 2 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file.
+**
+** 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>
+#include <qlistview.h>
+
+class ProcessInfo : public QWidget
+{
+ Q_OBJECT
+public:
+ ProcessInfo( QWidget *parent = 0, const char *name = 0, WFlags f = 0 );
+ ~ProcessInfo();
+
+private slots:
+ void updateData();
+ void viewProcess(QListViewItem *);
+
+private:
+ QListView* ProcessView;
+};
+
+#endif
+/**********************************************************************
+** ProcessInfo
+**
+** Display process information
+**
+** Copyright (C) 2002, Dan Williams
+** williamsdr@acm.org
+** http://draknor.net
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU General Public License version 2 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file.
+**
+** 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>
+#include <qlistview.h>
+
+class ProcessInfo : public QWidget
+{
+ Q_OBJECT
+public:
+ ProcessInfo( QWidget *parent = 0, const char *name = 0, WFlags f = 0 );
+ ~ProcessInfo();
+
+private slots:
+ void updateData();
+ void viewProcess(QListViewItem *);
+
+private:
+ QListView* ProcessView;
+};
+
+#endif
+/**********************************************************************
+** ProcessInfo
+**
+** Display process information
+**
+** Copyright (C) 2002, Dan Williams
+** williamsdr@acm.org
+** http://draknor.net
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU General Public License version 2 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file.
+**
+** 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>
+#include <qlistview.h>
+
+class ProcessInfo : public QWidget
+{
+ Q_OBJECT
+public:
+ ProcessInfo( QWidget *parent = 0, const char *name = 0, WFlags f = 0 );
+ ~ProcessInfo();
+
+private slots:
+ void updateData();
+ void viewProcess(QListViewItem *);
+
+private:
+ QListView* ProcessView;
+};
+
+#endif
diff --git a/noncore/settings/sysinfo/sysinfo.cpp b/noncore/settings/sysinfo/sysinfo.cpp
index bc483aa..5697f36 100644
--- a/noncore/settings/sysinfo/sysinfo.cpp
+++ b/noncore/settings/sysinfo/sysinfo.cpp
@@ -22,6 +22,7 @@
#include "load.h"
#include "storage.h"
//#include "graphics.h"
+#include "processinfo.h"
#include "versioninfo.h"
#include "sysinfo.h"
@@ -45,6 +46,7 @@ SystemInfo::SystemInfo( QWidget *parent, const char *name, WFlags f )
#endif
tab->addTab( new LoadInfo( tab ), tr("CPU") );
// tab->addTab( new Graphics( tab ), tr("Graphics") );
+ tab->addTab( new ProcessInfo( tab ), tr("Process") );
tab->addTab( new VersionInfo( tab ), tr("Version") );
resize( 220, 180 );
diff --git a/noncore/settings/sysinfo/sysinfo.pro b/noncore/settings/sysinfo/sysinfo.pro
index 3393a12..7f84dec 100644
--- a/noncore/settings/sysinfo/sysinfo.pro
+++ b/noncore/settings/sysinfo/sysinfo.pro
@@ -1,25 +1,27 @@
-TEMPLATE = app
-CONFIG = qt warn_on release
-DESTDIR = $(OPIEDIR)/bin
-HEADERS = memory.h \
- graph.h \
- load.h \
- storage.h \
- versioninfo.h \
- sysinfo.h
-SOURCES = main.cpp \
- memory.cpp \
- graph.cpp \
- load.cpp \
- storage.cpp \
- versioninfo.cpp \
- sysinfo.cpp
-INTERFACES =
+TEMPLATE = app
+CONFIG = qt warn_on release
+DESTDIR = $(OPIEDIR)/bin
+HEADERS = memory.h \
+ graph.h \
+ load.h \
+ storage.h \
+ processinfo.h \
+ versioninfo.h \
+ sysinfo.h
+SOURCES = main.cpp \
+ memory.cpp \
+ graph.cpp \
+ load.cpp \
+ storage.cpp \
+ processinfo.cpp \
+ versioninfo.cpp \
+ sysinfo.cpp
+INTERFACES =
INCLUDEPATH += $(OPIEDIR)/include
-DEPENDPATH += $(OPIEDIR)/include
+DEPENDPATH += $(OPIEDIR)/include
LIBS += -lqpe
-TARGET = sysinfo
+TARGET = sysinfo
TRANSLATIONS = ../i18n/de/sysinfo.ts