From 128343cd009009e42ce6bcdfd45a294c7ea44f83 Mon Sep 17 00:00:00 2001 From: andyq Date: Wed, 04 Dec 2002 23:14:12 +0000 Subject: Added Available space for destination chosen --- (limited to 'noncore/settings') diff --git a/noncore/settings/aqpkg/install.ui b/noncore/settings/aqpkg/install.ui index daa0ff6..c5a3596 100644 --- a/noncore/settings/aqpkg/install.ui +++ b/noncore/settings/aqpkg/install.ui @@ -12,7 +12,7 @@ 0 0 196 - 271 + 278 @@ -28,25 +28,36 @@ spacing 6 - - QLabel + + QComboBox name - TextLabel1 + destination + + + + QPushButton + + name + btnInstall text - Destination + Start - - QComboBox + + QPushButton name - destination + btnOptions + + + text + Options - + QGroupBox name @@ -74,26 +85,37 @@ - - QPushButton + + QLabel name - btnInstall + TextLabel1 text - Start + Destination - - QPushButton + + QLabel name - btnOptions + TextLabel3 text - Options + Space Avail + + + + QLabel + + name + txtAvailableSpace + + + text + 100000000 @@ -111,8 +133,14 @@ InstallDlg installSelected() + + destination + highlighted(const QString&) + InstallDlg + displayAvailableSpace( const QString& ) + + displayAvailableSpace( const QString& ) installSelected() - displayText(const QString &) optionsSelected() 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 @@ #ifdef QWS #include #include +#include #endif #include @@ -25,12 +26,14 @@ #include #include #include +#include #include "datamgr.h" #include "instoptionsimpl.h" #include "destination.h" #include "installdlgimpl.h" +#include "utils.h" #include "global.h" InstallDlgImpl::InstallDlgImpl( vector &packageList, DataManager *dataManager, QWidget * parent, const char* name, bool modal, WFlags fl ) @@ -101,6 +104,8 @@ InstallDlgImpl::InstallDlgImpl( vector &packageList, DataManager *d } output->setText( remove + install + upgrade ); + + displayAvailableSpace( destination->currentText() ); } InstallDlgImpl::InstallDlgImpl( Ipkg *ipkg, QString initialText, QWidget *parent, const char *name, bool modal, WFlags fl ) @@ -177,7 +182,7 @@ void InstallDlgImpl :: installSelected() 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::iterator it; pIpkg->setOption( "remove" ); @@ -237,3 +242,33 @@ void InstallDlgImpl :: displayText(const QString &text ) output->setText( t ); output->setCursorPosition( output->numLines(), 0 ); } + + +void InstallDlgImpl :: displayAvailableSpace( const QString &text ) +{ + vector::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 ); +} + diff --git a/noncore/settings/aqpkg/installdlgimpl.h b/noncore/settings/aqpkg/installdlgimpl.h index 9819b2e..2f80f08 100644 --- a/noncore/settings/aqpkg/installdlgimpl.h +++ b/noncore/settings/aqpkg/installdlgimpl.h @@ -44,6 +44,7 @@ public: bool showDlg(); bool upgradeServer( QString &server ); + protected: private: @@ -60,6 +61,7 @@ private: void optionsSelected(); void installSelected(); void displayText(const QString &text ); + void displayAvailableSpace( const QString &text); }; #endif -- cgit v0.9.0.2