summaryrefslogtreecommitdiff
authorandyq <andyq>2002-11-11 22:13:45 (UTC)
committer andyq <andyq>2002-11-11 22:13:45 (UTC)
commit99232d320496b78e92f9bd9a3c1af064940592a6 (patch) (unidiff)
treed41bc5235f2d4a62d8c3f4a8a9811116920acc81
parent503bb111313dfb62ee6341069a75dad56bbd47bf (diff)
downloadopie-99232d320496b78e92f9bd9a3c1af064940592a6.zip
opie-99232d320496b78e92f9bd9a3c1af064940592a6.tar.gz
opie-99232d320496b78e92f9bd9a3c1af064940592a6.tar.bz2
Fixed a bug where you couldn't download from installed pgks view
and another where buttons looked crap
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/aqpkg/networkpkgmgr.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/noncore/settings/aqpkg/networkpkgmgr.cpp b/noncore/settings/aqpkg/networkpkgmgr.cpp
index d43c6ac..188f90d 100644
--- a/noncore/settings/aqpkg/networkpkgmgr.cpp
+++ b/noncore/settings/aqpkg/networkpkgmgr.cpp
@@ -177,257 +177,257 @@ void NetworkPackageManager :: initGui()
177 QHBoxLayout *hbox2 = new QHBoxLayout( vbox, -1, "HBox2" ); 177 QHBoxLayout *hbox2 = new QHBoxLayout( vbox, -1, "HBox2" );
178 hbox2->addWidget( update ); 178 hbox2->addWidget( update );
179 hbox2->addWidget( download ); 179 hbox2->addWidget( download );
180 hbox2->addWidget( upgrade ); 180 hbox2->addWidget( upgrade );
181 hbox2->addWidget( apply ); 181 hbox2->addWidget( apply );
182} 182}
183 183
184void NetworkPackageManager :: setupConnections() 184void NetworkPackageManager :: setupConnections()
185{ 185{
186 connect( serversList, SIGNAL(activated( int )), this, SLOT(serverSelected( int ))); 186 connect( serversList, SIGNAL(activated( int )), this, SLOT(serverSelected( int )));
187 connect( apply, SIGNAL(released()), this, SLOT(applyChanges()) ); 187 connect( apply, SIGNAL(released()), this, SLOT(applyChanges()) );
188 connect( download, SIGNAL(released()), this, SLOT(downloadPackage()) ); 188 connect( download, SIGNAL(released()), this, SLOT(downloadPackage()) );
189 connect( upgrade, SIGNAL( released()), this, SLOT(upgradePackages()) ); 189 connect( upgrade, SIGNAL( released()), this, SLOT(upgradePackages()) );
190 connect( update, SIGNAL(released()), this, SLOT(updateServer()) ); 190 connect( update, SIGNAL(released()), this, SLOT(updateServer()) );
191} 191}
192 192
193void NetworkPackageManager :: showProgressDialog( char *initialText ) 193void NetworkPackageManager :: showProgressDialog( char *initialText )
194{ 194{
195 if ( !progressDlg ) 195 if ( !progressDlg )
196 progressDlg = new ProgressDlg( this, "Progress", false ); 196 progressDlg = new ProgressDlg( this, "Progress", false );
197 progressDlg->setText( initialText ); 197 progressDlg->setText( initialText );
198 progressDlg->show(); 198 progressDlg->show();
199} 199}
200 200
201 201
202void NetworkPackageManager :: serverSelected( int ) 202void NetworkPackageManager :: serverSelected( int )
203{ 203{
204 packagesList->clear(); 204 packagesList->clear();
205 205
206 // display packages 206 // display packages
207 QString serverName = serversList->currentText(); 207 QString serverName = serversList->currentText();
208 currentlySelectedServer = serverName; 208 currentlySelectedServer = serverName;
209 209
210#ifdef QWS 210#ifdef QWS
211 // read download directory from config file 211 // read download directory from config file
212 Config cfg( "aqpkg" ); 212 Config cfg( "aqpkg" );
213 cfg.setGroup( "settings" ); 213 cfg.setGroup( "settings" );
214 cfg.writeEntry( "selectedServer", currentlySelectedServer ); 214 cfg.writeEntry( "selectedServer", currentlySelectedServer );
215#endif 215#endif
216 216
217 Server *s = dataMgr->getServer( serverName ); 217 Server *s = dataMgr->getServer( serverName );
218 218
219 vector<Package> &list = s->getPackageList(); 219 vector<Package> &list = s->getPackageList();
220 vector<Package>::iterator it; 220 vector<Package>::iterator it;
221 for ( it = list.begin() ; it != list.end() ; ++it ) 221 for ( it = list.begin() ; it != list.end() ; ++it )
222 { 222 {
223 223
224 QString text = ""; 224 QString text = "";
225 225
226 // Apply show only uninstalled packages filter 226 // Apply show only uninstalled packages filter
227 if ( showUninstalledPkgs && it->isInstalled() ) 227 if ( showUninstalledPkgs && it->isInstalled() )
228 continue; 228 continue;
229 229
230 // Apply show only installed packages filter 230 // Apply show only installed packages filter
231 if ( showInstalledPkgs && !it->isInstalled() ) 231 if ( showInstalledPkgs && !it->isInstalled() )
232 continue; 232 continue;
233 233
234 // Apply show only new installed packages filter 234 // Apply show only new installed packages filter
235 if ( showUpgradedPkgs ) 235 if ( showUpgradedPkgs )
236 { 236 {
237 if ( !it->isInstalled() || 237 if ( !it->isInstalled() ||
238 compareVersions( it->getInstalledVersion(), it->getVersion() ) != 1 ) 238 compareVersions( it->getInstalledVersion(), it->getVersion() ) != 1 )
239 continue; 239 continue;
240 } 240 }
241 241
242 // If the local server, only display installed packages 242 // If the local server, only display installed packages
243 if ( serverName == LOCAL_SERVER && !it->isInstalled() ) 243 if ( serverName == LOCAL_SERVER && !it->isInstalled() )
244 continue; 244 continue;
245 245
246 246
247 text += it->getPackageName(); 247 text += it->getPackageName();
248 if ( it->isInstalled() ) 248 if ( it->isInstalled() )
249 { 249 {
250 text += " (installed)"; 250 text += " (installed)";
251 251
252 // If a different version of package is available, postfix it with an * 252 // If a different version of package is available, postfix it with an *
253 if ( it->getVersion() != it->getInstalledVersion() ) 253 if ( it->getVersion() != it->getInstalledVersion() )
254 { 254 {
255 255
256 if ( compareVersions( it->getInstalledVersion(), it->getVersion() ) == 1 ) 256 if ( compareVersions( it->getInstalledVersion(), it->getVersion() ) == 1 )
257 text += "*"; 257 text += "*";
258 } 258 }
259 } 259 }
260 260
261 QCheckListItem *item = new QCheckListItem( packagesList, text, QCheckListItem::CheckBox ); 261 QCheckListItem *item = new QCheckListItem( packagesList, text, QCheckListItem::CheckBox );
262 262
263 if ( it->isInstalled() ) 263 if ( it->isInstalled() )
264 { 264 {
265 QString destName = ""; 265 QString destName = "";
266 if ( it->getLocalPackage() ) 266 if ( it->getLocalPackage() )
267 { 267 {
268 if ( it->getLocalPackage()->getInstalledTo() ) 268 if ( it->getLocalPackage()->getInstalledTo() )
269 destName = it->getLocalPackage()->getInstalledTo()->getDestinationName(); 269 destName = it->getLocalPackage()->getInstalledTo()->getDestinationName();
270 } 270 }
271 else 271 else
272 { 272 {
273 if ( it->getInstalledTo() ) 273 if ( it->getInstalledTo() )
274 destName = it->getInstalledTo()->getDestinationName(); 274 destName = it->getInstalledTo()->getDestinationName();
275 } 275 }
276 if ( destName != "" ) 276 if ( destName != "" )
277 new QCheckListItem( item, QString( "Installed To - " ) + destName ); 277 new QCheckListItem( item, QString( "Installed To - " ) + destName );
278 } 278 }
279 279
280 if ( !it->isPackageStoredLocally() ) 280 if ( !it->isPackageStoredLocally() )
281 new QCheckListItem( item, QString( "Description - " ) + it->getDescription() ); 281 new QCheckListItem( item, QString( "Description - " ) + it->getDescription() );
282 else 282 else
283 new QCheckListItem( item, QString( "Filename - " ) + it->getFilename() ); 283 new QCheckListItem( item, QString( "Filename - " ) + it->getFilename() );
284 284
285 if ( serverName == LOCAL_SERVER ) 285 if ( serverName == LOCAL_SERVER )
286 { 286 {
287 new QCheckListItem( item, QString( "V. Installed - " ) + it->getVersion() ); 287 new QCheckListItem( item, QString( "V. Installed - " ) + it->getVersion() );
288 } 288 }
289 else 289 else
290 { 290 {
291 new QCheckListItem( item, QString( "V. Available - " ) + it->getVersion() ); 291 new QCheckListItem( item, QString( "V. Available - " ) + it->getVersion() );
292 if ( it->getLocalPackage() ) 292 if ( it->getLocalPackage() )
293 { 293 {
294 if ( it->isInstalled() ) 294 if ( it->isInstalled() )
295 new QCheckListItem( item, QString( "V. Installed - " ) + it->getInstalledVersion() ); 295 new QCheckListItem( item, QString( "V. Installed - " ) + it->getInstalledVersion() );
296 } 296 }
297 } 297 }
298 packagesList->insertItem( item ); 298 packagesList->insertItem( item );
299 } 299 }
300 300
301 // If the local server or the local ipkgs server disable the download button 301 // If the local server or the local ipkgs server disable the download button
302 if ( serverName == LOCAL_SERVER ) 302 if ( serverName == LOCAL_SERVER )
303 { 303 {
304 upgrade->setEnabled( false ); 304 upgrade->setEnabled( false );
305 download->setText( "Install Remote" ); 305 download->setText( "Download" );
306 download->setEnabled( true ); 306 download->setEnabled( true );
307 } 307 }
308 else if ( serverName == LOCAL_IPKGS ) 308 else if ( serverName == LOCAL_IPKGS )
309 { 309 {
310 upgrade->setEnabled( false ); 310 upgrade->setEnabled( false );
311 download->setEnabled( true ); 311 download->setEnabled( true );
312 download->setText( "Remove" ); 312 download->setText( "Remove" );
313 } 313 }
314 else 314 else
315 { 315 {
316 upgrade->setEnabled( true ); 316 upgrade->setEnabled( true );
317 download->setEnabled( true ); 317 download->setEnabled( true );
318 download->setText( "Download" ); 318 download->setText( "Download" );
319 } 319 }
320} 320}
321 321
322void NetworkPackageManager :: updateServer() 322void NetworkPackageManager :: updateServer()
323{ 323{
324 QString serverName = serversList->currentText(); 324 QString serverName = serversList->currentText();
325 325
326 // Update the current server 326 // Update the current server
327 // Display dialog 327 // Display dialog
328// ProgressDlg *progDlg = new ProgressDlg( this ); 328// ProgressDlg *progDlg = new ProgressDlg( this );
329// QString status = "Updating package lists..."; 329// QString status = "Updating package lists...";
330// progDlg->show(); 330// progDlg->show();
331// progDlg->setText( status ); 331// progDlg->setText( status );
332 332
333 // Disable buttons to stop silly people clicking lots on them :) 333 // Disable buttons to stop silly people clicking lots on them :)
334 334
335 // First, write out ipkg_conf file so that ipkg can use it 335 // First, write out ipkg_conf file so that ipkg can use it
336 dataMgr->writeOutIpkgConf(); 336 dataMgr->writeOutIpkgConf();
337 337
338 Ipkg ipkg; 338 Ipkg ipkg;
339 ipkg.setOption( "update" ); 339 ipkg.setOption( "update" );
340 340
341 InstallDlgImpl dlg( &ipkg, "Refreshing server package lists", this, "Upgrade", true ); 341 InstallDlgImpl dlg( &ipkg, "Refreshing server package lists", this, "Upgrade", true );
342 dlg.showDlg(); 342 dlg.showDlg();
343 343
344 // Reload data 344 // Reload data
345 dataMgr->reloadServerData(); 345 dataMgr->reloadServerData();
346 serverSelected(-1); 346 serverSelected(-1);
347// delete progDlg; 347// delete progDlg;
348} 348}
349 349
350void NetworkPackageManager :: upgradePackages() 350void NetworkPackageManager :: upgradePackages()
351{ 351{
352 // We're gonna do an upgrade of all packages 352 // We're gonna do an upgrade of all packages
353 // First warn user that this isn't recommended 353 // First warn user that this isn't recommended
354 QString text = "WARNING: Upgrading while\nOpie/Qtopia is running\nis NOT recommended!\n\nAre you sure?\n"; 354 QString text = "WARNING: Upgrading while\nOpie/Qtopia is running\nis NOT recommended!\n\nAre you sure?\n";
355 QMessageBox warn("Warning", text, QMessageBox::Warning, 355 QMessageBox warn("Warning", text, QMessageBox::Warning,
356 QMessageBox::Yes, 356 QMessageBox::Yes,
357 QMessageBox::No | QMessageBox::Escape | QMessageBox::Default , 357 QMessageBox::No | QMessageBox::Escape | QMessageBox::Default ,
358 0, this ); 358 0, this );
359 warn.adjustSize(); 359 warn.adjustSize();
360 360
361 if ( warn.exec() == QMessageBox::Yes ) 361 if ( warn.exec() == QMessageBox::Yes )
362 { 362 {
363 // First, write out ipkg_conf file so that ipkg can use it 363 // First, write out ipkg_conf file so that ipkg can use it
364 dataMgr->writeOutIpkgConf(); 364 dataMgr->writeOutIpkgConf();
365 365
366 // Now run upgrade 366 // Now run upgrade
367 Ipkg ipkg; 367 Ipkg ipkg;
368 ipkg.setOption( "upgrade" ); 368 ipkg.setOption( "upgrade" );
369 369
370 InstallDlgImpl dlg( &ipkg, "Upgrading installed packages", this, "Upgrade", true ); 370 InstallDlgImpl dlg( &ipkg, "Upgrading installed packages", this, "Upgrade", true );
371 dlg.showDlg(); 371 dlg.showDlg();
372 372
373 // Reload data 373 // Reload data
374 dataMgr->reloadServerData(); 374 dataMgr->reloadServerData();
375 serverSelected(-1); 375 serverSelected(-1);
376 } 376 }
377} 377}
378 378
379 379
380void NetworkPackageManager :: downloadPackage() 380void NetworkPackageManager :: downloadPackage()
381{ 381{
382 bool doUpdate = true; 382 bool doUpdate = true;
383 if ( download->text() == "Download" ) 383 if ( download->text() == "Download" )
384 { 384 {
385 // See if any packages are selected 385 // See if any packages are selected
386 bool found = false; 386 bool found = false;
387 if ( serversList->currentText() != LOCAL_SERVER ) 387 if ( serversList->currentText() != LOCAL_SERVER )
388 { 388 {
389 for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); 389 for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild();
390 item != 0 && !found; 390 item != 0 && !found;
391 item = (QCheckListItem *)item->nextSibling() ) 391 item = (QCheckListItem *)item->nextSibling() )
392 { 392 {
393 if ( item->isOn() ) 393 if ( item->isOn() )
394 found = true; 394 found = true;
395 } 395 }
396 } 396 }
397 397
398 // If user selected some packages then download the and store the locally 398 // If user selected some packages then download the and store the locally
399 // otherwise, display dialog asking user what package to download from an http server 399 // otherwise, display dialog asking user what package to download from an http server
400 // and whether to install it 400 // and whether to install it
401 if ( found ) 401 if ( found )
402 downloadSelectedPackages(); 402 downloadSelectedPackages();
403 else 403 else
404 downloadRemotePackage(); 404 downloadRemotePackage();
405 405
406 } 406 }
407 else if ( download->text() == "Remove" ) 407 else if ( download->text() == "Remove" )
408 { 408 {
409 doUpdate = false; 409 doUpdate = false;
410 for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); 410 for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild();
411 item != 0 ; 411 item != 0 ;
412 item = (QCheckListItem *)item->nextSibling() ) 412 item = (QCheckListItem *)item->nextSibling() )
413 { 413 {
414 if ( item->isOn() ) 414 if ( item->isOn() )
415 { 415 {
416 QString name = item->text(); 416 QString name = item->text();
417 int pos = name.find( "*" ); 417 int pos = name.find( "*" );
418 name.truncate( pos ); 418 name.truncate( pos );
419 419
420 // if (there is a (installed), remove it 420 // if (there is a (installed), remove it
421 pos = name.find( "(installed)" ); 421 pos = name.find( "(installed)" );
422 if ( pos > 0 ) 422 if ( pos > 0 )
423 name.truncate( pos - 1 ); 423 name.truncate( pos - 1 );
424 424
425 Package *p = dataMgr->getServer( serversList->currentText() )->getPackage( name ); 425 Package *p = dataMgr->getServer( serversList->currentText() )->getPackage( name );
426 426
427 QString msgtext; 427 QString msgtext;
428 msgtext.sprintf( "Are you sure you wish to delete\n%s?", (const char *)p->getPackageName() ); 428 msgtext.sprintf( "Are you sure you wish to delete\n%s?", (const char *)p->getPackageName() );
429 if ( QMessageBox::information( this, "Are you sure?", 429 if ( QMessageBox::information( this, "Are you sure?",
430 msgtext, "No", "Yes" ) == 1 ) 430 msgtext, "No", "Yes" ) == 1 )
431 { 431 {
432 doUpdate = true; 432 doUpdate = true;
433 QFile f( p->getFilename() ); 433 QFile f( p->getFilename() );