Diffstat (limited to 'noncore/settings/aqpkg/mainwin.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/settings/aqpkg/mainwin.cpp | 143 |
1 files changed, 76 insertions, 67 deletions
diff --git a/noncore/settings/aqpkg/mainwin.cpp b/noncore/settings/aqpkg/mainwin.cpp index 361946c..8ae5815 100644 --- a/noncore/settings/aqpkg/mainwin.cpp +++ b/noncore/settings/aqpkg/mainwin.cpp @@ -545,3 +545,3 @@ void MainWindow :: updateData() { - m_progress->setTotalSteps( mgr->getServerList().size() ); + m_progress->setTotalSteps( mgr->getServerList().count() ); @@ -550,9 +550,13 @@ void MainWindow :: updateData() - vector<Server>::iterator it; int activeItem = -1; - int i; + int i = 0; QString serverName; - for ( i = 0, it = mgr->getServerList().begin() ; it != mgr->getServerList().end() ; ++it, ++i ) + + QListIterator<Server> it( mgr->getServerList() ); + Server *server; + + for ( ; it.current(); ++it, ++i ) { - serverName = it->getServerName(); + server = it.current(); + serverName = server->getServerName(); m_status->setText( tr( "Building server list:\n\t%1" ).arg( serverName ) ); @@ -562,3 +566,3 @@ void MainWindow :: updateData() // cout << "Adding " << it->getServerName() << " to combobox" << endl; - if ( !it->isServerActive() ) + if ( !server->isServerActive() ) { @@ -594,9 +598,9 @@ void MainWindow :: serverSelected( int, bool raiseProgress ) - vector<Server>::iterator s = mgr->getServer( serverName ); + Server *s = mgr->getServer( serverName ); - vector<Package> &list = s->getPackageList(); - vector<Package>::iterator it; + QList<Package> &list = s->getPackageList(); + QListIterator<Package> it( list ); // Display progress widget while loading list - bool doProgress = ( list.size() > 200 ); + bool doProgress = ( list.count() > 200 ); if ( doProgress ) @@ -607,3 +611,3 @@ void MainWindow :: serverSelected( int, bool raiseProgress ) } - m_progress->setTotalSteps( list.size() ); + m_progress->setTotalSteps( list.count() ); m_status->setText( tr( "Building package list for:\n\t%1" ).arg( serverName ) ); @@ -621,3 +625,4 @@ void MainWindow :: serverSelected( int, bool raiseProgress ) int i = 0; - for ( it = list.begin() ; it != list.end() ; ++it ) + Package *package; + for ( ; it.current(); ++it ) { @@ -636,4 +641,6 @@ void MainWindow :: serverSelected( int, bool raiseProgress ) + package = it.current(); + // Apply show only uninstalled packages filter - if ( showUninstalledPkgs && it->isInstalled() ) + if ( showUninstalledPkgs && package->isInstalled() ) continue; @@ -641,3 +648,3 @@ void MainWindow :: serverSelected( int, bool raiseProgress ) // Apply show only installed packages filter - if ( showInstalledPkgs && !it->isInstalled() ) + if ( showInstalledPkgs && !package->isInstalled() ) continue; @@ -647,4 +654,4 @@ void MainWindow :: serverSelected( int, bool raiseProgress ) { - if ( !it->isInstalled() || - compareVersions( it->getInstalledVersion(), it->getVersion() ) != 1 ) + if ( !package->isInstalled() || + compareVersions( package->getInstalledVersion(), package->getVersion() ) != 1 ) continue; @@ -655,3 +662,3 @@ void MainWindow :: serverSelected( int, bool raiseProgress ) { - if ( it->getSection() == "" || categoryFilter.find( it->getSection().lower() ) == -1 ) + if ( package->getSection() == "" || categoryFilter.find( package->getSection().lower() ) == -1 ) continue; @@ -660,3 +667,3 @@ void MainWindow :: serverSelected( int, bool raiseProgress ) // If the local server, only display installed packages - if ( serverName == LOCAL_SERVER && !it->isInstalled() ) + if ( serverName == LOCAL_SERVER && !package->isInstalled() ) continue; @@ -664,5 +671,6 @@ void MainWindow :: serverSelected( int, bool raiseProgress ) - QCheckListItem *item = new QCheckListItem( packagesList, it->getPackageName(), QCheckListItem::CheckBox ); + QCheckListItem *item = new QCheckListItem( packagesList, package->getPackageName(), + QCheckListItem::CheckBox ); - if ( it->isInstalled() ) + if ( package->isInstalled() ) { @@ -670,4 +678,4 @@ void MainWindow :: serverSelected( int, bool raiseProgress ) // Otherwise, show installed icon - if ( it->getVersion() != it->getInstalledVersion() && - compareVersions( it->getInstalledVersion(), it->getVersion() ) == 1) + if ( package->getVersion() != package->getInstalledVersion() && + compareVersions( package->getInstalledVersion(), package->getVersion() ) == 1) { @@ -682,6 +690,6 @@ void MainWindow :: serverSelected( int, bool raiseProgress ) QString destName = ""; - if ( it->getLocalPackage() ) + if ( package->getLocalPackage() ) { - if ( it->getLocalPackage()->getInstalledTo() ) - destName = it->getLocalPackage()->getInstalledTo()->getDestinationName(); + if ( package->getLocalPackage()->getInstalledTo() ) + destName = package->getLocalPackage()->getInstalledTo()->getDestinationName(); } @@ -689,4 +697,4 @@ void MainWindow :: serverSelected( int, bool raiseProgress ) { - if ( it->getInstalledTo() ) - destName = it->getInstalledTo()->getDestinationName(); + if ( package->getInstalledTo() ) + destName = package->getInstalledTo()->getDestinationName(); } @@ -700,10 +708,10 @@ void MainWindow :: serverSelected( int, bool raiseProgress ) - if ( !it->isPackageStoredLocally() ) + if ( !package->isPackageStoredLocally() ) { - new QCheckListItem( item, QString( tr( "Description - %1" ).arg( it->getDescription() ) ) ); - new QCheckListItem( item, QString( tr( "Size - %1" ).arg( it->getPackageSize() ) ) ); - new QCheckListItem( item, QString( tr( "Section - %1" ).arg( it->getSection() ) ) ); + new QCheckListItem( item, QString( tr( "Description - %1" ).arg( package->getDescription() ) ) ); + new QCheckListItem( item, QString( tr( "Size - %1" ).arg( package->getPackageSize() ) ) ); + new QCheckListItem( item, QString( tr( "Section - %1" ).arg( package->getSection() ) ) ); } else - new QCheckListItem( item, QString( tr( "Filename - %1" ).arg( it->getFilename() ) ) ); + new QCheckListItem( item, QString( tr( "Filename - %1" ).arg( package->getFilename() ) ) ); @@ -711,3 +719,3 @@ void MainWindow :: serverSelected( int, bool raiseProgress ) { - new QCheckListItem( item, QString( tr( "V. Installed - %1" ).arg( it->getVersion() ) ) ); + new QCheckListItem( item, QString( tr( "V. Installed - %1" ).arg( package->getVersion() ) ) ); } @@ -715,7 +723,7 @@ void MainWindow :: serverSelected( int, bool raiseProgress ) { - new QCheckListItem( item, QString( tr( "V. Available - %1" ).arg( it->getVersion() ) ) ); - if ( it->getLocalPackage() ) + new QCheckListItem( item, QString( tr( "V. Available - %1" ).arg( package->getVersion() ) ) ); + if ( package->getLocalPackage() ) { - if ( it->isInstalled() ) - new QCheckListItem( item, QString( tr( "V. Installed - %1" ).arg( it->getInstalledVersion() ) ) ); + if ( package->isInstalled() ) + new QCheckListItem( item, QString( tr( "V. Installed - %1" ).arg( package->getInstalledVersion() ) ) ); } @@ -757,3 +765,3 @@ void MainWindow :: searchForPackage( const QString &text ) // look through package list for text startng at current position - vector<InstallData> workingPackages; +// vector<InstallData> workingPackages; QCheckListItem *start = (QCheckListItem *)packagesList->currentItem(); @@ -959,7 +967,8 @@ void MainWindow :: downloadRemotePackage() - InstallData item; - item.option = "I"; - item.packageName = package; - vector<InstallData> workingPackages; - workingPackages.push_back( item ); + InstallData *item = new InstallData(); + item->option = "I"; + item->packageName = package; + QList<InstallData> workingPackages; + workingPackages.setAutoDelete( TRUE ); + workingPackages.append( item ); @@ -981,3 +990,4 @@ void MainWindow :: applyChanges() - vector<InstallData> workingPackages; + QList<InstallData> workingPackages; + workingPackages.setAutoDelete( TRUE ); for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); @@ -988,4 +998,3 @@ void MainWindow :: applyChanges() { - InstallData data = dealWithItem( item ); - workingPackages.push_back( data ); + workingPackages.append( dealWithItem( item ) ); } @@ -993,3 +1002,3 @@ void MainWindow :: applyChanges() - if ( workingPackages.size() == 0 ) + if ( workingPackages.count() == 0 ) { @@ -1013,3 +1022,3 @@ void MainWindow :: applyChanges() // If installed and version up to date - remove -InstallData MainWindow :: dealWithItem( QCheckListItem *item ) +InstallData *MainWindow :: dealWithItem( QCheckListItem *item ) { @@ -1018,3 +1027,3 @@ InstallData MainWindow :: dealWithItem( QCheckListItem *item ) // Get package - vector<Server>::iterator s = mgr->getServer( serversList->currentText() ); + Server *s = mgr->getServer( serversList->currentText() ); Package *p = s->getPackage( name ); @@ -1029,6 +1038,6 @@ InstallData MainWindow :: dealWithItem( QCheckListItem *item ) { - InstallData item; - item.option = "I"; - item.packageName = name; - return item; + InstallData *newitem = new InstallData();; + newitem->option = "I"; + newitem->packageName = name; + return newitem; } @@ -1036,8 +1045,8 @@ InstallData MainWindow :: dealWithItem( QCheckListItem *item ) { - InstallData item; - item.option = "D"; + InstallData *newitem = new InstallData();; + newitem->option = "D"; if ( !p->isPackageStoredLocally() ) - item.packageName = p->getInstalledPackageName(); + newitem->packageName = p->getInstalledPackageName(); else - item.packageName = name; + newitem->packageName = name; @@ -1045,3 +1054,3 @@ InstallData MainWindow :: dealWithItem( QCheckListItem *item ) { - item.destination = p->getInstalledTo(); + newitem->destination = p->getInstalledTo(); // cout << "dest - " << p->getInstalledTo()->getDestinationName() << endl; @@ -1051,3 +1060,3 @@ InstallData MainWindow :: dealWithItem( QCheckListItem *item ) { - item.destination = p->getLocalPackage()->getInstalledTo(); + newitem->destination = p->getLocalPackage()->getInstalledTo(); } @@ -1068,3 +1077,3 @@ InstallData MainWindow :: dealWithItem( QCheckListItem *item ) // Version available is older - remove only - item.option = "D"; + newitem->option = "D"; } @@ -1104,6 +1113,6 @@ InstallData MainWindow :: dealWithItem( QCheckListItem *item ) // option 0 = Remove - item.option = "D"; + newitem->option = "D"; break; case 1: // Quit or Escape - item.option = secondOption; + newitem->option = secondOption; break; @@ -1113,3 +1122,3 @@ InstallData MainWindow :: dealWithItem( QCheckListItem *item ) { -// item.option = stickyOption; +// newitem->option = stickyOption; } @@ -1119,9 +1128,9 @@ InstallData MainWindow :: dealWithItem( QCheckListItem *item ) // Check if we are reinstalling the same version - if ( item.option != "R" ) - item.recreateLinks = true; + if ( newitem->option != "R" ) + newitem->recreateLinks = true; else - item.recreateLinks = false; + newitem->recreateLinks = false; // User hit cancel (on dlg - assume remove) - return item; + return newitem; } |