summaryrefslogtreecommitdiff
path: root/noncore/settings/aqpkg/networkpkgmgr.cpp
Unidiff
Diffstat (limited to 'noncore/settings/aqpkg/networkpkgmgr.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/aqpkg/networkpkgmgr.cpp81
1 files changed, 59 insertions, 22 deletions
diff --git a/noncore/settings/aqpkg/networkpkgmgr.cpp b/noncore/settings/aqpkg/networkpkgmgr.cpp
index 3971aea..02e4e73 100644
--- a/noncore/settings/aqpkg/networkpkgmgr.cpp
+++ b/noncore/settings/aqpkg/networkpkgmgr.cpp
@@ -43,6 +43,8 @@ using namespace std;
43 43
44#include "global.h" 44#include "global.h"
45 45
46extern int compareVersions( const char *v1, const char *v2 );
47
46NetworkPackageManager::NetworkPackageManager( DataManager *dataManager, QWidget *parent, const char *name) 48NetworkPackageManager::NetworkPackageManager( DataManager *dataManager, QWidget *parent, const char *name)
47 : QWidget(parent, name) 49 : QWidget(parent, name)
48{ 50{
@@ -232,7 +234,10 @@ void NetworkPackageManager :: serverSelected( int )
232 234
233 // If a different version of package is available, postfix it with an * 235 // If a different version of package is available, postfix it with an *
234 if ( it->getVersion() != it->getInstalledVersion() ) 236 if ( it->getVersion() != it->getInstalledVersion() )
235 text += "*"; 237 {
238 if ( compareVersions( it->getInstalledVersion(), it->getVersion() ) == 1 )
239 text += "*";
240 }
236 } 241 }
237 242
238 QCheckListItem *item = new QCheckListItem( packagesList, text, QCheckListItem::CheckBox ); 243 QCheckListItem *item = new QCheckListItem( packagesList, text, QCheckListItem::CheckBox );
@@ -533,37 +538,69 @@ InstallData NetworkPackageManager :: dealWithItem( QCheckListItem *item )
533 item.destination = p->getLocalPackage()->getInstalledTo(); 538 item.destination = p->getLocalPackage()->getInstalledTo();
534 } 539 }
535 540
536 // Sticky option not implemented yet, but will eventually allow 541 // Now see if version is newer or not
537 // the user to say something like 'remove all' 542 int val = compareVersions( p->getInstalledVersion(), p->getVersion() );
538 if ( stickyOption == "" ) 543 if ( val == -2 )
539 { 544 {
540 QString msgtext; 545 // Error - should handle
541 msgtext.sprintf( "Do you wish to remove or reinstall\n%s?", (const char *)name ); 546 }
542 switch( QMessageBox::information( this, "Remove or ReInstall", 547 else if ( val == -1 )
543 msgtext, "Remove", "ReInstall" ) ) 548 {
544 { 549 // Version available is older - remove only
545 case 0: // Try again or Enter 550 item.option = "R";
546 item.option = "D";
547 break;
548 case 1: // Quit or Escape
549 item.option = "U";
550 break;
551 }
552 } 551 }
553 else 552 else
554 { 553 {
555// item.option = stickyOption; 554 QString caption;
555 QString text;
556 QString secondButton;
557 QString secondOption;
558 if ( val == 0 )
559 {
560 // Version available is the same - option to remove or reinstall
561 caption = "Do you wish to remove or reinstall\n%s?";
562 text = "Remove or ReInstall";
563 secondButton = "ReInstall";
564 secondOption = "R";
565 }
566 else if ( val == 1 )
567 {
568 // Version available is newer - option to remove or upgrade
569 caption = "Do you wish to remove or upgrade\n%s?";
570 text = "Remove or Upgrade";
571 secondButton = "Upgrade";
572 secondOption = "U";
573 }
574
575 // Sticky option not implemented yet, but will eventually allow
576 // the user to say something like 'remove all'
577 if ( stickyOption == "" )
578 {
579 QString msgtext;
580 msgtext.sprintf( caption, (const char *)name );
581 switch( QMessageBox::information( this, text,
582 msgtext, "Remove", secondButton ) )
583 {
584 case 0: // Try again or Enter
585 item.option = "D";
586 break;
587 case 1: // Quit or Escape
588 item.option = secondOption;
589 break;
590 }
591 }
592 else
593 {
594// item.option = stickyOption;
595 }
556 } 596 }
597
557 598
558 // Check if we are reinstalling the same version 599 // Check if we are reinstalling the same version
559 if ( p->getVersion() != p->getInstalledVersion() ) 600 if ( item.option != "R" )
560 item.recreateLinks = true; 601 item.recreateLinks = true;
561 else 602 else
562 {
563 if ( item.option == "U" )
564 item.option = "R";
565 item.recreateLinks = false; 603 item.recreateLinks = false;
566 }
567 604
568 // User hit cancel (on dlg - assume remove) 605 // User hit cancel (on dlg - assume remove)
569 return item; 606 return item;