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 | |||
@@ -543,24 +543,28 @@ void MainWindow :: updateProgress( int progress ) | |||
543 | 543 | ||
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 ); |
560 | qApp->processEvents(); | 564 | qApp->processEvents(); |
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; |
566 | i--; | 570 | i--; |
@@ -592,20 +596,20 @@ void MainWindow :: serverSelected( int, bool raiseProgress ) | |||
592 | QString serverName = serversList->currentText(); | 596 | QString serverName = serversList->currentText(); |
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 | { |
604 | if ( raiseProgress ) | 608 | if ( raiseProgress ) |
605 | { | 609 | { |
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 | } |
611 | 615 | ||
@@ -619,7 +623,8 @@ void MainWindow :: serverSelected( int, bool raiseProgress ) | |||
619 | #endif | 623 | #endif |
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) |
625 | i++; | 630 | i++; |
@@ -633,43 +638,46 @@ void MainWindow :: serverSelected( int, bool raiseProgress ) | |||
633 | } | 638 | } |
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 | ||
645 | // Apply show only new installed packages filter | 652 | // Apply show only new installed packages filter |
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 | } |
652 | 659 | ||
653 | // Apply the section filter | 660 | // Apply the section filter |
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 | ||
675 | item->setPixmap( 0, updatedIcon ); | 683 | item->setPixmap( 0, updatedIcon ); |
@@ -680,15 +688,15 @@ void MainWindow :: serverSelected( int, bool raiseProgress ) | |||
680 | } | 688 | } |
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 != "" ) |
694 | new QCheckListItem( item, QString( tr( "Installed To - %1" ).arg( destName ) ) ); | 702 | new QCheckListItem( item, QString( tr( "Installed To - %1" ).arg( destName ) ) ); |
@@ -698,26 +706,26 @@ void MainWindow :: serverSelected( int, bool raiseProgress ) | |||
698 | item->setPixmap( 0, nullIcon ); | 706 | item->setPixmap( 0, nullIcon ); |
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 | } |
723 | 731 | ||
@@ -755,7 +763,7 @@ void MainWindow :: searchForPackage( const QString &text ) | |||
755 | { | 763 | { |
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 ) |
761 | // start = (QCheckListItem *)start->nextSibling(); | 769 | // start = (QCheckListItem *)start->nextSibling(); |
@@ -957,11 +965,12 @@ void MainWindow :: downloadRemotePackage() | |||
957 | // grab details from dialog | 965 | // grab details from dialog |
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" ) ); |
967 | connect( dlg, SIGNAL( reloadData( InstallDlgImpl * ) ), this, SLOT( reloadData( InstallDlgImpl * ) ) ); | 976 | connect( dlg, SIGNAL( reloadData( InstallDlgImpl * ) ), this, SLOT( reloadData( InstallDlgImpl * ) ) ); |
@@ -979,19 +988,19 @@ void MainWindow :: applyChanges() | |||
979 | // Now for each selected item | 988 | // Now for each selected item |
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 ; |
985 | item = (QCheckListItem *)item->nextSibling() ) | 995 | item = (QCheckListItem *)item->nextSibling() ) |
986 | { | 996 | { |
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 |
997 | QMessageBox::information( this, tr( "Nothing to do" ), | 1006 | QMessageBox::information( this, tr( "Nothing to do" ), |
@@ -1011,12 +1020,12 @@ void MainWindow :: applyChanges() | |||
1011 | // If not installed - install | 1020 | // If not installed - install |
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 | ||
1022 | // If the package has a filename then it is a local file | 1031 | // If the package has a filename then it is a local file |
@@ -1027,29 +1036,29 @@ InstallData MainWindow :: dealWithItem( QCheckListItem *item ) | |||
1027 | QString dest = "root"; | 1036 | QString dest = "root"; |
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; |
1049 | } | 1058 | } |
1050 | else | 1059 | else |
1051 | { | 1060 | { |
1052 | item.destination = p->getLocalPackage()->getInstalledTo(); | 1061 | newitem->destination = p->getLocalPackage()->getInstalledTo(); |
1053 | } | 1062 | } |
1054 | 1063 | ||
1055 | // Now see if version is newer or not | 1064 | // Now see if version is newer or not |
@@ -1066,7 +1075,7 @@ InstallData MainWindow :: dealWithItem( QCheckListItem *item ) | |||
1066 | else if ( val == -1 ) | 1075 | else if ( val == -1 ) |
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 |
1072 | { | 1081 | { |
@@ -1102,28 +1111,28 @@ InstallData MainWindow :: dealWithItem( QCheckListItem *item ) | |||
1102 | { | 1111 | { |
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 | } |
1111 | } | 1120 | } |
1112 | else | 1121 | else |
1113 | { | 1122 | { |
1114 | // item.option = stickyOption; | 1123 | // newitem->option = stickyOption; |
1115 | } | 1124 | } |
1116 | } | 1125 | } |
1117 | 1126 | ||
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 | } |
1129 | 1138 | ||