Diffstat (limited to 'noncore/settings/aqpkg/networkpkgmgr.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/settings/aqpkg/networkpkgmgr.cpp | 55 |
1 files changed, 46 insertions, 9 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,14 +231,17 @@ 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() ) |
237 | { | ||
238 | if ( compareVersions( it->getInstalledVersion(), it->getVersion() ) == 1 ) | ||
235 | text += "*"; | 239 | text += "*"; |
236 | } | 240 | } |
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 | { |
242 | QString destName = ""; | 247 | QString destName = ""; |
@@ -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 | ||
541 | // Now see if version is newer or not | ||
542 | int val = compareVersions( p->getInstalledVersion(), p->getVersion() ); | ||
543 | if ( val == -2 ) | ||
544 | { | ||
545 | // Error - should handle | ||
546 | } | ||
547 | else if ( val == -1 ) | ||
548 | { | ||
549 | // Version available is older - remove only | ||
550 | item.option = "R"; | ||
551 | } | ||
552 | else | ||
553 | { | ||
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 | |||
536 | // Sticky option not implemented yet, but will eventually allow | 575 | // Sticky option not implemented yet, but will eventually allow |
537 | // the user to say something like 'remove all' | 576 | // the user to say something like 'remove all' |
538 | if ( stickyOption == "" ) | 577 | if ( stickyOption == "" ) |
539 | { | 578 | { |
540 | QString msgtext; | 579 | QString msgtext; |
541 | msgtext.sprintf( "Do you wish to remove or reinstall\n%s?", (const char *)name ); | 580 | msgtext.sprintf( caption, (const char *)name ); |
542 | switch( QMessageBox::information( this, "Remove or ReInstall", | 581 | switch( QMessageBox::information( this, text, |
543 | msgtext, "Remove", "ReInstall" ) ) | 582 | msgtext, "Remove", secondButton ) ) |
544 | { | 583 | { |
545 | case 0: // Try again or Enter | 584 | case 0: // Try again or Enter |
546 | item.option = "D"; | 585 | item.option = "D"; |
547 | break; | 586 | break; |
548 | case 1: // Quit or Escape | 587 | case 1: // Quit or Escape |
549 | item.option = "U"; | 588 | item.option = secondOption; |
550 | break; | 589 | break; |
551 | } | 590 | } |
552 | } | 591 | } |
553 | else | 592 | else |
554 | { | 593 | { |
555 | // item.option = stickyOption; | 594 | // item.option = stickyOption; |
556 | } | 595 | } |
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 | ||