summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/sysinfo/storage.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/noncore/settings/sysinfo/storage.cpp b/noncore/settings/sysinfo/storage.cpp
index fc583e3..9f70fc5 100644
--- a/noncore/settings/sysinfo/storage.cpp
+++ b/noncore/settings/sysinfo/storage.cpp
@@ -1,177 +1,182 @@
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// additions copyright 2002 by L.J. Potter 20// additions copyright 2002 by L.J. Potter
21 21
22#include <qpe/storage.h> 22#include <qpe/storage.h>
23 23
24#include <qlabel.h> 24#include <qlabel.h>
25#include <qlayout.h> 25#include <qlayout.h>
26#include <qscrollview.h> 26#include <qscrollview.h>
27#include <qwhatsthis.h> 27#include <qwhatsthis.h>
28 28
29#include "graph.h" 29#include "graph.h"
30#include "storage.h" 30#include "storage.h"
31 31
32#include <stdio.h> 32#include <stdio.h>
33 #if defined(_OS_LINUX_) || defined(Q_OS_LINUX) 33 #if defined(_OS_LINUX_) || defined(Q_OS_LINUX)
34#include <sys/vfs.h> 34#include <sys/vfs.h>
35#include <mntent.h> 35#include <mntent.h>
36 #endif 36 #endif
37 37
38FileSysInfo::FileSysInfo( QWidget *parent, const char *name ) 38FileSysInfo::FileSysInfo( QWidget *parent, const char *name )
39 : QWidget( parent, name ) 39 : QWidget( parent, name )
40{ 40{
41 QVBoxLayout *tmpvb = new QVBoxLayout( this ); 41 QVBoxLayout *tmpvb = new QVBoxLayout( this );
42 QScrollView *sv = new QScrollView( this ); 42 QScrollView *sv = new QScrollView( this );
43 tmpvb->addWidget( sv, 0, 0 ); 43 tmpvb->addWidget( sv, 0, 0 );
44 sv->setResizePolicy( QScrollView::AutoOneFit ); 44 sv->setResizePolicy( QScrollView::AutoOneFit );
45 sv->setFrameStyle( QFrame::NoFrame ); 45 sv->setFrameStyle( QFrame::NoFrame );
46 container = new QWidget( sv->viewport() ); 46 container = new QWidget( sv->viewport() );
47 sv->addChild( container ); 47 sv->addChild( container );
48 vb = 0x0; 48 vb = 0x0;
49 49
50 storage = new StorageInfo( this ); 50 storage = new StorageInfo( this );
51 connect( storage, SIGNAL( disksChanged() ), this, SLOT( disksChanged() ) ); 51 connect( storage, SIGNAL( disksChanged() ), this, SLOT( disksChanged() ) );
52 52
53 lines.setAutoDelete(TRUE); 53 lines.setAutoDelete(TRUE);
54 54
55 rebuildDisks = TRUE; 55 rebuildDisks = TRUE;
56 updateMounts(); 56 updateMounts();
57 startTimer( 5000 ); 57 startTimer( 5000 );
58} 58}
59 59
60 60
61void FileSysInfo::timerEvent(QTimerEvent*) 61void FileSysInfo::timerEvent(QTimerEvent*)
62{ 62{
63 updateMounts(); 63 updateMounts();
64} 64}
65 65
66void FileSysInfo::updateMounts() 66void FileSysInfo::updateMounts()
67{ 67{
68 storage->update(); 68 storage->update();
69 69
70 if ( rebuildDisks ) 70 if ( rebuildDisks )
71 { 71 {
72 disks.clear(); 72 disks.clear();
73 lines.clear(); 73 lines.clear();
74 74
75 delete vb; 75 delete vb;
76 vb = new QVBoxLayout( container/*, n > 3 ? 1 : 5*/ ); 76 vb = new QVBoxLayout( container/*, n > 3 ? 1 : 5*/ );
77 77
78 bool frst=TRUE; 78 bool frst=TRUE;
79 79
80 FileSystem *fs; 80 FileSystem *fs;
81 for ( QListIterator<FileSystem> it(storage->fileSystems()); it.current(); ++it ) 81 for ( QListIterator<FileSystem> it(storage->fileSystems()); it.current(); ++it )
82 { 82 {
83 fs = it.current(); 83 fs = it.current();
84 84
85 if(fs->disk().left(5) == "tmpfs")
86 {
87 continue;
88 }
89
85 if ( !frst ) 90 if ( !frst )
86 { 91 {
87 QFrame *f = new QFrame( container ); 92 QFrame *f = new QFrame( container );
88 vb->addWidget(f); 93 vb->addWidget(f);
89 f->setFrameStyle( QFrame::HLine | QFrame::Sunken ); 94 f->setFrameStyle( QFrame::HLine | QFrame::Sunken );
90 lines.append(f); 95 lines.append(f);
91 f->show(); 96 f->show();
92 } 97 }
93 frst = FALSE; 98 frst = FALSE;
94 99
95 MountInfo *mi = new MountInfo( fs, container ); 100 MountInfo *mi = new MountInfo( fs, container );
96 vb->addWidget( mi ); 101 vb->addWidget( mi );
97 disks.insert( fs->path(), mi ); 102 disks.insert( fs->path(), mi );
98 mi->show(); 103 mi->show();
99 QString tempstr = fs->name().left( 2 ); 104 QString tempstr = fs->name().left( 2 );
100 if ( tempstr == tr( "CF" ) ) 105 if ( tempstr == tr( "CF" ) )
101 QWhatsThis::add( mi, tr( "This graph represents how much memory is currently used on this Compact Flash memory card." ) ); 106 QWhatsThis::add( mi, tr( "This graph represents how much memory is currently used on this Compact Flash memory card." ) );
102 else if ( tempstr == tr( "Ha" ) ) 107 else if ( tempstr == tr( "Ha" ) )
103 QWhatsThis::add( mi, tr( "This graph represents how much storage is currently used on this hard drive." ) ); 108 QWhatsThis::add( mi, tr( "This graph represents how much storage is currently used on this hard drive." ) );
104 else if ( tempstr == tr( "SD" ) ) 109 else if ( tempstr == tr( "SD" ) )
105 QWhatsThis::add( mi, tr( "This graph represents how much memory is currently used on this Secure Digital memory card." ) ); 110 QWhatsThis::add( mi, tr( "This graph represents how much memory is currently used on this Secure Digital memory card." ) );
106 else if ( tempstr == tr( "SC" ) ) 111 else if ( tempstr == tr( "SC" ) )
107 QWhatsThis::add( mi, tr( "This graph represents how much storage is currently used on this hard drive." ) ); 112 QWhatsThis::add( mi, tr( "This graph represents how much storage is currently used on this hard drive." ) );
108 else if ( tempstr == tr( "In" ) ) 113 else if ( tempstr == tr( "In" ) )
109 QWhatsThis::add( mi, tr( "This graph represents how much memory is currently used of the built-in memory (i.e. Flash memory) on this handheld device." ) ); 114 QWhatsThis::add( mi, tr( "This graph represents how much memory is currently used of the built-in memory (i.e. Flash memory) on this handheld device." ) );
110 else if ( tempstr == tr( "RA" ) ) 115 else if ( tempstr == tr( "RA" ) )
111 QWhatsThis::add( mi, tr( "This graph represents how much memory is currently used of the temporary RAM disk." ) ); 116 QWhatsThis::add( mi, tr( "This graph represents how much memory is currently used of the temporary RAM disk." ) );
112 } 117 }
113 vb->addStretch(); 118 vb->addStretch();
114 } 119 }
115 else 120 else
116 { 121 {
117 for (QDictIterator<MountInfo> i(disks); i.current(); ++i) 122 for (QDictIterator<MountInfo> i(disks); i.current(); ++i)
118 i.current()->updateData(); 123 i.current()->updateData();
119 } 124 }
120 125
121 rebuildDisks = FALSE; 126 rebuildDisks = FALSE;
122} 127}
123 128
124void FileSysInfo::disksChanged() 129void FileSysInfo::disksChanged()
125{ 130{
126 rebuildDisks = TRUE; 131 rebuildDisks = TRUE;
127} 132}
128 133
129MountInfo::MountInfo( FileSystem *filesys, QWidget *parent, const char *name ) 134MountInfo::MountInfo( FileSystem *filesys, QWidget *parent, const char *name )
130 : QWidget( parent, name ) 135 : QWidget( parent, name )
131{ 136{
132 QVBoxLayout *vb = new QVBoxLayout( this, 3 ); 137 QVBoxLayout *vb = new QVBoxLayout( this, 3 );
133 138
134 totalSize = new QLabel( this ); 139 totalSize = new QLabel( this );
135 vb->addWidget( totalSize ); 140 vb->addWidget( totalSize );
136 141
137 fs = filesys; 142 fs = filesys;
138 title = fs->name(); 143 title = fs->name() + "\t (" + fs->path() + ')';
139 144
140 data = new GraphData(); 145 data = new GraphData();
141 graph = new BarGraph( this ); 146 graph = new BarGraph( this );
142 graph->setFrameStyle( QFrame::Panel | QFrame::Sunken ); 147 graph->setFrameStyle( QFrame::Panel | QFrame::Sunken );
143 vb->addWidget( graph, 1 ); 148 vb->addWidget( graph, 1 );
144 graph->setData( data ); 149 graph->setData( data );
145 150
146 legend = new GraphLegend( this ); 151 legend = new GraphLegend( this );
147 legend->setOrientation(Horizontal); 152 legend->setOrientation(Horizontal);
148 vb->addWidget( legend ); 153 vb->addWidget( legend );
149 legend->setData( data ); 154 legend->setData( data );
150 155
151 updateData(); 156 updateData();
152} 157}
153 158
154MountInfo::~MountInfo() 159MountInfo::~MountInfo()
155{ 160{
156 delete data; 161 delete data;
157} 162}
158 163
159void MountInfo::updateData() 164void MountInfo::updateData()
160{ 165{
161 long mult = fs->blockSize() / 1024; 166 long mult = fs->blockSize() / 1024;
162 long div = 1024 / fs->blockSize(); 167 long div = 1024 / fs->blockSize();
163 if ( !mult ) mult = 1; 168 if ( !mult ) mult = 1;
164 if ( !div ) div = 1; 169 if ( !div ) div = 1;
165 long total = fs->totalBlocks() * mult / div; 170 long total = fs->totalBlocks() * mult / div;
166 long avail = fs->availBlocks() * mult / div; 171 long avail = fs->availBlocks() * mult / div;
167 long used = total - avail; 172 long used = total - avail;
168 totalSize->setText( title + tr(" : %1 kB").arg( total ) ); 173 totalSize->setText( title + tr(" : %1 kB").arg( total ) );
169 data->clear(); 174 data->clear();
170 data->addItem( tr("Used (%1 kB)").arg(used), used ); 175 data->addItem( tr("Used (%1 kB)").arg(used), used );
171 data->addItem( tr("Available (%1 kB)").arg(avail), avail ); 176 data->addItem( tr("Available (%1 kB)").arg(avail), avail );
172 graph->repaint( FALSE ); 177 graph->repaint( FALSE );
173 legend->update(); 178 legend->update();
174 graph->show(); 179 graph->show();
175 legend->show(); 180 legend->show();
176} 181}
177 182