summaryrefslogtreecommitdiff
path: root/noncore/settings/aqpkg/installdlgimpl.cpp
authorandyq <andyq>2002-12-04 23:14:12 (UTC)
committer andyq <andyq>2002-12-04 23:14:12 (UTC)
commit128343cd009009e42ce6bcdfd45a294c7ea44f83 (patch) (unidiff)
treec27ae8892ce9038e5ae523aaecc4632fafb05929 /noncore/settings/aqpkg/installdlgimpl.cpp
parent4c3a3a2eb2ed79f9e833d356b28c8be9a514ed50 (diff)
downloadopie-128343cd009009e42ce6bcdfd45a294c7ea44f83.zip
opie-128343cd009009e42ce6bcdfd45a294c7ea44f83.tar.gz
opie-128343cd009009e42ce6bcdfd45a294c7ea44f83.tar.bz2
Added Available space for destination chosen
Diffstat (limited to 'noncore/settings/aqpkg/installdlgimpl.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/aqpkg/installdlgimpl.cpp37
1 files changed, 36 insertions, 1 deletions
diff --git a/noncore/settings/aqpkg/installdlgimpl.cpp b/noncore/settings/aqpkg/installdlgimpl.cpp
index 485fe3d..bfb4f62 100644
--- a/noncore/settings/aqpkg/installdlgimpl.cpp
+++ b/noncore/settings/aqpkg/installdlgimpl.cpp
@@ -18,6 +18,7 @@
18#ifdef QWS 18#ifdef QWS
19#include <qpe/config.h> 19#include <qpe/config.h>
20#include <qpe/qpeapplication.h> 20#include <qpe/qpeapplication.h>
21#include <qpe/storage.h>
21#endif 22#endif
22 23
23#include <qmultilineedit.h> 24#include <qmultilineedit.h>
@@ -25,12 +26,14 @@
25#include <qcombobox.h> 26#include <qcombobox.h>
26#include <qcheckbox.h> 27#include <qcheckbox.h>
27#include <qpushbutton.h> 28#include <qpushbutton.h>
29#include <qlabel.h>
28 30
29 31
30#include "datamgr.h" 32#include "datamgr.h"
31#include "instoptionsimpl.h" 33#include "instoptionsimpl.h"
32#include "destination.h" 34#include "destination.h"
33#include "installdlgimpl.h" 35#include "installdlgimpl.h"
36#include "utils.h"
34#include "global.h" 37#include "global.h"
35 38
36InstallDlgImpl::InstallDlgImpl( vector<InstallData> &packageList, DataManager *dataManager, QWidget * parent, const char* name, bool modal, WFlags fl ) 39InstallDlgImpl::InstallDlgImpl( vector<InstallData> &packageList, DataManager *dataManager, QWidget * parent, const char* name, bool modal, WFlags fl )
@@ -101,6 +104,8 @@ InstallDlgImpl::InstallDlgImpl( vector<InstallData> &packageList, DataManager *d
101 } 104 }
102 105
103 output->setText( remove + install + upgrade ); 106 output->setText( remove + install + upgrade );
107
108 displayAvailableSpace( destination->currentText() );
104} 109}
105 110
106InstallDlgImpl::InstallDlgImpl( Ipkg *ipkg, QString initialText, QWidget *parent, const char *name, bool modal, WFlags fl ) 111InstallDlgImpl::InstallDlgImpl( Ipkg *ipkg, QString initialText, QWidget *parent, const char *name, bool modal, WFlags fl )
@@ -177,7 +182,7 @@ void InstallDlgImpl :: installSelected()
177 182
178 pIpkg = new Ipkg; 183 pIpkg = new Ipkg;
179 connect( pIpkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &))); 184 connect( pIpkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &)));
180 185
181 // First run through the remove list, then the install list then the upgrade list 186 // First run through the remove list, then the install list then the upgrade list
182 vector<InstallData>::iterator it; 187 vector<InstallData>::iterator it;
183 pIpkg->setOption( "remove" ); 188 pIpkg->setOption( "remove" );
@@ -237,3 +242,33 @@ void InstallDlgImpl :: displayText(const QString &text )
237 output->setText( t ); 242 output->setText( t );
238 output->setCursorPosition( output->numLines(), 0 ); 243 output->setCursorPosition( output->numLines(), 0 );
239} 244}
245
246
247void InstallDlgImpl :: displayAvailableSpace( const QString &text )
248{
249 vector<Destination>::iterator d = dataMgr->getDestination( text );
250 QString destDir = d->getDestinationPath();
251
252 long blockSize = 0;
253 long totalBlocks = 0;
254 long availBlocks = 0;
255 QString space;
256 if ( Utils::getStorageSpace( (const char *)destDir, &blockSize, &totalBlocks, &availBlocks ) )
257 {
258 long mult = blockSize / 1024;
259 long div = 1024 / blockSize;
260
261 if ( !mult ) mult = 1;
262 if ( !div ) div = 1;
263// long total = totalBlocks * mult / div;
264 long avail = availBlocks * mult / div;
265// long used = total - avail;
266
267 space.sprintf( "%ld Kb", avail );
268 }
269 else
270 space = "Unknown";
271
272 txtAvailableSpace->setText( space );
273}
274