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>
32 #include <qapplication.h>
34 #include <qcheckbox.h>
36 #include <q3filedialog.h>
41 #include <qmessagebox.h>
42 #include <qpushbutton.h>
43 #include <qsplitter.h>
44 #include <qtabwidget.h>
47 #include <q3popupmenu.h>
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() ) );
215 YQPackageSelector::basicLayout()
217 layoutMenuBar( this );
219 QSplitter * outer_splitter = new QSplitter( Qt::Horizontal, this );
220 Q_CHECK_PTR( outer_splitter );
222 QWidget * left_pane = layoutLeftPane ( outer_splitter );
223 QWidget * right_pane = layoutRightPane( outer_splitter );
225 outer_splitter->setResizeMode( left_pane, QSplitter::KeepSize );
226 outer_splitter->setResizeMode( right_pane, QSplitter::Stretch );
231 YQPackageSelector::layoutLeftPane( QWidget * parent )
233 QSplitter * splitter = new QSplitter( Qt::Vertical, parent );
234 Q_CHECK_PTR( splitter );
235 splitter->setMargin( MARGIN );
237 Q3VBox * upper_vbox = new Q3VBox( splitter );
238 Q_CHECK_PTR( upper_vbox );
239 layoutFilters( upper_vbox );
240 addVSpacing( upper_vbox, MARGIN );
242 Q3VBox * lower_vbox = new Q3VBox( splitter );
243 addVSpacing( lower_vbox, MARGIN );
244 _diskUsageList = new YQPkgDiskUsageList( lower_vbox );
245 Q_CHECK_PTR( _diskUsageList );
247 splitter->setResizeMode( upper_vbox, QSplitter::Stretch );
248 splitter->setResizeMode( lower_vbox, QSplitter::KeepSize );
255 YQPackageSelector::layoutFilters( QWidget * parent )
257 _filters = new QY2ComboTabWidget( _( "Fi<er:" ), parent );
258 Q_CHECK_PTR( _filters );
262 // Update problem view
267 if ( YQPkgUpdateProblemFilterView::haveProblematicPackages()
270 _updateProblemFilterView = new YQPkgUpdateProblemFilterView( parent );
271 Q_CHECK_PTR( _updateProblemFilterView );
272 _filters->addPage( _( "Update Problems" ), _updateProblemFilterView );
281 if ( onlineUpdateMode()
282 #if ALWAYS_SHOW_PATCHES_VIEW_IF_PATCHES_AVAILABLE
283 || ! zyppPool().empty<zypp::Patch>()
286 addPatchFilterView();
293 if ( ! zyppPool().empty<zypp::Pattern>() || testMode() )
295 _patternList = new YQPkgPatternList( parent, true );
296 Q_CHECK_PTR( _patternList );
297 _filters->addPage( _( "Patterns" ), _patternList );
299 connect( _patternList, SIGNAL( statusChanged() ),
300 this, SLOT ( autoResolveDependencies() ) );
302 connect( this, SIGNAL( refresh() ),
303 _patternList, SLOT ( updateItemStates() ) );
305 if ( _pkgConflictDialog )
307 connect( _pkgConflictDialog, SIGNAL( updatePackages() ),
308 _patternList, SLOT ( updateItemStates() ) );
317 if ( ! zyppPool().empty<zypp::Selection>() || testMode() )
320 _selList = new YQPkgSelList( parent, true );
321 Q_CHECK_PTR( _selList );
322 _filters->addPage( _( "Selections" ), _selList );
324 connect( _selList, SIGNAL( statusChanged() ),
325 this, SLOT ( autoResolveDependencies() ) );
327 connect( this, SIGNAL( refresh() ),
328 _selList, SLOT ( updateItemStates() ) );
330 if ( _pkgConflictDialog )
332 connect( _pkgConflictDialog, SIGNAL( updatePackages() ),
333 _selList, SLOT ( updateItemStates() ) );
339 // RPM group tags view
342 _rpmGroupTagsFilterView = new YQPkgRpmGroupTagsFilterView( parent );
343 Q_CHECK_PTR( _rpmGroupTagsFilterView );
344 _filters->addPage( _( "Package Groups" ), _rpmGroupTagsFilterView );
346 connect( this, SIGNAL( loadData() ),
347 _rpmGroupTagsFilterView, SLOT ( filter() ) );
354 _langList = new YQPkgLangList( parent );
355 Q_CHECK_PTR( _langList );
357 _filters->addPage( _( "Languages" ), _langList );
358 _langList->setSizePolicy( QSizePolicy( QSizePolicy::Ignored, QSizePolicy::Ignored ) ); // hor/vert
360 connect( _langList, SIGNAL( statusChanged() ),
361 this, SLOT ( autoResolveDependencies() ) );
363 connect( this, SIGNAL( refresh() ),
364 _langList, SLOT ( updateItemStates() ) );
371 _repoFilterView = new YQPkgRepoFilterView( parent );
372 Q_CHECK_PTR( _repoFilterView );
373 _filters->addPage( _( "Repositories" ), _repoFilterView );
377 // Package search view
380 _searchFilterView = new YQPkgSearchFilterView( parent );
381 Q_CHECK_PTR( _searchFilterView );
382 _filters->addPage( _( "Search" ), _searchFilterView );
386 // Status change view
389 _statusFilterView = new YQPkgStatusFilterView( parent );
390 Q_CHECK_PTR( _statusFilterView );
391 _filters->addPage( _( "Installation Summary" ), _statusFilterView );
397 _filters->addPage( _( "Keywords" ), new QLabel( "Keywords\nfilter\n\nfor future use", 0 ) );
398 _filters->addPage( _( "MIME Types" ), new QLabel( "MIME Types\nfilter\n\nfor future use" , 0 ) );
405 YQPackageSelector::layoutRightPane( QWidget * parent )
407 Q3VBox * right_pane_vbox = new Q3VBox( parent );
408 Q_CHECK_PTR( right_pane_vbox );
409 right_pane_vbox->setMargin( MARGIN );
411 QSplitter * splitter = new QSplitter( Qt::Vertical, right_pane_vbox );
412 Q_CHECK_PTR( splitter );
414 Q3VBox * splitter_vbox = new Q3VBox( splitter );
415 Q_CHECK_PTR( splitter_vbox );
416 layoutPkgList( splitter_vbox );
417 addVSpacing( splitter_vbox, MARGIN );
419 layoutDetailsViews( splitter );
421 layoutButtons( right_pane_vbox );
423 return right_pane_vbox;
428 YQPackageSelector::layoutPkgList( QWidget * parent )
430 _pkgList= new YQPkgList( parent );
431 Q_CHECK_PTR( _pkgList );
433 connect( _pkgList, SIGNAL( statusChanged() ),
434 this, SLOT ( autoResolveDependencies() ) );
439 YQPackageSelector::layoutDetailsViews( QWidget * parent )
441 bool haveInstalledPkgs = YQPkgList::haveInstalledPkgs();
443 Q3VBox * details_vbox = new Q3VBox( parent );
444 Q_CHECK_PTR( details_vbox );
445 details_vbox->setMinimumSize( 0, 0 );
447 addVSpacing( details_vbox, 8 );
449 _detailsViews = new QTabWidget( details_vbox );
450 Q_CHECK_PTR( _detailsViews );
451 _detailsViews->setMargin( MARGIN );
453 // _detailsViews->setTabPosition( QTabWidget::Bottom );
460 _pkgDescriptionView = new YQPkgDescriptionView( _detailsViews );
461 Q_CHECK_PTR( _pkgDescriptionView );
463 _detailsViews->addTab( _pkgDescriptionView, _( "D&escription" ) );
464 _detailsViews->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) ); // hor/vert
466 connect( _pkgList, SIGNAL( selectionChanged ( ZyppSel ) ),
467 _pkgDescriptionView, SLOT ( showDetailsIfVisible( ZyppSel ) ) );
473 _pkgTechnicalDetailsView = new YQPkgTechnicalDetailsView( _detailsViews );
474 Q_CHECK_PTR( _pkgTechnicalDetailsView );
476 _detailsViews->addTab( _pkgTechnicalDetailsView, _( "&Technical Data" ) );
478 connect( _pkgList, SIGNAL( selectionChanged ( ZyppSel ) ),
479 _pkgTechnicalDetailsView, SLOT ( showDetailsIfVisible( ZyppSel ) ) );
486 _pkgDependenciesView = new YQPkgDependenciesView( _detailsViews );
487 Q_CHECK_PTR( _pkgDependenciesView );
489 _detailsViews->addTab( _pkgDependenciesView, _( "Dependencies" ) );
490 _detailsViews->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) ); // hor/vert
492 connect( _pkgList, SIGNAL( selectionChanged ( ZyppSel ) ),
493 _pkgDependenciesView, SLOT ( showDetailsIfVisible( ZyppSel ) ) );
501 _pkgVersionsView = new YQPkgVersionsView( _detailsViews,
502 true ); // userCanSwitchVersions
503 Q_CHECK_PTR( _pkgVersionsView );
505 _detailsViews->addTab( _pkgVersionsView, _( "&Versions" ) );
507 connect( _pkgList, SIGNAL( selectionChanged ( ZyppSel ) ),
508 _pkgVersionsView, SLOT ( showDetailsIfVisible( ZyppSel ) ) );
515 if ( haveInstalledPkgs ) // file list information is only available for installed pkgs
517 _pkgFileListView = new YQPkgFileListView( _detailsViews );
518 Q_CHECK_PTR( _pkgFileListView );
520 _detailsViews->addTab( _pkgFileListView, _( "File List" ) );
521 _detailsViews->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) ); // hor/vert
523 connect( _pkgList, SIGNAL( selectionChanged ( ZyppSel ) ),
524 _pkgFileListView, SLOT ( showDetailsIfVisible( ZyppSel ) ) );
532 if ( haveInstalledPkgs ) // change log information is only available for installed pkgs
534 _pkgChangeLogView = new YQPkgChangeLogView( _detailsViews );
535 Q_CHECK_PTR( _pkgChangeLogView );
537 _detailsViews->addTab( _pkgChangeLogView, _( "Change Log" ) );
538 _detailsViews->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) ); // hor/vert
540 connect( _pkgList, SIGNAL( selectionChanged ( ZyppSel ) ),
541 _pkgChangeLogView, SLOT ( showDetailsIfVisible( ZyppSel ) ) );
547 YQPackageSelector::layoutButtons( QWidget * parent )
549 Q3HBox * button_box = new Q3HBox( parent );
550 Q_CHECK_PTR( button_box );
551 button_box->setSpacing( SPACING );
553 // Button: Dependency check
554 // Translators: Please keep this short!
555 _checkDependenciesButton = new QPushButton( _( "Chec&k" ), button_box );
556 Q_CHECK_PTR( _checkDependenciesButton );
557 _checkDependenciesButton->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ) ); // hor/vert
558 _normalButtonBackground = _checkDependenciesButton->paletteBackgroundColor();
560 connect( _checkDependenciesButton, SIGNAL( clicked() ),
561 this, SLOT ( manualResolvePackageDependencies() ) );
564 // Checkbox: Automatically check dependencies for every package status change?
565 // Translators: Please keep this short!
566 _autoDependenciesCheckBox = new QCheckBox( _( "A&utocheck" ), button_box );
567 Q_CHECK_PTR( _autoDependenciesCheckBox );
568 _autoDependenciesCheckBox->setChecked( AUTO_CHECK_DEPENDENCIES_DEFAULT );
570 addHStretch( button_box );
572 QPushButton * cancel_button = new QPushButton( _( "&Cancel" ), button_box );
573 Q_CHECK_PTR( cancel_button );
574 cancel_button->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ) ); // hor/vert
576 connect( cancel_button, SIGNAL( clicked() ),
577 this, SLOT ( reject() ) );
580 QPushButton * accept_button = new QPushButton( _( "&Accept" ), button_box );
581 Q_CHECK_PTR( accept_button );
582 accept_button->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ) ); // hor/vert
584 connect( accept_button, SIGNAL( clicked() ),
585 this, SLOT ( accept() ) );
587 button_box->setFixedHeight( button_box->sizeHint().height() );
592 YQPackageSelector::layoutMenuBar( QWidget * parent )
594 _menuBar = new QMenuBar( parent );
595 Q_CHECK_PTR( _menuBar );
608 YQPackageSelector::addMenus()
614 _fileMenu = new Q3PopupMenu( _menuBar );
615 Q_CHECK_PTR( _fileMenu );
616 _menuBar->insertItem( _( "&File" ), _fileMenu );
618 _fileMenu->insertItem( _( "&Import..." ), this, SLOT( pkgImport() ) );
619 _fileMenu->insertItem( _( "&Export..." ), this, SLOT( pkgExport() ) );
621 _fileMenu->insertSeparator();
623 _fileMenu->insertItem( _( "E&xit -- Discard Changes" ), this, SLOT( reject() ) );
624 _fileMenu->insertItem( _( "&Quit -- Save Changes" ), this, SLOT( accept() ) );
633 _viewMenu = new Q3PopupMenu( _menuBar );
634 Q_CHECK_PTR( _viewMenu );
635 _menuBar->insertItem( _( "&View" ), _viewMenu );
637 // Translators: This is about packages ending in "-devel", so don't translate that "-devel"!
638 _viewShowDevelID = _viewMenu->insertItem( _( "Show -de&vel Packages" ),
639 this, SLOT( pkgExcludeRulesChanged( int ) ), Qt::Key_F7 );
640 _viewMenu->setItemChecked( _viewShowDevelID, true );
641 _excludeDevelPkgs = new YQPkgObjList::ExcludeRule( _pkgList, QRegExp( ".*-devel(-\\d+bit)?$" ), _pkgList->nameCol() );
642 Q_CHECK_PTR( _excludeDevelPkgs );
643 _excludeDevelPkgs->enable( false );
645 // Translators: This is about packages ending in "-debuginfo", so don't translate that "-debuginfo"!
646 _viewShowDebugInfoID = _viewMenu->insertItem( _( "Show -&debuginfo Packages" ),
647 this, SLOT( pkgExcludeRulesChanged( int ) ), Qt::Key_F8 );
648 _viewMenu->setItemChecked( _viewShowDebugInfoID, true );
649 _excludeDebugInfoPkgs = new YQPkgObjList::ExcludeRule( _pkgList, QRegExp( ".*-debuginfo$" ), _pkgList->nameCol() );
650 Q_CHECK_PTR( _excludeDebugInfoPkgs );
651 _excludeDebugInfoPkgs->enable( false );
658 _pkgMenu = new Q3PopupMenu( _menuBar );
659 Q_CHECK_PTR( _pkgMenu );
660 _menuBar->insertItem( _( "&Package" ), _pkgMenu );
662 _pkgList->actionSetCurrentInstall->addTo( _pkgMenu );
663 _pkgList->actionSetCurrentDontInstall->addTo( _pkgMenu );
664 _pkgList->actionSetCurrentKeepInstalled->addTo( _pkgMenu );
665 _pkgList->actionSetCurrentDelete->addTo( _pkgMenu );
666 _pkgList->actionSetCurrentUpdate->addTo( _pkgMenu );
667 _pkgList->actionSetCurrentTaboo->addTo( _pkgMenu );
668 _pkgList->actionSetCurrentProtected->addTo( _pkgMenu );
670 _pkgMenu->insertSeparator();
672 _pkgList->actionInstallSourceRpm->addTo( _pkgMenu );
673 _pkgList->actionDontInstallSourceRpm->addTo( _pkgMenu );
675 _pkgMenu->insertSeparator();
676 Q3PopupMenu * submenu = _pkgList->addAllInListSubMenu( _pkgMenu );
677 Q_CHECK_PTR( submenu );
679 submenu->insertSeparator();
680 _pkgList->actionInstallListSourceRpms->addTo( submenu );
681 _pkgList->actionDontInstallListSourceRpms->addTo( submenu );
685 // Submenu for all packages
688 submenu = new Q3PopupMenu( _pkgMenu );
689 Q_CHECK_PTR( submenu );
691 // Translators: Unlike the "all in this list" submenu, this submenu
692 // refers to all packages globally, not only to those that are
693 // currently visible in the packages list.
694 _pkgMenu->insertItem( _( "All Packages" ), submenu );
696 submenu->insertItem( _( "Update if newer version available" ),
697 this, SLOT( globalUpdatePkg() ) );
699 submenu->insertItem( _( "Update unconditionally" ),
700 this, SLOT( globalUpdatePkgForce() ) );
710 _patchMenu = new Q3PopupMenu( _menuBar );
711 Q_CHECK_PTR( _patchMenu );
712 _menuBar->insertItem( _( "&Patch" ), _patchMenu );
714 _patchList->actionSetCurrentInstall->addTo( _patchMenu );
715 _patchList->actionSetCurrentDontInstall->addTo( _patchMenu );
716 _patchList->actionSetCurrentKeepInstalled->addTo( _patchMenu );
717 #if ENABLE_DELETING_PATCHES
718 _patchList->actionSetCurrentDelete->addTo( _patchMenu );
720 _patchList->actionSetCurrentUpdate->addTo( _patchMenu );
721 _patchList->actionSetCurrentTaboo->addTo( _patchMenu );
723 _patchMenu->insertSeparator();
724 _patchList->addAllInListSubMenu( _patchMenu );
732 _extrasMenu = new Q3PopupMenu( _menuBar );
733 Q_CHECK_PTR( _extrasMenu );
734 _menuBar->insertItem( _( "&Extras" ), _extrasMenu );
736 _extrasMenu->insertItem( _( "Show &Products" ), this, SLOT( showProducts() ) );
737 _extrasMenu->insertItem( _( "Show &Automatic Package Changes" ), this, SLOT( showAutoPkgList() ), Qt::CTRL + Qt::Key_A );
738 _extrasMenu->insertItem( _( "&Verify System" ), this, SLOT( verifySystem() ) );
740 _extrasMenu->insertSeparator();
742 // Translators: This is about packages ending in "-devel", so don't translate that "-devel"!
743 _extrasMenu->insertItem( _( "Install All Matching -&devel Packages" ), this, SLOT( installDevelPkgs() ) );
745 // Translators: This is about packages ending in "-debuginfo", so don't translate that "-debuginfo"!
746 _extrasMenu->insertItem( _( "Install All Matching -de&buginfo Packages" ), this, SLOT( installDebugInfoPkgs() ) );
748 _extrasMenu->insertSeparator();
750 if ( _pkgConflictDialog )
751 _extrasMenu->insertItem( _( "Generate Dependency Resolver &Test Case" ),
752 _pkgConflictDialog, SLOT( askCreateSolverTestCase() ) );
754 if ( _actionResetIgnoredDependencyProblems )
755 _actionResetIgnoredDependencyProblems->addTo( _extrasMenu );
760 _patchList->actionShowRawPatchInfo->addTo( _extrasMenu );
768 _helpMenu = new Q3PopupMenu( _menuBar );
769 Q_CHECK_PTR( _helpMenu );
770 _menuBar->insertSeparator();
771 _menuBar->insertItem( _( "&Help" ), _helpMenu );
773 // Note: The help functions and their texts are moved out
774 // to a separate source file YQPackageSelectorHelp.cc
776 // Menu entry for help overview
777 _helpMenu->insertItem( _( "&Overview" ), this, SLOT( help() ), Qt::Key_F1 );
779 // Menu entry for help about used symbols ( icons )
780 _helpMenu->insertItem( _( "&Symbols" ), this, SLOT( symbolHelp() ), Qt::SHIFT + Qt::Key_F1 );
782 // Menu entry for keyboard help
783 _helpMenu->insertItem( _( "&Keys" ), this, SLOT( keyboardHelp() ) );
788 YQPackageSelector::connectFilter( QWidget * filter,
790 bool hasUpdateSignal )
792 if ( ! filter ) return;
793 if ( ! pkgList ) return;
797 connect( _filters, SIGNAL( currentChanged(QWidget *) ),
798 filter, SLOT ( filterIfVisible() ) );
801 connect( this, SIGNAL( refresh() ),
802 filter, SLOT ( filterIfVisible() ) );
804 connect( filter, SIGNAL( filterStart() ),
805 pkgList, SLOT ( clear() ) );
807 connect( filter, SIGNAL( filterMatch( ZyppSel, ZyppPkg ) ),
808 pkgList, SLOT ( addPkgItem ( ZyppSel, ZyppPkg ) ) );
810 connect( filter, SIGNAL( filterFinished() ),
811 pkgList, SLOT ( selectSomething() ) );
813 connect( filter, SIGNAL( filterFinished() ),
814 pkgList, SLOT ( logExcludeStatistics() ) );
817 if ( hasUpdateSignal )
819 connect( filter, SIGNAL( updatePackages() ),
820 pkgList, SLOT ( updateItemStates() ) );
822 if ( _diskUsageList )
824 connect( filter, SIGNAL( updatePackages() ),
825 _diskUsageList, SLOT ( updateDiskUsage() ) );
832 YQPackageSelector::makeConnections()
834 connect( this, SIGNAL( resolvingStarted() ),
835 this, SLOT ( animateCheckButton() ) );
837 connect( this, SIGNAL( resolvingFinished() ),
838 this, SLOT ( restoreCheckButton() ) );
840 connectFilter( _updateProblemFilterView, _pkgList, false );
841 connectFilter( _patternList, _pkgList );
842 connectFilter( _selList, _pkgList );
843 connectFilter( _repoFilterView, _pkgList, false );
844 connectFilter( _rpmGroupTagsFilterView, _pkgList, false );
845 connectFilter( _langList, _pkgList );
846 connectFilter( _statusFilterView, _pkgList, false );
847 connectFilter( _searchFilterView, _pkgList, false );
849 if ( _searchFilterView && _pkgList )
851 connect( _searchFilterView, SIGNAL( message( const QString & ) ),
852 _pkgList, SLOT ( message( const QString & ) ) );
855 if ( _repoFilterView && _pkgList )
857 connect( _repoFilterView, SIGNAL( filterNearMatch ( ZyppSel, ZyppPkg ) ),
858 _pkgList, SLOT ( addPkgItemDimmed ( ZyppSel, ZyppPkg ) ) );
861 if ( _pkgList && _diskUsageList )
864 connect( _pkgList, SIGNAL( statusChanged() ),
865 _diskUsageList, SLOT ( updateDiskUsage() ) );
873 // Connect package conflict dialog
876 if ( _pkgConflictDialog )
880 connect( _pkgConflictDialog, SIGNAL( updatePackages() ),
881 _pkgList, SLOT ( updateItemStates() ) );
886 connect( _pkgConflictDialog, SIGNAL( updatePackages() ),
887 _patternList, SLOT ( updateItemStates() ) );
892 connect( _pkgConflictDialog, SIGNAL( updatePackages() ),
893 _selList, SLOT ( updateItemStates() ) );
896 if ( _diskUsageList )
898 connect( _pkgConflictDialog, SIGNAL( updatePackages() ),
899 _diskUsageList, SLOT ( updateDiskUsage() ) );
905 // Connect package versions view
908 if ( _pkgVersionsView && _pkgList )
910 connect( _pkgVersionsView, SIGNAL( candidateChanged( ZyppObj ) ),
911 _pkgList, SLOT ( updateItemData() ) );
916 // Hotkey to enable "patches" filter view on the fly
919 Q3Accel * accel = new Q3Accel( this );
920 Q_CHECK_PTR( accel );
921 accel->connectItem( accel->insertItem( Qt::Key_F2 ),
922 this, SLOT( hotkeyInsertPatchFilterView() ) );
926 // Update actions just before opening menus
929 if ( _pkgMenu && _pkgList )
931 connect( _pkgMenu, SIGNAL( aboutToShow() ),
932 _pkgList, SLOT ( updateActions() ) );
935 if ( _patchMenu && _patchList )
937 connect( _patchMenu, SIGNAL( aboutToShow() ),
938 _patchList, SLOT ( updateActions() ) );
944 YQPackageSelector::animateCheckButton()
946 if ( _checkDependenciesButton )
948 _checkDependenciesButton->setPaletteBackgroundColor( QColor( 0xE0, 0xE0, 0xF8 ) );
949 _checkDependenciesButton->repaint();
955 YQPackageSelector::restoreCheckButton()
957 if ( _checkDependenciesButton )
958 _checkDependenciesButton->setPaletteBackgroundColor( _normalButtonBackground );
963 YQPackageSelector::autoResolveDependencies()
965 if ( _autoDependenciesCheckBox && ! _autoDependenciesCheckBox->isChecked() )
968 resolveDependencies();
973 YQPackageSelector::manualResolvePackageDependencies()
975 if ( ! _pkgConflictDialog )
977 y2error( "No package conflict dialog existing" );
978 return QDialog::Accepted;
981 YQUI::ui()->busyCursor();
982 int result = _pkgConflictDialog->solveAndShowConflicts();
983 YQUI::ui()->normalCursor();
985 #if DEPENDENCY_FEEDBACK_IF_OK
987 if ( result == QDialog::Accepted )
989 QMessageBox::information( this, "",
990 _( "All package dependencies are OK." ),
1000 YQPackageSelector::addPatchFilterView()
1002 if ( ! _patchFilterView )
1004 _patchFilterView = new YQPkgPatchFilterView( this );
1005 Q_CHECK_PTR( _patchFilterView );
1006 _filters->addPage( _( "Patches" ), _patchFilterView );
1008 _patchList = _patchFilterView->patchList();
1009 Q_CHECK_PTR( _patchList );
1017 YQPackageSelector::hotkeyInsertPatchFilterView()
1019 if ( ! _patchFilterView )
1021 y2milestone( "Activating patches filter view" );
1023 addPatchFilterView();
1026 _filters->showPage( _patchFilterView );
1028 _patchList->filter();
1034 YQPackageSelector::connectPatchList()
1036 if ( _pkgList && _patchList )
1038 connectFilter( _patchList, _pkgList );
1040 connect( _patchList, SIGNAL( filterMatch ( const QString &, const QString &, FSize ) ),
1041 _pkgList, SLOT ( addPassiveItem( const QString &, const QString &, FSize ) ) );
1043 connect( _patchList, SIGNAL( statusChanged() ),
1044 this, SLOT ( autoResolveDependencies() ) );
1046 if ( _pkgConflictDialog )
1048 connect( _pkgConflictDialog,SIGNAL( updatePackages() ),
1049 _patchList, SLOT ( updateItemStates() ) );
1052 connect( this, SIGNAL( refresh() ),
1053 _patchList, SLOT ( updateItemStates() ) );
1060 YQPackageSelector::pkgExport()
1062 QString filename = YQUI::ui()->askForSaveFileName( QString( DEFAULT_EXPORT_FILE_NAME ), // startsWith
1063 QString( "*.xml;;*" ), // filter
1064 _( "Save Package List" ) );
1066 if ( ! filename.isEmpty() )
1068 zypp::syscontent::Writer writer;
1069 const zypp::ResPool & pool = zypp::getZYpp()->pool();
1071 // The ZYPP obfuscated C++ contest proudly presents:
1073 for_each( pool.begin(), pool.end(),
1074 boost::bind( &zypp::syscontent::Writer::addIf,
1075 boost::ref( writer ),
1077 // Yuck. What a mess.
1079 // Does anybody seriously believe this kind of thing is easier to read,
1080 // let alone use? Get real. This is an argument in favour of all C++
1081 // haters. And it's one that is really hard to counter.
1087 std::ofstream exportFile( toUTF8( filename ).c_str() );
1088 exportFile.exceptions( std::ios_base::badbit | std::ios_base::failbit );
1089 exportFile << writer;
1091 y2milestone( "Package list exported to %s", (const char *) filename );
1093 catch ( std::exception & exception )
1095 y2warning( "Error exporting package list to %s", (const char *) filename );
1097 // The export might have left over a partially written file.
1098 // Try to delete it. Don't care if it doesn't exist and unlink() fails.
1099 (void) unlink( (const char *) filename );
1102 QMessageBox::warning( this, // parent
1103 _( "Error" ), // caption
1104 _( "Error exporting package list to %1" ).arg( filename ),
1105 QMessageBox::Ok | QMessageBox::Default, // button0
1106 Qt::NoButton, // button1
1107 Qt::NoButton ); // button2
1114 YQPackageSelector::pkgImport()
1116 QString filename = Q3FileDialog::getOpenFileName( DEFAULT_EXPORT_FILE_NAME, // startsWith
1117 "*.xml+;;*", // filter
1120 _( "Load Package List" ) ); // caption
1122 if ( ! filename.isEmpty() )
1124 y2milestone( "Importing package list from %s", (const char *) filename );
1128 std::ifstream importFile( toUTF8( filename ).c_str() );
1129 zypp::syscontent::Reader reader( importFile );
1132 // Put reader contents into maps
1135 typedef zypp::syscontent::Reader::Entry ZyppReaderEntry;
1136 typedef std::pair<string, ZyppReaderEntry> ImportMapPair;
1138 map<string, ZyppReaderEntry> importPkg;
1139 map<string, ZyppReaderEntry> importPatterns;
1141 for ( zypp::syscontent::Reader::const_iterator it = reader.begin();
1145 string kind = it->kind();
1147 if ( kind == "package" ) importPkg.insert ( ImportMapPair( it->name(), *it ) );
1148 else if ( kind == "pattern" ) importPatterns.insert( ImportMapPair( it->name(), *it ) );
1151 y2debug( "Found %zu packages and %zu patterns in %s",
1153 importPatterns.size(),
1154 (const char *) filename );
1158 // Set status of all patterns and packages according to import map
1161 for ( ZyppPoolIterator it = zyppPatternsBegin();
1162 it != zyppPatternsEnd();
1165 ZyppSel selectable = *it;
1166 importSelectable( *it, importPatterns.find( selectable->name() ) != importPatterns.end(), "pattern" );
1169 for ( ZyppPoolIterator it = zyppPkgBegin();
1173 ZyppSel selectable = *it;
1174 importSelectable( *it, importPkg.find( selectable->name() ) != importPkg.end(), "package" );
1184 if ( _statusFilterView )
1186 // Switch to "Installation Summary" filter view
1188 _filters->showPage( _statusFilterView );
1189 _statusFilterView->filter();
1193 catch ( const zypp::Exception & exception )
1195 y2warning( "Error reading package list from %s", (const char *) filename );
1198 QMessageBox::warning( this, // parent
1199 _( "Error" ), // caption
1200 _( "Error loading package list from %1" ).arg( filename ),
1201 QMessageBox::Ok | QMessageBox::Default, // button0
1202 QMessageBox::NoButton, // button1
1203 QMessageBox::NoButton ); // button2
1210 YQPackageSelector::importSelectable( ZyppSel selectable,
1214 ZyppStatus oldStatus = selectable->status();
1215 ZyppStatus newStatus = oldStatus;
1220 // Make sure this selectable does not get installed
1223 switch ( oldStatus )
1227 case S_KeepInstalled:
1231 newStatus = oldStatus;
1236 newStatus = S_KeepInstalled;
1237 y2debug( "Keeping %s %s", kind, selectable->name().c_str() );
1243 if ( selectable->hasCandidateObj() )
1245 newStatus = S_Install;
1246 y2debug( "Adding %s %s", kind, selectable->name().c_str() );
1250 y2debug( "Can't add %s %s: No candidate",
1251 kind, selectable->name().c_str() );
1259 // Make sure this selectable does not get installed
1262 switch ( oldStatus )
1266 case S_KeepInstalled:
1271 y2debug( "Deleting %s %s", kind, selectable->name().c_str() );
1278 newStatus = oldStatus;
1283 if ( oldStatus != newStatus )
1284 selectable->set_status( newStatus );
1289 YQPackageSelector::globalUpdatePkg( bool force )
1294 int count = _pkgList->globalSetPkgStatus( S_Update, force,
1295 true ); // countOnly
1296 y2milestone( "%d pkgs found for update", count );
1298 if ( count >= GLOBAL_UPDATE_CONFIRMATION_THRESHOLD )
1300 if ( QMessageBox::question( this, "", // caption
1301 // Translators: %1 is the number of affected packages
1302 _( "%1 packages will be updated" ).arg( count ),
1303 _( "&Continue" ), _( "C&ancel" ),
1304 0, // defaultButtonNumber (from 0)
1305 1 ) // escapeButtonNumber
1312 (void) _pkgList->globalSetPkgStatus( S_Update, force,
1313 false ); // countOnly
1315 if ( _statusFilterView )
1317 _filters->showPage( _statusFilterView );
1318 _statusFilterView->clear();
1319 _statusFilterView->showTransactions();
1320 _statusFilterView->filter();
1326 YQPackageSelector::showProducts()
1328 YQPkgProductDialog::showProductDialog();
1332 YQPackageSelector::installDevelPkgs()
1334 installSubPkgs( "-devel" );
1339 YQPackageSelector::installDebugInfoPkgs()
1341 installSubPkgs( "-debuginfo" );
1346 YQPackageSelector::pkgExcludeRulesChanged( int menuItemID )
1348 if ( _viewMenu && _pkgList )
1350 _viewMenu->setItemChecked( menuItemID, ! _viewMenu->isItemChecked( menuItemID ) );
1352 if ( _excludeDevelPkgs )
1353 _excludeDevelPkgs->enable( ! _viewMenu->isItemChecked( _viewShowDevelID ) );
1355 if ( _excludeDebugInfoPkgs )
1356 _excludeDebugInfoPkgs->enable( ! _viewMenu->isItemChecked( _viewShowDebugInfoID ) );
1358 _pkgList->applyExcludeRules();
1364 YQPackageSelector::installSubPkgs( const QString suffix )
1366 // Find all matching packages and put them into a QMap
1368 QMap<QString, ZyppSel> subPkgs;
1370 for ( ZyppPoolIterator it = zyppPkgBegin();
1374 QString name = (*it)->name().c_str();
1376 if ( name.endsWith( suffix ) )
1378 subPkgs[ name ] = *it;
1380 y2debug( "Found subpackage: %s", (const char *) name );
1385 // Now go through all packages and look if there is a corresponding subpackage in the QMap
1387 for ( ZyppPoolIterator it = zyppPkgBegin();
1391 QString name = (*it)->name().c_str();
1393 if ( subPkgs.contains( name + suffix ) )
1395 QString subPkgName( name + suffix );
1396 ZyppSel subPkg = subPkgs[ subPkgName ];
1398 switch ( (*it)->status() )
1405 // Don't install the subpackage
1406 y2milestone( "Ignoring unwanted subpackage %s", (const char *) subPkgName );
1411 case S_KeepInstalled:
1413 // Install the subpackage, but don't try to update it
1415 if ( ! subPkg->installedObj() )
1417 subPkg->set_status( S_Install );
1418 y2milestone( "Installing subpackage %s", (const char *) subPkgName );
1426 // Install or update the subpackage
1428 if ( ! subPkg->installedObj() )
1430 subPkg->set_status( S_Install );
1431 y2milestone( "Installing subpackage %s", (const char *) subPkgName );
1435 subPkg->set_status( S_Update );
1436 y2milestone( "Updating subpackage %s", (const char *) subPkgName );
1440 // Intentionally omitting 'default' branch so the compiler can
1441 // catch unhandled enum states
1447 if ( _filters && _statusFilterView )
1449 _filters->showPage( _statusFilterView );
1450 _statusFilterView->filter();
1453 YQPkgChangesDialog::showChangesDialog( _( "Added Subpackages:" ),
1454 QRegExp( ".*" + suffix + "$" ),
1456 QString::null, // rejectButtonLabel
1457 true ); // showIfEmpty
1461 #include "YQPackageSelector.moc"