1 /*---------------------------------------------------------------------\
3 | __ __ ____ _____ ____ |
4 | \ \ / /_ _/ ___|_ _|___ \ |
5 | \ V / _` \___ \ | | __) | |
6 | | | (_| |___) || | / __/ |
7 | |_|\__,_|____/ |_| |_____| |
11 \----------------------------------------------------------------------/
13 File: YQPackageSelector.cc
14 See also: YQPackageSelectorHelp.cc
16 Author: Stefan Hundhammer <sh@suse.de>
18 Textdomain "packages-qt"
22 #define CHECK_DEPENDENCIES_ON_STARTUP 1
23 #define DEPENDENCY_FEEDBACK_IF_OK 1
24 #define AUTO_CHECK_DEPENDENCIES_DEFAULT true
25 #define ALWAYS_SHOW_PATCHES_VIEW_IF_PATCHES_AVAILABLE 0
26 #define GLOBAL_UPDATE_CONFIRMATION_THRESHOLD 20
29 #include <boost/bind.hpp>
31 #include <QHBoxLayout>
32 #include <QVBoxLayout>
35 #include <QApplication>
38 #include <QFileDialog>
42 #include <QMessageBox>
43 #include <QPushButton>
49 #define y2log_component "qt-pkg"
50 #include <ycp/y2log.h>
52 #include "QY2LayoutUtils.h"
54 #include "YQPackageSelector.h"
55 #include "YQPkgChangeLogView.h"
56 #include "YQPkgChangesDialog.h"
57 #include "YQPkgConflictDialog.h"
58 #include "YQPkgConflictList.h"
59 #include "YQPkgDependenciesView.h"
60 #include "YQPkgDescriptionView.h"
61 #include "YQPkgDiskUsageList.h"
62 #include "YQPkgDiskUsageWarningDialog.h"
63 #include "YQPkgFileListView.h"
64 #include "YQPkgRepoFilterView.h"
65 #include "YQPkgRepoList.h"
66 #include "YQPkgLangList.h"
67 #include "YQPkgList.h"
68 #include "YQPkgPatchFilterView.h"
69 #include "YQPkgPatchList.h"
70 #include "YQPkgPatternList.h"
71 #include "YQPkgProductDialog.h"
72 #include "YQPkgRpmGroupTagsFilterView.h"
73 #include "YQPkgSearchFilterView.h"
74 #include "YQPkgSelList.h"
75 #include "YQPkgStatusFilterView.h"
76 #include "YQPkgTechnicalDetailsView.h"
77 #include "YQPkgTextDialog.h"
78 #include "YQPkgUpdateProblemFilterView.h"
79 #include "YQPkgVersionsView.h"
80 #include "zypp/SysContent.h"
82 #include "QY2ComboTabWidget.h"
97 #define DEFAULT_EXPORT_FILE_NAME "user-packages.xml"
102 YQPackageSelector::YQPackageSelector( YWidget * parent,
104 : YQPackageSelectorBase( parent, modeFlags )
106 _showChangesDialog = true;
107 _autoDependenciesCheckBox = 0;
114 _pkgChangeLogView = 0;
115 _pkgDependenciesView = 0;
116 _pkgDescriptionView = 0;
117 _pkgFileListView = 0;
119 _pkgTechnicalDetailsView = 0;
120 _pkgVersionsView = 0;
121 _rpmGroupTagsFilterView = 0;
122 _searchFilterView = 0;
124 _statusFilterView = 0;
125 _updateProblemFilterView = 0;
126 _patchFilterView = 0;
128 _excludeDevelPkgs = 0;
129 _excludeDebugInfoPkgs = 0;
132 if ( onlineUpdateMode() ) y2milestone( "Online update mode" );
133 if ( updateMode() ) y2milestone( "Update mode" );
137 addMenus(); // Only after all widgets are created!
144 if ( _patchFilterView && onlineUpdateMode() )
146 if ( _filters && _patchFilterView && _patchList )
148 _filters->showPage( _patchFilterView );
149 _patchList->filter();
152 else if ( _repoFilterView && repoMode() )
154 if ( YQPkgRepoList::countEnabledRepositories() > 1 )
156 _filters->showPage( _repoFilterView );
157 _repoFilterView->filter();
159 else if ( _searchFilterView )
161 y2milestone( "No multiple repositories - falling back to search mode" );
162 _filters->showPage( _searchFilterView );
163 _searchFilterView->filter();
164 QTimer::singleShot( 0, _searchFilterView, SLOT( setFocus() ) );
167 else if ( _updateProblemFilterView )
169 _filters->showPage( _updateProblemFilterView );
170 _updateProblemFilterView->filter();
173 else if ( searchMode() && _searchFilterView )
175 _filters->showPage( _searchFilterView );
176 _searchFilterView->filter();
177 QTimer::singleShot( 0, _searchFilterView, SLOT( setFocus() ) );
179 else if ( summaryMode() && _statusFilterView )
181 _filters->showPage( _statusFilterView );
182 _statusFilterView->filter();
184 else if ( _patternList )
186 _filters->showPage( _patternList );
187 _patternList->filter();
191 _filters->showPage( _selList );
196 if ( _diskUsageList )
197 _diskUsageList->updateDiskUsage();
199 y2milestone( "PackageSelector init done" );
202 #if CHECK_DEPENDENCIES_ON_STARTUP
204 if ( ! testMode() && ! onlineUpdateMode() )
206 // Fire up the first dependency check in the main loop.
207 // Don't do this right away - wait until all initializations are finished.
208 QTimer::singleShot( 0, this, SLOT( resolveDependencies() ) );
216 YQPackageSelector::basicLayout()
218 QVBoxLayout *layout = new QVBoxLayout(this);
222 QSplitter * outer_splitter = new QSplitter( Qt::Horizontal, this );
223 Q_CHECK_PTR( outer_splitter );
225 layout->addWidget(outer_splitter);
227 QWidget * left_pane = layoutLeftPane ( outer_splitter );
229 QWidget * right_pane = layoutRightPane( outer_splitter );
231 outer_splitter->setStretchFactor(outer_splitter->indexOf(left_pane), 0);
232 outer_splitter->setStretchFactor(outer_splitter->indexOf(right_pane), 1);
237 YQPackageSelector::layoutLeftPane( QWidget *parent )
239 QSplitter * splitter = new QSplitter( Qt::Vertical, parent );
240 Q_CHECK_PTR( splitter );
242 QWidget * upper_vbox = new QWidget( splitter );
243 QVBoxLayout *layout = new QVBoxLayout(upper_vbox);
244 upper_vbox->setLayout(layout);
246 Q_CHECK_PTR( upper_vbox );
247 layoutFilters( upper_vbox );
248 addVSpacing( upper_vbox, MARGIN );
250 QWidget * lower_vbox = new QWidget( splitter );
251 layout = new QVBoxLayout(lower_vbox);
252 lower_vbox->setLayout(layout);
254 addVSpacing( lower_vbox, MARGIN );
255 _diskUsageList = new YQPkgDiskUsageList( lower_vbox );
256 Q_CHECK_PTR( _diskUsageList );
257 layout->addWidget(_diskUsageList);
259 splitter->setStretchFactor(splitter->indexOf(upper_vbox), 0);
260 splitter->setStretchFactor(splitter->indexOf(lower_vbox), 1);
267 YQPackageSelector::layoutFilters( QWidget *parent )
269 _filters = new QY2ComboTabWidget( _( "Fi<er:" ), parent );
270 Q_CHECK_PTR( _filters );
271 parent->layout()->addWidget(_filters);
274 // Update problem view
279 if ( YQPkgUpdateProblemFilterView::haveProblematicPackages()
282 _updateProblemFilterView = new YQPkgUpdateProblemFilterView( parent);
283 Q_CHECK_PTR( _updateProblemFilterView );
284 _filters->addPage( _( "Update Problems" ), _updateProblemFilterView );
293 if ( onlineUpdateMode()
294 #if ALWAYS_SHOW_PATCHES_VIEW_IF_PATCHES_AVAILABLE
295 || ! zyppPool().empty<zypp::Patch>()
298 addPatchFilterView();
305 if ( ! zyppPool().empty<zypp::Pattern>() || testMode() )
307 _patternList = new YQPkgPatternList( parent, true );
308 Q_CHECK_PTR( _patternList );
309 _filters->addPage( _( "Patterns" ), _patternList );
311 connect( _patternList, SIGNAL( statusChanged() ),
312 this, SLOT ( autoResolveDependencies() ) );
314 connect( this, SIGNAL( refresh() ),
315 _patternList, SLOT ( updateItemStates() ) );
317 if ( _pkgConflictDialog )
319 connect( _pkgConflictDialog, SIGNAL( updatePackages() ),
320 _patternList, SLOT ( updateItemStates() ) );
329 if ( ! zyppPool().empty<zypp::Selection>() || testMode() )
332 _selList = new YQPkgSelList( parent, true );
333 Q_CHECK_PTR( _selList );
334 _filters->addPage( _( "Selections" ), _selList );
336 connect( _selList, SIGNAL( statusChanged() ),
337 this, SLOT ( autoResolveDependencies() ) );
339 connect( this, SIGNAL( refresh() ),
340 _selList, SLOT ( updateItemStates() ) );
342 if ( _pkgConflictDialog )
344 connect( _pkgConflictDialog, SIGNAL( updatePackages() ),
345 _selList, SLOT ( updateItemStates() ) );
351 // RPM group tags view
354 _rpmGroupTagsFilterView = new YQPkgRpmGroupTagsFilterView( parent );
355 Q_CHECK_PTR( _rpmGroupTagsFilterView );
356 _filters->addPage( _( "Package Groups" ), _rpmGroupTagsFilterView );
358 connect( this, SIGNAL( loadData() ),
359 _rpmGroupTagsFilterView, SLOT ( filter() ) );
366 _langList = new YQPkgLangList( parent );
367 Q_CHECK_PTR( _langList );
369 _filters->addPage( _( "Languages" ), _langList );
370 _langList->setSizePolicy( QSizePolicy( QSizePolicy::Ignored, QSizePolicy::Ignored ) ); // hor/vert
372 connect( _langList, SIGNAL( statusChanged() ),
373 this, SLOT ( autoResolveDependencies() ) );
375 connect( this, SIGNAL( refresh() ),
376 _langList, SLOT ( updateItemStates() ) );
383 _repoFilterView = new YQPkgRepoFilterView( parent );
384 Q_CHECK_PTR( _repoFilterView );
385 _filters->addPage( _( "Repositories" ), _repoFilterView );
389 // Package search view
392 _searchFilterView = new YQPkgSearchFilterView( parent );
393 Q_CHECK_PTR( _searchFilterView );
394 _filters->addPage( _( "Search" ), _searchFilterView );
398 // Status change view
401 _statusFilterView = new YQPkgStatusFilterView( parent );
402 Q_CHECK_PTR( _statusFilterView );
403 _filters->addPage( _( "Installation Summary" ), _statusFilterView );
409 _filters->addPage( _( "Keywords" ), new QLabel( "Keywords\nfilter\n\nfor future use", 0 ) );
410 _filters->addPage( _( "MIME Types" ), new QLabel( "MIME Types\nfilter\n\nfor future use" , 0 ) );
417 YQPackageSelector::layoutRightPane( QWidget *parent )
419 QWidget * right_pane_vbox = new QWidget( parent );
421 QVBoxLayout *layout = new QVBoxLayout(right_pane_vbox);
422 right_pane_vbox->setLayout(layout);
424 Q_CHECK_PTR( right_pane_vbox );
426 layout->setMargin( MARGIN );
429 QSplitter * splitter = new QSplitter( Qt::Vertical, right_pane_vbox );
430 Q_CHECK_PTR( splitter );
431 layout->addWidget(splitter);
433 Q_CHECK_PTR( splitter );
434 layoutPkgList( splitter );
436 addVSpacing( splitter, MARGIN );
438 layoutDetailsViews( splitter );
440 layoutButtons( splitter );
442 return right_pane_vbox;
447 YQPackageSelector::layoutPkgList( QWidget *parent )
449 _pkgList= new YQPkgList( parent );
450 Q_CHECK_PTR( _pkgList );
452 connect( _pkgList, SIGNAL( statusChanged() ),
453 this, SLOT ( autoResolveDependencies() ) );
458 YQPackageSelector::layoutDetailsViews( QWidget *parent )
460 bool haveInstalledPkgs = YQPkgList::haveInstalledPkgs();
462 QWidget * details_vbox = new QWidget( parent );
463 Q_CHECK_PTR( details_vbox );
465 QVBoxLayout *layout = new QVBoxLayout(details_vbox);
466 details_vbox->setLayout(layout);
467 //details_vbox->setMinimumSize( 0, 0 );
469 addVSpacing( details_vbox, 8 );
471 _detailsViews = new QTabWidget( details_vbox );
472 layout->addWidget(_detailsViews);
474 Q_CHECK_PTR( _detailsViews );
475 //FIXME _detailsViews->setMargin( MARGIN );
477 // _detailsViews->setTabPosition( QTabWidget::Bottom );
484 _pkgDescriptionView = new YQPkgDescriptionView( _detailsViews );
485 Q_CHECK_PTR( _pkgDescriptionView );
487 _detailsViews->addTab( _pkgDescriptionView, _( "D&escription" ) );
488 _detailsViews->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) ); // hor/vert
490 connect( _pkgList, SIGNAL( currentItemChanged ( ZyppSel ) ),
491 _pkgDescriptionView, SLOT ( showDetailsIfVisible( ZyppSel ) ) );
497 _pkgTechnicalDetailsView = new YQPkgTechnicalDetailsView( _detailsViews );
498 Q_CHECK_PTR( _pkgTechnicalDetailsView );
500 _detailsViews->addTab( _pkgTechnicalDetailsView, _( "&Technical Data" ) );
502 connect( _pkgList, SIGNAL( currentItemChanged ( ZyppSel ) ),
503 _pkgTechnicalDetailsView, SLOT ( showDetailsIfVisible( ZyppSel ) ) );
510 _pkgDependenciesView = new YQPkgDependenciesView( _detailsViews );
511 Q_CHECK_PTR( _pkgDependenciesView );
513 _detailsViews->addTab( _pkgDependenciesView, _( "Dependencies" ) );
514 _detailsViews->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) ); // hor/vert
516 connect( _pkgList, SIGNAL( currentItemChanged ( ZyppSel ) ),
517 _pkgDependenciesView, SLOT ( showDetailsIfVisible( ZyppSel ) ) );
525 _pkgVersionsView = new YQPkgVersionsView( _detailsViews,
526 true ); // userCanSwitchVersions
527 Q_CHECK_PTR( _pkgVersionsView );
529 _detailsViews->addTab( _pkgVersionsView, _( "&Versions" ) );
531 connect( _pkgList, SIGNAL( currentItemChanged ( ZyppSel ) ),
532 _pkgVersionsView, SLOT ( showDetailsIfVisible( ZyppSel ) ) );
539 if ( haveInstalledPkgs ) // file list information is only available for installed pkgs
541 _pkgFileListView = new YQPkgFileListView( _detailsViews );
542 Q_CHECK_PTR( _pkgFileListView );
544 _detailsViews->addTab( _pkgFileListView, _( "File List" ) );
545 _detailsViews->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) ); // hor/vert
547 connect( _pkgList, SIGNAL( currentItemChanged ( ZyppSel ) ),
548 _pkgFileListView, SLOT ( showDetailsIfVisible( ZyppSel ) ) );
556 if ( haveInstalledPkgs ) // change log information is only available for installed pkgs
558 _pkgChangeLogView = new YQPkgChangeLogView( _detailsViews );
559 Q_CHECK_PTR( _pkgChangeLogView );
561 _detailsViews->addTab( _pkgChangeLogView, _( "Change Log" ) );
562 _detailsViews->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) ); // hor/vert
564 connect( _pkgList, SIGNAL( currentItemChanged ( ZyppSel ) ),
565 _pkgChangeLogView, SLOT ( showDetailsIfVisible( ZyppSel ) ) );
571 YQPackageSelector::layoutButtons( QWidget *parent )
573 QWidget * button_box = new QWidget( parent );
574 Q_CHECK_PTR( button_box );
576 QHBoxLayout *layout = new QHBoxLayout(button_box);
577 button_box->setLayout(layout);
579 layout->setSpacing( SPACING );
581 // Button: Dependency check
582 // Translators: Please keep this short!
583 _checkDependenciesButton = new QPushButton( _( "Chec&k" ), button_box );
584 layout->addWidget(_checkDependenciesButton);
586 Q_CHECK_PTR( _checkDependenciesButton );
587 _checkDependenciesButton->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ) ); // hor/vert
588 _normalButtonBackground = _checkDependenciesButton->palette().color(QPalette::Background);;
590 connect( _checkDependenciesButton, SIGNAL( clicked() ),
591 this, SLOT ( manualResolvePackageDependencies() ) );
594 // Checkbox: Automatically check dependencies for every package status change?
595 // Translators: Please keep this short!
596 _autoDependenciesCheckBox = new QCheckBox( _( "A&utocheck" ), button_box );
597 Q_CHECK_PTR( _autoDependenciesCheckBox );
598 layout->addWidget(_autoDependenciesCheckBox);
600 _autoDependenciesCheckBox->setChecked( AUTO_CHECK_DEPENDENCIES_DEFAULT );
602 addHStretch( button_box );
604 QPushButton * cancel_button = new QPushButton( _( "&Cancel" ), button_box );
605 Q_CHECK_PTR( cancel_button );
606 layout->addWidget(cancel_button);
608 cancel_button->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ) ); // hor/vert
610 connect( cancel_button, SIGNAL( clicked() ),
611 this, SLOT ( reject() ) );
614 QPushButton * accept_button = new QPushButton( _( "&Accept" ), button_box );
615 Q_CHECK_PTR( accept_button );
616 layout->addWidget(accept_button);
617 accept_button->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ) ); // hor/vert
619 connect( accept_button, SIGNAL( clicked() ),
620 this, SLOT ( accept() ) );
622 button_box->setFixedHeight( button_box->sizeHint().height() );
627 YQPackageSelector::layoutMenuBar( QWidget *parent )
629 _menuBar = new QMenuBar( parent );
630 Q_CHECK_PTR( _menuBar );
632 parent->layout()->addWidget(_menuBar);
645 YQPackageSelector::addMenus()
651 _fileMenu = new QMenu( _menuBar );
652 Q_CHECK_PTR( _fileMenu );
653 QAction *action = _menuBar->addMenu( _fileMenu );
654 action->setText(( "&File" ));
656 _fileMenu->addAction( _( "&Import..." ), this, SLOT( pkgImport() ) );
657 _fileMenu->addAction( _( "&Export..." ), this, SLOT( pkgExport() ) );
659 _fileMenu->addSeparator();
661 _fileMenu->addAction( _( "E&xit -- Discard Changes" ), this, SLOT( reject() ) );
662 _fileMenu->addAction( _( "&Quit -- Save Changes" ), this, SLOT( accept() ) );
671 _viewMenu = new QMenu( _menuBar );
672 Q_CHECK_PTR( _viewMenu );
673 QAction *action = _menuBar->addMenu( _viewMenu );
674 action->setText(_( "&View" ));
676 // Translators: This is about packages ending in "-devel", so don't translate that "-devel"!
677 _showDevelAction = _viewMenu->addAction( _( "Show -de&vel Packages" ),
678 this, SLOT( pkgExcludeRulesChanged() ), Qt::Key_F7 );
679 _showDevelAction->setChecked(true);
680 _excludeDevelPkgs = new YQPkgObjList::ExcludeRule( _pkgList, QRegExp( ".*-devel(-\\d+bit)?$" ), _pkgList->nameCol() );
681 Q_CHECK_PTR( _excludeDevelPkgs );
682 _excludeDevelPkgs->enable( false );
684 // Translators: This is about packages ending in "-debuginfo", so don't translate that "-debuginfo"!
685 _showDebugAction = _viewMenu->addAction( _( "Show -&debuginfo Packages" ),
686 this, SLOT( pkgExcludeRulesChanged() ), Qt::Key_F8 );
687 _showDebugAction->setChecked(true);
688 _excludeDebugInfoPkgs = new YQPkgObjList::ExcludeRule( _pkgList, QRegExp( ".*-debuginfo$" ), _pkgList->nameCol() );
689 Q_CHECK_PTR( _excludeDebugInfoPkgs );
690 _excludeDebugInfoPkgs->enable( false );
697 _pkgMenu = new QMenu( _menuBar );
698 Q_CHECK_PTR( _pkgMenu );
699 action = _menuBar->addMenu( _pkgMenu );
700 action->setText(_( "&Package" ));
702 _pkgMenu->addAction(_pkgList->actionSetCurrentInstall);
703 _pkgMenu->addAction(_pkgList->actionSetCurrentDontInstall);
704 _pkgMenu->addAction(_pkgList->actionSetCurrentKeepInstalled);
705 _pkgMenu->addAction(_pkgList->actionSetCurrentDelete);
706 _pkgMenu->addAction(_pkgList->actionSetCurrentUpdate);
707 _pkgMenu->addAction(_pkgList->actionSetCurrentTaboo);
709 _pkgMenu->addSeparator();
711 _pkgMenu->addAction(_pkgList->actionInstallSourceRpm);
712 _pkgMenu->addAction(_pkgList->actionDontInstallSourceRpm);
714 _pkgMenu->addSeparator();
715 QMenu * submenu = _pkgList->addAllInListSubMenu( _pkgMenu );
716 Q_CHECK_PTR( submenu );
718 submenu->addSeparator();
720 _pkgMenu->addAction(_pkgList->actionInstallListSourceRpms);
721 _pkgMenu->addAction(_pkgList->actionDontInstallListSourceRpms);
724 // Submenu for all packages
727 submenu = new QMenu( _pkgMenu );
728 Q_CHECK_PTR( submenu );
730 // Translators: Unlike the "all in this list" submenu, this submenu
731 // refers to all packages globally, not only to those that are
732 // currently visible in the packages list.
733 action = _pkgMenu->addMenu( submenu );
734 action->setText(_( "All Packages" ));
736 submenu->addAction( _( "Update if newer version available" ),
737 this, SLOT( globalUpdatePkg() ) );
739 submenu->addAction( _( "Update unconditionally" ),
740 this, SLOT( globalUpdatePkgForce() ) );
750 _patchMenu = new QMenu( _menuBar );
751 Q_CHECK_PTR( _patchMenu );
752 action = _menuBar->addMenu( _patchMenu );
753 action->setText(_( "&Patch" ));
755 _patchMenu->addAction(_patchList->actionSetCurrentInstall);
756 _patchMenu->addAction(_patchList->actionSetCurrentDontInstall);
757 _patchMenu->addAction(_patchList->actionSetCurrentKeepInstalled);
759 #if ENABLE_DELETING_PATCHES
760 _patchMenu->addAction(_patchList->actionSetCurrentDelete);
762 _patchMenu->addAction(_patchList->actionSetCurrentUpdate);
763 _patchMenu->addAction(_patchList->actionSetCurrentTaboo);
765 _patchMenu->addSeparator();
766 _patchList->addAllInListSubMenu( _patchMenu );
774 _extrasMenu = new QMenu( _menuBar );
775 Q_CHECK_PTR( _extrasMenu );
776 action = _menuBar->addMenu( _extrasMenu );
777 action->setText(_( "&Extras" ));
779 _extrasMenu->addAction( _( "Show &Products" ), this, SLOT( showProducts() ) );
780 _extrasMenu->addAction( _( "Show &Automatic Package Changes" ), this, SLOT( showAutoPkgList() ), Qt::CTRL + Qt::Key_A );
781 _extrasMenu->addAction( _( "&Verify System" ), this, SLOT( verifySystem() ) );
783 _extrasMenu->addSeparator();
785 // Translators: This is about packages ending in "-devel", so don't translate that "-devel"!
786 _extrasMenu->addAction( _( "Install All Matching -&devel Packages" ), this, SLOT( installDevelPkgs() ) );
788 // Translators: This is about packages ending in "-debuginfo", so don't translate that "-debuginfo"!
789 _extrasMenu->addAction( _( "Install All Matching -de&buginfo Packages" ), this, SLOT( installDebugInfoPkgs() ) );
791 _extrasMenu->addSeparator();
793 if ( _pkgConflictDialog )
794 _extrasMenu->addAction( _( "Generate Dependency Resolver &Test Case" ),
795 _pkgConflictDialog, SLOT( askCreateSolverTestCase() ) );
797 if ( _actionResetIgnoredDependencyProblems )
798 _extrasMenu->addAction(_actionResetIgnoredDependencyProblems);
803 _extrasMenu->addAction(_patchList->actionShowRawPatchInfo);
811 _helpMenu = new QMenu( _menuBar );
812 Q_CHECK_PTR( _helpMenu );
813 _menuBar->addSeparator();
814 action = _menuBar->addMenu( _helpMenu );
815 action->setText(_( "&Help" ));
817 // Note: The help functions and their texts are moved out
818 // to a separate source file YQPackageSelectorHelp.cc
820 // Menu entry for help overview
821 _helpMenu->addAction( _( "&Overview" ), this, SLOT( help() ), Qt::Key_F1 );
823 // Menu entry for help about used symbols ( icons )
824 _helpMenu->addAction( _( "&Symbols" ), this, SLOT( symbolHelp() ), Qt::SHIFT + Qt::Key_F1 );
826 // Menu entry for keyboard help
827 _helpMenu->addAction( _( "&Keys" ), this, SLOT( keyboardHelp() ) );
832 YQPackageSelector::connectFilter( QWidget * filter,
834 bool hasUpdateSignal )
836 if ( ! filter ) return;
837 if ( ! pkgList ) return;
841 connect( _filters, SIGNAL( currentChanged(QWidget *) ),
842 filter, SLOT ( filterIfVisible() ) );
845 connect( this, SIGNAL( refresh() ),
846 filter, SLOT ( filterIfVisible() ) );
848 connect( filter, SIGNAL( filterStart() ),
849 pkgList, SLOT ( clear() ) );
851 connect( filter, SIGNAL( filterMatch( ZyppSel, ZyppPkg ) ),
852 pkgList, SLOT ( addPkgItem ( ZyppSel, ZyppPkg ) ) );
854 connect( filter, SIGNAL( filterFinished() ),
855 pkgList, SLOT ( selectSomething() ) );
857 connect( filter, SIGNAL( filterFinished() ),
858 pkgList, SLOT ( logExcludeStatistics() ) );
861 if ( hasUpdateSignal )
863 connect( filter, SIGNAL( updatePackages() ),
864 pkgList, SLOT ( updateItemStates() ) );
866 if ( _diskUsageList )
868 connect( filter, SIGNAL( updatePackages() ),
869 _diskUsageList, SLOT ( updateDiskUsage() ) );
876 YQPackageSelector::makeConnections()
878 connect( this, SIGNAL( resolvingStarted() ),
879 this, SLOT ( animateCheckButton() ) );
881 connect( this, SIGNAL( resolvingFinished() ),
882 this, SLOT ( restoreCheckButton() ) );
884 connectFilter( _updateProblemFilterView, _pkgList, false );
885 connectFilter( _patternList, _pkgList );
886 connectFilter( _selList, _pkgList );
887 connectFilter( _repoFilterView, _pkgList, false );
888 connectFilter( _rpmGroupTagsFilterView, _pkgList, false );
889 connectFilter( _langList, _pkgList );
890 connectFilter( _statusFilterView, _pkgList, false );
891 connectFilter( _searchFilterView, _pkgList, false );
893 if ( _searchFilterView && _pkgList )
895 connect( _searchFilterView, SIGNAL( message( const QString & ) ),
896 _pkgList, SLOT ( message( const QString & ) ) );
899 if ( _repoFilterView && _pkgList )
901 connect( _repoFilterView, SIGNAL( filterNearMatch ( ZyppSel, ZyppPkg ) ),
902 _pkgList, SLOT ( addPkgItemDimmed ( ZyppSel, ZyppPkg ) ) );
905 if ( _pkgList && _diskUsageList )
908 connect( _pkgList, SIGNAL( statusChanged() ),
909 _diskUsageList, SLOT ( updateDiskUsage() ) );
917 // Connect package conflict dialog
920 if ( _pkgConflictDialog )
924 connect( _pkgConflictDialog, SIGNAL( updatePackages() ),
925 _pkgList, SLOT ( updateItemStates() ) );
930 connect( _pkgConflictDialog, SIGNAL( updatePackages() ),
931 _patternList, SLOT ( updateItemStates() ) );
936 connect( _pkgConflictDialog, SIGNAL( updatePackages() ),
937 _selList, SLOT ( updateItemStates() ) );
940 if ( _diskUsageList )
942 connect( _pkgConflictDialog, SIGNAL( updatePackages() ),
943 _diskUsageList, SLOT ( updateDiskUsage() ) );
949 // Connect package versions view
952 if ( _pkgVersionsView && _pkgList )
954 connect( _pkgVersionsView, SIGNAL( candidateChanged( ZyppObj ) ),
955 _pkgList, SLOT ( updateItemData() ) );
960 // Hotkey to enable "patches" filter view on the fly
963 QShortcut * accel = new QShortcut( Qt::Key_F2, this, SLOT( hotkeyInsertPatchFilterView() ) );
964 Q_CHECK_PTR( accel );
967 // Update actions just before opening menus
970 if ( _pkgMenu && _pkgList )
972 connect( _pkgMenu, SIGNAL( aboutToShow() ),
973 _pkgList, SLOT ( updateActions() ) );
976 if ( _patchMenu && _patchList )
978 connect( _patchMenu, SIGNAL( aboutToShow() ),
979 _patchList, SLOT ( updateActions() ) );
985 YQPackageSelector::animateCheckButton()
987 if ( _checkDependenciesButton )
989 QPalette p = _checkDependenciesButton->palette();
990 p.setColor(QPalette::Background, QColor( 0xE0, 0xE0, 0xF8 ));
991 _checkDependenciesButton->setPalette(p);
992 _checkDependenciesButton->repaint();
998 YQPackageSelector::restoreCheckButton()
1000 if ( _checkDependenciesButton )
1002 QPalette p = _checkDependenciesButton->palette();
1003 p.setColor(QPalette::Background, _normalButtonBackground);
1004 _checkDependenciesButton->setPalette(p);
1010 YQPackageSelector::autoResolveDependencies()
1012 if ( _autoDependenciesCheckBox && ! _autoDependenciesCheckBox->isChecked() )
1015 resolveDependencies();
1020 YQPackageSelector::manualResolvePackageDependencies()
1022 if ( ! _pkgConflictDialog )
1024 y2error( "No package conflict dialog existing" );
1025 return QDialog::Accepted;
1028 YQUI::ui()->busyCursor();
1029 int result = _pkgConflictDialog->solveAndShowConflicts();
1030 YQUI::ui()->normalCursor();
1032 #if DEPENDENCY_FEEDBACK_IF_OK
1034 if ( result == QDialog::Accepted )
1036 QMessageBox::information( this, "",
1037 _( "All package dependencies are OK." ),
1047 YQPackageSelector::addPatchFilterView()
1049 if ( ! _patchFilterView )
1051 _patchFilterView = new YQPkgPatchFilterView( this );
1052 Q_CHECK_PTR( _patchFilterView );
1053 _filters->addPage( _( "Patches" ), _patchFilterView );
1055 _patchList = _patchFilterView->patchList();
1056 Q_CHECK_PTR( _patchList );
1064 YQPackageSelector::hotkeyInsertPatchFilterView()
1066 if ( ! _patchFilterView )
1068 y2milestone( "Activating patches filter view" );
1070 addPatchFilterView();
1073 _filters->showPage( _patchFilterView );
1075 _patchList->filter();
1081 YQPackageSelector::connectPatchList()
1083 if ( _pkgList && _patchList )
1085 connectFilter( _patchList, _pkgList );
1087 connect( _patchList, SIGNAL( filterMatch ( const QString &, const QString &, FSize ) ),
1088 _pkgList, SLOT ( addPassiveItem( const QString &, const QString &, FSize ) ) );
1090 connect( _patchList, SIGNAL( statusChanged() ),
1091 this, SLOT ( autoResolveDependencies() ) );
1093 if ( _pkgConflictDialog )
1095 connect( _pkgConflictDialog,SIGNAL( updatePackages() ),
1096 _patchList, SLOT ( updateItemStates() ) );
1099 connect( this, SIGNAL( refresh() ),
1100 _patchList, SLOT ( updateItemStates() ) );
1107 YQPackageSelector::pkgExport()
1109 QString filename = YQUI::ui()->askForSaveFileName( QString( DEFAULT_EXPORT_FILE_NAME ), // startsWith
1110 QString( "*.xml;;*" ), // filter
1111 _( "Save Package List" ) );
1113 if ( ! filename.isEmpty() )
1115 zypp::syscontent::Writer writer;
1116 const zypp::ResPool & pool = zypp::getZYpp()->pool();
1118 // The ZYPP obfuscated C++ contest proudly presents:
1120 for_each( pool.begin(), pool.end(),
1121 boost::bind( &zypp::syscontent::Writer::addIf,
1122 boost::ref( writer ),
1124 // Yuck. What a mess.
1126 // Does anybody seriously believe this kind of thing is easier to read,
1127 // let alone use? Get real. This is an argument in favour of all C++
1128 // haters. And it's one that is really hard to counter.
1134 std::ofstream exportFile( toUTF8( filename ).c_str() );
1135 exportFile.exceptions( std::ios_base::badbit | std::ios_base::failbit );
1136 exportFile << writer;
1138 y2milestone( "Package list exported to %s", qPrintable(filename) );
1140 catch ( std::exception & exception )
1142 y2warning( "Error exporting package list to %s", qPrintable(filename) );
1144 // The export might have left over a partially written file.
1145 // Try to delete it. Don't care if it doesn't exist and unlink() fails.
1146 QFile::remove(filename);
1149 QMessageBox::warning( this, // parent
1150 _( "Error" ), // caption
1151 _( "Error exporting package list to %1" ).arg( filename ),
1152 QMessageBox::Ok | QMessageBox::Default, // button0
1153 Qt::NoButton, // button1
1154 Qt::NoButton ); // button2
1161 YQPackageSelector::pkgImport()
1163 QString filename = QFileDialog::getOpenFileName( this, _( "Load Package List" ), DEFAULT_EXPORT_FILE_NAME, // startsWi
1164 "*.xml+;;*"// filter
1167 if ( ! filename.isEmpty() )
1169 y2milestone( "Importing package list from %s", qPrintable(filename) );
1173 std::ifstream importFile( toUTF8( filename ).c_str() );
1174 zypp::syscontent::Reader reader( importFile );
1177 // Put reader contents into maps
1180 typedef zypp::syscontent::Reader::Entry ZyppReaderEntry;
1181 typedef std::pair<string, ZyppReaderEntry> ImportMapPair;
1183 map<string, ZyppReaderEntry> importPkg;
1184 map<string, ZyppReaderEntry> importPatterns;
1186 for ( zypp::syscontent::Reader::const_iterator it = reader.begin();
1190 string kind = it->kind();
1192 if ( kind == "package" ) importPkg.insert ( ImportMapPair( it->name(), *it ) );
1193 else if ( kind == "pattern" ) importPatterns.insert( ImportMapPair( it->name(), *it ) );
1196 y2debug( "Found %zu packages and %zu patterns in %s",
1198 importPatterns.size(),
1199 qPrintable(filename) );
1203 // Set status of all patterns and packages according to import map
1206 for ( ZyppPoolIterator it = zyppPatternsBegin();
1207 it != zyppPatternsEnd();
1210 ZyppSel selectable = *it;
1211 importSelectable( *it, importPatterns.find( selectable->name() ) != importPatterns.end(), "pattern" );
1214 for ( ZyppPoolIterator it = zyppPkgBegin();
1218 ZyppSel selectable = *it;
1219 importSelectable( *it, importPkg.find( selectable->name() ) != importPkg.end(), "package" );
1229 if ( _statusFilterView )
1231 // Switch to "Installation Summary" filter view
1233 _filters->showPage( _statusFilterView );
1234 _statusFilterView->filter();
1238 catch ( const zypp::Exception & exception )
1240 y2warning( "Error reading package list from %s", qPrintable(filename) );
1243 QMessageBox::warning( this, // parent
1244 _( "Error" ), // caption
1245 _( "Error loading package list from %1" ).arg( filename ),
1246 QMessageBox::Ok | QMessageBox::Default, // button0
1247 QMessageBox::NoButton, // button1
1248 QMessageBox::NoButton ); // button2
1255 YQPackageSelector::importSelectable( ZyppSel selectable,
1259 ZyppStatus oldStatus = selectable->status();
1260 ZyppStatus newStatus = oldStatus;
1265 // Make sure this selectable does not get installed
1268 switch ( oldStatus )
1272 case S_KeepInstalled:
1276 newStatus = oldStatus;
1281 newStatus = S_KeepInstalled;
1282 y2debug( "Keeping %s %s", kind, selectable->name().c_str() );
1288 if ( selectable->hasCandidateObj() )
1290 newStatus = S_Install;
1291 y2debug( "Adding %s %s", kind, selectable->name().c_str() );
1295 y2debug( "Can't add %s %s: No candidate",
1296 kind, selectable->name().c_str() );
1304 // Make sure this selectable does not get installed
1307 switch ( oldStatus )
1311 case S_KeepInstalled:
1316 y2debug( "Deleting %s %s", kind, selectable->name().c_str() );
1323 newStatus = oldStatus;
1328 if ( oldStatus != newStatus )
1329 selectable->set_status( newStatus );
1334 YQPackageSelector::globalUpdatePkg( bool force )
1339 int count = _pkgList->globalSetPkgStatus( S_Update, force,
1340 true ); // countOnly
1341 y2milestone( "%d pkgs found for update", count );
1343 if ( count >= GLOBAL_UPDATE_CONFIRMATION_THRESHOLD )
1345 if ( QMessageBox::question( this, "", // caption
1346 // Translators: %1 is the number of affected packages
1347 _( "%1 packages will be updated" ).arg( count ),
1348 _( "&Continue" ), _( "C&ancel" ),
1349 0, // defaultButtonNumber (from 0)
1350 1 ) // escapeButtonNumber
1357 (void) _pkgList->globalSetPkgStatus( S_Update, force,
1358 false ); // countOnly
1360 if ( _statusFilterView )
1362 _filters->showPage( _statusFilterView );
1363 _statusFilterView->clear();
1364 _statusFilterView->showTransactions();
1365 _statusFilterView->filter();
1371 YQPackageSelector::showProducts()
1373 YQPkgProductDialog::showProductDialog();
1377 YQPackageSelector::installDevelPkgs()
1379 installSubPkgs( "-devel" );
1384 YQPackageSelector::installDebugInfoPkgs()
1386 installSubPkgs( "-debuginfo" );
1391 YQPackageSelector::pkgExcludeRulesChanged()
1393 QAction *action = dynamic_cast<QAction *>(QObject::sender());
1395 if ( _viewMenu && _pkgList )
1397 //action->setChecked();
1398 //_viewMenu->setItemChecked( menuItemID, ! _viewMenu->isItemChecked( menuItemID ) );
1400 if ( _excludeDevelPkgs )
1401 _excludeDevelPkgs->enable( ! _showDevelAction->isChecked() );
1403 if ( _excludeDebugInfoPkgs )
1404 _excludeDebugInfoPkgs->enable( ! _showDebugAction->isChecked() );
1406 _pkgList->applyExcludeRules();
1412 YQPackageSelector::installSubPkgs( const QString suffix )
1414 // Find all matching packages and put them into a QMap
1416 QMap<QString, ZyppSel> subPkgs;
1418 for ( ZyppPoolIterator it = zyppPkgBegin();
1422 QString name = (*it)->name().c_str();
1424 if ( name.endsWith( suffix ) )
1426 subPkgs[ name ] = *it;
1428 y2debug( "Found subpackage: %s", qPrintable(name) );
1433 // Now go through all packages and look if there is a corresponding subpackage in the QMap
1435 for ( ZyppPoolIterator it = zyppPkgBegin();
1439 QString name = (*it)->name().c_str();
1441 if ( subPkgs.contains( name + suffix ) )
1443 QString subPkgName( name + suffix );
1444 ZyppSel subPkg = subPkgs[ subPkgName ];
1446 switch ( (*it)->status() )
1453 // Don't install the subpackage
1454 y2milestone( "Ignoring unwanted subpackage %s", qPrintable(subPkgName) );
1459 case S_KeepInstalled:
1461 // Install the subpackage, but don't try to update it
1463 if ( ! subPkg->installedObj() )
1465 subPkg->set_status( S_Install );
1466 y2milestone( "Installing subpackage %s", qPrintable(subPkgName) );
1474 // Install or update the subpackage
1476 if ( ! subPkg->installedObj() )
1478 subPkg->set_status( S_Install );
1479 y2milestone( "Installing subpackage %s", qPrintable(subPkgName) );
1483 subPkg->set_status( S_Update );
1484 y2milestone( "Updating subpackage %s", qPrintable(subPkgName) );
1488 // Intentionally omitting 'default' branch so the compiler can
1489 // catch unhandled enum states
1495 if ( _filters && _statusFilterView )
1497 _filters->showPage( _statusFilterView );
1498 _statusFilterView->filter();
1501 YQPkgChangesDialog::showChangesDialog( _( "Added Subpackages:" ),
1502 QRegExp( ".*" + suffix + "$" ),
1504 QString::null, // rejectButtonLabel
1505 true ); // showIfEmpty
1509 #include "YQPackageSelector.moc"