Diffstat (limited to 'noncore/settings/aqpkg/networkpkgmgr.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/settings/aqpkg/networkpkgmgr.cpp | 81 |
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 | |||
@@ -40,12 +40,14 @@ using namespace std; | |||
40 | #include "ipkg.h" | 40 | #include "ipkg.h" |
41 | #include "inputdlg.h" | 41 | #include "inputdlg.h" |
42 | #include "letterpushbutton.h" | 42 | #include "letterpushbutton.h" |
43 | 43 | ||
44 | #include "global.h" | 44 | #include "global.h" |
45 | 45 | ||
46 | extern int compareVersions( const char *v1, const char *v2 ); | ||
47 | |||
46 | NetworkPackageManager::NetworkPackageManager( DataManager *dataManager, QWidget *parent, const char *name) | 48 | NetworkPackageManager::NetworkPackageManager( DataManager *dataManager, QWidget *parent, const char *name) |
47 | : QWidget(parent, name) | 49 | : QWidget(parent, name) |
48 | { | 50 | { |
49 | dataMgr = dataManager; | 51 | dataMgr = dataManager; |
50 | 52 | ||
51 | #ifdef QWS | 53 | #ifdef QWS |
@@ -229,13 +231,16 @@ void NetworkPackageManager :: serverSelected( int ) | |||
229 | if ( it->isInstalled() ) | 231 | if ( it->isInstalled() ) |
230 | { | 232 | { |
231 | text += " (installed)"; | 233 | text += " (installed)"; |
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 ); |
239 | 244 | ||
240 | if ( it->isInstalled() ) | 245 | if ( it->isInstalled() ) |
241 | { | 246 | { |
@@ -530,43 +535,75 @@ InstallData NetworkPackageManager :: dealWithItem( QCheckListItem *item ) | |||
530 | } | 535 | } |
531 | else | 536 | else |
532 | { | 537 | { |
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; |
570 | } | 607 | } |
571 | } | 608 | } |
572 | 609 | ||