summaryrefslogtreecommitdiff
authorandyq <andyq>2002-10-16 18:56:10 (UTC)
committer andyq <andyq>2002-10-16 18:56:10 (UTC)
commit73b4588d48fdb0c004646e5d8468f57a4a20ac14 (patch) (unidiff)
treeafe5da9173aa9ad8f77959fce921f22af944f75d
parent63d3299669d5147e16c56b016b0ee3cca2127a75 (diff)
downloadopie-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
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/aqpkg/networkpkgmgr.cpp65
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
@@ -29,12 +29,13 @@ using namespace std;
29#include <qpe/config.h> 29#include <qpe/config.h>
30#else 30#else
31#include <qapplication.h> 31#include <qapplication.h>
32#endif 32#endif
33#include <qlabel.h> 33#include <qlabel.h>
34#include <qfile.h> 34#include <qfile.h>
35#include <qmessagebox.h>
35 36
36#include "datamgr.h" 37#include "datamgr.h"
37#include "networkpkgmgr.h" 38#include "networkpkgmgr.h"
38#include "installdlgimpl.h" 39#include "installdlgimpl.h"
39#include "ipkg.h" 40#include "ipkg.h"
40#include "inputdlg.h" 41#include "inputdlg.h"
@@ -94,12 +95,13 @@ void NetworkPackageManager :: initGui()
94{ 95{
95 QLabel *l = new QLabel( "Servers", this ); 96 QLabel *l = new QLabel( "Servers", this );
96 serversList = new QComboBox( this ); 97 serversList = new QComboBox( this );
97 packagesList = new QListView( this ); 98 packagesList = new QListView( this );
98 update = new QPushButton( "Refresh List", this ); 99 update = new QPushButton( "Refresh List", this );
99 download = new QPushButton( "Download", this ); 100 download = new QPushButton( "Download", this );
101 upgrade = new QPushButton( "Upgrade", this );
100 apply = new QPushButton( "Apply", this ); 102 apply = new QPushButton( "Apply", this );
101 103
102 QVBoxLayout *vbox = new QVBoxLayout( this, 0, -1, "VBox" ); 104 QVBoxLayout *vbox = new QVBoxLayout( this, 0, -1, "VBox" );
103 QHBoxLayout *hbox1 = new QHBoxLayout( vbox, -1, "HBox1" ); 105 QHBoxLayout *hbox1 = new QHBoxLayout( vbox, -1, "HBox1" );
104 hbox1->addWidget( l ); 106 hbox1->addWidget( l );
105 hbox1->addWidget( serversList ); 107 hbox1->addWidget( serversList );
@@ -107,28 +109,30 @@ void NetworkPackageManager :: initGui()
107 vbox->addWidget( packagesList ); 109 vbox->addWidget( packagesList );
108 packagesList->addColumn( "Packages" ); 110 packagesList->addColumn( "Packages" );
109 111
110 QHBoxLayout *hbox2 = new QHBoxLayout( vbox, -1, "HBox2" ); 112 QHBoxLayout *hbox2 = new QHBoxLayout( vbox, -1, "HBox2" );
111 hbox2->addWidget( update ); 113 hbox2->addWidget( update );
112 hbox2->addWidget( download ); 114 hbox2->addWidget( download );
115 hbox2->addWidget( upgrade );
113 hbox2->addWidget( apply ); 116 hbox2->addWidget( apply );
114} 117}
115 118
116void NetworkPackageManager :: setupConnections() 119void NetworkPackageManager :: setupConnections()
117{ 120{
118 connect( serversList, SIGNAL(activated( int )), this, SLOT(serverSelected( int ))); 121 connect( serversList, SIGNAL(activated( int )), this, SLOT(serverSelected( int )));
119 connect( apply, SIGNAL(released()), this, SLOT(applyChanges()) ); 122 connect( apply, SIGNAL(released()), this, SLOT(applyChanges()) );
120 connect( download, SIGNAL(released()), this, SLOT(downloadPackage()) ); 123 connect( download, SIGNAL(released()), this, SLOT(downloadPackage()) );
124 connect( upgrade, SIGNAL( released()), this, SLOT(upgradePackages()) );
121 connect( update, SIGNAL(released()), this, SLOT(updateServer()) ); 125 connect( update, SIGNAL(released()), this, SLOT(updateServer()) );
122} 126}
123 127
124void NetworkPackageManager :: showProgressDialog() 128void NetworkPackageManager :: showProgressDialog( char *initialText )
125{ 129{
126 if ( !progressDlg ) 130 if ( !progressDlg )
127 progressDlg = new ProgressDlg( this, "Progress", false ); 131 progressDlg = new ProgressDlg( this, "Progress", false );
128 progressDlg->setText( "Reading installed packages" ); 132 progressDlg->setText( initialText );
129 progressDlg->show(); 133 progressDlg->show();
130} 134}
131 135
132 136
133void NetworkPackageManager :: serverSelected( int ) 137void NetworkPackageManager :: serverSelected( int )
134{ 138{
@@ -172,22 +176,30 @@ void NetworkPackageManager :: serverSelected( int )
172 new QCheckListItem( item, QString( "V. Installed - " ) + it->getInstalledVersion() ); 176 new QCheckListItem( item, QString( "V. Installed - " ) + it->getInstalledVersion() );
173 } 177 }
174 packagesList->insertItem( item ); 178 packagesList->insertItem( item );
175 } 179 }
176 180
177 // If the local server or the local ipkgs server disable the download button 181 // If the local server or the local ipkgs server disable the download button
178 download->setText( "Download" );
179 if ( serverName == LOCAL_SERVER ) 182 if ( serverName == LOCAL_SERVER )
183 {
184 upgrade->setEnabled( false );
185 download->setText( "Download" );
180 download->setEnabled( false ); 186 download->setEnabled( false );
187 }
181 else if ( serverName == LOCAL_IPKGS ) 188 else if ( serverName == LOCAL_IPKGS )
182 { 189 {
190 upgrade->setEnabled( false );
183 download->setEnabled( true ); 191 download->setEnabled( true );
184 download->setText( "Remove" ); 192 download->setText( "Remove" );
185 } 193 }
186 else 194 else
195 {
196 upgrade->setEnabled( true );
187 download->setEnabled( true ); 197 download->setEnabled( true );
198 download->setText( "Download" );
199 }
188} 200}
189 201
190void NetworkPackageManager :: updateServer() 202void NetworkPackageManager :: updateServer()
191{ 203{
192 QString serverName = serversList->currentText(); 204 QString serverName = serversList->currentText();
193 205
@@ -222,12 +234,40 @@ void NetworkPackageManager :: updateServer()
222 // Reload data 234 // Reload data
223 dataMgr->reloadServerData( serversList->currentText() ); 235 dataMgr->reloadServerData( serversList->currentText() );
224 serverSelected(-1); 236 serverSelected(-1);
225 delete dlg; 237 delete dlg;
226} 238}
227 239
240void NetworkPackageManager :: upgradePackages()
241{
242 // We're gonna do an upgrade of all packages
243 // First warn user that this isn't recommended
244 QString text = "WARNING: Upgrading while\nOpie/Qtopia is running\nis NOT recommended!\n\nAre you sure?\n";
245 QMessageBox warn("Warning", text, QMessageBox::Warning,
246 QMessageBox::Yes,
247 QMessageBox::No | QMessageBox::Escape | QMessageBox::Default ,
248 0, this );
249 warn.adjustSize();
250
251 if ( warn.exec() == QMessageBox::Yes )
252 {
253 // First, write out ipkg_conf file so that ipkg can use it
254 dataMgr->writeOutIpkgConf();
255
256 // Now run upgrade
257 InstallDlgImpl dlg( this, "Upgrade", true );
258 dlg.showDlg();
259
260 // Reload data
261 dataMgr->reloadServerData( LOCAL_SERVER );
262
263 dataMgr->reloadServerData( serversList->currentText() );
264 serverSelected(-1);
265 }
266}
267
228 268
229void NetworkPackageManager :: downloadPackage() 269void NetworkPackageManager :: downloadPackage()
230{ 270{
231 if ( download->text() == "Download" ) 271 if ( download->text() == "Download" )
232 { 272 {
233 // First, write out ipkg_conf file so that ipkg can use it 273 // First, write out ipkg_conf file so that ipkg can use it
@@ -340,12 +380,13 @@ void NetworkPackageManager :: applyChanges()
340 // do the stuff 380 // do the stuff
341 InstallDlgImpl dlg( workingPackages, dataMgr, this, "Install", true ); 381 InstallDlgImpl dlg( workingPackages, dataMgr, this, "Install", true );
342 dlg.showDlg(); 382 dlg.showDlg();
343 383
344 // Reload data 384 // Reload data
345 dataMgr->reloadServerData( LOCAL_SERVER ); 385 dataMgr->reloadServerData( LOCAL_SERVER );
386
346 dataMgr->reloadServerData( serversList->currentText() ); 387 dataMgr->reloadServerData( serversList->currentText() );
347 serverSelected(-1); 388 serverSelected(-1);
348 389
349#ifdef QWS 390#ifdef QWS
350 // Finally let the main system update itself 391 // Finally let the main system update itself
351 QCopEnvelope e("QPE/System", "linkChanged(QString)"); 392 QCopEnvelope e("QPE/System", "linkChanged(QString)");
@@ -381,13 +422,29 @@ QString NetworkPackageManager :: dealWithItem( QCheckListItem *item )
381 QString dest = "root"; 422 QString dest = "root";
382 if ( !p->isInstalled() ) 423 if ( !p->isInstalled() )
383 return QString( "I" ) + name; 424 return QString( "I" ) + name;
384 else 425 else
385 { 426 {
386 if ( p->getVersion() == p->getInstalledVersion() ) 427 if ( p->getVersion() == p->getInstalledVersion() )
387 return QString( "D" ) + name; 428 {
429 QString msgtext;
430 msgtext.sprintf( "Do you wish to remove or reinstall\n%s?", (const char *)name );
431 switch( QMessageBox::information( this, "Remove or ReInstall",
432 msgtext, "Remove", "ReInstall" ) )
433 {
434 case 0: // Try again or Enter
435 return QString( "D" ) + name;
436 break;
437 case 1: // Quit or Escape
438 return QString( "U" ) + name;
439 break;
440 }
441
442 // User hit cancel (on dlg - assume remove)
443 return QString( "D" ) + name;
444 }
388 else 445 else
389 return QString( "U" ) + name; 446 return QString( "U" ) + name;
390 } 447 }
391} 448}
392 449
393void NetworkPackageManager :: displayText( const QString &t ) 450void NetworkPackageManager :: displayText( const QString &t )