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 @@ -44,4 +44,6 @@ using namespace std; #include "global.h" +extern int compareVersions( const char *v1, const char *v2 ); + NetworkPackageManager::NetworkPackageManager( DataManager *dataManager, QWidget *parent, const char *name) : QWidget(parent, name) @@ -233,5 +235,8 @@ void NetworkPackageManager :: serverSelected( int ) // If a different version of package is available, postfix it with an * if ( it->getVersion() != it->getInstalledVersion() ) - text += "*"; + { + if ( compareVersions( it->getInstalledVersion(), it->getVersion() ) == 1 ) + text += "*"; + } } @@ -534,35 +539,67 @@ InstallData NetworkPackageManager :: dealWithItem( QCheckListItem *item ) } - // Sticky option not implemented yet, but will eventually allow - // the user to say something like 'remove all' - if ( stickyOption == "" ) + // Now see if version is newer or not + int val = compareVersions( p->getInstalledVersion(), p->getVersion() ); + if ( val == -2 ) { - QString msgtext; - msgtext.sprintf( "Do you wish to remove or reinstall\n%s?", (const char *)name ); - switch( QMessageBox::information( this, "Remove or ReInstall", - msgtext, "Remove", "ReInstall" ) ) - { - case 0: // Try again or Enter - item.option = "D"; - break; - case 1: // Quit or Escape - item.option = "U"; - break; - } + // Error - should handle + } + else if ( val == -1 ) + { + // Version available is older - remove only + item.option = "R"; } else { -// item.option = stickyOption; + QString caption; + QString text; + QString secondButton; + QString secondOption; + if ( val == 0 ) + { + // Version available is the same - option to remove or reinstall + caption = "Do you wish to remove or reinstall\n%s?"; + text = "Remove or ReInstall"; + secondButton = "ReInstall"; + secondOption = "R"; + } + else if ( val == 1 ) + { + // Version available is newer - option to remove or upgrade + caption = "Do you wish to remove or upgrade\n%s?"; + text = "Remove or Upgrade"; + secondButton = "Upgrade"; + secondOption = "U"; + } + + // Sticky option not implemented yet, but will eventually allow + // the user to say something like 'remove all' + if ( stickyOption == "" ) + { + QString msgtext; + msgtext.sprintf( caption, (const char *)name ); + switch( QMessageBox::information( this, text, + msgtext, "Remove", secondButton ) ) + { + case 0: // Try again or Enter + item.option = "D"; + break; + case 1: // Quit or Escape + item.option = secondOption; + break; + } + } + else + { +// item.option = stickyOption; + } } + // Check if we are reinstalling the same version - if ( p->getVersion() != p->getInstalledVersion() ) + if ( item.option != "R" ) item.recreateLinks = true; else - { - if ( item.option == "U" ) - item.option = "R"; item.recreateLinks = false; - } // User hit cancel (on dlg - assume remove) |