Diffstat (limited to 'noncore/settings/aqpkg/installdlgimpl.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/settings/aqpkg/installdlgimpl.cpp | 84 |
1 files changed, 47 insertions, 37 deletions
diff --git a/noncore/settings/aqpkg/installdlgimpl.cpp b/noncore/settings/aqpkg/installdlgimpl.cpp index 19fe46a..9339086 100644 --- a/noncore/settings/aqpkg/installdlgimpl.cpp +++ b/noncore/settings/aqpkg/installdlgimpl.cpp @@ -42,5 +42,5 @@ #include "global.h" -InstallDlgImpl::InstallDlgImpl( vector<InstallData> &packageList, DataManager *dataManager, const char *title ) +InstallDlgImpl::InstallDlgImpl( QList<InstallData> &packageList, DataManager *dataManager, const char *title ) : QWidget( 0, 0, 0 ) { @@ -51,5 +51,4 @@ InstallDlgImpl::InstallDlgImpl( vector<InstallData> &packageList, DataManager *d upgradePackages = false; dataMgr = dataManager; - vector<Destination>::iterator dit; QString defaultDest = "root"; @@ -75,8 +74,9 @@ InstallDlgImpl::InstallDlgImpl( vector<InstallData> &packageList, DataManager *d int defIndex = 0; int i; - for ( i = 0 , dit = dataMgr->getDestinationList().begin() ; dit != dataMgr->getDestinationList().end() ; ++dit, ++i ) + QListIterator<Destination> dit( dataMgr->getDestinationList() ); + for ( i = 0; dit.current(); ++dit, ++i ) { - destination->insertItem( dit->getDestinationName() ); - if ( dit->getDestinationName() == defaultDest ) + destination->insertItem( dit.current()->getDestinationName() ); + if ( dit.current()->getDestinationName() == defaultDest ) defIndex = i; } @@ -84,34 +84,40 @@ InstallDlgImpl::InstallDlgImpl( vector<InstallData> &packageList, DataManager *d destination->setCurrentItem( defIndex ); - vector<InstallData>::iterator it; + QListIterator<InstallData> it( packageList ); // setup package data QString remove = tr( "Remove\n" ); QString install = tr( "Install\n" ); QString upgrade = tr( "Upgrade\n" ); - for ( it = packageList.begin() ; it != packageList.end() ; ++it ) + for ( ; it.current(); ++it ) { - InstallData item = *it; - if ( item.option == "I" ) + InstallData *item = it.current(); + InstallData *newitem = new InstallData(); + + newitem->option = item->option; + newitem->packageName = item->packageName; + newitem->destination = item->destination; + newitem->recreateLinks = item->recreateLinks; + + if ( item->option == "I" ) { - installList.push_back( item ); - install.append( QString( " %1\n" ).arg( item.packageName ) ); + installList.append( newitem ); + install.append( QString( " %1\n" ).arg( item->packageName ) ); } - else if ( item.option == "D" ) + else if ( item->option == "D" ) { - removeList.push_back( item ); - remove.append( QString( " %1\n" ).arg( item.packageName ) ); + removeList.append( newitem ); + remove.append( QString( " %1\n" ).arg( item->packageName ) ); } - else if ( item.option == "U" || item.option == "R" ) + else if ( item->option == "U" || item->option == "R" ) { - updateList.push_back( item ); + updateList.append( newitem ); QString type; - if ( item.option == "R" ) + if ( item->option == "R" ) type = tr( "(ReInstall)" ); else type = tr( "(Upgrade)" ); - upgrade.append( QString( " %1 %2\n" ).arg( item.packageName ).arg( type ) ); + upgrade.append( QString( " %1 %2\n" ).arg( item->packageName ).arg( type ) ); } } - output->setText( QString( "%1\n%2\n%3\n" ).arg( remove ).arg( install ).arg( upgrade ) ); @@ -214,5 +220,5 @@ void InstallDlgImpl :: installSelected() return; } - + // Disable buttons btnOptions->setEnabled( false ); @@ -230,5 +236,5 @@ void InstallDlgImpl :: installSelected() { output->setText( "" ); - vector<Destination>::iterator d = dataMgr->getDestination( destination->currentText() ); + Destination *d = dataMgr->getDestination( destination->currentText() ); QString dest = d->getDestinationName(); QString destDir = d->getDestinationPath(); @@ -248,14 +254,16 @@ void InstallDlgImpl :: installSelected() // 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 ) + QListIterator<InstallData> it( removeList ); + InstallData *idata; + for ( ; it.current(); ++it ) { - pIpkg->setDestination( it->destination->getDestinationName() ); - pIpkg->setDestinationDir( it->destination->getDestinationPath() ); - pIpkg->setPackage( it->packageName ); + idata = it.current(); + pIpkg->setDestination( idata->destination->getDestinationName() ); + pIpkg->setDestinationDir( idata->destination->getDestinationPath() ); + pIpkg->setPackage( idata->packageName ); int tmpFlags = flags; - if ( it->destination->linkToRoot() ) + if ( idata->destination->linkToRoot() ) tmpFlags |= MAKE_LINKS; @@ -268,23 +276,26 @@ void InstallDlgImpl :: installSelected() pIpkg->setDestinationDir( destDir ); pIpkg->setFlags( instFlags ); - for ( it = installList.begin() ; it != installList.end() ; ++it ) + QListIterator<InstallData> it2( installList ); + for ( ; it2.current(); ++it2 ) { - pIpkg->setPackage( it->packageName ); + pIpkg->setPackage( it2.current()->packageName ); pIpkg->runIpkg(); } flags |= FORCE_REINSTALL; - for ( it = updateList.begin() ; it != updateList.end() ; ++it ) + QListIterator<InstallData> it3( updateList ); + for ( ; it3.current() ; ++it3 ) { - if ( it->option == "R" ) + idata = it3.current(); + if ( idata->option == "R" ) pIpkg->setOption( "reinstall" ); else pIpkg->setOption( "upgrade" ); - pIpkg->setDestination( it->destination->getDestinationName() ); - pIpkg->setDestinationDir( it->destination->getDestinationPath() ); - pIpkg->setPackage( it->packageName ); + pIpkg->setDestination( idata->destination->getDestinationName() ); + pIpkg->setDestinationDir( idata->destination->getDestinationPath() ); + pIpkg->setPackage( idata->packageName ); int tmpFlags = flags; - if ( it->destination->linkToRoot() && it->recreateLinks ) + if ( idata->destination->linkToRoot() && idata->recreateLinks ) tmpFlags |= MAKE_LINKS; pIpkg->setFlags( tmpFlags ); @@ -308,5 +319,4 @@ void InstallDlgImpl :: installSelected() void InstallDlgImpl :: displayText(const QString &text ) { - //output->setText( QString( "%1\n%2" ).arg( output->text() ).arg( text ) ); QString newtext = QString( "%1\n%2" ).arg( output->text() ).arg( text ); output->setText( newtext ); @@ -317,5 +327,5 @@ void InstallDlgImpl :: displayText(const QString &text ) void InstallDlgImpl :: displayAvailableSpace( const QString &text ) { - vector<Destination>::iterator d = dataMgr->getDestination( text ); + Destination *d = dataMgr->getDestination( text ); QString destDir = d->getDestinationPath(); |