summaryrefslogtreecommitdiff
authormickeyl <mickeyl>2003-11-03 22:29:08 (UTC)
committer mickeyl <mickeyl>2003-11-03 22:29:08 (UTC)
commit28812a7f2c5bd370a55824a73f6a0010f8ea9f7e (patch) (unidiff)
tree0f90e62371740645a631f06c01750b9c2bd7b381
parentfd87de118d519108b99125f190f3aa6bd2a0b4cb (diff)
downloadopie-28812a7f2c5bd370a55824a73f6a0010f8ea9f7e.zip
opie-28812a7f2c5bd370a55824a73f6a0010f8ea9f7e.tar.gz
opie-28812a7f2c5bd370a55824a73f6a0010f8ea9f7e.tar.bz2
show swap memory on Memory tab
Diffstat (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
@@ -21,8 +21,7 @@
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"
@@ -30,4 +29,4 @@
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{
@@ -39,3 +38,2 @@ MemoryInfo::MemoryInfo( QWidget *parent, const char *name, WFlags )
39 data = new GraphData(); 38 data = new GraphData();
40// graph = new PieGraph( this );
41 graph = new BarGraph( this ); 39 graph = new BarGraph( this );
@@ -49,2 +47,15 @@ MemoryInfo::MemoryInfo( QWidget *parent, const char *name, WFlags )
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 );
@@ -56,3 +67,4 @@ MemoryInfo::MemoryInfo( QWidget *parent, const char *name, WFlags )
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}
@@ -68,3 +80,4 @@ void MemoryInfo::updateData()
68 80
69 if ( file.open( IO_ReadOnly ) ) { 81 if ( file.open( IO_ReadOnly ) )
82 {
70 QTextStream t( &file ); 83 QTextStream t( &file );
@@ -72,3 +85,2 @@ void MemoryInfo::updateData()
72 t >> dummy; 85 t >> dummy;
73 int total, used, memfree, shared, buffers, cached;
74 t >> total; 86 t >> total;
@@ -85,3 +97,5 @@ void MemoryInfo::updateData()
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();
@@ -91,8 +105,37 @@ void MemoryInfo::updateData()
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
@@ -37,2 +37,13 @@ public:
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:
@@ -45,2 +56,7 @@ private:
45 GraphLegend *legend; 56 GraphLegend *legend;
57
58 QLabel* swapMem;
59 GraphData *swapdata;
60 Graph *swapgraph;
61 GraphLegend *swaplegend;
46}; 62};