Diffstat (limited to 'noncore/settings/sysinfo/memory.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/settings/sysinfo/memory.cpp | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/noncore/settings/sysinfo/memory.cpp b/noncore/settings/sysinfo/memory.cpp index 781f0df..30d42d5 100644 --- a/noncore/settings/sysinfo/memory.cpp +++ b/noncore/settings/sysinfo/memory.cpp | |||
@@ -1,94 +1,98 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | #include <qlabel.h> | 21 | #include <qlabel.h> |
22 | #include <qtimer.h> | ||
23 | #include <qfile.h> | 22 | #include <qfile.h> |
24 | #include <qtextstream.h> | ||
25 | #include <qlayout.h> | 23 | #include <qlayout.h> |
24 | #include <qtextstream.h> | ||
25 | #include <qtimer.h> | ||
26 | #include <qwhatsthis.h> | ||
27 | |||
26 | #include "graph.h" | 28 | #include "graph.h" |
27 | #include "memory.h" | 29 | #include "memory.h" |
28 | 30 | ||
29 | MemoryInfo::MemoryInfo( QWidget *parent, const char *name, WFlags f ) | 31 | MemoryInfo::MemoryInfo( QWidget *parent, const char *name, WFlags f ) |
30 | : QWidget( parent, name, f ) | 32 | : QWidget( parent, name, WStyle_ContextHelp ) |
31 | { | 33 | { |
32 | QVBoxLayout *vb = new QVBoxLayout( this, 5 ); | 34 | QVBoxLayout *vb = new QVBoxLayout( this, 5 ); |
33 | 35 | ||
34 | totalMem = new QLabel( this ); | 36 | totalMem = new QLabel( this ); |
35 | vb->addWidget( totalMem ); | 37 | vb->addWidget( totalMem ); |
36 | 38 | ||
37 | data = new GraphData(); | 39 | data = new GraphData(); |
38 | // graph = new PieGraph( this ); | 40 | // graph = new PieGraph( this ); |
39 | graph = new BarGraph( this ); | 41 | graph = new BarGraph( this ); |
40 | graph->setFrameStyle( QFrame::Panel | QFrame::Sunken ); | 42 | graph->setFrameStyle( QFrame::Panel | QFrame::Sunken ); |
41 | vb->addWidget( graph, 1 ); | 43 | vb->addWidget( graph, 1 ); |
42 | graph->setData( data ); | 44 | graph->setData( data ); |
43 | 45 | ||
44 | legend = new GraphLegend( this ); | 46 | legend = new GraphLegend( this ); |
45 | vb->addWidget( legend ); | 47 | vb->addWidget( legend ); |
46 | legend->setData( data ); | 48 | legend->setData( data ); |
47 | 49 | ||
48 | vb->addStretch( 1 ); | 50 | vb->addStretch( 1 ); |
49 | updateData(); | 51 | updateData(); |
50 | 52 | ||
51 | QTimer *t = new QTimer( this ); | 53 | QTimer *t = new QTimer( this ); |
52 | connect( t, SIGNAL( timeout() ), this, SLOT( updateData() ) ); | 54 | connect( t, SIGNAL( timeout() ), this, SLOT( updateData() ) ); |
53 | t->start( 5000 ); | 55 | t->start( 5000 ); |
56 | |||
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." ) ); | ||
54 | } | 58 | } |
55 | 59 | ||
56 | MemoryInfo::~MemoryInfo() | 60 | MemoryInfo::~MemoryInfo() |
57 | { | 61 | { |
58 | delete data; | 62 | delete data; |
59 | } | 63 | } |
60 | 64 | ||
61 | void MemoryInfo::updateData() | 65 | void MemoryInfo::updateData() |
62 | { | 66 | { |
63 | QFile file( "/proc/meminfo" ); | 67 | QFile file( "/proc/meminfo" ); |
64 | 68 | ||
65 | if ( file.open( IO_ReadOnly ) ) { | 69 | if ( file.open( IO_ReadOnly ) ) { |
66 | QTextStream t( &file ); | 70 | QTextStream t( &file ); |
67 | QString dummy = t.readLine();// title | 71 | QString dummy = t.readLine();// title |
68 | t >> dummy; | 72 | t >> dummy; |
69 | int total, used, memfree, shared, buffers, cached; | 73 | int total, used, memfree, shared, buffers, cached; |
70 | t >> total; | 74 | t >> total; |
71 | total /= 1000; | 75 | total /= 1000; |
72 | t >> used; | 76 | t >> used; |
73 | used /= 1000; | 77 | used /= 1000; |
74 | t >> memfree; | 78 | t >> memfree; |
75 | memfree /= 1000; | 79 | memfree /= 1000; |
76 | t >> shared; | 80 | t >> shared; |
77 | shared /= 1000; | 81 | shared /= 1000; |
78 | t >> buffers; | 82 | t >> buffers; |
79 | buffers /= 1000; | 83 | buffers /= 1000; |
80 | t >> cached; | 84 | t >> cached; |
81 | cached /= 1000; | 85 | cached /= 1000; |
82 | int realUsed = total - ( buffers + cached + memfree ); | 86 | int realUsed = total - ( buffers + cached + memfree ); |
83 | data->clear(); | 87 | data->clear(); |
84 | data->addItem( tr("Used (%1 kB)").arg(realUsed), realUsed ); | 88 | data->addItem( tr("Used (%1 kB)").arg(realUsed), realUsed ); |
85 | data->addItem( tr("Buffers (%1 kB)").arg(buffers), buffers ); | 89 | data->addItem( tr("Buffers (%1 kB)").arg(buffers), buffers ); |
86 | data->addItem( tr("Cached (%1 kB)").arg(cached), cached ); | 90 | data->addItem( tr("Cached (%1 kB)").arg(cached), cached ); |
87 | data->addItem( tr("Free (%1 kB)").arg(memfree), memfree ); | 91 | data->addItem( tr("Free (%1 kB)").arg(memfree), memfree ); |
88 | totalMem->setText( tr( "Total Memory: %1 kB" ).arg( total ) ); | 92 | totalMem->setText( tr( "Total Memory: %1 kB" ).arg( total ) ); |
89 | graph->repaint( FALSE ); | 93 | graph->repaint( FALSE ); |
90 | legend->update(); | 94 | legend->update(); |
91 | } | 95 | } |
92 | } | 96 | } |
93 | 97 | ||
94 | 98 | ||