summaryrefslogtreecommitdiff
path: root/noncore/settings/aqpkg/mainwin.cpp
Unidiff
Diffstat (limited to 'noncore/settings/aqpkg/mainwin.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/aqpkg/mainwin.cpp143
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
@@ -540,30 +540,34 @@ void MainWindow :: updateProgress( int progress )
540{ 540{
541 m_progress->setProgress( progress ); 541 m_progress->setProgress( progress );
542} 542}
543 543
544void MainWindow :: updateData() 544void 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--;
567 continue; 571 continue;
568 } 572 }
569 573
@@ -589,26 +593,26 @@ void MainWindow :: serverSelected( int, bool raiseProgress )
589 nullIcon.fill( colorGroup().base() ); 593 nullIcon.fill( colorGroup().base() );
590 594
591 // display packages 595 // display packages
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
612 packagesList->clear(); 616 packagesList->clear();
613 617
614#ifdef QWS 618#ifdef QWS
@@ -616,13 +620,14 @@ void MainWindow :: serverSelected( int, bool raiseProgress )
616 Config cfg( "aqpkg" ); 620 Config cfg( "aqpkg" );
617 cfg.setGroup( "settings" ); 621 cfg.setGroup( "settings" );
618 cfg.writeEntry( "selectedServer", currentlySelectedServer ); 622 cfg.writeEntry( "selectedServer", currentlySelectedServer );
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++;
626 if ( ( i % 100 ) == 0 ) 631 if ( ( i % 100 ) == 0 )
627 { 632 {
628 if ( doProgress ) 633 if ( doProgress )
@@ -630,97 +635,100 @@ void MainWindow :: serverSelected( int, bool raiseProgress )
630 m_progress->setProgress( i ); 635 m_progress->setProgress( i );
631 } 636 }
632 qApp->processEvents(); 637 qApp->processEvents();
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 );
676 } 684 }
677 else 685 else
678 { 686 {
679 item->setPixmap( 0, installedIcon ); 687 item->setPixmap( 0, installedIcon );
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 ) ) );
695 } 703 }
696 else 704 else
697 { 705 {
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
724 packagesList->insertItem( item ); 732 packagesList->insertItem( item );
725 } 733 }
726 734
@@ -752,13 +760,13 @@ void MainWindow :: serverSelected( int, bool raiseProgress )
752void MainWindow :: searchForPackage( const QString &text ) 760void MainWindow :: searchForPackage( const QString &text )
753{ 761{
754 if ( !text.isEmpty() ) 762 if ( !text.isEmpty() )
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();
762 770
763 if ( start == 0 ) 771 if ( start == 0 )
764 start = (QCheckListItem *)packagesList->firstChild(); 772 start = (QCheckListItem *)packagesList->firstChild();
@@ -954,17 +962,18 @@ void MainWindow :: downloadRemotePackage()
954// if ( dlg.exec() == QDialog::Rejected ) 962// if ( dlg.exec() == QDialog::Rejected )
955// return; 963// return;
956 964
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 * ) ) );
968 dlg->showMaximized(); 977 dlg->showMaximized();
969} 978}
970 979
@@ -976,25 +985,25 @@ void MainWindow :: applyChanges()
976 // First, write out ipkg_conf file so that ipkg can use it 985 // First, write out ipkg_conf file so that ipkg can use it
977 mgr->writeOutIpkgConf(); 986 mgr->writeOutIpkgConf();
978 987
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" ),
998 tr( "No packages selected" ), tr( "OK" ) ); 1007 tr( "No packages selected" ), tr( "OK" ) );
999 1008
1000 return; 1009 return;
@@ -1008,51 +1017,51 @@ void MainWindow :: applyChanges()
1008 1017
1009// decide what to do - either remove, upgrade or install 1018// decide what to do - either remove, upgrade or install
1010// Current rules: 1019// Current rules:
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
1014InstallData MainWindow :: dealWithItem( QCheckListItem *item ) 1023InstallData *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
1023 if ( p->isPackageStoredLocally() ) 1032 if ( p->isPackageStoredLocally() )
1024 name = p->getFilename(); 1033 name = p->getFilename();
1025 1034
1026 QString option; 1035 QString option;
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
1056 int val = compareVersions( p->getInstalledVersion(), p->getVersion() ); 1065 int val = compareVersions( p->getInstalledVersion(), p->getVersion() );
1057 1066
1058 // If the version requested is older and user selected a local ipk file, then reinstall the file 1067 // If the version requested is older and user selected a local ipk file, then reinstall the file
@@ -1063,13 +1072,13 @@ InstallData MainWindow :: dealWithItem( QCheckListItem *item )
1063 { 1072 {
1064 // Error - should handle 1073 // Error - should handle
1065 } 1074 }
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 {
1073 QString caption; 1082 QString caption;
1074 QString text; 1083 QString text;
1075 QString secondButton; 1084 QString secondButton;
@@ -1099,34 +1108,34 @@ InstallData MainWindow :: dealWithItem( QCheckListItem *item )
1099 msgtext = caption.arg( ( const char * )name ); 1108 msgtext = caption.arg( ( const char * )name );
1100 switch( QMessageBox::information( this, text, 1109 switch( QMessageBox::information( this, text,
1101 msgtext, tr( "Remove" ), secondButton ) ) 1110 msgtext, tr( "Remove" ), secondButton ) )
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
1130void MainWindow :: reloadData( InstallDlgImpl *dlg ) 1139void MainWindow :: reloadData( InstallDlgImpl *dlg )
1131{ 1140{
1132 stack->raiseWidget( progressWindow ); 1141 stack->raiseWidget( progressWindow );