author | andyq <andyq> | 2002-10-16 18:56:10 (UTC) |
---|---|---|
committer | andyq <andyq> | 2002-10-16 18:56:10 (UTC) |
commit | 73b4588d48fdb0c004646e5d8468f57a4a20ac14 (patch) (side-by-side diff) | |
tree | afe5da9173aa9ad8f77959fce921f22af944f75d | |
parent | 63d3299669d5147e16c56b016b0ee3cca2127a75 (diff) | |
download | opie-73b4588d48fdb0c004646e5d8468f57a4a20ac14.zip opie-73b4588d48fdb0c004646e5d8468f57a4a20ac14.tar.gz opie-73b4588d48fdb0c004646e5d8468f57a4a20ac14.tar.bz2 |
Updated GUI so that we can upgrade all packages within a feed.
User is asked whether to remove or reinstall when selecting a package with
the same version
-rw-r--r-- | noncore/settings/aqpkg/networkpkgmgr.cpp | 65 |
1 files changed, 61 insertions, 4 deletions
diff --git a/noncore/settings/aqpkg/networkpkgmgr.cpp b/noncore/settings/aqpkg/networkpkgmgr.cpp index 06e2a03..0bc01df 100644 --- a/noncore/settings/aqpkg/networkpkgmgr.cpp +++ b/noncore/settings/aqpkg/networkpkgmgr.cpp @@ -23,24 +23,25 @@ using namespace std; #include <stdlib.h> #include <linux/limits.h> #ifdef QWS #include <qpe/qpeapplication.h> #include <qpe/qcopenvelope_qws.h> #include <qpe/config.h> #else #include <qapplication.h> #endif #include <qlabel.h> #include <qfile.h> +#include <qmessagebox.h> #include "datamgr.h" #include "networkpkgmgr.h" #include "installdlgimpl.h" #include "ipkg.h" #include "inputdlg.h" #include "global.h" NetworkPackageManager::NetworkPackageManager( DataManager *dataManager, QWidget *parent, const char *name) : QWidget(parent, name) { @@ -88,53 +89,56 @@ void NetworkPackageManager :: updateData() serversList->setCurrentItem( activeItem ); serverSelected( 0 ); } void NetworkPackageManager :: initGui() { QLabel *l = new QLabel( "Servers", this ); serversList = new QComboBox( this ); packagesList = new QListView( this ); update = new QPushButton( "Refresh List", this ); download = new QPushButton( "Download", this ); + upgrade = new QPushButton( "Upgrade", this ); apply = new QPushButton( "Apply", this ); QVBoxLayout *vbox = new QVBoxLayout( this, 0, -1, "VBox" ); QHBoxLayout *hbox1 = new QHBoxLayout( vbox, -1, "HBox1" ); hbox1->addWidget( l ); hbox1->addWidget( serversList ); vbox->addWidget( packagesList ); packagesList->addColumn( "Packages" ); QHBoxLayout *hbox2 = new QHBoxLayout( vbox, -1, "HBox2" ); hbox2->addWidget( update ); hbox2->addWidget( download ); + hbox2->addWidget( upgrade ); hbox2->addWidget( apply ); } void NetworkPackageManager :: setupConnections() { connect( serversList, SIGNAL(activated( int )), this, SLOT(serverSelected( int ))); connect( apply, SIGNAL(released()), this, SLOT(applyChanges()) ); connect( download, SIGNAL(released()), this, SLOT(downloadPackage()) ); + connect( upgrade, SIGNAL( released()), this, SLOT(upgradePackages()) ); connect( update, SIGNAL(released()), this, SLOT(updateServer()) ); } -void NetworkPackageManager :: showProgressDialog() +void NetworkPackageManager :: showProgressDialog( char *initialText ) { if ( !progressDlg ) progressDlg = new ProgressDlg( this, "Progress", false ); - progressDlg->setText( "Reading installed packages" ); + progressDlg->setText( initialText ); progressDlg->show(); } void NetworkPackageManager :: serverSelected( int ) { packagesList->clear(); // display packages QString serverName = serversList->currentText(); Server *s = dataMgr->getServer( serverName ); dataMgr->setActiveServer( serverName ); @@ -166,34 +170,42 @@ void NetworkPackageManager :: serverSelected( int ) new QCheckListItem( item, QString( "Filename - " ) + it->getFilename() ); new QCheckListItem( item, QString( "V. Available - " ) + it->getVersion() ); if ( it->getLocalPackage() ) { if ( it->isInstalled() ) new QCheckListItem( item, QString( "V. Installed - " ) + it->getInstalledVersion() ); } packagesList->insertItem( item ); } // If the local server or the local ipkgs server disable the download button - download->setText( "Download" ); if ( serverName == LOCAL_SERVER ) + { + upgrade->setEnabled( false ); + download->setText( "Download" ); download->setEnabled( false ); + } else if ( serverName == LOCAL_IPKGS ) { + upgrade->setEnabled( false ); download->setEnabled( true ); download->setText( "Remove" ); } else + { + upgrade->setEnabled( true ); download->setEnabled( true ); + download->setText( "Download" ); + } } void NetworkPackageManager :: updateServer() { QString serverName = serversList->currentText(); // Update the current server // Display dialog ProgressDlg *dlg = new ProgressDlg( this ); QString status = "Updating package list for "; status += serverName; dlg->show(); @@ -216,24 +228,52 @@ void NetworkPackageManager :: updateServer() connect( &ipkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &))); ipkg.setOption( option ); ipkg.runIpkg( ); } // Reload data dataMgr->reloadServerData( serversList->currentText() ); serverSelected(-1); delete dlg; } +void NetworkPackageManager :: upgradePackages() +{ + // We're gonna do an upgrade of all packages + // First warn user that this isn't recommended + QString text = "WARNING: Upgrading while\nOpie/Qtopia is running\nis NOT recommended!\n\nAre you sure?\n"; + QMessageBox warn("Warning", text, QMessageBox::Warning, + QMessageBox::Yes, + QMessageBox::No | QMessageBox::Escape | QMessageBox::Default , + 0, this ); + warn.adjustSize(); + + if ( warn.exec() == QMessageBox::Yes ) + { + // First, write out ipkg_conf file so that ipkg can use it + dataMgr->writeOutIpkgConf(); + + // Now run upgrade + InstallDlgImpl dlg( this, "Upgrade", true ); + dlg.showDlg(); + + // Reload data + dataMgr->reloadServerData( LOCAL_SERVER ); + + dataMgr->reloadServerData( serversList->currentText() ); + serverSelected(-1); + } +} + void NetworkPackageManager :: downloadPackage() { if ( download->text() == "Download" ) { // First, write out ipkg_conf file so that ipkg can use it dataMgr->writeOutIpkgConf(); // Display dialog to user asking where to download the files to bool ok = FALSE; QString dir = ""; #ifdef QWS @@ -334,24 +374,25 @@ void NetworkPackageManager :: applyChanges() workingPackages.push_back( p ); } item = (QCheckListItem *)item->nextSibling(); } while ( item ); // do the stuff InstallDlgImpl dlg( workingPackages, dataMgr, this, "Install", true ); dlg.showDlg(); // Reload data dataMgr->reloadServerData( LOCAL_SERVER ); + dataMgr->reloadServerData( serversList->currentText() ); serverSelected(-1); #ifdef QWS // Finally let the main system update itself QCopEnvelope e("QPE/System", "linkChanged(QString)"); QString lf = QString::null; e << lf; #endif } // decide what to do - either remove, upgrade or install @@ -375,22 +416,38 @@ QString NetworkPackageManager :: dealWithItem( QCheckListItem *item ) Package *p = s->getPackage( name ); // If the package has a filename then it is a local file if ( p->isPackageStoredLocally() ) name = p->getFilename(); QString option; QString dest = "root"; if ( !p->isInstalled() ) return QString( "I" ) + name; else { if ( p->getVersion() == p->getInstalledVersion() ) - return QString( "D" ) + name; + { + 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 + return QString( "D" ) + name; + break; + case 1: // Quit or Escape + return QString( "U" ) + name; + break; + } + + // User hit cancel (on dlg - assume remove) + return QString( "D" ) + name; + } else return QString( "U" ) + name; } } void NetworkPackageManager :: displayText( const QString &t ) { cout << t << endl; } |