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 | |||
@@ -522,261 +522,269 @@ void MainWindow :: enableDownload( bool enabled ) | |||
522 | { | 522 | { |
523 | actionDownload->setIconSet( iconRemove ); | 523 | actionDownload->setIconSet( iconRemove ); |
524 | actionDownload->setText( tr( "Remove" ) ); | 524 | actionDownload->setText( tr( "Remove" ) ); |
525 | actionDownload->setWhatsThis( tr( "Click here to uninstall the currently selected package(s)." ) ); | 525 | actionDownload->setWhatsThis( tr( "Click here to uninstall the currently selected package(s)." ) ); |
526 | } | 526 | } |
527 | } | 527 | } |
528 | 528 | ||
529 | void MainWindow :: setProgressSteps( int numsteps ) | 529 | void MainWindow :: setProgressSteps( int numsteps ) |
530 | { | 530 | { |
531 | m_progress->setTotalSteps( numsteps ); | 531 | m_progress->setTotalSteps( numsteps ); |
532 | } | 532 | } |
533 | 533 | ||
534 | void MainWindow :: setProgressMessage( const QString &msg ) | 534 | void MainWindow :: setProgressMessage( const QString &msg ) |
535 | { | 535 | { |
536 | m_status->setText( msg ); | 536 | m_status->setText( msg ); |
537 | } | 537 | } |
538 | 538 | ||
539 | void MainWindow :: updateProgress( int progress ) | 539 | void MainWindow :: updateProgress( int progress ) |
540 | { | 540 | { |
541 | m_progress->setProgress( progress ); | 541 | m_progress->setProgress( progress ); |
542 | } | 542 | } |
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--; |
567 | continue; | 571 | continue; |
568 | } | 572 | } |
569 | 573 | ||
570 | serversList->insertItem( serverName ); | 574 | serversList->insertItem( serverName ); |
571 | if ( serverName == currentlySelectedServer ) | 575 | if ( serverName == currentlySelectedServer ) |
572 | activeItem = i; | 576 | activeItem = i; |
573 | } | 577 | } |
574 | 578 | ||
575 | // set selected server to be active server | 579 | // set selected server to be active server |
576 | if ( activeItem != -1 ) | 580 | if ( activeItem != -1 ) |
577 | serversList->setCurrentItem( activeItem ); | 581 | serversList->setCurrentItem( activeItem ); |
578 | serverSelected( 0, FALSE ); | 582 | serverSelected( 0, FALSE ); |
579 | } | 583 | } |
580 | 584 | ||
581 | void MainWindow :: serverSelected( int index ) | 585 | void MainWindow :: serverSelected( int index ) |
582 | { | 586 | { |
583 | serverSelected( index, TRUE ); | 587 | serverSelected( index, TRUE ); |
584 | } | 588 | } |
585 | 589 | ||
586 | void MainWindow :: serverSelected( int, bool raiseProgress ) | 590 | void MainWindow :: serverSelected( int, bool raiseProgress ) |
587 | { | 591 | { |
588 | QPixmap nullIcon( installedIcon.size() ); | 592 | QPixmap nullIcon( installedIcon.size() ); |
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 |
615 | // read download directory from config file | 619 | // read download directory from config file |
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 ) |
629 | { | 634 | { |
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 | ||
727 | // If the local server or the local ipkgs server disable the download button | 735 | // If the local server or the local ipkgs server disable the download button |
728 | if ( serverName == LOCAL_SERVER ) | 736 | if ( serverName == LOCAL_SERVER ) |
729 | { | 737 | { |
730 | downloadEnabled = TRUE; | 738 | downloadEnabled = TRUE; |
731 | actionUpgrade->setEnabled( FALSE ); | 739 | actionUpgrade->setEnabled( FALSE ); |
732 | } | 740 | } |
733 | else if ( serverName == LOCAL_IPKGS ) | 741 | else if ( serverName == LOCAL_IPKGS ) |
734 | { | 742 | { |
735 | downloadEnabled = FALSE; | 743 | downloadEnabled = FALSE; |
736 | actionUpgrade->setEnabled( FALSE ); | 744 | actionUpgrade->setEnabled( FALSE ); |
737 | } | 745 | } |
738 | else | 746 | else |
739 | { | 747 | { |
740 | downloadEnabled = TRUE; | 748 | downloadEnabled = TRUE; |
741 | actionUpgrade->setEnabled( TRUE ); | 749 | actionUpgrade->setEnabled( TRUE ); |
742 | } | 750 | } |
743 | enableDownload( downloadEnabled ); | 751 | enableDownload( downloadEnabled ); |
744 | 752 | ||
745 | // Display this widget once everything is done | 753 | // Display this widget once everything is done |
746 | if ( doProgress && raiseProgress ) | 754 | if ( doProgress && raiseProgress ) |
747 | { | 755 | { |
748 | stack->raiseWidget( networkPkgWindow ); | 756 | stack->raiseWidget( networkPkgWindow ); |
749 | } | 757 | } |
750 | } | 758 | } |
751 | 759 | ||
752 | void MainWindow :: searchForPackage( const QString &text ) | 760 | void 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(); |
765 | 773 | ||
766 | for ( QCheckListItem *item = start; item != 0 ; | 774 | for ( QCheckListItem *item = start; item != 0 ; |
767 | item = (QCheckListItem *)item->nextSibling() ) | 775 | item = (QCheckListItem *)item->nextSibling() ) |
768 | { | 776 | { |
769 | // cout << "checking " << item->text().lower() << endl; | 777 | // cout << "checking " << item->text().lower() << endl; |
770 | if ( item->text().lower().find( text ) != -1 ) | 778 | if ( item->text().lower().find( text ) != -1 ) |
771 | { | 779 | { |
772 | // cout << "matched " << item->text() << endl; | 780 | // cout << "matched " << item->text() << endl; |
773 | packagesList->ensureItemVisible( item ); | 781 | packagesList->ensureItemVisible( item ); |
774 | packagesList->setCurrentItem( item ); | 782 | packagesList->setCurrentItem( item ); |
775 | break; | 783 | break; |
776 | } | 784 | } |
777 | } | 785 | } |
778 | } | 786 | } |
779 | } | 787 | } |
780 | 788 | ||
781 | void MainWindow :: updateServer() | 789 | void MainWindow :: updateServer() |
782 | { | 790 | { |
@@ -936,215 +944,216 @@ void MainWindow :: downloadSelectedPackages() | |||
936 | item = (QCheckListItem *)item->nextSibling() ) | 944 | item = (QCheckListItem *)item->nextSibling() ) |
937 | { | 945 | { |
938 | if ( item->isOn() ) | 946 | if ( item->isOn() ) |
939 | { | 947 | { |
940 | ipkg.setPackage( item->text() ); | 948 | ipkg.setPackage( item->text() ); |
941 | ipkg.runIpkg( ); | 949 | ipkg.runIpkg( ); |
942 | } | 950 | } |
943 | } | 951 | } |
944 | } | 952 | } |
945 | 953 | ||
946 | void MainWindow :: downloadRemotePackage() | 954 | void MainWindow :: downloadRemotePackage() |
947 | { | 955 | { |
948 | // Display dialog | 956 | // Display dialog |
949 | bool ok; | 957 | bool ok; |
950 | QString package = InputDialog::getText( tr( "Install Remote Package" ), tr( "Enter package location" ), "http://", &ok, this ); | 958 | QString package = InputDialog::getText( tr( "Install Remote Package" ), tr( "Enter package location" ), "http://", &ok, this ); |
951 | if ( !ok || package.isEmpty() ) | 959 | if ( !ok || package.isEmpty() ) |
952 | return; | 960 | return; |
953 | // DownloadRemoteDlgImpl dlg( this, "Install", true ); | 961 | // DownloadRemoteDlgImpl dlg( this, "Install", true ); |
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 | ||
971 | 980 | ||
972 | void MainWindow :: applyChanges() | 981 | void MainWindow :: applyChanges() |
973 | { | 982 | { |
974 | stickyOption = ""; | 983 | stickyOption = ""; |
975 | 984 | ||
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; |
1001 | } | 1010 | } |
1002 | 1011 | ||
1003 | // do the stuff | 1012 | // do the stuff |
1004 | InstallDlgImpl *dlg = new InstallDlgImpl( workingPackages, mgr, tr( "Apply changes" ) ); | 1013 | InstallDlgImpl *dlg = new InstallDlgImpl( workingPackages, mgr, tr( "Apply changes" ) ); |
1005 | connect( dlg, SIGNAL( reloadData( InstallDlgImpl * ) ), this, SLOT( reloadData( InstallDlgImpl * ) ) ); | 1014 | connect( dlg, SIGNAL( reloadData( InstallDlgImpl * ) ), this, SLOT( reloadData( InstallDlgImpl * ) ) ); |
1006 | dlg->showMaximized(); | 1015 | dlg->showMaximized(); |
1007 | } | 1016 | } |
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 |
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 |
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 |
1059 | if ( p->isPackageStoredLocally() && val == -1 ) | 1068 | if ( p->isPackageStoredLocally() && val == -1 ) |
1060 | val = 0; | 1069 | val = 0; |
1061 | 1070 | ||
1062 | if ( val == -2 ) | 1071 | if ( val == -2 ) |
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; |
1076 | QString secondOption; | 1085 | QString secondOption; |
1077 | if ( val == 0 ) | 1086 | if ( val == 0 ) |
1078 | { | 1087 | { |
1079 | // Version available is the same - option to remove or reinstall | 1088 | // Version available is the same - option to remove or reinstall |
1080 | caption = tr( "Do you wish to remove or reinstall\n%1?" ); | 1089 | caption = tr( "Do you wish to remove or reinstall\n%1?" ); |
1081 | text = tr( "Remove or ReInstall" ); | 1090 | text = tr( "Remove or ReInstall" ); |
1082 | secondButton = tr( "ReInstall" ); | 1091 | secondButton = tr( "ReInstall" ); |
1083 | secondOption = tr( "R" ); | 1092 | secondOption = tr( "R" ); |
1084 | } | 1093 | } |
1085 | else if ( val == 1 ) | 1094 | else if ( val == 1 ) |
1086 | { | 1095 | { |
1087 | // Version available is newer - option to remove or upgrade | 1096 | // Version available is newer - option to remove or upgrade |
1088 | caption = tr( "Do you wish to remove or upgrade\n%1?" ); | 1097 | caption = tr( "Do you wish to remove or upgrade\n%1?" ); |
1089 | text = tr( "Remove or Upgrade" ); | 1098 | text = tr( "Remove or Upgrade" ); |
1090 | secondButton = tr( "Upgrade" ); | 1099 | secondButton = tr( "Upgrade" ); |
1091 | secondOption = tr( "U" ); | 1100 | secondOption = tr( "U" ); |
1092 | } | 1101 | } |
1093 | 1102 | ||
1094 | // Sticky option not implemented yet, but will eventually allow | 1103 | // Sticky option not implemented yet, but will eventually allow |
1095 | // the user to say something like 'remove all' | 1104 | // the user to say something like 'remove all' |
1096 | if ( stickyOption == "" ) | 1105 | if ( stickyOption == "" ) |
1097 | { | 1106 | { |
1098 | QString msgtext; | 1107 | QString msgtext; |
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 | ||
1130 | void MainWindow :: reloadData( InstallDlgImpl *dlg ) | 1139 | void MainWindow :: reloadData( InstallDlgImpl *dlg ) |
1131 | { | 1140 | { |
1132 | stack->raiseWidget( progressWindow ); | 1141 | stack->raiseWidget( progressWindow ); |
1133 | 1142 | ||
1134 | if ( dlg ) | 1143 | if ( dlg ) |
1135 | { | 1144 | { |
1136 | dlg->close(); | 1145 | dlg->close(); |
1137 | delete dlg; | 1146 | delete dlg; |
1138 | } | 1147 | } |
1139 | 1148 | ||
1140 | mgr->reloadServerData(); | 1149 | mgr->reloadServerData(); |
1141 | serverSelected( -1, FALSE ); | 1150 | serverSelected( -1, FALSE ); |
1142 | 1151 | ||
1143 | #ifdef QWS | 1152 | #ifdef QWS |
1144 | m_status->setText( tr( "Updating Launcher..." ) ); | 1153 | m_status->setText( tr( "Updating Launcher..." ) ); |
1145 | 1154 | ||
1146 | // Finally let the main system update itself | 1155 | // Finally let the main system update itself |
1147 | QCopEnvelope e("QPE/System", "linkChanged(QString)"); | 1156 | QCopEnvelope e("QPE/System", "linkChanged(QString)"); |
1148 | QString lf = QString::null; | 1157 | QString lf = QString::null; |
1149 | e << lf; | 1158 | e << lf; |
1150 | #endif | 1159 | #endif |