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 @@ -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,6 +235,9 @@ void NetworkPackageManager :: serverSelected( int ) // If a different version of package is available, postfix it with an * if ( it->getVersion() != it->getInstalledVersion() ) + { + if ( compareVersions( it->getInstalledVersion(), it->getVersion() ) == 1 ) text += "*"; } + } QCheckListItem *item = new QCheckListItem( packagesList, text, QCheckListItem::CheckBox ); @@ -534,4 +539,38 @@ 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 // the user to say something like 'remove all' @@ -539,7 +578,7 @@ 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 ) ) { case 0: // Try again or Enter @@ -547,5 +586,5 @@ InstallData NetworkPackageManager :: dealWithItem( QCheckListItem *item ) break; case 1: // Quit or Escape - item.option = "U"; + item.option = secondOption; break; } @@ -555,14 +594,12 @@ InstallData NetworkPackageManager :: dealWithItem( QCheckListItem *item ) // 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) |