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 <qfiledialog.h>
41 #include <qmessagebox.h>
42 #include <qpushbutton.h>
43 #include <qsplitter.h>
44 #include <qtabwidget.h>
47 #define y2log_component "qt-pkg"
48 #include <ycp/y2log.h>
50 #include "QY2LayoutUtils.h"
52 #include "YQPackageSelector.h"
53 #include "YQPkgChangeLogView.h"
54 #include "YQPkgChangesDialog.h"
55 #include "YQPkgConflictDialog.h"
56 #include "YQPkgConflictList.h"
57 #include "YQPkgDependenciesView.h"
58 #include "YQPkgDescriptionView.h"
59 #include "YQPkgDiskUsageList.h"
60 #include "YQPkgDiskUsageWarningDialog.h"
61 #include "YQPkgFileListView.h"
62 #include "YQPkgRepoFilterView.h"
63 #include "YQPkgRepoList.h"
64 #include "YQPkgLangList.h"
65 #include "YQPkgList.h"
66 #include "YQPkgPatchFilterView.h"
67 #include "YQPkgPatchList.h"
68 #include "YQPkgPatternList.h"
69 #include "YQPkgProductDialog.h"
70 #include "YQPkgRpmGroupTagsFilterView.h"
71 #include "YQPkgSearchFilterView.h"
72 #include "YQPkgSelList.h"
73 #include "YQPkgStatusFilterView.h"
74 #include "YQPkgTechnicalDetailsView.h"
75 #include "YQPkgTextDialog.h"
76 #include "YQPkgUpdateProblemFilterView.h"
77 #include "YQPkgVersionsView.h"
78 #include "zypp/SysContent.h"
80 #include "QY2ComboTabWidget.h"
95 #define DEFAULT_EXPORT_FILE_NAME "user-packages.xml"
100 YQPackageSelector::YQPackageSelector( YWidget * parent,
102 : YQPackageSelectorBase( parent, modeFlags )
104 _showChangesDialog = true;
105 _autoDependenciesCheckBox = 0;
112 _pkgChangeLogView = 0;
113 _pkgDependenciesView = 0;
114 _pkgDescriptionView = 0;
115 _pkgFileListView = 0;
117 _pkgTechnicalDetailsView = 0;
118 _pkgVersionsView = 0;
119 _rpmGroupTagsFilterView = 0;
120 _searchFilterView = 0;
122 _statusFilterView = 0;
123 _updateProblemFilterView = 0;
124 _patchFilterView = 0;
126 _excludeDevelPkgs = 0;
127 _excludeDebugInfoPkgs = 0;
130 if ( onlineUpdateMode() ) y2milestone( "Online update mode" );
131 if ( updateMode() ) y2milestone( "Update mode" );
135 addMenus(); // Only after all widgets are created!
142 if ( _patchFilterView && onlineUpdateMode() )
144 if ( _filters && _patchFilterView && _patchList )
146 _filters->showPage( _patchFilterView );
147 _patchList->filter();
150 else if ( _repoFilterView && repoMode() )
152 if ( YQPkgRepoList::countEnabledRepositories() > 1 )
154 _filters->showPage( _repoFilterView );
155 _repoFilterView->filter();
157 else if ( _searchFilterView )
159 y2milestone( "No multiple repositories - falling back to search mode" );
160 _filters->showPage( _searchFilterView );
161 _searchFilterView->filter();
162 QTimer::singleShot( 0, _searchFilterView, SLOT( setFocus() ) );
165 else if ( _updateProblemFilterView )
167 _filters->showPage( _updateProblemFilterView );
168 _updateProblemFilterView->filter();
171 else if ( searchMode() && _searchFilterView )
173 _filters->showPage( _searchFilterView );
174 _searchFilterView->filter();
175 QTimer::singleShot( 0, _searchFilterView, SLOT( setFocus() ) );
177 else if ( summaryMode() && _statusFilterView )
179 _filters->showPage( _statusFilterView );
180 _statusFilterView->filter();
182 else if ( _patternList )
184 _filters->showPage( _patternList );
185 _patternList->filter();
189 _filters->showPage( _selList );
194 if ( _diskUsageList )
195 _diskUsageList->updateDiskUsage();
197 y2milestone( "PackageSelector init done" );
200 #if CHECK_DEPENDENCIES_ON_STARTUP
202 if ( ! testMode() && ! onlineUpdateMode() )
204 // Fire up the first dependency check in the main loop.
205 // Don't do this right away - wait until all initializations are finished.
206 QTimer::singleShot( 0, this, SLOT( resolveDependencies() ) );
213 YQPackageSelector::basicLayout()
215 layoutMenuBar( this );
217 QSplitter * outer_splitter = new QSplitter( QSplitter::Horizontal, this );
218 CHECK_PTR( outer_splitter );
220 QWidget * left_pane = layoutLeftPane ( outer_splitter );
221 QWidget * right_pane = layoutRightPane( outer_splitter );
223 outer_splitter->setResizeMode( left_pane, QSplitter::KeepSize );
224 outer_splitter->setResizeMode( right_pane, QSplitter::Stretch );
229 YQPackageSelector::layoutLeftPane( QWidget * parent )
231 QSplitter * splitter = new QSplitter( QSplitter::Vertical, parent );
232 CHECK_PTR( splitter );
233 splitter->setMargin( MARGIN );
235 QVBox * upper_vbox = new QVBox( splitter );
236 CHECK_PTR( upper_vbox );
237 layoutFilters( upper_vbox );
238 addVSpacing( upper_vbox, MARGIN );
240 QVBox * lower_vbox = new QVBox( splitter );
241 addVSpacing( lower_vbox, MARGIN );
242 _diskUsageList = new YQPkgDiskUsageList( lower_vbox );
243 CHECK_PTR( _diskUsageList );
245 splitter->setResizeMode( upper_vbox, QSplitter::Stretch );
246 splitter->setResizeMode( lower_vbox, QSplitter::FollowSizeHint );
253 YQPackageSelector::layoutFilters( QWidget * parent )
255 _filters = new QY2ComboTabWidget( _( "Fi<er:" ), parent );
256 CHECK_PTR( _filters );
260 // Update problem view
265 if ( YQPkgUpdateProblemFilterView::haveProblematicPackages()
268 _updateProblemFilterView = new YQPkgUpdateProblemFilterView( parent );
269 CHECK_PTR( _updateProblemFilterView );
270 _filters->addPage( _( "Update Problems" ), _updateProblemFilterView );
279 if ( onlineUpdateMode()
280 #if ALWAYS_SHOW_PATCHES_VIEW_IF_PATCHES_AVAILABLE
281 || ! zyppPool().empty<zypp::Patch>()
284 addPatchFilterView();
291 if ( ! zyppPool().empty<zypp::Pattern>() || testMode() )
293 _patternList = new YQPkgPatternList( parent, true );
294 CHECK_PTR( _patternList );
295 _filters->addPage( _( "Patterns" ), _patternList );
297 connect( _patternList, SIGNAL( statusChanged() ),
298 this, SLOT ( autoResolveDependencies() ) );
300 connect( this, SIGNAL( refresh() ),
301 _patternList, SLOT ( updateItemStates() ) );
303 if ( _pkgConflictDialog )
305 connect( _pkgConflictDialog, SIGNAL( updatePackages() ),
306 _patternList, SLOT ( updateItemStates() ) );
315 if ( ! zyppPool().empty<zypp::Selection>() || testMode() )
318 _selList = new YQPkgSelList( parent, true );
319 CHECK_PTR( _selList );
320 _filters->addPage( _( "Selections" ), _selList );
322 connect( _selList, SIGNAL( statusChanged() ),
323 this, SLOT ( autoResolveDependencies() ) );
325 connect( this, SIGNAL( refresh() ),
326 _selList, SLOT ( updateItemStates() ) );
328 if ( _pkgConflictDialog )
330 connect( _pkgConflictDialog, SIGNAL( updatePackages() ),
331 _selList, SLOT ( updateItemStates() ) );
337 // RPM group tags view
340 _rpmGroupTagsFilterView = new YQPkgRpmGroupTagsFilterView( parent );
341 CHECK_PTR( _rpmGroupTagsFilterView );
342 _filters->addPage( _( "Package Groups" ), _rpmGroupTagsFilterView );
344 connect( this, SIGNAL( loadData() ),
345 _rpmGroupTagsFilterView, SLOT ( filter() ) );
352 _langList = new YQPkgLangList( parent );
353 CHECK_PTR( _langList );
355 _filters->addPage( _( "Languages" ), _langList );
356 _langList->setSizePolicy( QSizePolicy( QSizePolicy::Ignored, QSizePolicy::Ignored ) ); // hor/vert
358 connect( _langList, SIGNAL( statusChanged() ),
359 this, SLOT ( autoResolveDependencies() ) );
361 connect( this, SIGNAL( refresh() ),
362 _langList, SLOT ( updateItemStates() ) );
369 _repoFilterView = new YQPkgRepoFilterView( parent );
370 CHECK_PTR( _repoFilterView );
371 _filters->addPage( _( "Repositories" ), _repoFilterView );
375 // Package search view
378 _searchFilterView = new YQPkgSearchFilterView( parent );
379 CHECK_PTR( _searchFilterView );
380 _filters->addPage( _( "Search" ), _searchFilterView );
384 // Status change view
387 _statusFilterView = new YQPkgStatusFilterView( parent );
388 CHECK_PTR( _statusFilterView );
389 _filters->addPage( _( "Installation Summary" ), _statusFilterView );
395 _filters->addPage( _( "Keywords" ), new QLabel( "Keywords\nfilter\n\nfor future use", 0 ) );
396 _filters->addPage( _( "MIME Types" ), new QLabel( "MIME Types\nfilter\n\nfor future use" , 0 ) );
403 YQPackageSelector::layoutRightPane( QWidget * parent )
405 QVBox * right_pane_vbox = new QVBox( parent );
406 CHECK_PTR( right_pane_vbox );
407 right_pane_vbox->setMargin( MARGIN );
409 QSplitter * splitter = new QSplitter( QSplitter::Vertical, right_pane_vbox );
410 CHECK_PTR( splitter );
412 QVBox * splitter_vbox = new QVBox( splitter );
413 CHECK_PTR( splitter_vbox );
414 layoutPkgList( splitter_vbox );
415 addVSpacing( splitter_vbox, MARGIN );
417 layoutDetailsViews( splitter );
419 layoutButtons( right_pane_vbox );
421 return right_pane_vbox;
426 YQPackageSelector::layoutPkgList( QWidget * parent )
428 _pkgList= new YQPkgList( parent );
429 CHECK_PTR( _pkgList );
431 connect( _pkgList, SIGNAL( statusChanged() ),
432 this, SLOT ( autoResolveDependencies() ) );
437 YQPackageSelector::layoutDetailsViews( QWidget * parent )
439 bool haveInstalledPkgs = YQPkgList::haveInstalledPkgs();
441 QVBox * details_vbox = new QVBox( parent );
442 CHECK_PTR( details_vbox );
443 details_vbox->setMinimumSize( 0, 0 );
445 addVSpacing( details_vbox, 8 );
447 _detailsViews = new QTabWidget( details_vbox );
448 CHECK_PTR( _detailsViews );
449 _detailsViews->setMargin( MARGIN );
451 // _detailsViews->setTabPosition( QTabWidget::Bottom );
458 _pkgDescriptionView = new YQPkgDescriptionView( _detailsViews );
459 CHECK_PTR( _pkgDescriptionView );
461 _detailsViews->addTab( _pkgDescriptionView, _( "D&escription" ) );
462 _detailsViews->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) ); // hor/vert
464 connect( _pkgList, SIGNAL( selectionChanged ( ZyppSel ) ),
465 _pkgDescriptionView, SLOT ( showDetailsIfVisible( ZyppSel ) ) );
471 _pkgTechnicalDetailsView = new YQPkgTechnicalDetailsView( _detailsViews );
472 CHECK_PTR( _pkgTechnicalDetailsView );
474 _detailsViews->addTab( _pkgTechnicalDetailsView, _( "&Technical Data" ) );
476 connect( _pkgList, SIGNAL( selectionChanged ( ZyppSel ) ),
477 _pkgTechnicalDetailsView, SLOT ( showDetailsIfVisible( ZyppSel ) ) );
484 _pkgDependenciesView = new YQPkgDependenciesView( _detailsViews );
485 CHECK_PTR( _pkgDependenciesView );
487 _detailsViews->addTab( _pkgDependenciesView, _( "Dependencies" ) );
488 _detailsViews->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) ); // hor/vert
490 connect( _pkgList, SIGNAL( selectionChanged ( ZyppSel ) ),
491 _pkgDependenciesView, SLOT ( showDetailsIfVisible( ZyppSel ) ) );
499 _pkgVersionsView = new YQPkgVersionsView( _detailsViews,
500 true ); // userCanSwitchVersions
501 CHECK_PTR( _pkgVersionsView );
503 _detailsViews->addTab( _pkgVersionsView, _( "&Versions" ) );
505 connect( _pkgList, SIGNAL( selectionChanged ( ZyppSel ) ),
506 _pkgVersionsView, SLOT ( showDetailsIfVisible( ZyppSel ) ) );
513 if ( haveInstalledPkgs ) // file list information is only available for installed pkgs
515 _pkgFileListView = new YQPkgFileListView( _detailsViews );
516 CHECK_PTR( _pkgFileListView );
518 _detailsViews->addTab( _pkgFileListView, _( "File List" ) );
519 _detailsViews->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) ); // hor/vert
521 connect( _pkgList, SIGNAL( selectionChanged ( ZyppSel ) ),
522 _pkgFileListView, SLOT ( showDetailsIfVisible( ZyppSel ) ) );
530 if ( haveInstalledPkgs ) // change log information is only available for installed pkgs
532 _pkgChangeLogView = new YQPkgChangeLogView( _detailsViews );
533 CHECK_PTR( _pkgChangeLogView );
535 _detailsViews->addTab( _pkgChangeLogView, _( "Change Log" ) );
536 _detailsViews->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) ); // hor/vert
538 connect( _pkgList, SIGNAL( selectionChanged ( ZyppSel ) ),
539 _pkgChangeLogView, SLOT ( showDetailsIfVisible( ZyppSel ) ) );
545 YQPackageSelector::layoutButtons( QWidget * parent )
547 QHBox * button_box = new QHBox( parent );
548 CHECK_PTR( button_box );
549 button_box->setSpacing( SPACING );
551 // Button: Dependency check
552 // Translators: Please keep this short!
553 _checkDependenciesButton = new QPushButton( _( "Chec&k" ), button_box );
554 CHECK_PTR( _checkDependenciesButton );
555 _checkDependenciesButton->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ) ); // hor/vert
556 _normalButtonBackground = _checkDependenciesButton->paletteBackgroundColor();
558 connect( _checkDependenciesButton, SIGNAL( clicked() ),
559 this, SLOT ( manualResolvePackageDependencies() ) );
562 // Checkbox: Automatically check dependencies for every package status change?
563 // Translators: Please keep this short!
564 _autoDependenciesCheckBox = new QCheckBox( _( "A&utocheck" ), button_box );
565 CHECK_PTR( _autoDependenciesCheckBox );
566 _autoDependenciesCheckBox->setChecked( AUTO_CHECK_DEPENDENCIES_DEFAULT );
568 addHStretch( button_box );
570 QPushButton * cancel_button = new QPushButton( _( "&Cancel" ), button_box );
571 CHECK_PTR( cancel_button );
572 cancel_button->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ) ); // hor/vert
574 connect( cancel_button, SIGNAL( clicked() ),
575 this, SLOT ( reject() ) );
578 QPushButton * accept_button = new QPushButton( _( "&Accept" ), button_box );
579 CHECK_PTR( accept_button );
580 accept_button->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ) ); // hor/vert
582 connect( accept_button, SIGNAL( clicked() ),
583 this, SLOT ( accept() ) );
585 button_box->setFixedHeight( button_box->sizeHint().height() );
590 YQPackageSelector::layoutMenuBar( QWidget * parent )
592 _menuBar = new QMenuBar( parent );
593 CHECK_PTR( _menuBar );
606 YQPackageSelector::addMenus()
612 _fileMenu = new QPopupMenu( _menuBar );
613 CHECK_PTR( _fileMenu );
614 _menuBar->insertItem( _( "&File" ), _fileMenu );
616 _fileMenu->insertItem( _( "&Import..." ), this, SLOT( pkgImport() ) );
617 _fileMenu->insertItem( _( "&Export..." ), this, SLOT( pkgExport() ) );
619 _fileMenu->insertSeparator();
621 _fileMenu->insertItem( _( "E&xit -- Discard Changes" ), this, SLOT( reject() ) );
622 _fileMenu->insertItem( _( "&Quit -- Save Changes" ), this, SLOT( accept() ) );
631 _viewMenu = new QPopupMenu( _menuBar );
632 CHECK_PTR( _viewMenu );
633 _menuBar->insertItem( _( "&View" ), _viewMenu );
635 // Translators: This is about packages ending in "-devel", so don't translate that "-devel"!
636 _viewShowDevelID = _viewMenu->insertItem( _( "Show -de&vel Packages" ),
637 this, SLOT( pkgExcludeRulesChanged( int ) ), Key_F7 );
638 _viewMenu->setItemChecked( _viewShowDevelID, true );
639 _excludeDevelPkgs = new YQPkgObjList::ExcludeRule( _pkgList, QRegExp( ".*-devel(-\\d+bit)?$" ), _pkgList->nameCol() );
640 CHECK_PTR( _excludeDevelPkgs );
641 _excludeDevelPkgs->enable( false );
643 // Translators: This is about packages ending in "-debuginfo", so don't translate that "-debuginfo"!
644 _viewShowDebugInfoID = _viewMenu->insertItem( _( "Show -&debuginfo Packages" ),
645 this, SLOT( pkgExcludeRulesChanged( int ) ), Key_F8 );
646 _viewMenu->setItemChecked( _viewShowDebugInfoID, true );
647 _excludeDebugInfoPkgs = new YQPkgObjList::ExcludeRule( _pkgList, QRegExp( ".*-debuginfo$" ), _pkgList->nameCol() );
648 CHECK_PTR( _excludeDebugInfoPkgs );
649 _excludeDebugInfoPkgs->enable( false );
656 _pkgMenu = new QPopupMenu( _menuBar );
657 CHECK_PTR( _pkgMenu );
658 _menuBar->insertItem( _( "&Package" ), _pkgMenu );
660 _pkgList->actionSetCurrentInstall->addTo( _pkgMenu );
661 _pkgList->actionSetCurrentDontInstall->addTo( _pkgMenu );
662 _pkgList->actionSetCurrentKeepInstalled->addTo( _pkgMenu );
663 _pkgList->actionSetCurrentDelete->addTo( _pkgMenu );
664 _pkgList->actionSetCurrentUpdate->addTo( _pkgMenu );
665 _pkgList->actionSetCurrentTaboo->addTo( _pkgMenu );
666 _pkgList->actionSetCurrentProtected->addTo( _pkgMenu );
668 _pkgMenu->insertSeparator();
670 _pkgList->actionInstallSourceRpm->addTo( _pkgMenu );
671 _pkgList->actionDontInstallSourceRpm->addTo( _pkgMenu );
673 _pkgMenu->insertSeparator();
674 QPopupMenu * submenu = _pkgList->addAllInListSubMenu( _pkgMenu );
675 CHECK_PTR( submenu );
677 submenu->insertSeparator();
678 _pkgList->actionInstallListSourceRpms->addTo( submenu );
679 _pkgList->actionDontInstallListSourceRpms->addTo( submenu );
683 // Submenu for all packages
686 submenu = new QPopupMenu( _pkgMenu );
687 CHECK_PTR( submenu );
689 // Translators: Unlike the "all in this list" submenu, this submenu
690 // refers to all packages globally, not only to those that are
691 // currently visible in the packages list.
692 _pkgMenu->insertItem( _( "All Packages" ), submenu );
694 submenu->insertItem( _( "Update if newer version available" ),
695 this, SLOT( globalUpdatePkg() ) );
697 submenu->insertItem( _( "Update unconditionally" ),
698 this, SLOT( globalUpdatePkgForce() ) );
708 _patchMenu = new QPopupMenu( _menuBar );
709 CHECK_PTR( _patchMenu );
710 _menuBar->insertItem( _( "&Patch" ), _patchMenu );
712 _patchList->actionSetCurrentInstall->addTo( _patchMenu );
713 _patchList->actionSetCurrentDontInstall->addTo( _patchMenu );
714 _patchList->actionSetCurrentKeepInstalled->addTo( _patchMenu );
715 #if ENABLE_DELETING_PATCHES
716 _patchList->actionSetCurrentDelete->addTo( _patchMenu );
718 _patchList->actionSetCurrentUpdate->addTo( _patchMenu );
719 _patchList->actionSetCurrentTaboo->addTo( _patchMenu );
721 _patchMenu->insertSeparator();
722 _patchList->addAllInListSubMenu( _patchMenu );
730 _extrasMenu = new QPopupMenu( _menuBar );
731 CHECK_PTR( _extrasMenu );
732 _menuBar->insertItem( _( "&Extras" ), _extrasMenu );
734 _extrasMenu->insertItem( _( "Show &Products" ), this, SLOT( showProducts() ) );
735 _extrasMenu->insertItem( _( "Show &Automatic Package Changes" ), this, SLOT( showAutoPkgList() ), CTRL + Key_A );
736 _extrasMenu->insertItem( _( "&Verify System" ), this, SLOT( verifySystem() ) );
738 _extrasMenu->insertSeparator();
740 // Translators: This is about packages ending in "-devel", so don't translate that "-devel"!
741 _extrasMenu->insertItem( _( "Install All Matching -&devel Packages" ), this, SLOT( installDevelPkgs() ) );
743 // Translators: This is about packages ending in "-debuginfo", so don't translate that "-debuginfo"!
744 _extrasMenu->insertItem( _( "Install All Matching -de&buginfo Packages" ), this, SLOT( installDebugInfoPkgs() ) );
746 _extrasMenu->insertSeparator();
748 if ( _pkgConflictDialog )
749 _extrasMenu->insertItem( _( "Generate Dependency Resolver &Test Case" ),
750 _pkgConflictDialog, SLOT( askCreateSolverTestCase() ) );
752 if ( _actionResetIgnoredDependencyProblems )
753 _actionResetIgnoredDependencyProblems->addTo( _extrasMenu );
758 _patchList->actionShowRawPatchInfo->addTo( _extrasMenu );
766 _helpMenu = new QPopupMenu( _menuBar );
767 CHECK_PTR( _helpMenu );
768 _menuBar->insertSeparator();
769 _menuBar->insertItem( _( "&Help" ), _helpMenu );
771 // Note: The help functions and their texts are moved out
772 // to a separate source file YQPackageSelectorHelp.cc
774 // Menu entry for help overview
775 _helpMenu->insertItem( _( "&Overview" ), this, SLOT( help() ), Key_F1 );
777 // Menu entry for help about used symbols ( icons )
778 _helpMenu->insertItem( _( "&Symbols" ), this, SLOT( symbolHelp() ), SHIFT + Key_F1 );
780 // Menu entry for keyboard help
781 _helpMenu->insertItem( _( "&Keys" ), this, SLOT( keyboardHelp() ) );
786 YQPackageSelector::connectFilter( QWidget * filter,
788 bool hasUpdateSignal )
790 if ( ! filter ) return;
791 if ( ! pkgList ) return;
795 connect( _filters, SIGNAL( currentChanged(QWidget *) ),
796 filter, SLOT ( filterIfVisible() ) );
799 connect( this, SIGNAL( refresh() ),
800 filter, SLOT ( filterIfVisible() ) );
802 connect( filter, SIGNAL( filterStart() ),
803 pkgList, SLOT ( clear() ) );
805 connect( filter, SIGNAL( filterMatch( ZyppSel, ZyppPkg ) ),
806 pkgList, SLOT ( addPkgItem ( ZyppSel, ZyppPkg ) ) );
808 connect( filter, SIGNAL( filterFinished() ),
809 pkgList, SLOT ( selectSomething() ) );
811 connect( filter, SIGNAL( filterFinished() ),
812 pkgList, SLOT ( logExcludeStatistics() ) );
815 if ( hasUpdateSignal )
817 connect( filter, SIGNAL( updatePackages() ),
818 pkgList, SLOT ( updateItemStates() ) );
820 if ( _diskUsageList )
822 connect( filter, SIGNAL( updatePackages() ),
823 _diskUsageList, SLOT ( updateDiskUsage() ) );
830 YQPackageSelector::makeConnections()
832 connect( this, SIGNAL( resolvingStarted() ),
833 this, SLOT ( animateCheckButton() ) );
835 connect( this, SIGNAL( resolvingFinished() ),
836 this, SLOT ( restoreCheckButton() ) );
838 connectFilter( _updateProblemFilterView, _pkgList, false );
839 connectFilter( _patternList, _pkgList );
840 connectFilter( _selList, _pkgList );
841 connectFilter( _repoFilterView, _pkgList, false );
842 connectFilter( _rpmGroupTagsFilterView, _pkgList, false );
843 connectFilter( _langList, _pkgList );
844 connectFilter( _statusFilterView, _pkgList, false );
845 connectFilter( _searchFilterView, _pkgList, false );
847 if ( _searchFilterView && _pkgList )
849 connect( _searchFilterView, SIGNAL( message( const QString & ) ),
850 _pkgList, SLOT ( message( const QString & ) ) );
853 if ( _repoFilterView && _pkgList )
855 connect( _repoFilterView, SIGNAL( filterNearMatch ( ZyppSel, ZyppPkg ) ),
856 _pkgList, SLOT ( addPkgItemDimmed ( ZyppSel, ZyppPkg ) ) );
859 if ( _pkgList && _diskUsageList )
862 connect( _pkgList, SIGNAL( statusChanged() ),
863 _diskUsageList, SLOT ( updateDiskUsage() ) );
871 // Connect package conflict dialog
874 if ( _pkgConflictDialog )
878 connect( _pkgConflictDialog, SIGNAL( updatePackages() ),
879 _pkgList, SLOT ( updateItemStates() ) );
884 connect( _pkgConflictDialog, SIGNAL( updatePackages() ),
885 _patternList, SLOT ( updateItemStates() ) );
890 connect( _pkgConflictDialog, SIGNAL( updatePackages() ),
891 _selList, SLOT ( updateItemStates() ) );
894 if ( _diskUsageList )
896 connect( _pkgConflictDialog, SIGNAL( updatePackages() ),
897 _diskUsageList, SLOT ( updateDiskUsage() ) );
903 // Connect package versions view
906 if ( _pkgVersionsView && _pkgList )
908 connect( _pkgVersionsView, SIGNAL( candidateChanged( ZyppObj ) ),
909 _pkgList, SLOT ( updateItemData() ) );
914 // Hotkey to enable "patches" filter view on the fly
917 QAccel * accel = new QAccel( this );
919 accel->connectItem( accel->insertItem( Key_F2 ),
920 this, SLOT( hotkeyInsertPatchFilterView() ) );
924 // Update actions just before opening menus
927 if ( _pkgMenu && _pkgList )
929 connect( _pkgMenu, SIGNAL( aboutToShow() ),
930 _pkgList, SLOT ( updateActions() ) );
933 if ( _patchMenu && _patchList )
935 connect( _patchMenu, SIGNAL( aboutToShow() ),
936 _patchList, SLOT ( updateActions() ) );
942 YQPackageSelector::animateCheckButton()
944 if ( _checkDependenciesButton )
946 _checkDependenciesButton->setPaletteBackgroundColor( QColor( 0xE0, 0xE0, 0xF8 ) );
947 _checkDependenciesButton->repaint();
953 YQPackageSelector::restoreCheckButton()
955 if ( _checkDependenciesButton )
956 _checkDependenciesButton->setPaletteBackgroundColor( _normalButtonBackground );
961 YQPackageSelector::autoResolveDependencies()
963 if ( _autoDependenciesCheckBox && ! _autoDependenciesCheckBox->isChecked() )
966 resolveDependencies();
971 YQPackageSelector::manualResolvePackageDependencies()
973 if ( ! _pkgConflictDialog )
975 y2error( "No package conflict dialog existing" );
976 return QDialog::Accepted;
979 YQUI::ui()->busyCursor();
980 int result = _pkgConflictDialog->solveAndShowConflicts();
981 YQUI::ui()->normalCursor();
983 #if DEPENDENCY_FEEDBACK_IF_OK
985 if ( result == QDialog::Accepted )
987 QMessageBox::information( this, "",
988 _( "All package dependencies are OK." ),
998 YQPackageSelector::addPatchFilterView()
1000 if ( ! _patchFilterView )
1002 _patchFilterView = new YQPkgPatchFilterView( this );
1003 CHECK_PTR( _patchFilterView );
1004 _filters->addPage( _( "Patches" ), _patchFilterView );
1006 _patchList = _patchFilterView->patchList();
1007 CHECK_PTR( _patchList );
1015 YQPackageSelector::hotkeyInsertPatchFilterView()
1017 if ( ! _patchFilterView )
1019 y2milestone( "Activating patches filter view" );
1021 addPatchFilterView();
1024 _filters->showPage( _patchFilterView );
1026 _patchList->filter();
1032 YQPackageSelector::connectPatchList()
1034 if ( _pkgList && _patchList )
1036 connectFilter( _patchList, _pkgList );
1038 connect( _patchList, SIGNAL( filterMatch ( const QString &, const QString &, FSize ) ),
1039 _pkgList, SLOT ( addPassiveItem( const QString &, const QString &, FSize ) ) );
1041 connect( _patchList, SIGNAL( statusChanged() ),
1042 this, SLOT ( autoResolveDependencies() ) );
1044 if ( _pkgConflictDialog )
1046 connect( _pkgConflictDialog,SIGNAL( updatePackages() ),
1047 _patchList, SLOT ( updateItemStates() ) );
1050 connect( this, SIGNAL( refresh() ),
1051 _patchList, SLOT ( updateItemStates() ) );
1058 YQPackageSelector::pkgExport()
1060 QString filename = YQUI::ui()->askForSaveFileName( QString( DEFAULT_EXPORT_FILE_NAME ), // startsWith
1061 QString( "*.xml;;*" ), // filter
1062 _( "Save Package List" ) );
1064 if ( ! filename.isEmpty() )
1066 zypp::syscontent::Writer writer;
1067 const zypp::ResPool & pool = zypp::getZYpp()->pool();
1069 // The ZYPP obfuscated C++ contest proudly presents:
1071 for_each( pool.begin(), pool.end(),
1072 boost::bind( &zypp::syscontent::Writer::addIf,
1073 boost::ref( writer ),
1075 // Yuck. What a mess.
1077 // Does anybody seriously believe this kind of thing is easier to read,
1078 // let alone use? Get real. This is an argument in favour of all C++
1079 // haters. And it's one that is really hard to counter.
1085 std::ofstream exportFile( toUTF8( filename ).c_str() );
1086 exportFile.exceptions( std::ios_base::badbit | std::ios_base::failbit );
1087 exportFile << writer;
1089 y2milestone( "Package list exported to %s", (const char *) filename );
1091 catch ( std::exception & exception )
1093 y2warning( "Error exporting package list to %s", (const char *) filename );
1095 // The export might have left over a partially written file.
1096 // Try to delete it. Don't care if it doesn't exist and unlink() fails.
1097 (void) unlink( (const char *) filename );
1100 QMessageBox::warning( this, // parent
1101 _( "Error" ), // caption
1102 _( "Error exporting package list to %1" ).arg( filename ),
1103 QMessageBox::Ok | QMessageBox::Default, // button0
1104 QMessageBox::NoButton, // button1
1105 QMessageBox::NoButton ); // button2
1112 YQPackageSelector::pkgImport()
1114 QString filename = QFileDialog::getOpenFileName( DEFAULT_EXPORT_FILE_NAME, // startsWith
1115 "*.xml+;;*", // filter
1118 _( "Load Package List" ) ); // caption
1120 if ( ! filename.isEmpty() )
1122 y2milestone( "Importing package list from %s", (const char *) filename );
1126 std::ifstream importFile( toUTF8( filename ).c_str() );
1127 zypp::syscontent::Reader reader( importFile );
1130 // Put reader contents into maps
1133 typedef zypp::syscontent::Reader::Entry ZyppReaderEntry;
1134 typedef std::pair<string, ZyppReaderEntry> ImportMapPair;
1136 map<string, ZyppReaderEntry> importPkg;
1137 map<string, ZyppReaderEntry> importPatterns;
1139 for ( zypp::syscontent::Reader::const_iterator it = reader.begin();
1143 string kind = it->kind();
1145 if ( kind == "package" ) importPkg.insert ( ImportMapPair( it->name(), *it ) );
1146 else if ( kind == "pattern" ) importPatterns.insert( ImportMapPair( it->name(), *it ) );
1149 y2debug( "Found %zu packages and %zu patterns in %s",
1151 importPatterns.size(),
1152 (const char *) filename );
1156 // Set status of all patterns and packages according to import map
1159 for ( ZyppPoolIterator it = zyppPatternsBegin();
1160 it != zyppPatternsEnd();
1163 ZyppSel selectable = *it;
1164 importSelectable( *it, importPatterns.find( selectable->name() ) != importPatterns.end(), "pattern" );
1167 for ( ZyppPoolIterator it = zyppPkgBegin();
1171 ZyppSel selectable = *it;
1172 importSelectable( *it, importPkg.find( selectable->name() ) != importPkg.end(), "package" );
1182 if ( _statusFilterView )
1184 // Switch to "Installation Summary" filter view
1186 _filters->showPage( _statusFilterView );
1187 _statusFilterView->filter();
1191 catch ( const zypp::Exception & exception )
1193 y2warning( "Error reading package list from %s", (const char *) filename );
1196 QMessageBox::warning( this, // parent
1197 _( "Error" ), // caption
1198 _( "Error loading package list from %1" ).arg( filename ),
1199 QMessageBox::Ok | QMessageBox::Default, // button0
1200 QMessageBox::NoButton, // button1
1201 QMessageBox::NoButton ); // button2
1208 YQPackageSelector::importSelectable( ZyppSel selectable,
1212 ZyppStatus oldStatus = selectable->status();
1213 ZyppStatus newStatus = oldStatus;
1218 // Make sure this selectable does not get installed
1221 switch ( oldStatus )
1225 case S_KeepInstalled:
1229 newStatus = oldStatus;
1234 newStatus = S_KeepInstalled;
1235 y2debug( "Keeping %s %s", kind, selectable->name().c_str() );
1241 if ( selectable->hasCandidateObj() )
1243 newStatus = S_Install;
1244 y2debug( "Adding %s %s", kind, selectable->name().c_str() );
1248 y2debug( "Can't add %s %s: No candidate",
1249 kind, selectable->name().c_str() );
1257 // Make sure this selectable does not get installed
1260 switch ( oldStatus )
1264 case S_KeepInstalled:
1269 y2debug( "Deleting %s %s", kind, selectable->name().c_str() );
1276 newStatus = oldStatus;
1281 if ( oldStatus != newStatus )
1282 selectable->set_status( newStatus );
1287 YQPackageSelector::globalUpdatePkg( bool force )
1292 int count = _pkgList->globalSetPkgStatus( S_Update, force,
1293 true ); // countOnly
1294 y2milestone( "%d pkgs found for update", count );
1296 if ( count >= GLOBAL_UPDATE_CONFIRMATION_THRESHOLD )
1298 if ( QMessageBox::question( this, "", // caption
1299 // Translators: %1 is the number of affected packages
1300 _( "%1 packages will be updated" ).arg( count ),
1301 _( "&Continue" ), _( "C&ancel" ),
1302 0, // defaultButtonNumber (from 0)
1303 1 ) // escapeButtonNumber
1310 (void) _pkgList->globalSetPkgStatus( S_Update, force,
1311 false ); // countOnly
1313 if ( _statusFilterView )
1315 _filters->showPage( _statusFilterView );
1316 _statusFilterView->clear();
1317 _statusFilterView->showTransactions();
1318 _statusFilterView->filter();
1324 YQPackageSelector::showProducts()
1326 YQPkgProductDialog::showProductDialog();
1330 YQPackageSelector::installDevelPkgs()
1332 installSubPkgs( "-devel" );
1337 YQPackageSelector::installDebugInfoPkgs()
1339 installSubPkgs( "-debuginfo" );
1344 YQPackageSelector::pkgExcludeRulesChanged( int menuItemID )
1346 if ( _viewMenu && _pkgList )
1348 _viewMenu->setItemChecked( menuItemID, ! _viewMenu->isItemChecked( menuItemID ) );
1350 if ( _excludeDevelPkgs )
1351 _excludeDevelPkgs->enable( ! _viewMenu->isItemChecked( _viewShowDevelID ) );
1353 if ( _excludeDebugInfoPkgs )
1354 _excludeDebugInfoPkgs->enable( ! _viewMenu->isItemChecked( _viewShowDebugInfoID ) );
1356 _pkgList->applyExcludeRules();
1362 YQPackageSelector::installSubPkgs( const QString suffix )
1364 // Find all matching packages and put them into a QMap
1366 QMap<QString, ZyppSel> subPkgs;
1368 for ( ZyppPoolIterator it = zyppPkgBegin();
1372 QString name = (*it)->name().c_str();
1374 if ( name.endsWith( suffix ) )
1376 subPkgs[ name ] = *it;
1378 y2debug( "Found subpackage: %s", (const char *) name );
1383 // Now go through all packages and look if there is a corresponding subpackage in the QMap
1385 for ( ZyppPoolIterator it = zyppPkgBegin();
1389 QString name = (*it)->name().c_str();
1391 if ( subPkgs.contains( name + suffix ) )
1393 QString subPkgName( name + suffix );
1394 ZyppSel subPkg = subPkgs[ subPkgName ];
1396 switch ( (*it)->status() )
1403 // Don't install the subpackage
1404 y2milestone( "Ignoring unwanted subpackage %s", (const char *) subPkgName );
1409 case S_KeepInstalled:
1411 // Install the subpackage, but don't try to update it
1413 if ( ! subPkg->installedObj() )
1415 subPkg->set_status( S_Install );
1416 y2milestone( "Installing subpackage %s", (const char *) subPkgName );
1424 // Install or update the subpackage
1426 if ( ! subPkg->installedObj() )
1428 subPkg->set_status( S_Install );
1429 y2milestone( "Installing subpackage %s", (const char *) subPkgName );
1433 subPkg->set_status( S_Update );
1434 y2milestone( "Updating subpackage %s", (const char *) subPkgName );
1438 // Intentionally omitting 'default' branch so the compiler can
1439 // catch unhandled enum states
1445 if ( _filters && _statusFilterView )
1447 _filters->showPage( _statusFilterView );
1448 _statusFilterView->filter();
1451 YQPkgChangesDialog::showChangesDialog( _( "Added Subpackages:" ),
1452 QRegExp( ".*" + suffix + "$" ),
1454 QString::null, // rejectButtonLabel
1455 true ); // showIfEmpty
1459 #include "YQPackageSelector.moc"