Diffstat (limited to 'noncore/settings/aqpkg/installdlgimpl.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/settings/aqpkg/installdlgimpl.cpp | 37 |
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 @@ -5,45 +5,48 @@ copyright : (C) 2002 by Andy Qua email : andy.qua@blueyonder.co.uk ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ #ifdef QWS #include <qpe/config.h> #include <qpe/qpeapplication.h> +#include <qpe/storage.h> #endif #include <qmultilineedit.h> #include <qdialog.h> #include <qcombobox.h> #include <qcheckbox.h> #include <qpushbutton.h> +#include <qlabel.h> #include "datamgr.h" #include "instoptionsimpl.h" #include "destination.h" #include "installdlgimpl.h" +#include "utils.h" #include "global.h" InstallDlgImpl::InstallDlgImpl( vector<InstallData> &packageList, DataManager *dataManager, QWidget * parent, const char* name, bool modal, WFlags fl ) : InstallDlg( parent, name, modal, fl ) { pIpkg = 0; upgradePackages = false; dataMgr = dataManager; vector<Destination>::iterator dit; QString defaultDest = "root"; #ifdef QWS Config cfg( "aqpkg" ); cfg.setGroup( "settings" ); defaultDest = cfg.readEntry( "dest", "root" ); @@ -88,32 +91,34 @@ InstallDlgImpl::InstallDlgImpl( vector<InstallData> &packageList, DataManager *d else if ( item.option == "D" ) { removeList.push_back( item ); remove += " " + item.packageName + "\n"; } else if ( item.option == "U" || item.option == "R" ) { updateList.push_back( item ); QString type = " (Upgrade)"; if ( item.option == "R" ) type = " (ReInstall)"; upgrade += " " + item.packageName + type + "\n"; } } output->setText( remove + install + upgrade ); + + displayAvailableSpace( destination->currentText() ); } InstallDlgImpl::InstallDlgImpl( Ipkg *ipkg, QString initialText, QWidget *parent, const char *name, bool modal, WFlags fl ) : InstallDlg( parent, name, modal, fl ) { pIpkg = ipkg; output->setText( initialText ); } InstallDlgImpl::~InstallDlgImpl() { } bool InstallDlgImpl :: showDlg() { @@ -164,33 +169,33 @@ void InstallDlgImpl :: installSelected() vector<Destination>::iterator d = dataMgr->getDestination( destination->currentText() ); QString dest = d->getDestinationName(); QString destDir = d->getDestinationPath(); int instFlags = flags; if ( d->linkToRoot() ) instFlags |= MAKE_LINKS; #ifdef QWS // Save settings Config cfg( "aqpkg" ); cfg.setGroup( "settings" ); cfg.writeEntry( "dest", dest ); #endif pIpkg = new Ipkg; connect( pIpkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &))); - + // First run through the remove list, then the install list then the upgrade list vector<InstallData>::iterator it; pIpkg->setOption( "remove" ); for ( it = removeList.begin() ; it != removeList.end() ; ++it ) { pIpkg->setDestination( it->destination->getDestinationName() ); pIpkg->setDestinationDir( it->destination->getDestinationPath() ); pIpkg->setPackage( it->packageName ); int tmpFlags = flags; if ( it->destination->linkToRoot() ) tmpFlags |= MAKE_LINKS; pIpkg->setFlags( tmpFlags ); pIpkg->runIpkg(); } @@ -224,16 +229,46 @@ void InstallDlgImpl :: installSelected() } delete pIpkg; } btnOptions->setEnabled( true ); btnInstall->setEnabled( true ); btnInstall->setText( tr( "Close" ) ); } void InstallDlgImpl :: displayText(const QString &text ) { QString t = output->text() + "\n" + text; output->setText( t ); output->setCursorPosition( output->numLines(), 0 ); } + + +void InstallDlgImpl :: displayAvailableSpace( const QString &text ) +{ + vector<Destination>::iterator d = dataMgr->getDestination( text ); + QString destDir = d->getDestinationPath(); + + long blockSize = 0; + long totalBlocks = 0; + long availBlocks = 0; + QString space; + if ( Utils::getStorageSpace( (const char *)destDir, &blockSize, &totalBlocks, &availBlocks ) ) + { + long mult = blockSize / 1024; + long div = 1024 / blockSize; + + if ( !mult ) mult = 1; + if ( !div ) div = 1; +// long total = totalBlocks * mult / div; + long avail = availBlocks * mult / div; +// long used = total - avail; + + space.sprintf( "%ld Kb", avail ); + } + else + space = "Unknown"; + + txtAvailableSpace->setText( space ); +} + |