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 @@ -45,2 +45,4 @@ using namespace std; +extern int compareVersions( const char *v1, const char *v2 ); + NetworkPackageManager::NetworkPackageManager( DataManager *dataManager, QWidget *parent, const char *name) @@ -234,4 +236,7 @@ void NetworkPackageManager :: serverSelected( int ) if ( it->getVersion() != it->getInstalledVersion() ) + { + if ( compareVersions( it->getInstalledVersion(), it->getVersion() ) == 1 ) text += "*"; } + } @@ -535,2 +540,36 @@ InstallData NetworkPackageManager :: dealWithItem( QCheckListItem *item ) + // Now see if version is newer or not + int val = compareVersions( p->getInstalledVersion(), p->getVersion() ); + if ( val == -2 ) + { + // Error - should handle + } + else if ( val == -1 ) + { + // Version available is older - remove only + item.option = "R"; + } + else + { + 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 @@ -540,5 +579,5 @@ InstallData NetworkPackageManager :: dealWithItem( QCheckListItem *item ) 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" ) ) + msgtext.sprintf( caption, (const char *)name ); + switch( QMessageBox::information( this, text, + msgtext, "Remove", secondButton ) ) { @@ -548,3 +587,3 @@ InstallData NetworkPackageManager :: dealWithItem( QCheckListItem *item ) case 1: // Quit or Escape - item.option = "U"; + item.option = secondOption; break; @@ -556,12 +595,10 @@ InstallData NetworkPackageManager :: dealWithItem( QCheckListItem *item ) } + } + // 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; - } |