summaryrefslogtreecommitdiff
path: root/noncore/settings/sysinfo
authormickeyl <mickeyl>2003-11-03 22:29:08 (UTC)
committer mickeyl <mickeyl>2003-11-03 22:29:08 (UTC)
commit28812a7f2c5bd370a55824a73f6a0010f8ea9f7e (patch) (unidiff)
tree0f90e62371740645a631f06c01750b9c2bd7b381 /noncore/settings/sysinfo
parentfd87de118d519108b99125f190f3aa6bd2a0b4cb (diff)
downloadopie-28812a7f2c5bd370a55824a73f6a0010f8ea9f7e.zip
opie-28812a7f2c5bd370a55824a73f6a0010f8ea9f7e.tar.gz
opie-28812a7f2c5bd370a55824a73f6a0010f8ea9f7e.tar.bz2
show swap memory on Memory tab
Diffstat (limited to 'noncore/settings/sysinfo') (more/less context) (show whitespace changes)
-rw-r--r--noncore/settings/sysinfo/memory.cpp71
-rw-r--r--noncore/settings/sysinfo/memory.h16
2 files changed, 73 insertions, 14 deletions
diff --git a/noncore/settings/sysinfo/memory.cpp b/noncore/settings/sysinfo/memory.cpp
index 4f612d8..23dd8bd 100644
--- a/noncore/settings/sysinfo/memory.cpp
+++ b/noncore/settings/sysinfo/memory.cpp
@@ -19,17 +19,16 @@
19**********************************************************************/ 19**********************************************************************/
20 20
21#include <qlabel.h> 21#include <qlabel.h>
22#include <qtimer.h>
22#include <qfile.h> 23#include <qfile.h>
23#include <qlayout.h>
24#include <qtextstream.h> 24#include <qtextstream.h>
25#include <qtimer.h> 25#include <qlayout.h>
26#include <qwhatsthis.h> 26#include <qwhatsthis.h>
27
28#include "graph.h" 27#include "graph.h"
29#include "memory.h" 28#include "memory.h"
30 29
31MemoryInfo::MemoryInfo( QWidget *parent, const char *name, WFlags ) 30MemoryInfo::MemoryInfo( QWidget *parent, const char *name, WFlags f )
32 : QWidget( parent, name, WStyle_ContextHelp ) 31 : QWidget( parent, name, f )
33{ 32{
34 QVBoxLayout *vb = new QVBoxLayout( this, 5 ); 33 QVBoxLayout *vb = new QVBoxLayout( this, 5 );
35 34
@@ -37,7 +36,6 @@ MemoryInfo::MemoryInfo( QWidget *parent, const char *name, WFlags )
37 vb->addWidget( totalMem ); 36 vb->addWidget( totalMem );
38 37
39 data = new GraphData(); 38 data = new GraphData();
40// graph = new PieGraph( this );
41 graph = new BarGraph( this ); 39 graph = new BarGraph( this );
42 graph->setFrameStyle( QFrame::Panel | QFrame::Sunken ); 40 graph->setFrameStyle( QFrame::Panel | QFrame::Sunken );
43 vb->addWidget( graph, 1 ); 41 vb->addWidget( graph, 1 );
@@ -47,6 +45,19 @@ MemoryInfo::MemoryInfo( QWidget *parent, const char *name, WFlags )
47 vb->addWidget( legend ); 45 vb->addWidget( legend );
48 legend->setData( data ); 46 legend->setData( data );
49 47
48 swapMem = new QLabel( this );
49 vb->addWidget( swapMem );
50
51 swapdata = new GraphData();
52 swapgraph = new BarGraph( this );
53 swapgraph->setFrameStyle( QFrame::Panel | QFrame::Sunken );
54 vb->addWidget( swapgraph, 1 );
55 swapgraph->setData( swapdata );
56
57 swaplegend = new GraphLegend( this );
58 vb->addWidget( swaplegend );
59 swaplegend->setData( swapdata );
60
50 vb->addStretch( 1 ); 61 vb->addStretch( 1 );
51 updateData(); 62 updateData();
52 63
@@ -54,7 +65,8 @@ MemoryInfo::MemoryInfo( QWidget *parent, const char *name, WFlags )
54 connect( t, SIGNAL( timeout() ), this, SLOT( updateData() ) ); 65 connect( t, SIGNAL( timeout() ), this, SLOT( updateData() ) );
55 t->start( 5000 ); 66 t->start( 5000 );
56 67
57 QWhatsThis::add( this, tr( "This page shows how memory (i.e. RAM) is being allocated on your handheld device.\nMemory is categorized as follows:\n\n1. Used - memory used to by Opie and any running applications.\n2. Buffers - temporary storage used to improve performance\n3. Cached - information that has recently been used, but has not been freed yet.\n4. Free - memory not currently used by Opie or any running applications." ) ); 68 QWhatsThis::add( this, tr( "This page shows how memory (i.e. RAM) is being allocated on your device.\nMemory is categorized as follows:\n\n1. Used - memory used to by Opie and any running applications.\n2. Buffers - temporary storage used to improve performance\n3. Cached - information that has recently been used, but has not been freed yet.\n4. Free - memory not currently used by Opie or any running applications." ) );
69
58} 70}
59 71
60MemoryInfo::~MemoryInfo() 72MemoryInfo::~MemoryInfo()
@@ -66,11 +78,11 @@ void MemoryInfo::updateData()
66{ 78{
67 QFile file( "/proc/meminfo" ); 79 QFile file( "/proc/meminfo" );
68 80
69 if ( file.open( IO_ReadOnly ) ) { 81 if ( file.open( IO_ReadOnly ) )
82 {
70 QTextStream t( &file ); 83 QTextStream t( &file );
71 QString dummy = t.readLine();// title 84 QString dummy = t.readLine();// title
72 t >> dummy; 85 t >> dummy;
73 int total, used, memfree, shared, buffers, cached;
74 t >> total; 86 t >> total;
75 total /= 1000; 87 total /= 1000;
76 t >> used; 88 t >> used;
@@ -83,16 +95,47 @@ void MemoryInfo::updateData()
83 buffers /= 1000; 95 buffers /= 1000;
84 t >> cached; 96 t >> cached;
85 cached /= 1000; 97 cached /= 1000;
86 int realUsed = total - ( buffers + cached + memfree ); 98 realUsed = total - ( buffers + cached + memfree );
99
100 totalMem->setText( tr( "Total Memory: %1 kB" ).arg( total ) );
87 data->clear(); 101 data->clear();
88 data->addItem( tr("Used (%1 kB)").arg(realUsed), realUsed ); 102 data->addItem( tr("Used (%1 kB)").arg(realUsed), realUsed );
89 data->addItem( tr("Buffers (%1 kB)").arg(buffers), buffers ); 103 data->addItem( tr("Buffers (%1 kB)").arg(buffers), buffers );
90 data->addItem( tr("Cached (%1 kB)").arg(cached), cached ); 104 data->addItem( tr("Cached (%1 kB)").arg(cached), cached );
91 data->addItem( tr("Free (%1 kB)").arg(memfree), memfree ); 105 data->addItem( tr("Free (%1 kB)").arg(memfree), memfree );
92 totalMem->setText( tr( "Total Memory: %1 kB" ).arg( total ) ); 106
93 graph->repaint( FALSE ); 107 graph->hide();
108 graph->show();
94 legend->update(); 109 legend->update();
95 }
96}
97 110
111 // swapfile
112 t >> dummy;
113 t >> swaptotal;
114 swaptotal /= 1000;
115 t >> swapused;
116 swapused /= 1000;
117 t >> swapfree;
118 swapfree /= 1000;
119
120 if (swaptotal > 0)
121 {
122 swapMem->setText( tr( "Total Swap: %1 kB" ).arg( swaptotal ) );
123 swapdata->clear();
124 swapdata->addItem( tr("Used (%1 kB)").arg(swapused), swapused );
125 swapdata->addItem( tr("Free (%1 kB)").arg(swapfree), swapfree );
126
127 swapMem->show();
128 swapgraph->show();
129 swaplegend->show();
98 130
131 swapgraph->repaint( FALSE );
132 swaplegend->update();
133 }
134 else
135 {
136 swapMem->hide();
137 swapgraph->hide();
138 swaplegend->hide();
139 }
140 }
141}
diff --git a/noncore/settings/sysinfo/memory.h b/noncore/settings/sysinfo/memory.h
index 696f97c..c2af948 100644
--- a/noncore/settings/sysinfo/memory.h
+++ b/noncore/settings/sysinfo/memory.h
@@ -35,6 +35,17 @@ public:
35 MemoryInfo( QWidget *parent = 0, const char *name = 0, WFlags f = 0 ); 35 MemoryInfo( QWidget *parent = 0, const char *name = 0, WFlags f = 0 );
36 ~MemoryInfo(); 36 ~MemoryInfo();
37 37
38 unsigned long total;
39 unsigned long used;
40 unsigned long memfree;
41 unsigned long shared;
42 unsigned long buffers;
43 unsigned long cached;
44 unsigned long realUsed;
45 unsigned long swaptotal;
46 unsigned long swapused;
47 unsigned long swapfree;
48
38private slots: 49private slots:
39 void updateData(); 50 void updateData();
40 51
@@ -43,6 +54,11 @@ private:
43 GraphData *data; 54 GraphData *data;
44 Graph *graph; 55 Graph *graph;
45 GraphLegend *legend; 56 GraphLegend *legend;
57
58 QLabel* swapMem;
59 GraphData *swapdata;
60 Graph *swapgraph;
61 GraphLegend *swaplegend;
46}; 62};
47 63
48#endif 64#endif