summaryrefslogtreecommitdiff
path: root/noncore/settings/packagemanager/mainwindow.cpp
Unidiff
Diffstat (limited to 'noncore/settings/packagemanager/mainwindow.cpp') (more/less context) (show whitespace changes)
-rw-r--r--noncore/settings/packagemanager/mainwindow.cpp25
1 files changed, 11 insertions, 14 deletions
diff --git a/noncore/settings/packagemanager/mainwindow.cpp b/noncore/settings/packagemanager/mainwindow.cpp
index 459a75b..8a5b90c 100644
--- a/noncore/settings/packagemanager/mainwindow.cpp
+++ b/noncore/settings/packagemanager/mainwindow.cpp
@@ -267,316 +267,313 @@ void MainWindow::loadPackageList( OPackageList *packages, bool clearList )
267 for ( OPackageListIterator packageIt( *packages ); packageIt.current(); ++packageIt ) 267 for ( OPackageListIterator packageIt( *packages ); packageIt.current(); ++packageIt )
268 { 268 {
269 OPackage *package = packageIt.current(); 269 OPackage *package = packageIt.current();
270 QCheckListItem *item = new QCheckListItem( &m_packageList, package->name(), 270 QCheckListItem *item = new QCheckListItem( &m_packageList, package->name(),
271 QCheckListItem::CheckBox ); 271 QCheckListItem::CheckBox );
272 m_packageList.insertItem( item ); 272 m_packageList.insertItem( item );
273 273
274 // If a different version of package is available, show update available icon 274 // If a different version of package is available, show update available icon
275 // Otherwise, show installed icon 275 // Otherwise, show installed icon
276 if ( !package->versionInstalled().isNull() ) 276 if ( !package->versionInstalled().isNull() )
277 { 277 {
278 if ( m_packman.compareVersions( package->version(), package->versionInstalled() ) == 1 ) 278 if ( m_packman.compareVersions( package->version(), package->versionInstalled() ) == 1 )
279 item->setPixmap( 0, m_iconUpdated ); 279 item->setPixmap( 0, m_iconUpdated );
280 else 280 else
281 item->setPixmap( 0, m_iconInstalled ); 281 item->setPixmap( 0, m_iconInstalled );
282 } 282 }
283 else 283 else
284 item->setPixmap( 0, m_iconNull ); 284 item->setPixmap( 0, m_iconNull );
285 } 285 }
286 } 286 }
287} 287}
288 288
289void MainWindow::searchForPackage( const QString &text ) 289void MainWindow::searchForPackage( const QString &text )
290{ 290{
291 if ( !text.isEmpty() ) 291 if ( !text.isEmpty() )
292 { 292 {
293 // look through package list for text startng at current position 293 // look through package list for text startng at current position
294 QCheckListItem *start = static_cast<QCheckListItem *>(m_packageList.currentItem()); 294 QCheckListItem *start = static_cast<QCheckListItem *>(m_packageList.currentItem());
295 if ( start == 0 ) 295 if ( start == 0 )
296 start = static_cast<QCheckListItem *>(m_packageList.firstChild()); 296 start = static_cast<QCheckListItem *>(m_packageList.firstChild());
297 297
298// for ( QCheckListItem *item = static_cast<QCheckListItem *>(start->nextSibling()); item != 0 ; 298// for ( QCheckListItem *item = static_cast<QCheckListItem *>(start->nextSibling()); item != 0 ;
299 for ( QCheckListItem *item = static_cast<QCheckListItem *>(start); item != 0 ; 299 for ( QCheckListItem *item = static_cast<QCheckListItem *>(start); item != 0 ;
300 item = static_cast<QCheckListItem *>(item->nextSibling()) ) 300 item = static_cast<QCheckListItem *>(item->nextSibling()) )
301 { 301 {
302 if ( item->text().lower().find( text ) != -1 ) 302 if ( item->text().lower().find( text ) != -1 )
303 { 303 {
304 m_packageList.ensureItemVisible( item ); 304 m_packageList.ensureItemVisible( item );
305 m_packageList.setCurrentItem( item ); 305 m_packageList.setCurrentItem( item );
306 break; 306 break;
307 } 307 }
308 } 308 }
309 } 309 }
310} 310}
311 311
312void MainWindow::installLocalPackage( const QString &ipkFile ) 312void MainWindow::installLocalPackage( const QString &ipkFile )
313{ 313{
314 // Install selected file 314 // Install selected file
315 InstallDlg *dlg = new InstallDlg( this, &m_packman, tr( "Install local package" ), true, 315 InstallDlg *dlg = new InstallDlg( this, &m_packman, tr( "Install local package" ),
316 OPackage::Install, ipkFile ); 316 OPackage::Install, ipkFile );
317 connect( dlg, SIGNAL(closeInstallDlg()), this, SLOT(slotCloseDlg()) ); 317 connect( dlg, SIGNAL(closeInstallDlg()), this, SLOT(slotCloseDlg()) );
318 318
319 // Display widget 319 // Display widget
320 m_widgetStack.addWidget( dlg, 3 ); 320 m_widgetStack.addWidget( dlg, 3 );
321 m_widgetStack.raiseWidget( dlg ); 321 m_widgetStack.raiseWidget( dlg );
322} 322}
323 323
324void MainWindow::setDocument( const QString &ipkFile ) 324void MainWindow::setDocument( const QString &ipkFile )
325{ 325{
326 QString file = ipkFile; 326 QString file = ipkFile;
327 DocLnk lnk( ipkFile ); 327 DocLnk lnk( ipkFile );
328 if ( lnk.isValid() ) 328 if ( lnk.isValid() )
329 file = lnk.file(); 329 file = lnk.file();
330 330
331 installLocalPackage( file ); 331 installLocalPackage( file );
332} 332}
333 333
334void MainWindow::initPackageInfo() 334void MainWindow::initPackageInfo()
335{ 335{
336 m_widgetStack.raiseWidget( &m_statusWidget ); 336 m_widgetStack.raiseWidget( &m_statusWidget );
337 337
338 // Load package list 338 // Load package list
339 m_packman.loadAvailablePackages(); 339 m_packman.loadAvailablePackages();
340 m_packman.loadInstalledPackages(); 340 m_packman.loadInstalledPackages();
341 341
342 OPackageList *packageList = m_packman.packages(); 342 OPackageList *packageList = m_packman.packages();
343 if ( packageList ) 343 if ( packageList )
344 { 344 {
345 loadPackageList( packageList, true ); 345 loadPackageList( packageList, true );
346 delete packageList; 346 delete packageList;
347 } 347 }
348 348
349 QWidget *widget = m_widgetStack.widget( 3 ); 349 QWidget *widget = m_widgetStack.widget( 3 );
350 if ( !widget ) 350 if ( !widget )
351 widget = &m_packageList; 351 widget = &m_packageList;
352 m_widgetStack.raiseWidget( widget ); 352 m_widgetStack.raiseWidget( widget );
353} 353}
354 354
355void MainWindow::slotWidgetStackShow( QWidget *widget ) 355void MainWindow::slotWidgetStackShow( QWidget *widget )
356{ 356{
357 if ( widget == &m_packageList ) 357 if ( widget == &m_packageList )
358 { 358 {
359 setCaption( tr( "Package Manager" ) ); 359 setCaption( tr( "Package Manager" ) );
360 360
361 m_menuBar.show(); 361 m_menuBar.show();
362 m_toolBar.show(); 362 m_toolBar.show();
363 } 363 }
364 else 364 else
365 { 365 {
366 m_menuBar.hide(); 366 m_menuBar.hide();
367 m_toolBar.hide(); 367 m_toolBar.hide();
368 } 368 }
369} 369}
370 370
371void MainWindow::slotInitStatusBar( int numSteps ) 371void MainWindow::slotInitStatusBar( int numSteps )
372{ 372{
373 m_statusBar.setTotalSteps( numSteps ); 373 m_statusBar.setTotalSteps( numSteps );
374} 374}
375 375
376void MainWindow::slotStatusText( const QString &status ) 376void MainWindow::slotStatusText( const QString &status )
377{ 377{
378 m_statusText.setText( status ); 378 m_statusText.setText( status );
379} 379}
380 380
381void MainWindow::slotStatusBar( int currStep ) 381void MainWindow::slotStatusBar( int currStep )
382{ 382{
383 m_statusBar.setProgress( currStep ); 383 m_statusBar.setProgress( currStep );
384} 384}
385 385
386void MainWindow::slotUpdate() 386void MainWindow::slotUpdate()
387{ 387{
388 // Create package manager output widget 388 // Create package manager output widget
389 InstallDlg *dlg = new InstallDlg( this, &m_packman, tr( "Update package information" ), false, 389 InstallDlg *dlg = new InstallDlg( this, &m_packman, tr( "Update package information" ),
390 OPackage::Update ); 390 OPackage::Update );
391 connect( dlg, SIGNAL(closeInstallDlg()), this, SLOT(slotCloseDlg()) ); 391 connect( dlg, SIGNAL(closeInstallDlg()), this, SLOT(slotCloseDlg()) );
392 392
393 // Display widget 393 // Display widget
394 m_widgetStack.addWidget( dlg, 3 ); 394 m_widgetStack.addWidget( dlg, 3 );
395 m_widgetStack.raiseWidget( dlg ); 395 m_widgetStack.raiseWidget( dlg );
396} 396}
397 397
398void MainWindow::slotUpgrade() 398void MainWindow::slotUpgrade()
399{ 399{
400 // Create package manager output widget 400 // Create package manager output widget
401 InstallDlg *dlg = new InstallDlg( this, &m_packman, tr( "Upgrade installed packages" ), false, 401 InstallDlg *dlg = new InstallDlg( this, &m_packman, tr( "Upgrade installed packages" ),
402 OPackage::Upgrade ); 402 OPackage::Upgrade );
403 connect( dlg, SIGNAL(closeInstallDlg()), this, SLOT(slotCloseDlg()) ); 403 connect( dlg, SIGNAL(closeInstallDlg()), this, SLOT(slotCloseDlg()) );
404 404
405 // Display widget 405 // Display widget
406 m_widgetStack.addWidget( dlg, 3 ); 406 m_widgetStack.addWidget( dlg, 3 );
407 m_widgetStack.raiseWidget( dlg ); 407 m_widgetStack.raiseWidget( dlg );
408} 408}
409 409
410void MainWindow::slotDownload() 410void MainWindow::slotDownload()
411{ 411{
412 // Retrieve list of packages selected for download (if any) 412 // Retrieve list of packages selected for download (if any)
413 QStringList workingPackages; 413 QStringList workingPackages;
414 414
415 for ( QCheckListItem *item = static_cast<QCheckListItem *>(m_packageList.firstChild()); 415 for ( QCheckListItem *item = static_cast<QCheckListItem *>(m_packageList.firstChild());
416 item != 0 ; 416 item != 0 ;
417 item = static_cast<QCheckListItem *>(item->nextSibling()) ) 417 item = static_cast<QCheckListItem *>(item->nextSibling()) )
418 { 418 {
419 if ( item->isOn() ) 419 if ( item->isOn() )
420 workingPackages.append( item->text() ); 420 workingPackages.append( item->text() );
421 } 421 }
422 422
423 if ( workingPackages.isEmpty() ) 423 if ( workingPackages.isEmpty() )
424 { 424 {
425 QMessageBox::information( this, tr( "Nothing to do" ), tr( "No packages selected" ), tr( "OK" ) ); 425 QMessageBox::information( this, tr( "Nothing to do" ), tr( "No packages selected" ), tr( "OK" ) );
426 return; 426 return;
427 } 427 }
428 else 428 else
429 { 429 {
430 // Download selected packages 430 // Download selected packages
431 m_config.setGroup( "settings" ); 431 m_config.setGroup( "settings" );
432 QString workingDir = m_config.readEntry( "DownloadDir", "/tmp" ); 432 QString workingDir = m_config.readEntry( "DownloadDir", "/tmp" );
433 433
434 bool ok = false; 434 bool ok = false;
435 QString text = EntryDlg::getText( tr( "Download" ), tr( "Enter path to download package to:" ), workingDir, &ok, this ); 435 QString text = EntryDlg::getText( tr( "Download" ), tr( "Enter path to download package to:" ), workingDir, &ok, this );
436 if ( ok && !text.isEmpty() ) 436 if ( ok && !text.isEmpty() )
437 workingDir = text; // user entered something and pressed ok 437 workingDir = text; // user entered something and pressed ok
438 else 438 else
439 return; // user entered nothing or pressed cancel 439 return; // user entered nothing or pressed cancel
440 440
441 // Store download directory in config file 441 // Store download directory in config file
442 m_config.writeEntry( "DownloadDir", workingDir ); 442 m_config.writeEntry( "DownloadDir", workingDir );
443 443
444 // Get starting directory 444 // Get starting directory
445 QDir::setCurrent( workingDir ); 445 QDir::setCurrent( workingDir );
446 446
447 // Create package manager output widget 447 // Create package manager output widget
448 InstallDlg *dlg = new InstallDlg( this, &m_packman, tr( "Download packages" ), false, 448 InstallDlg *dlg = new InstallDlg( this, &m_packman, tr( "Download packages" ),
449 OPackage::Download, workingPackages ); 449 OPackage::Download, workingPackages );
450 connect( dlg, SIGNAL(closeInstallDlg()), this, SLOT(slotCloseDlg()) ); 450 connect( dlg, SIGNAL(closeInstallDlg()), this, SLOT(slotCloseDlg()) );
451 451
452 // Display widget 452 // Display widget
453 m_widgetStack.addWidget( dlg, 3 ); 453 m_widgetStack.addWidget( dlg, 3 );
454 m_widgetStack.raiseWidget( dlg ); 454 m_widgetStack.raiseWidget( dlg );
455 } 455 }
456} 456}
457 457
458void MainWindow::slotApply() 458void MainWindow::slotApply()
459{ 459{
460 QStringList removeList; 460 QStringList removeList;
461 QStringList installList; 461 QStringList installList;
462 QStringList upgradeList; 462 QStringList upgradeList;
463 463
464 for ( QCheckListItem *item = static_cast<QCheckListItem *>(m_packageList.firstChild()); 464 for ( QCheckListItem *item = static_cast<QCheckListItem *>(m_packageList.firstChild());
465 item != 0 ; 465 item != 0 ;
466 item = static_cast<QCheckListItem *>(item->nextSibling()) ) 466 item = static_cast<QCheckListItem *>(item->nextSibling()) )
467 { 467 {
468 if ( item->isOn() ) 468 if ( item->isOn() )
469 { 469 {
470 OPackage *package = m_packman.findPackage( item->text() ); 470 OPackage *package = m_packman.findPackage( item->text() );
471 if ( package ) 471 if ( package )
472 { 472 {
473 if ( !package->versionInstalled().isNull() ) 473 if ( !package->versionInstalled().isNull() )
474 { 474 {
475 if ( m_packman.compareVersions( package->version(), package->versionInstalled() ) == 1 ) 475 if ( m_packman.compareVersions( package->version(), package->versionInstalled() ) == 1 )
476 { 476 {
477 // Remove/upgrade package 477 // Remove/upgrade package
478 int answer = PromptDlg::ask( tr( "Remove or upgrade" ), 478 int answer = PromptDlg::ask( tr( "Remove or upgrade" ),
479 tr( QString( "Do you wish to remove or upgrade\n%1?" ).arg( item->text() ) ), 479 tr( QString( "Do you wish to remove or upgrade\n%1?" ).arg( item->text() ) ),
480 tr( "Remove" ), tr( "Upgrade" ), this ); 480 tr( "Remove" ), tr( "Upgrade" ), this );
481 if ( answer == 1 ) // Remove 481 if ( answer == 1 ) // Remove
482 { 482 {
483 removeList.append( item->text() ); 483 removeList.append( item->text() );
484 } 484 }
485 else if ( answer == 2 ) // Upgrade 485 else if ( answer == 2 ) // Upgrade
486 { 486 {
487 upgradeList.append( item->text() ); 487 upgradeList.append( item->text() );
488 } 488 }
489 } 489 }
490 else 490 else
491 { 491 {
492 // Remove/reinstall package 492 // Remove/reinstall package
493 int answer = PromptDlg::ask( tr( "Remove or reinstall" ), 493 int answer = PromptDlg::ask( tr( "Remove or reinstall" ),
494 tr( QString( "Do you wish to remove or reinstall\n%1?" ).arg( item->text() ) ), 494 tr( QString( "Do you wish to remove or reinstall\n%1?" ).arg( item->text() ) ),
495 tr( "Remove" ), tr( "Reinstall" ), this ); 495 tr( "Remove" ), tr( "Reinstall" ), this );
496 if ( answer == 1 ) // Remove 496 if ( answer == 1 ) // Remove
497 { 497 {
498 removeList.append( item->text() ); 498 removeList.append( item->text() );
499 } 499 }
500 else if ( answer == 2 ) // Reinstall 500 else if ( answer == 2 ) // Reinstall
501 { 501 {
502 installList.append( item->text() ); 502 installList.append( item->text() );
503 } 503 }
504 } 504 }
505 } 505 }
506 else 506 else
507 { 507 {
508 // Install package 508 // Install package
509 installList.append( item->text() ); 509 installList.append( item->text() );
510 } 510 }
511 } 511 }
512 } 512 }
513 } 513 }
514 514
515 // If nothing is selected, display message and exit 515 // If nothing is selected, display message and exit
516 if ( removeList.isEmpty() && installList.isEmpty() && upgradeList.isEmpty() ) 516 if ( removeList.isEmpty() && installList.isEmpty() && upgradeList.isEmpty() )
517 { 517 {
518 QMessageBox::information( this, tr( "Nothing to do" ), tr( "No packages selected" ), tr( "OK" ) ); 518 QMessageBox::information( this, tr( "Nothing to do" ), tr( "No packages selected" ), tr( "OK" ) );
519 return; 519 return;
520 } 520 }
521 521
522 // Send command only if there are packages to process 522 // Send command only if there are packages to process
523 OPackage::Command removeCmd = OPackage::NotDefined; 523 OPackage::Command removeCmd = !removeList.isEmpty() ? OPackage::Remove
524 if ( !removeList.isEmpty() ) 524 : OPackage::NotDefined;
525 removeCmd = OPackage::Remove; 525 OPackage::Command installCmd = !installList.isEmpty() ? OPackage::Install
526 OPackage::Command installCmd = OPackage::NotDefined; 526 : OPackage::NotDefined;
527 if ( !installList.isEmpty() ) 527 OPackage::Command upgradeCmd = !upgradeList.isEmpty() ? OPackage::Upgrade
528 installCmd = OPackage::Install; 528 : OPackage::NotDefined;
529 OPackage::Command upgradeCmd = OPackage::NotDefined;
530 if ( !upgradeList.isEmpty() )
531 upgradeCmd = OPackage::Upgrade;
532 529
533 // Create package manager output widget 530 // Create package manager output widget
534 InstallDlg *dlg = new InstallDlg( this, &m_packman, tr( "Apply changes" ), !installList.isEmpty(), 531 InstallDlg *dlg = new InstallDlg( this, &m_packman, tr( "Apply changes" ),
535 removeCmd, removeList, 532 removeCmd, removeList,
536 installCmd, installList, 533 installCmd, installList,
537 upgradeCmd, upgradeList ); 534 upgradeCmd, upgradeList );
538 connect( dlg, SIGNAL(closeInstallDlg()), this, SLOT(slotCloseDlg()) ); 535 connect( dlg, SIGNAL(closeInstallDlg()), this, SLOT(slotCloseDlg()) );
539 536
540 // Display widget 537 // Display widget
541 m_widgetStack.addWidget( dlg, 3 ); 538 m_widgetStack.addWidget( dlg, 3 );
542 m_widgetStack.raiseWidget( dlg ); 539 m_widgetStack.raiseWidget( dlg );
543} 540}
544 541
545void MainWindow::slotInstallLocal() 542void MainWindow::slotInstallLocal()
546{ 543{
547 // Display file open dialog with only package files 544 // Display file open dialog with only package files
548 MimeTypes type; 545 MimeTypes type;
549 QStringList packages; 546 QStringList packages;
550 packages << "application/ipkg"; 547 packages << "application/ipkg";
551 type.insert( tr( "Application Packages" ), packages ); 548 type.insert( tr( "Application Packages" ), packages );
552 QString package = Opie::Ui::OFileDialog::getOpenFileName( Opie::Ui::OFileSelector::NORMAL, 549 QString package = Opie::Ui::OFileDialog::getOpenFileName( Opie::Ui::OFileSelector::NORMAL,
553 "/", QString::null, type ); 550 "/", QString::null, type );
554 if ( !package.isNull() ) 551 if ( !package.isNull() )
555 installLocalPackage( package ); 552 installLocalPackage( package );
556} 553}
557 554
558void MainWindow::slotCloseDlg() 555void MainWindow::slotCloseDlg()
559{ 556{
560 // Close install dialog 557 // Close install dialog
561 delete m_widgetStack.visibleWidget(); 558 delete m_widgetStack.visibleWidget();
562 559
563 // Reload package list 560 // Reload package list
564 initPackageInfo(); 561 initPackageInfo();
565 562
566 // Update Opie launcher links 563 // Update Opie launcher links
567 QCopEnvelope e("QPE/System", "linkChanged(QString)"); 564 QCopEnvelope e("QPE/System", "linkChanged(QString)");
568 QString lf = QString::null; 565 QString lf = QString::null;
569 e << lf; 566 e << lf;
570 567
571 // Reapply any filters previously set 568 // Reapply any filters previously set
572 if ( m_actionShowNotInstalled->isOn() ) 569 if ( m_actionShowNotInstalled->isOn() )
573 slotShowNotInstalled(); 570 slotShowNotInstalled();
574 else if ( m_actionShowInstalled->isOn() ) 571 else if ( m_actionShowInstalled->isOn() )
575 slotShowInstalled(); 572 slotShowInstalled();
576 else if ( m_actionShowUpdated->isOn() ) 573 else if ( m_actionShowUpdated->isOn() )
577 slotShowUpdated(); 574 slotShowUpdated();
578 else if ( m_actionFilter->isOn() ) 575 else if ( m_actionFilter->isOn() )
579 slotFilter( true ); 576 slotFilter( true );
580} 577}
581 578
582void MainWindow::slotConfigure() 579void MainWindow::slotConfigure()