summaryrefslogtreecommitdiff
path: root/noncore/settings/sysinfo/storage.cpp
Unidiff
Diffstat (limited to 'noncore/settings/sysinfo/storage.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/sysinfo/storage.cpp27
1 files changed, 9 insertions, 18 deletions
diff --git a/noncore/settings/sysinfo/storage.cpp b/noncore/settings/sysinfo/storage.cpp
index c4474d5..4ef7122 100644
--- a/noncore/settings/sysinfo/storage.cpp
+++ b/noncore/settings/sysinfo/storage.cpp
@@ -41,75 +41,67 @@ FileSysInfo::FileSysInfo( QWidget *parent, const char *name )
41{ 41{
42 QVBoxLayout *tmpvb = new QVBoxLayout( this ); 42 QVBoxLayout *tmpvb = new QVBoxLayout( this );
43 QScrollView *sv = new QScrollView( this ); 43 QScrollView *sv = new QScrollView( this );
44 tmpvb->addWidget( sv, 0, 0 ); 44 tmpvb->addWidget( sv, 0, 0 );
45 sv->setResizePolicy( QScrollView::AutoOneFit ); 45 sv->setResizePolicy( QScrollView::AutoOneFit );
46 sv->setFrameStyle( QFrame::NoFrame ); 46 sv->setFrameStyle( QFrame::NoFrame );
47 container = new QWidget( sv->viewport() ); 47 container = new QWidget( sv->viewport() );
48 sv->addChild( container ); 48 sv->addChild( container );
49 vb = 0x0; 49 vb = 0x0;
50 50
51 storage = new StorageInfo( this ); 51 storage = new StorageInfo( this );
52 connect( storage, SIGNAL( disksChanged() ), this, SLOT( disksChanged() ) ); 52 connect( storage, SIGNAL( disksChanged() ), this, SLOT( disksChanged() ) );
53 53
54 lines.setAutoDelete(TRUE); 54 lines.setAutoDelete(TRUE);
55 55
56 rebuildDisks = TRUE; 56 rebuildDisks = TRUE;
57 updateMounts(); 57 updateMounts();
58 startTimer( 5000 ); 58 startTimer( 5000 );
59} 59}
60 60
61
61void FileSysInfo::timerEvent(QTimerEvent*) 62void FileSysInfo::timerEvent(QTimerEvent*)
62{ 63{
63 updateMounts(); 64 updateMounts();
64} 65}
65 66
66void FileSysInfo::updateMounts() 67void FileSysInfo::updateMounts()
67{ 68{
68 storage->update(); 69 storage->update();
69 70
70 if ( rebuildDisks ) 71 if ( rebuildDisks )
71 { 72 {
72 // Cannot auto delete QDict<MountInfo> disks because it seems to delete
73 // the filesystem object as well causing a segfault
74 MountInfo *mi;
75 for ( QDictIterator<MountInfo> delit(disks); delit.current(); ++delit )
76 {
77 mi = delit.current();
78 mi->fs = 0x0;
79 delete mi;
80 }
81 disks.clear(); 73 disks.clear();
82 lines.clear(); 74 lines.clear();
83 75
84 delete vb; 76 delete vb;
85 vb = new QVBoxLayout( container/*, n > 3 ? 1 : 5*/ ); 77 vb = new QVBoxLayout( container/*, n > 3 ? 1 : 5*/ );
86 78
87 bool frst=TRUE; 79 bool frst=TRUE;
88 80
89 FileSystem *fs; 81 FileSystem *fs;
90 for ( QListIterator<FileSystem> it(storage->fileSystems()); it.current(); ++it ) 82 for ( QListIterator<FileSystem> it(storage->fileSystems()); it.current(); ++it )
91 { 83 {
92 fs = it.current(); 84 fs = it.current();
93 85
94 if ( !frst ) 86 if ( !frst )
95 { 87 {
96 QFrame *f = new QFrame( container ); 88 QFrame *f = new QFrame( container );
97 vb->addWidget(f); 89 vb->addWidget(f);
98 f->setFrameStyle( QFrame::HLine | QFrame::Sunken ); 90 f->setFrameStyle( QFrame::HLine | QFrame::Sunken );
99 lines.append(f); 91 lines.append(f);
100 f->show(); 92 f->show();
101 } 93 }
102 frst = FALSE; 94 frst = FALSE;
103 95
104 MountInfo *mi = new MountInfo( fs, container ); 96 MountInfo *mi = new MountInfo( fs, container );
105 vb->addWidget( mi ); 97 vb->addWidget( mi );
106 disks.insert( fs->path(), mi ); 98 disks.insert( fs->path(), mi );
107 mi->show(); 99 mi->show();
108 QString tempstr = fs->name().left( 2 ); 100 QString tempstr = fs->name().left( 2 );
109 if ( tempstr == tr( "CF" ) ) 101 if ( tempstr == tr( "CF" ) )
110 QWhatsThis::add( mi, tr( "This graph represents how much memory is currently used on this Compact Flash memory card." ) ); 102 QWhatsThis::add( mi, tr( "This graph represents how much memory is currently used on this Compact Flash memory card." ) );
111 else if ( tempstr == tr( "Ha" ) ) 103 else if ( tempstr == tr( "Ha" ) )
112 QWhatsThis::add( mi, tr( "This graph represents how much storage is currently used on this hard drive." ) ); 104 QWhatsThis::add( mi, tr( "This graph represents how much storage is currently used on this hard drive." ) );
113 else if ( tempstr == tr( "SD" ) ) 105 else if ( tempstr == tr( "SD" ) )
114 QWhatsThis::add( mi, tr( "This graph represents how much memory is currently used on this Secure Digital memory card." ) ); 106 QWhatsThis::add( mi, tr( "This graph represents how much memory is currently used on this Secure Digital memory card." ) );
115 else if ( tempstr == tr( "SC" ) ) 107 else if ( tempstr == tr( "SC" ) )
@@ -117,62 +109,61 @@ void FileSysInfo::updateMounts()
117 else if ( tempstr == tr( "In" ) ) 109 else if ( tempstr == tr( "In" ) )
118 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 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." ) );
119 else if ( tempstr == tr( "RA" ) ) 111 else if ( tempstr == tr( "RA" ) )
120 QWhatsThis::add( mi, tr( "This graph represents how much memory is currently used of the temporary RAM disk." ) ); 112 QWhatsThis::add( mi, tr( "This graph represents how much memory is currently used of the temporary RAM disk." ) );
121 } 113 }
122 vb->addStretch(); 114 vb->addStretch();
123 } 115 }
124 else 116 else
125 { 117 {
126 for (QDictIterator<MountInfo> i(disks); i.current(); ++i) 118 for (QDictIterator<MountInfo> i(disks); i.current(); ++i)
127 i.current()->updateData(); 119 i.current()->updateData();
128 } 120 }
129 121
130 rebuildDisks = FALSE; 122 rebuildDisks = FALSE;
131} 123}
132 124
133void FileSysInfo::disksChanged() 125void FileSysInfo::disksChanged()
134{ 126{
135 rebuildDisks = TRUE; 127 rebuildDisks = TRUE;
136} 128}
137 129
138MountInfo::MountInfo( FileSystem *filesys, QWidget *parent, const char *name ) 130MountInfo::MountInfo( FileSystem *filesys, QWidget *parent, const char *name )
139 : QWidget( parent, name ) 131 : QWidget( parent, name )
140{ 132{
141 QVBoxLayout *vb = new QVBoxLayout( this, 3 ); 133 QVBoxLayout *vb = new QVBoxLayout( this, 3 );
142 134
143 totalSize = new QLabel( this ); 135 totalSize = new QLabel( this );
144 vb->addWidget( totalSize ); 136 vb->addWidget( totalSize );
145 137
146 fs = filesys; 138 fs = filesys;
147 title = fs->name(); 139 title = fs->name();
148 140
149 data = new GraphData(); 141 data = new GraphData();
150 graph = new BarGraph( this ); 142 graph = new BarGraph( this );
151 graph->setFrameStyle( QFrame::Panel | QFrame::Sunken ); 143 graph->setFrameStyle( QFrame::Panel | QFrame::Sunken );
152 vb->addWidget( graph, 1 ); 144 vb->addWidget( graph, 1 );
153 graph->setData( data ); 145 graph->setData( data );
154 146
155 legend = new GraphLegend( this ); 147 legend = new GraphLegend( this );
156 legend->setOrientation(Horizontal); 148 legend->setOrientation(Horizontal);
157 vb->addWidget( legend ); 149 vb->addWidget( legend );
158 legend->setData( data ); 150 legend->setData( data );
159 151
160 updateData(); 152 updateData();
161} 153}
162 154
163MountInfo::~MountInfo() 155MountInfo::~MountInfo()
164{ 156{
165 delete data; 157 delete data;
166 delete fs;
167} 158}
168 159
169void MountInfo::updateData() 160void MountInfo::updateData()
170{ 161{
171 long mult = fs->blockSize() / 1024; 162 long mult = fs->blockSize() / 1024;
172 long div = 1024 / fs->blockSize(); 163 long div = 1024 / fs->blockSize();
173 if ( !mult ) mult = 1; 164 if ( !mult ) mult = 1;
174 if ( !div ) div = 1; 165 if ( !div ) div = 1;
175 long total = fs->totalBlocks() * mult / div; 166 long total = fs->totalBlocks() * mult / div;
176 long avail = fs->availBlocks() * mult / div; 167 long avail = fs->availBlocks() * mult / div;
177 long used = total - avail; 168 long used = total - avail;
178 totalSize->setText( title + tr(" : %1 kB").arg( total ) ); 169 totalSize->setText( title + tr(" : %1 kB").arg( total ) );