summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/aqpkg/networkpkgmgr.cpp22
1 files changed, 19 insertions, 3 deletions
diff --git a/noncore/settings/aqpkg/networkpkgmgr.cpp b/noncore/settings/aqpkg/networkpkgmgr.cpp
index 3ce7960..6f528a1 100644
--- a/noncore/settings/aqpkg/networkpkgmgr.cpp
+++ b/noncore/settings/aqpkg/networkpkgmgr.cpp
@@ -367,142 +367,158 @@ void NetworkPackageManager :: downloadPackage()
367 { 367 {
368 for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); 368 for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild();
369 item != 0 ; 369 item != 0 ;
370 item = (QCheckListItem *)item->nextSibling() ) 370 item = (QCheckListItem *)item->nextSibling() )
371 { 371 {
372 if ( item->isOn() ) 372 if ( item->isOn() )
373 { 373 {
374 QString name = item->text(); 374 QString name = item->text();
375 int pos = name.find( "*" ); 375 int pos = name.find( "*" );
376 name.truncate( pos ); 376 name.truncate( pos );
377 377
378 // if (there is a (installed), remove it 378 // if (there is a (installed), remove it
379 pos = name.find( "(installed)" ); 379 pos = name.find( "(installed)" );
380 if ( pos > 0 ) 380 if ( pos > 0 )
381 name.truncate( pos - 1 ); 381 name.truncate( pos - 1 );
382 382
383 Package *p = dataMgr->getServer( serversList->currentText() )->getPackage( name ); 383 Package *p = dataMgr->getServer( serversList->currentText() )->getPackage( name );
384 QFile f( p->getFilename() ); 384 QFile f( p->getFilename() );
385 f.remove(); 385 f.remove();
386 } 386 }
387 } 387 }
388 } 388 }
389 389
390 dataMgr->reloadServerData( LOCAL_IPKGS ); 390 dataMgr->reloadServerData( LOCAL_IPKGS );
391 serverSelected( -1 ); 391 serverSelected( -1 );
392} 392}
393 393
394 394
395void NetworkPackageManager :: applyChanges() 395void NetworkPackageManager :: applyChanges()
396{ 396{
397 // Disable buttons to stop silly people clicking lots on them :) 397 // Disable buttons to stop silly people clicking lots on them :)
398 398
399 // First, write out ipkg_conf file so that ipkg can use it 399 // First, write out ipkg_conf file so that ipkg can use it
400 dataMgr->writeOutIpkgConf(); 400 dataMgr->writeOutIpkgConf();
401 401
402 // Now for each selected item 402 // Now for each selected item
403 // deal with it 403 // deal with it
404 404
405 vector<QString> workingPackages; 405 vector<QString> workingPackages;
406 for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); 406 for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild();
407 item != 0 ; 407 item != 0 ;
408 item = (QCheckListItem *)item->nextSibling() ) 408 item = (QCheckListItem *)item->nextSibling() )
409 { 409 {
410 if ( item->isOn() ) 410 if ( item->isOn() )
411 { 411 {
412 QString p = dealWithItem( item ); 412 QString p = dealWithItem( item );
413 workingPackages.push_back( p ); 413 workingPackages.push_back( p );
414 } 414 }
415 } 415 }
416 416
417 // do the stuff 417 // do the stuff
418 InstallDlgImpl dlg( workingPackages, dataMgr, this, "Install", true ); 418 InstallDlgImpl dlg( workingPackages, dataMgr, this, "Install", true );
419 dlg.showDlg(); 419 dlg.showDlg();
420 420
421 // Reload data 421 // Reload data
422 dataMgr->reloadServerData( LOCAL_SERVER ); 422 dataMgr->reloadServerData( LOCAL_SERVER );
423 423
424 dataMgr->reloadServerData( serversList->currentText() ); 424 dataMgr->reloadServerData( serversList->currentText() );
425 serverSelected(-1); 425 serverSelected(-1);
426 426
427#ifdef QWS 427#ifdef QWS
428 // Finally let the main system update itself 428 // Finally let the main system update itself
429 QCopEnvelope e("QPE/System", "linkChanged(QString)"); 429 QCopEnvelope e("QPE/System", "linkChanged(QString)");
430 QString lf = QString::null; 430 QString lf = QString::null;
431 e << lf; 431 e << lf;
432#endif 432#endif
433} 433}
434 434
435// decide what to do - either remove, upgrade or install 435// decide what to do - either remove, upgrade or install
436// Current rules: 436// Current rules:
437// If not installed - install 437// If not installed - install
438// If installed and different version available - upgrade 438// If installed and different version available - upgrade
439// If installed and version up to date - remove 439// If installed and version up to date - remove
440QString NetworkPackageManager :: dealWithItem( QCheckListItem *item ) 440QString NetworkPackageManager :: dealWithItem( QCheckListItem *item )
441{ 441{
442 QString name = item->text(); 442 QString name = item->text();
443 int pos = name.find( "*" ); 443 int pos = name.find( "*" );
444 name.truncate( pos ); 444 name.truncate( pos );
445 445
446 // if (there is a (installed), remove it 446 // if (there is a (installed), remove it
447 pos = name.find( "(installed)" ); 447 pos = name.find( "(installed)" );
448 if ( pos > 0 ) 448 if ( pos > 0 )
449 name.truncate( pos - 1 ); 449 name.truncate( pos - 1 );
450 450
451 // Get package 451 // Get package
452 Server *s = dataMgr->getServer( serversList->currentText() ); 452 Server *s = dataMgr->getServer( serversList->currentText() );
453 Package *p = s->getPackage( name ); 453 Package *p = s->getPackage( name );
454 454
455 // If the package has a filename then it is a local file 455 // If the package has a filename then it is a local file
456 if ( p->isPackageStoredLocally() ) 456 if ( p->isPackageStoredLocally() )
457 name = p->getFilename(); 457 name = p->getFilename();
458 QString option; 458 QString option;
459 QString dest = "root"; 459 QString dest = "root";
460 if ( !p->isInstalled() ) 460 if ( !p->isInstalled() )
461 return QString( "I" ) + name; 461 return QString( "I" ) + name;
462 else 462 else
463 { 463 {
464 if ( p->getVersion() == p->getInstalledVersion() ) 464 if ( p->getVersion() == p->getInstalledVersion() )
465 { 465 {
466 QString msgtext; 466 QString msgtext;
467 msgtext.sprintf( "Do you wish to remove or reinstall\n%s?", (const char *)name ); 467 msgtext.sprintf( "Do you wish to remove or reinstall\n%s?", (const char *)name );
468 switch( QMessageBox::information( this, "Remove or ReInstall", 468 switch( QMessageBox::information( this, "Remove or ReInstall",
469 msgtext, "Remove", "ReInstall" ) ) 469 msgtext, "Remove", "ReInstall" ) )
470 { 470 {
471 case 0: // Try again or Enter 471 case 0: // Try again or Enter
472 return QString( "D" ) + name; 472 return QString( "D" ) + name;
473 break; 473 break;
474 case 1: // Quit or Escape 474 case 1: // Quit or Escape
475 return QString( "U" ) + name; 475 return QString( "U" ) + name;
476 break; 476 break;
477 } 477 }
478 478
479 // User hit cancel (on dlg - assume remove) 479 // User hit cancel (on dlg - assume remove)
480 return QString( "D" ) + name; 480 return QString( "D" ) + name;
481 } 481 }
482 else 482 else
483 return QString( "U" ) + name; 483 return QString( "U" ) + name;
484 } 484 }
485} 485}
486 486
487void NetworkPackageManager :: displayText( const QString &t ) 487void NetworkPackageManager :: displayText( const QString &t )
488{ 488{
489 cout << t << endl; 489 cout << t << endl;
490} 490}
491 491
492 492
493void NetworkPackageManager :: letterPushed( QString t ) 493void NetworkPackageManager :: letterPushed( QString t )
494{ 494{
495 QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); 495 QCheckListItem *top = (QCheckListItem *)packagesList->firstChild();
496 QCheckListItem *start = (QCheckListItem *)packagesList->currentItem();
497 if ( packagesList->firstChild() == 0 )
498 return;
499
500 QCheckListItem *item;
501 if ( start == 0 )
502 {
503 item = (QCheckListItem *)packagesList->firstChild();
504 start = top;
505 }
506 else
507 item = (QCheckListItem *)start->nextSibling();
508
509 if ( item == 0 )
510 item = (QCheckListItem *)packagesList->firstChild();
496 do 511 do
497 { 512 {
498 if ( item->text().lower().startsWith( t.lower() ) ) 513 if ( item->text().lower().startsWith( t.lower() ) )
499 { 514 {
500 cout << "Found - item->text()" << endl;
501 packagesList->setSelected( item, true ); 515 packagesList->setSelected( item, true );
502 packagesList->ensureItemVisible( item ); 516 packagesList->ensureItemVisible( item );
503 break; 517 break;
504 } 518 }
505 519
506 item = (QCheckListItem *)item->nextSibling(); 520 item = (QCheckListItem *)item->nextSibling();
507 } while ( item ); 521 if ( !item )
522 item = (QCheckListItem *)packagesList->firstChild();
523 } while ( item != start);
508} 524}