author | drw <drw> | 2003-02-06 01:19:25 (UTC) |
---|---|---|
committer | drw <drw> | 2003-02-06 01:19:25 (UTC) |
commit | 79588befde53765db0a92977c6890a4d226096e7 (patch) (unidiff) | |
tree | 83b6dd14c49733b9759fad04147bf0bee50793fe /noncore/settings/aqpkg/mainwin.cpp | |
parent | bbb3690f12191763a407e6a0edd521113b3c25ac (diff) | |
download | opie-79588befde53765db0a92977c6890a4d226096e7.zip opie-79588befde53765db0a92977c6890a4d226096e7.tar.gz opie-79588befde53765db0a92977c6890a4d226096e7.tar.bz2 |
Change all vector<> to QList<>. First step in removing dependency on libstdc++.
Diffstat (limited to 'noncore/settings/aqpkg/mainwin.cpp') (more/less context) (ignore 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 | |||
@@ -544,16 +544,20 @@ void MainWindow :: updateProgress( int progress ) | |||
544 | void MainWindow :: updateData() | 544 | void MainWindow :: updateData() |
545 | { | 545 | { |
546 | m_progress->setTotalSteps( mgr->getServerList().size() ); | 546 | m_progress->setTotalSteps( mgr->getServerList().count() ); |
547 | 547 | ||
548 | serversList->clear(); | 548 | serversList->clear(); |
549 | packagesList->clear(); | 549 | packagesList->clear(); |
550 | 550 | ||
551 | vector<Server>::iterator it; | ||
552 | int activeItem = -1; | 551 | int activeItem = -1; |
553 | int i; | 552 | int i = 0; |
554 | QString serverName; | 553 | QString serverName; |
555 | for ( i = 0, it = mgr->getServerList().begin() ; it != mgr->getServerList().end() ; ++it, ++i ) | 554 | |
555 | QListIterator<Server> it( mgr->getServerList() ); | ||
556 | Server *server; | ||
557 | |||
558 | for ( ; it.current(); ++it, ++i ) | ||
556 | { | 559 | { |
557 | serverName = it->getServerName(); | 560 | server = it.current(); |
561 | serverName = server->getServerName(); | ||
558 | m_status->setText( tr( "Building server list:\n\t%1" ).arg( serverName ) ); | 562 | m_status->setText( tr( "Building server list:\n\t%1" ).arg( serverName ) ); |
559 | m_progress->setProgress( i ); | 563 | m_progress->setProgress( i ); |
@@ -561,5 +565,5 @@ void MainWindow :: updateData() | |||
561 | 565 | ||
562 | // cout << "Adding " << it->getServerName() << " to combobox" << endl; | 566 | // cout << "Adding " << it->getServerName() << " to combobox" << endl; |
563 | if ( !it->isServerActive() ) | 567 | if ( !server->isServerActive() ) |
564 | { | 568 | { |
565 | // cout << serverName << " is not active" << endl; | 569 | // cout << serverName << " is not active" << endl; |
@@ -593,11 +597,11 @@ void MainWindow :: serverSelected( int, bool raiseProgress ) | |||
593 | currentlySelectedServer = serverName; | 597 | currentlySelectedServer = serverName; |
594 | 598 | ||
595 | vector<Server>::iterator s = mgr->getServer( serverName ); | 599 | Server *s = mgr->getServer( serverName ); |
596 | 600 | ||
597 | vector<Package> &list = s->getPackageList(); | 601 | QList<Package> &list = s->getPackageList(); |
598 | vector<Package>::iterator it; | 602 | QListIterator<Package> it( list ); |
599 | 603 | ||
600 | // Display progress widget while loading list | 604 | // Display progress widget while loading list |
601 | bool doProgress = ( list.size() > 200 ); | 605 | bool doProgress = ( list.count() > 200 ); |
602 | if ( doProgress ) | 606 | if ( doProgress ) |
603 | { | 607 | { |
@@ -606,5 +610,5 @@ void MainWindow :: serverSelected( int, bool raiseProgress ) | |||
606 | stack->raiseWidget( progressWindow ); | 610 | stack->raiseWidget( progressWindow ); |
607 | } | 611 | } |
608 | m_progress->setTotalSteps( list.size() ); | 612 | m_progress->setTotalSteps( list.count() ); |
609 | m_status->setText( tr( "Building package list for:\n\t%1" ).arg( serverName ) ); | 613 | m_status->setText( tr( "Building package list for:\n\t%1" ).arg( serverName ) ); |
610 | } | 614 | } |
@@ -620,5 +624,6 @@ void MainWindow :: serverSelected( int, bool raiseProgress ) | |||
620 | 624 | ||
621 | int i = 0; | 625 | int i = 0; |
622 | for ( it = list.begin() ; it != list.end() ; ++it ) | 626 | Package *package; |
627 | for ( ; it.current(); ++it ) | ||
623 | { | 628 | { |
624 | // Update progress after every 100th package (arbitrary value, seems to give good balance) | 629 | // Update progress after every 100th package (arbitrary value, seems to give good balance) |
@@ -634,11 +639,13 @@ void MainWindow :: serverSelected( int, bool raiseProgress ) | |||
634 | 639 | ||
635 | QString text = ""; | 640 | QString text = ""; |
641 | |||
642 | package = it.current(); | ||
636 | 643 | ||
637 | // Apply show only uninstalled packages filter | 644 | // Apply show only uninstalled packages filter |
638 | if ( showUninstalledPkgs && it->isInstalled() ) | 645 | if ( showUninstalledPkgs && package->isInstalled() ) |
639 | continue; | 646 | continue; |
640 | 647 | ||
641 | // Apply show only installed packages filter | 648 | // Apply show only installed packages filter |
642 | if ( showInstalledPkgs && !it->isInstalled() ) | 649 | if ( showInstalledPkgs && !package->isInstalled() ) |
643 | continue; | 650 | continue; |
644 | 651 | ||
@@ -646,6 +653,6 @@ void MainWindow :: serverSelected( int, bool raiseProgress ) | |||
646 | if ( showUpgradedPkgs ) | 653 | if ( showUpgradedPkgs ) |
647 | { | 654 | { |
648 | if ( !it->isInstalled() || | 655 | if ( !package->isInstalled() || |
649 | compareVersions( it->getInstalledVersion(), it->getVersion() ) != 1 ) | 656 | compareVersions( package->getInstalledVersion(), package->getVersion() ) != 1 ) |
650 | continue; | 657 | continue; |
651 | } | 658 | } |
@@ -654,21 +661,22 @@ void MainWindow :: serverSelected( int, bool raiseProgress ) | |||
654 | if ( categoryFilterEnabled && categoryFilter != "" ) | 661 | if ( categoryFilterEnabled && categoryFilter != "" ) |
655 | { | 662 | { |
656 | if ( it->getSection() == "" || categoryFilter.find( it->getSection().lower() ) == -1 ) | 663 | if ( package->getSection() == "" || categoryFilter.find( package->getSection().lower() ) == -1 ) |
657 | continue; | 664 | continue; |
658 | } | 665 | } |
659 | 666 | ||
660 | // If the local server, only display installed packages | 667 | // If the local server, only display installed packages |
661 | if ( serverName == LOCAL_SERVER && !it->isInstalled() ) | 668 | if ( serverName == LOCAL_SERVER && !package->isInstalled() ) |
662 | continue; | 669 | continue; |
663 | 670 | ||
664 | 671 | ||
665 | QCheckListItem *item = new QCheckListItem( packagesList, it->getPackageName(), QCheckListItem::CheckBox ); | 672 | QCheckListItem *item = new QCheckListItem( packagesList, package->getPackageName(), |
673 | QCheckListItem::CheckBox ); | ||
666 | 674 | ||
667 | if ( it->isInstalled() ) | 675 | if ( package->isInstalled() ) |
668 | { | 676 | { |
669 | // If a different version of package is available, show update available icon | 677 | // If a different version of package is available, show update available icon |
670 | // Otherwise, show installed icon | 678 | // Otherwise, show installed icon |
671 | if ( it->getVersion() != it->getInstalledVersion() && | 679 | if ( package->getVersion() != package->getInstalledVersion() && |
672 | compareVersions( it->getInstalledVersion(), it->getVersion() ) == 1) | 680 | compareVersions( package->getInstalledVersion(), package->getVersion() ) == 1) |
673 | { | 681 | { |
674 | 682 | ||
@@ -681,13 +689,13 @@ void MainWindow :: serverSelected( int, bool raiseProgress ) | |||
681 | 689 | ||
682 | QString destName = ""; | 690 | QString destName = ""; |
683 | if ( it->getLocalPackage() ) | 691 | if ( package->getLocalPackage() ) |
684 | { | 692 | { |
685 | if ( it->getLocalPackage()->getInstalledTo() ) | 693 | if ( package->getLocalPackage()->getInstalledTo() ) |
686 | destName = it->getLocalPackage()->getInstalledTo()->getDestinationName(); | 694 | destName = package->getLocalPackage()->getInstalledTo()->getDestinationName(); |
687 | } | 695 | } |
688 | else | 696 | else |
689 | { | 697 | { |
690 | if ( it->getInstalledTo() ) | 698 | if ( package->getInstalledTo() ) |
691 | destName = it->getInstalledTo()->getDestinationName(); | 699 | destName = package->getInstalledTo()->getDestinationName(); |
692 | } | 700 | } |
693 | if ( destName != "" ) | 701 | if ( destName != "" ) |
@@ -699,24 +707,24 @@ void MainWindow :: serverSelected( int, bool raiseProgress ) | |||
699 | } | 707 | } |
700 | 708 | ||
701 | if ( !it->isPackageStoredLocally() ) | 709 | if ( !package->isPackageStoredLocally() ) |
702 | { | 710 | { |
703 | new QCheckListItem( item, QString( tr( "Description - %1" ).arg( it->getDescription() ) ) ); | 711 | new QCheckListItem( item, QString( tr( "Description - %1" ).arg( package->getDescription() ) ) ); |
704 | new QCheckListItem( item, QString( tr( "Size - %1" ).arg( it->getPackageSize() ) ) ); | 712 | new QCheckListItem( item, QString( tr( "Size - %1" ).arg( package->getPackageSize() ) ) ); |
705 | new QCheckListItem( item, QString( tr( "Section - %1" ).arg( it->getSection() ) ) ); | 713 | new QCheckListItem( item, QString( tr( "Section - %1" ).arg( package->getSection() ) ) ); |
706 | } | 714 | } |
707 | else | 715 | else |
708 | new QCheckListItem( item, QString( tr( "Filename - %1" ).arg( it->getFilename() ) ) ); | 716 | new QCheckListItem( item, QString( tr( "Filename - %1" ).arg( package->getFilename() ) ) ); |
709 | 717 | ||
710 | if ( serverName == LOCAL_SERVER ) | 718 | if ( serverName == LOCAL_SERVER ) |
711 | { | 719 | { |
712 | new QCheckListItem( item, QString( tr( "V. Installed - %1" ).arg( it->getVersion() ) ) ); | 720 | new QCheckListItem( item, QString( tr( "V. Installed - %1" ).arg( package->getVersion() ) ) ); |
713 | } | 721 | } |
714 | else | 722 | else |
715 | { | 723 | { |
716 | new QCheckListItem( item, QString( tr( "V. Available - %1" ).arg( it->getVersion() ) ) ); | 724 | new QCheckListItem( item, QString( tr( "V. Available - %1" ).arg( package->getVersion() ) ) ); |
717 | if ( it->getLocalPackage() ) | 725 | if ( package->getLocalPackage() ) |
718 | { | 726 | { |
719 | if ( it->isInstalled() ) | 727 | if ( package->isInstalled() ) |
720 | new QCheckListItem( item, QString( tr( "V. Installed - %1" ).arg( it->getInstalledVersion() ) ) ); | 728 | new QCheckListItem( item, QString( tr( "V. Installed - %1" ).arg( package->getInstalledVersion() ) ) ); |
721 | } | 729 | } |
722 | } | 730 | } |
@@ -756,5 +764,5 @@ void MainWindow :: searchForPackage( const QString &text ) | |||
756 | // cout << "searching for " << text << endl; | 764 | // cout << "searching for " << text << endl; |
757 | // look through package list for text startng at current position | 765 | // look through package list for text startng at current position |
758 | vector<InstallData> workingPackages; | 766 | // vector<InstallData> workingPackages; |
759 | QCheckListItem *start = (QCheckListItem *)packagesList->currentItem(); | 767 | QCheckListItem *start = (QCheckListItem *)packagesList->currentItem(); |
760 | // if ( start != 0 ) | 768 | // if ( start != 0 ) |
@@ -958,9 +966,10 @@ void MainWindow :: downloadRemotePackage() | |||
958 | // QString package = dlg.getPackageLocation(); | 966 | // QString package = dlg.getPackageLocation(); |
959 | 967 | ||
960 | InstallData item; | 968 | InstallData *item = new InstallData(); |
961 | item.option = "I"; | 969 | item->option = "I"; |
962 | item.packageName = package; | 970 | item->packageName = package; |
963 | vector<InstallData> workingPackages; | 971 | QList<InstallData> workingPackages; |
964 | workingPackages.push_back( item ); | 972 | workingPackages.setAutoDelete( TRUE ); |
973 | workingPackages.append( item ); | ||
965 | 974 | ||
966 | InstallDlgImpl *dlg = new InstallDlgImpl( workingPackages, mgr, tr( "Download" ) ); | 975 | InstallDlgImpl *dlg = new InstallDlgImpl( workingPackages, mgr, tr( "Download" ) ); |
@@ -980,5 +989,6 @@ void MainWindow :: applyChanges() | |||
980 | // deal with it | 989 | // deal with it |
981 | 990 | ||
982 | vector<InstallData> workingPackages; | 991 | QList<InstallData> workingPackages; |
992 | workingPackages.setAutoDelete( TRUE ); | ||
983 | for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); | 993 | for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); |
984 | item != 0 ; | 994 | item != 0 ; |
@@ -987,10 +997,9 @@ void MainWindow :: applyChanges() | |||
987 | if ( item->isOn() ) | 997 | if ( item->isOn() ) |
988 | { | 998 | { |
989 | InstallData data = dealWithItem( item ); | 999 | workingPackages.append( dealWithItem( item ) ); |
990 | workingPackages.push_back( data ); | ||
991 | } | 1000 | } |
992 | } | 1001 | } |
993 | 1002 | ||
994 | if ( workingPackages.size() == 0 ) | 1003 | if ( workingPackages.count() == 0 ) |
995 | { | 1004 | { |
996 | // Nothing to do | 1005 | // Nothing to do |
@@ -1012,10 +1021,10 @@ void MainWindow :: applyChanges() | |||
1012 | // If installed and different version available - upgrade | 1021 | // If installed and different version available - upgrade |
1013 | // If installed and version up to date - remove | 1022 | // If installed and version up to date - remove |
1014 | InstallData MainWindow :: dealWithItem( QCheckListItem *item ) | 1023 | InstallData *MainWindow :: dealWithItem( QCheckListItem *item ) |
1015 | { | 1024 | { |
1016 | QString name = item->text(); | 1025 | QString name = item->text(); |
1017 | 1026 | ||
1018 | // Get package | 1027 | // Get package |
1019 | vector<Server>::iterator s = mgr->getServer( serversList->currentText() ); | 1028 | Server *s = mgr->getServer( serversList->currentText() ); |
1020 | Package *p = s->getPackage( name ); | 1029 | Package *p = s->getPackage( name ); |
1021 | 1030 | ||
@@ -1028,21 +1037,21 @@ InstallData MainWindow :: dealWithItem( QCheckListItem *item ) | |||
1028 | if ( !p->isInstalled() ) | 1037 | if ( !p->isInstalled() ) |
1029 | { | 1038 | { |
1030 | InstallData item; | 1039 | InstallData *newitem = new InstallData();; |
1031 | item.option = "I"; | 1040 | newitem->option = "I"; |
1032 | item.packageName = name; | 1041 | newitem->packageName = name; |
1033 | return item; | 1042 | return newitem; |
1034 | } | 1043 | } |
1035 | else | 1044 | else |
1036 | { | 1045 | { |
1037 | InstallData item; | 1046 | InstallData *newitem = new InstallData();; |
1038 | item.option = "D"; | 1047 | newitem->option = "D"; |
1039 | if ( !p->isPackageStoredLocally() ) | 1048 | if ( !p->isPackageStoredLocally() ) |
1040 | item.packageName = p->getInstalledPackageName(); | 1049 | newitem->packageName = p->getInstalledPackageName(); |
1041 | else | 1050 | else |
1042 | item.packageName = name; | 1051 | newitem->packageName = name; |
1043 | 1052 | ||
1044 | if ( p->getInstalledTo() ) | 1053 | if ( p->getInstalledTo() ) |
1045 | { | 1054 | { |
1046 | item.destination = p->getInstalledTo(); | 1055 | newitem->destination = p->getInstalledTo(); |
1047 | // cout << "dest - " << p->getInstalledTo()->getDestinationName() << endl; | 1056 | // cout << "dest - " << p->getInstalledTo()->getDestinationName() << endl; |
1048 | // cout << "dest - " << p->getInstalledTo()->getDestinationPath() << endl; | 1057 | // cout << "dest - " << p->getInstalledTo()->getDestinationPath() << endl; |
@@ -1050,5 +1059,5 @@ InstallData MainWindow :: dealWithItem( QCheckListItem *item ) | |||
1050 | else | 1059 | else |
1051 | { | 1060 | { |
1052 | item.destination = p->getLocalPackage()->getInstalledTo(); | 1061 | newitem->destination = p->getLocalPackage()->getInstalledTo(); |
1053 | } | 1062 | } |
1054 | 1063 | ||
@@ -1067,5 +1076,5 @@ InstallData MainWindow :: dealWithItem( QCheckListItem *item ) | |||
1067 | { | 1076 | { |
1068 | // Version available is older - remove only | 1077 | // Version available is older - remove only |
1069 | item.option = "D"; | 1078 | newitem->option = "D"; |
1070 | } | 1079 | } |
1071 | else | 1080 | else |
@@ -1103,8 +1112,8 @@ InstallData MainWindow :: dealWithItem( QCheckListItem *item ) | |||
1103 | case 0: // Try again or Enter | 1112 | case 0: // Try again or Enter |
1104 | // option 0 = Remove | 1113 | // option 0 = Remove |
1105 | item.option = "D"; | 1114 | newitem->option = "D"; |
1106 | break; | 1115 | break; |
1107 | case 1: // Quit or Escape | 1116 | case 1: // Quit or Escape |
1108 | item.option = secondOption; | 1117 | newitem->option = secondOption; |
1109 | break; | 1118 | break; |
1110 | } | 1119 | } |
@@ -1112,5 +1121,5 @@ InstallData MainWindow :: dealWithItem( QCheckListItem *item ) | |||
1112 | else | 1121 | else |
1113 | { | 1122 | { |
1114 | // item.option = stickyOption; | 1123 | // newitem->option = stickyOption; |
1115 | } | 1124 | } |
1116 | } | 1125 | } |
@@ -1118,11 +1127,11 @@ InstallData MainWindow :: dealWithItem( QCheckListItem *item ) | |||
1118 | 1127 | ||
1119 | // Check if we are reinstalling the same version | 1128 | // Check if we are reinstalling the same version |
1120 | if ( item.option != "R" ) | 1129 | if ( newitem->option != "R" ) |
1121 | item.recreateLinks = true; | 1130 | newitem->recreateLinks = true; |
1122 | else | 1131 | else |
1123 | item.recreateLinks = false; | 1132 | newitem->recreateLinks = false; |
1124 | 1133 | ||
1125 | // User hit cancel (on dlg - assume remove) | 1134 | // User hit cancel (on dlg - assume remove) |
1126 | return item; | 1135 | return newitem; |
1127 | } | 1136 | } |
1128 | } | 1137 | } |