43 #define CHECK_DEPENDENCIES_ON_STARTUP 1
44 #define DEPENDENCY_FEEDBACK_IF_OK 1
45 #define AUTO_CHECK_DEPENDENCIES_DEFAULT true
46 #define ALWAYS_SHOW_PATCHES_VIEW_IF_PATCHES_AVAILABLE 0
47 #define GLOBAL_UPDATE_CONFIRMATION_THRESHOLD 20
48 #define ENABLE_SOURCE_RPMS 0
49 #define BRAINDEAD_LIB_NAMING_SCHEME 1
50 #define MARGIN 6 // around the widget
51 #define SPACING_BELOW_MENU_BAR 4
52 #define SPLITTER_HALF_SPACING 4
56 #include <boost/bind.hpp>
58 #include <QHBoxLayout>
59 #include <QVBoxLayout>
62 #include <QApplication>
65 #include <QFileDialog>
69 #include <QMessageBox>
70 #include <QPushButton>
77 #define YUILogComponent "qt-pkg"
80 #include "QY2LayoutUtils.h"
83 #include "YQPackageSelector.h"
84 #include "YQPkgChangeLogView.h"
85 #include "YQPkgChangesDialog.h"
86 #include "YQPkgConflictDialog.h"
87 #include "YQPkgConflictList.h"
88 #include "YQPkgDependenciesView.h"
89 #include "YQPkgDescriptionView.h"
90 #include "YQPkgDiskUsageList.h"
91 #include "YQPkgDiskUsageWarningDialog.h"
92 #include "YQPkgFileListView.h"
93 #include "YQPkgFilterTab.h"
94 #include "YQPkgHistoryDialog.h"
95 #include "YQPkgLangList.h"
96 #include "YQPkgList.h"
97 #include "YQPkgPackageKitGroupsFilterView.h"
98 #include "YQPkgPatchFilterView.h"
99 #include "YQPkgPatchList.h"
100 #include "YQPkgPatternList.h"
101 #include "YQPkgProductDialog.h"
102 #include "YQPkgRepoFilterView.h"
103 #include "YQPkgRepoList.h"
104 #include "YQPkgRpmGroupTagsFilterView.h"
105 #include "YQPkgSearchFilterView.h"
106 #include "YQPkgStatusFilterView.h"
107 #include "YQPkgTechnicalDetailsView.h"
108 #include "YQPkgTextDialog.h"
109 #include "YQPkgUpdateProblemFilterView.h"
110 #include "YQPkgVersionsView.h"
112 #include "zypp/SysContent.h"
113 #include "zypp/base/String.h"
115 #include "QY2ComboTabWidget.h"
116 #include "YQDialog.h"
117 #include "YQApplication.h"
130 #define DEFAULT_EXPORT_FILE_NAME "user-packages.xml"
131 #define FAST_SOLVER 1
133 #define SETTINGS_DIR "YaST2"
138 YQPackageSelector::YQPackageSelector( YWidget * parent,
142 _showChangesDialog =
true;
143 _autoDependenciesAction = 0;
147 _packageKitGroupsFilterView = 0;
148 _patchFilterView = 0;
151 _pkgChangeLogView = 0;
152 _pkgDependenciesView = 0;
153 _pkgDescriptionView = 0;
154 _pkgFileListView = 0;
156 _pkgTechnicalDetailsView = 0;
157 _pkgVersionsView = 0;
159 _rpmGroupTagsFilterView = 0;
160 _searchFilterView = 0;
161 _statusFilterView = 0;
162 _updateProblemFilterView = 0;
163 _excludeDevelPkgs = 0;
164 _excludeDebugInfoPkgs = 0;
166 yuiMilestone() <<
"This is libyui-qt-pkg " << VERSION << std::endl;
168 if ( onlineUpdateMode() ) yuiMilestone() <<
"Online update mode" << std::endl;
169 if ( updateMode() ) yuiMilestone() <<
"Update mode" << std::endl;
177 _filters->loadSettings();
178 bool pagesRestored = _filters->tabCount() > 0;
183 if ( ! pagesRestored )
185 yuiDebug() <<
"No page configuration saved, using fallbacks" << std::endl;
191 if ( _searchFilterView ) _filters->showPage( _searchFilterView );
193 if ( ! searchMode() && ! summaryMode()
194 && _patternList ) _filters->showPage( _patternList );
195 else if ( _rpmGroupTagsFilterView ) _filters->showPage( _rpmGroupTagsFilterView );
197 if ( _statusFilterView ) _filters->showPage( _statusFilterView );
205 if ( _patchFilterView && onlineUpdateMode() )
207 if ( _patchFilterView && _patchList )
209 _filters->showPage( _patchFilterView );
210 _patchList->filter();
213 else if ( _repoFilterView && repoMode() )
217 _filters->showPage( _repoFilterView );
218 _repoFilterView->filter();
221 else if ( _updateProblemFilterView )
223 _filters->showPage( _updateProblemFilterView );
224 _updateProblemFilterView->filter();
226 else if ( searchMode() && _searchFilterView )
228 _filters->showPage( _searchFilterView );
229 _searchFilterView->filter();
230 QTimer::singleShot( 0, _searchFilterView, SLOT( setFocus() ) );
232 else if ( summaryMode() && _statusFilterView )
234 _filters->showPage( _statusFilterView );
235 _statusFilterView->filter();
236 _pkgList->selectNextItem();
238 else if ( _patternList )
240 _filters->showPage( _patternList );
241 _patternList->filter();
245 if ( _filters->diskUsageList() )
246 _filters->diskUsageList()->updateDiskUsage();
248 yuiMilestone() <<
"PackageSelector init done" << std::endl;
251 #if CHECK_DEPENDENCIES_ON_STARTUP
257 QTimer::singleShot( 0,
this, SLOT( resolveDependencies() ) );
269 #define PREFIX "/usr/"
270 return zypp::str::form(
"%s/share/icons/hicolor/%dx%d/apps/%s.png",
271 PREFIX, size, size, name.c_str() );
276 YQPackageSelector::basicLayout()
278 QVBoxLayout *layout =
new QVBoxLayout();
280 layout->setContentsMargins( MARGIN,
284 layout->setSpacing( SPACING_BELOW_MENU_BAR );
285 layoutMenuBar(
this );
287 QString settingsName =
"YQPackageSelector";
289 if ( onlineUpdateMode() ) settingsName =
"YQOnlineUpdate";
290 if ( updateMode() ) settingsName =
"YQSystemUpdate";
293 YUI_CHECK_NEW( _filters );
295 layout->addWidget( _filters );
296 layoutFilters(
this );
297 layoutRightPane( _filters->
rightPane() );
302 YQPackageSelector::layoutFilters( QWidget *parent )
314 YUI_CHECK_NEW( _updateProblemFilterView );
315 _filters->
addPage( _(
"&Update Problems" ), _updateProblemFilterView,
"update_problems" );
324 if ( onlineUpdateMode()
325 #
if ALWAYS_SHOW_PATCHES_VIEW_IF_PATCHES_AVAILABLE
326 || ! zyppPool().empty<zypp::Patch>()
338 if ( ! zyppPool().empty<zypp::Pattern>() || testMode() )
341 YUI_CHECK_NEW( _patternList );
342 _filters->
addPage( _(
"Patter&ns" ), _patternList,
"patterns" );
344 connect( _patternList, SIGNAL( statusChanged() ),
347 connect(
this, SIGNAL(
refresh() ),
348 _patternList, SLOT ( updateItemStates() ) );
350 if ( _pkgConflictDialog )
352 connect( _pkgConflictDialog, SIGNAL( updatePackages() ),
353 _patternList, SLOT ( updateItemStates() ) );
363 YUI_CHECK_NEW( _packageKitGroupsFilterView );
364 _filters->
addPage( _(
"Package &Groups" ), _packageKitGroupsFilterView,
"package_groups" );
366 connect(
this, SIGNAL(
loadData() ),
367 _packageKitGroupsFilterView, SLOT ( filter() ) );
375 YUI_CHECK_NEW( _rpmGroupTagsFilterView );
376 _filters->
addPage( _(
"&RPM Groups" ), _rpmGroupTagsFilterView,
"rpm_groups" );
378 connect(
this, SIGNAL(
loadData() ),
379 _rpmGroupTagsFilterView, SLOT ( filter() ) );
387 YUI_CHECK_NEW( _langList );
389 _filters->
addPage( _(
"&Languages" ), _langList,
"languages" );
390 _langList->setSizePolicy( QSizePolicy( QSizePolicy::Ignored, QSizePolicy::Ignored ) );
392 connect( _langList, SIGNAL( statusChanged() ),
395 connect(
this, SIGNAL(
refresh() ),
396 _langList, SLOT ( updateItemStates() ) );
404 YUI_CHECK_NEW( _repoFilterView );
405 _filters->
addPage( _(
"&Repositories" ), _repoFilterView,
"repos" );
417 YUI_CHECK_NEW( _searchFilterView );
418 _filters->
addPage( _(
"S&earch" ), _searchFilterView,
"search" );
425 _filters->
addPage( _(
"&Keywords" ),
new QLabel(
"Keywords\nfilter\n\nfor future use",
this ),
"keywords" );
433 YUI_CHECK_NEW( _statusFilterView );
434 _filters->
addPage( _(
"&Installation Summary" ), _statusFilterView,
"inst_summary" );
438 YQPackageSelector::~YQPackageSelector()
444 YQPackageSelector::layoutRightPane( QWidget *parent )
446 QVBoxLayout *layout =
new QVBoxLayout( parent );
447 YUI_CHECK_NEW( layout );
448 layout->setContentsMargins( SPLITTER_HALF_SPACING,
453 QSplitter * splitter =
new QSplitter( Qt::Vertical, parent );
454 YUI_CHECK_NEW( splitter );
455 layout->addWidget(splitter);
457 layoutPkgList( splitter );
458 layoutDetailsViews( splitter );
459 layoutButtons( parent );
466 YQPackageSelector::layoutPkgList( QWidget *parent )
470 QWidget *_notificationsContainer =
new QWidget(parent);
471 QVBoxLayout *layout =
new QVBoxLayout(_notificationsContainer);
473 _repoUpgradingLabel =
new QLabel(_notificationsContainer);
474 _repoUpgradingLabel->setTextFormat(Qt::RichText);
475 _repoUpgradingLabel->setWordWrap(
true);
476 _repoUpgradingLabel->setVisible(
false);
478 _repoUpgradeLabel =
new QLabel(_notificationsContainer);
479 _repoUpgradeLabel->setTextFormat(Qt::RichText);
480 _repoUpgradeLabel->setStyleSheet(
"background-color: "+ QApplication::palette().color(QPalette::ToolTipBase).name() +
"; border: 1px solid black;");
481 _repoUpgradeLabel->setWordWrap(
true);
482 _repoUpgradeLabel->setVisible(
false);
484 layout->addWidget(_repoUpgradingLabel);
485 layout->addWidget(_repoUpgradeLabel);
497 YUI_CHECK_NEW( _pkgList );
499 connect( _pkgList, SIGNAL( statusChanged() ),
504 YQPackageSelector::layoutDetailsViews( QWidget *parent )
509 _detailsViews =
new QTabWidget( parent );
510 YUI_CHECK_NEW( _detailsViews );
517 YUI_CHECK_NEW( _pkgDescriptionView );
519 _detailsViews->addTab( _pkgDescriptionView, _(
"D&escription" ) );
520 _detailsViews->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) );
522 connect( _pkgList, SIGNAL( currentItemChanged ( ZyppSel ) ),
523 _pkgDescriptionView, SLOT ( showDetailsIfVisible( ZyppSel ) ) );
530 YUI_CHECK_NEW( _pkgTechnicalDetailsView );
532 _detailsViews->addTab( _pkgTechnicalDetailsView, _(
"&Technical Data" ) );
534 connect( _pkgList, SIGNAL( currentItemChanged ( ZyppSel ) ),
535 _pkgTechnicalDetailsView, SLOT ( showDetailsIfVisible( ZyppSel ) ) );
543 YUI_CHECK_NEW( _pkgDependenciesView );
545 _detailsViews->addTab( _pkgDependenciesView, _(
"Dependencies" ) );
546 _detailsViews->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) );
548 connect( _pkgList, SIGNAL( currentItemChanged ( ZyppSel ) ),
549 _pkgDependenciesView, SLOT ( showDetailsIfVisible( ZyppSel ) ) );
559 YUI_CHECK_NEW( _pkgVersionsView );
561 _detailsViews->addTab( _pkgVersionsView, _(
"&Versions" ) );
563 connect( _pkgList, SIGNAL( currentItemChanged ( ZyppSel ) ),
564 _pkgVersionsView, SLOT ( showDetailsIfVisible( ZyppSel ) ) );
566 connect( _pkgList, SIGNAL( statusChanged() ),
567 _pkgVersionsView, SLOT ( slotRefreshDetails() ) );
574 if ( haveInstalledPkgs )
577 YUI_CHECK_NEW( _pkgFileListView );
579 _detailsViews->addTab( _pkgFileListView, _(
"File List" ) );
580 _detailsViews->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) );
582 connect( _pkgList, SIGNAL( currentItemChanged ( ZyppSel ) ),
583 _pkgFileListView, SLOT ( showDetailsIfVisible( ZyppSel ) ) );
591 if ( haveInstalledPkgs )
594 YUI_CHECK_NEW( _pkgChangeLogView );
596 _detailsViews->addTab( _pkgChangeLogView, _(
"Change Log" ) );
597 _detailsViews->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) );
599 connect( _pkgList, SIGNAL( currentItemChanged ( ZyppSel ) ),
600 _pkgChangeLogView, SLOT ( showDetailsIfVisible( ZyppSel ) ) );
606 YQPackageSelector::layoutButtons( QWidget *parent )
608 QWidget * button_box =
new QWidget( parent );
609 YUI_CHECK_NEW( button_box );
610 parent->layout()->addWidget( button_box );
612 QHBoxLayout * layout =
new QHBoxLayout( button_box );
613 YUI_CHECK_NEW( layout );
615 button_box->setLayout( layout );
616 layout->setContentsMargins( 2,
621 layout->addStretch();
623 QPushButton * cancel_button =
new QPushButton( _(
"&Cancel" ), button_box );
624 YUI_CHECK_NEW( cancel_button );
625 layout->addWidget(cancel_button);
627 cancel_button->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ) );
629 connect( cancel_button, SIGNAL( clicked() ),
630 this, SLOT (
reject() ) );
633 QPushButton * accept_button =
new QPushButton( _(
"&Accept" ), button_box );
634 YUI_CHECK_NEW( accept_button );
635 layout->addWidget(accept_button);
636 accept_button->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ) );
638 connect( accept_button, SIGNAL( clicked() ),
639 this, SLOT (
accept() ) );
641 button_box->setFixedHeight( button_box->sizeHint().height() );
646 YQPackageSelector::layoutMenuBar( QWidget *parent )
648 _menuBar =
new QMenuBar( parent );
649 YUI_CHECK_NEW( _menuBar );
650 parent->layout()->addWidget(_menuBar);
673 _fileMenu =
new QMenu( _menuBar );
674 YUI_CHECK_NEW( _fileMenu );
675 QAction * action = _menuBar->addMenu( _fileMenu );
676 action->setText( _(
"&File" ));
678 _fileMenu->addAction( _(
"&Import..." ),
this, SLOT(
pkgImport() ) );
679 _fileMenu->addAction( _(
"&Export..." ),
this, SLOT(
pkgExport() ) );
681 _fileMenu->addSeparator();
683 _fileMenu->addAction( _(
"E&xit -- Discard Changes" ),
this, SLOT(
reject() ) );
684 _fileMenu->addAction( _(
"&Quit -- Save Changes" ),
this, SLOT(
accept() ) );
693 _pkgMenu =
new QMenu( _menuBar );
694 YUI_CHECK_NEW( _pkgMenu );
695 action = _menuBar->addMenu( _pkgMenu );
696 action->setText(_(
"&Package" ));
698 _pkgMenu->addAction(_pkgList->actionSetCurrentInstall);
699 _pkgMenu->addAction(_pkgList->actionSetCurrentDontInstall);
700 _pkgMenu->addAction(_pkgList->actionSetCurrentKeepInstalled);
701 _pkgMenu->addAction(_pkgList->actionSetCurrentDelete);
702 _pkgMenu->addAction(_pkgList->actionSetCurrentUpdate);
703 _pkgMenu->addAction(_pkgList->actionSetCurrentUpdateForce);
704 _pkgMenu->addAction(_pkgList->actionSetCurrentTaboo);
705 _pkgMenu->addAction(_pkgList->actionShowCurrentSolverInfo);
707 #if ENABLE_SOURCE_RPMS
708 _pkgMenu->addSeparator();
710 _pkgMenu->addAction(_pkgList->actionInstallSourceRpm);
711 _pkgMenu->addAction(_pkgList->actionDontInstallSourceRpm);
714 _pkgMenu->addSeparator();
716 YUI_CHECK_NEW( submenu );
718 #if ENABLE_SOURCE_RPMS
719 submenu->addSeparator();
721 _pkgMenu->addAction(_pkgList->actionInstallListSourceRpms);
722 _pkgMenu->addAction(_pkgList->actionDontInstallListSourceRpms);
729 submenu =
new QMenu( _pkgMenu );
730 YUI_CHECK_NEW( submenu );
735 action = _pkgMenu->addMenu( submenu );
736 action->setText(_(
"All Packages" ));
738 submenu->addAction( _(
"Update if newer version available" ),
741 submenu->addAction( _(
"Update unconditionally" ),
752 _patchMenu =
new QMenu( _menuBar );
753 YUI_CHECK_NEW( _patchMenu );
754 action = _menuBar->addMenu( _patchMenu );
755 action->setText(_(
"&Patch" ));
757 _patchMenu->addAction(_patchList->actionSetCurrentInstall);
758 _patchMenu->addAction(_patchList->actionSetCurrentDontInstall);
759 _patchMenu->addAction(_patchList->actionSetCurrentKeepInstalled);
761 #if ENABLE_DELETING_PATCHES
762 _patchMenu->addAction(_patchList->actionSetCurrentDelete);
764 _patchMenu->addAction(_patchList->actionSetCurrentUpdate);
765 _patchMenu->addAction(_patchList->actionSetCurrentUpdateForce);
766 _patchMenu->addAction(_patchList->actionSetCurrentTaboo);
768 _patchMenu->addSeparator();
777 if ( repoMgrEnabled() )
779 _configMenu =
new QMenu( _menuBar );
780 YUI_CHECK_NEW( _configMenu );
781 action = _menuBar->addMenu( _configMenu );
782 action->setText(_(
"Confi&guration" ));
783 _configMenu->addAction( _(
"&Repositories..." ),
this, SLOT(
repoManager() ), Qt::CTRL + Qt::Key_R );
785 _configMenu->addAction( _(
"Search Packages on &Web..." ),
this, SLOT( webpinSearch() ), Qt::CTRL + Qt::Key_W );
792 _dependencyMenu =
new QMenu( _menuBar );
793 YUI_CHECK_NEW( _dependencyMenu );
794 action = _menuBar->addMenu( _dependencyMenu );
795 action->setText(_(
"&Dependencies" ));
798 _autoDependenciesAction =
new QAction( _(
"&Autocheck" ),
this );
799 _autoDependenciesAction->setCheckable(
true );
800 _dependencyMenu->addAction( _autoDependenciesAction );
807 _optionsMenu =
new QMenu( _menuBar );
808 YUI_CHECK_NEW( _optionsMenu );
809 action = _menuBar->addMenu( _optionsMenu );
811 action->setText(_(
"&Options" ));
814 _showDevelAction = _optionsMenu->addAction( _(
"Show -de&vel Packages" ),
815 this, SLOT( pkgExcludeDevelChanged(
bool ) ), Qt::Key_F7 );
816 _showDevelAction->setCheckable(
true);
818 _excludeDevelPkgs =
new YQPkgObjList::ExcludeRule( _pkgList, QRegExp(
".*(\\d+bit)?-devel(-\\d+bit)?$" ), _pkgList->nameCol() );
819 YUI_CHECK_NEW( _excludeDevelPkgs );
820 _excludeDevelPkgs->
enable(
false );
823 _showDebugAction = _optionsMenu->addAction( _(
"Show -&debuginfo/-debugsource Packages" ),
825 _showDebugAction->setCheckable(
true);
826 _excludeDebugInfoPkgs =
new YQPkgObjList::ExcludeRule( _pkgList, QRegExp(
".*(-\\d+bit)?-(debuginfo|debugsource)(-32bit)?$" ), _pkgList->nameCol() );
827 YUI_CHECK_NEW( _excludeDebugInfoPkgs );
828 _excludeDebugInfoPkgs->
enable(
false );
831 _verifySystemModeAction = _optionsMenu->addAction( _(
"&System Verification Mode" ),
832 this, SLOT( pkgVerifySytemModeChanged(
bool ) ) );
833 _verifySystemModeAction->setCheckable(
true);
836 _ignoreAlreadyRecommendAction = _optionsMenu->addAction( _(
"&Ignore Recommended Packages for Already Installed Packages" ),
837 this, SLOT( pkgIgnoreAlreadyRecommendedChanged(
bool ) ) );
838 _ignoreAlreadyRecommendAction->setCheckable(
true);
842 _cleanDepsOnRemoveAction = _optionsMenu->addAction( _(
"&Cleanup when deleting packages" ),
843 this, SLOT( pkgCleanDepsOnRemoveChanged(
bool ) ) );
844 _cleanDepsOnRemoveAction->setCheckable(
true);
846 _allowVendorChangeAction = _optionsMenu->addAction( _(
"&Allow vendor change" ),
847 this, SLOT( pkgAllowVendorChangeChanged(
bool ) ) );
848 _allowVendorChangeAction->setCheckable(
true);
856 _extrasMenu =
new QMenu( _menuBar );
857 YUI_CHECK_NEW( _extrasMenu );
858 action = _menuBar->addMenu( _extrasMenu );
859 action->setText(_(
"E&xtras" ));
861 _extrasMenu->addAction( _(
"Show &Products" ),
this, SLOT(
showProducts() ) );
862 _extrasMenu->addAction( _(
"Show P&ackage Changes" ),
this, SLOT(
showAutoPkgList() ), Qt::CTRL + Qt::Key_A );
863 _extrasMenu->addAction( _(
"Show &History" ),
this, SLOT(
showHistory() ) );
865 _extrasMenu->addSeparator();
867 #if BRAINDEAD_LIB_NAMING_SCHEME
871 _extrasMenu->addAction( _(
"Install All Matching -&devel Packages" ),
this, SLOT(
installDevelPkgs() ) );
875 _extrasMenu->addAction( _(
"Install All Matching -de&buginfo Packages" ),
this, SLOT(
installDebugInfoPkgs() ) );
878 _extrasMenu->addAction( _(
"Install All Matching -debug&source Packages" ),
this, SLOT(
installDebugSourcePkgs() ) );
880 _extrasMenu->addSeparator();
882 if ( _pkgConflictDialog )
883 _extrasMenu->addAction( _(
"Generate Dependency Resolver &Test Case" ),
884 _pkgConflictDialog, SLOT( askCreateSolverTestCase() ) );
886 if ( _actionResetIgnoredDependencyProblems )
887 _extrasMenu->addAction(_actionResetIgnoredDependencyProblems);
891 _extrasMenu->addAction(_patchList->actionShowRawPatchInfo);
899 _helpMenu =
new QMenu( _menuBar );
900 YUI_CHECK_NEW( _helpMenu );
901 _menuBar->addSeparator();
902 action = _menuBar->addMenu( _helpMenu );
903 action->setText(_(
"&Help" ));
909 _helpMenu->addAction( _(
"&Overview" ),
this, SLOT(
help() ), Qt::Key_F1 );
912 _helpMenu->addAction( _(
"&Symbols" ),
this, SLOT(
symbolHelp() ), Qt::SHIFT + Qt::Key_F1 );
915 _helpMenu->addAction( _(
"&Keys" ),
this, SLOT(
keyboardHelp() ) );
922 bool hasUpdateSignal )
924 if ( ! filter )
return;
925 if ( ! pkgList )
return;
929 connect( _filters, SIGNAL( currentChanged(QWidget *) ),
930 filter, SLOT ( filterIfVisible() ) );
933 connect(
this, SIGNAL(
refresh() ),
934 filter, SLOT ( filterIfVisible() ) );
936 connect( filter, SIGNAL( filterStart() ),
937 pkgList, SLOT ( clear() ) );
939 connect( filter, SIGNAL( filterMatch( ZyppSel, ZyppPkg ) ),
940 pkgList, SLOT ( addPkgItem ( ZyppSel, ZyppPkg ) ) );
942 connect( filter, SIGNAL( filterFinished() ),
943 pkgList, SLOT ( resort() ) );
945 connect( filter, SIGNAL( filterFinished() ),
946 pkgList, SLOT ( selectSomething() ) );
948 connect( filter, SIGNAL( filterFinished() ),
949 pkgList, SLOT ( logExcludeStatistics() ) );
951 connect( filter, SIGNAL( filterFinished() ),
952 pkgList, SLOT ( setFocus() ) );
957 connect( filter, SIGNAL( updatePackages() ),
958 pkgList, SLOT ( updateItemStates() ) );
962 connect( filter, SIGNAL( updatePackages() ),
976 connectFilter( _packageKitGroupsFilterView, _pkgList,
false );
984 if ( _searchFilterView && _pkgList )
986 connect( _searchFilterView, SIGNAL( message(
const QString & ) ),
987 _pkgList, SLOT ( message(
const QString & ) ) );
990 if ( _repoFilterView && _pkgList )
992 connect( _repoFilterView, SIGNAL( filterNearMatch ( ZyppSel, ZyppPkg ) ),
993 _pkgList, SLOT ( addPkgItemDimmed ( ZyppSel, ZyppPkg ) ) );
999 connect( _pkgList, SIGNAL( statusChanged() ),
1011 if ( _pkgConflictDialog )
1015 connect( _pkgConflictDialog, SIGNAL( updatePackages() ),
1016 _pkgList, SLOT ( updateItemStates() ) );
1021 connect( _pkgConflictDialog, SIGNAL( updatePackages() ),
1022 _patternList, SLOT ( updateItemStates() ) );
1028 connect( _pkgConflictDialog, SIGNAL( updatePackages() ),
1038 if ( _pkgVersionsView && _pkgList )
1040 connect( _pkgVersionsView, SIGNAL( candidateChanged( ZyppObj ) ),
1041 _pkgList, SLOT ( updateItemData() ) );
1043 connect( _pkgVersionsView, SIGNAL( multiversionSelectionChanged( ) ),
1044 _pkgList, SLOT ( updateItemData() ) );
1053 YUI_CHECK_NEW( accel );
1059 if ( _pkgMenu && _pkgList )
1061 connect( _pkgMenu, SIGNAL( aboutToShow() ),
1062 _pkgList, SLOT ( updateActions() ) );
1065 if ( _patchMenu && _patchList )
1067 connect( _patchMenu, SIGNAL( aboutToShow() ),
1068 _patchList, SLOT ( updateActions() ) );
1076 if ( _autoDependenciesAction && ! _autoDependenciesAction->isChecked() )
1086 if ( ! _pkgConflictDialog )
1088 yuiError() <<
"No package conflict dialog existing" << std::endl;
1089 return QDialog::Accepted;
1092 YQUI::ui()->busyCursor();
1094 YQUI::ui()->normalCursor();
1096 #if DEPENDENCY_FEEDBACK_IF_OK
1098 if ( result == QDialog::Accepted )
1100 QMessageBox::information(
this,
"",
1101 _(
"All package dependencies are OK." ),
1113 if ( ! _patchFilterView )
1116 YUI_CHECK_NEW( _patchFilterView );
1117 _filters->
addPage( _(
"P&atches" ), _patchFilterView,
"patches" );
1119 _patchList = _patchFilterView->
patchList();
1120 YUI_CHECK_PTR( _patchList );
1130 if ( ! _patchFilterView )
1132 yuiMilestone() <<
"Activating patches filter view" << std::endl;
1137 _filters->
showPage( _patchFilterView );
1143 _filters->
showPage( _patchFilterView );
1151 if ( _pkgList && _patchList )
1155 connect( _patchList, SIGNAL( filterMatch (
const QString &,
const QString &, FSize ) ),
1156 _pkgList, SLOT ( addPassiveItem(
const QString &,
const QString &, FSize ) ) );
1158 connect( _patchList, SIGNAL( statusChanged() ),
1161 if ( _pkgConflictDialog )
1163 connect( _pkgConflictDialog,SIGNAL( updatePackages() ),
1164 _patchList, SLOT ( updateItemStates() ) );
1167 connect(
this, SIGNAL(
refresh() ),
1168 _patchList, SLOT ( updateItemStates() ) );
1177 QString filename = YQApplication::askForSaveFileName( QString( DEFAULT_EXPORT_FILE_NAME ),
1178 QString(
"*.xml;;*" ),
1179 _(
"Save Package List" ) );
1181 if ( ! filename.isEmpty() )
1183 zypp::syscontent::Writer writer;
1184 const zypp::ResPool & pool = zypp::getZYpp()->pool();
1188 for_each( pool.begin(), pool.end(),
1189 boost::bind( &zypp::syscontent::Writer::addIf,
1190 boost::ref( writer ),
1202 std::ofstream exportFile( toUTF8( filename ).c_str() );
1203 exportFile.exceptions( std::ios_base::badbit | std::ios_base::failbit );
1204 exportFile << writer;
1206 yuiMilestone() <<
"Package list exported to " << filename << std::endl;
1208 catch ( std::exception & exception )
1210 yuiWarning() <<
"Error exporting package list to " << filename << std::endl;
1214 QFile::remove(filename);
1217 QMessageBox::warning(
this,
1219 _(
"Error exporting package list to %1" ).arg( filename ),
1220 QMessageBox::Ok | QMessageBox::Default,
1231 QString filename = QFileDialog::getOpenFileName(
this, _(
"Load Package List" ), DEFAULT_EXPORT_FILE_NAME,
1235 if ( ! filename.isEmpty() )
1237 yuiMilestone() <<
"Importing package list from " << filename << std::endl;
1241 std::ifstream importFile( toUTF8( filename ).c_str() );
1242 zypp::syscontent::Reader reader( importFile );
1248 typedef zypp::syscontent::Reader::Entry ZyppReaderEntry;
1249 typedef std::pair<string, ZyppReaderEntry> ImportMapPair;
1251 map<string, ZyppReaderEntry> importPkg;
1252 map<string, ZyppReaderEntry> importPatterns;
1254 for ( zypp::syscontent::Reader::const_iterator it = reader.begin();
1258 string kind = it->kind();
1260 if ( kind ==
"package" ) importPkg.insert ( ImportMapPair( it->name(), *it ) );
1261 else if ( kind ==
"pattern" ) importPatterns.insert( ImportMapPair( it->name(), *it ) );
1264 yuiDebug() <<
"Found " << importPkg.size()
1265 <<
" packages and " << importPatterns.size()
1266 <<
" patterns in " << filename
1274 for ( ZyppPoolIterator it = zyppPatternsBegin();
1275 it != zyppPatternsEnd();
1278 ZyppSel selectable = *it;
1279 importSelectable( *it, importPatterns.find( selectable->name() ) != importPatterns.end(),
"pattern" );
1282 for ( ZyppPoolIterator it = zyppPkgBegin();
1286 ZyppSel selectable = *it;
1287 importSelectable( *it, importPkg.find( selectable->name() ) != importPkg.end(),
"package" );
1297 if ( _statusFilterView )
1301 _filters->
showPage( _statusFilterView );
1302 _statusFilterView->
filter();
1306 catch (
const zypp::Exception & exception )
1308 yuiWarning() <<
"Error reading package list from " << filename << std::endl;
1311 QMessageBox::warning(
this,
1313 _(
"Error loading package list from %1" ).arg( filename ),
1314 QMessageBox::Ok | QMessageBox::Default,
1315 QMessageBox::NoButton,
1316 QMessageBox::NoButton );
1327 ZyppStatus oldStatus = selectable->status();
1328 ZyppStatus newStatus = oldStatus;
1336 switch ( oldStatus )
1340 case S_KeepInstalled:
1344 newStatus = oldStatus;
1349 newStatus = S_KeepInstalled;
1350 yuiDebug() <<
"Keeping " << kind <<
" " << selectable->name() << std::endl;
1356 if ( selectable->hasCandidateObj() )
1358 newStatus = S_Install;
1359 yuiDebug() <<
"Adding " << kind <<
" " << selectable->name() << std::endl;
1363 yuiDebug() <<
"Can't add " << kind <<
" " << selectable->name()
1364 <<
": No candidate" << std::endl;
1375 switch ( oldStatus )
1379 case S_KeepInstalled:
1384 yuiDebug() <<
"Deleting " << kind <<
" " << selectable->name() << std::endl;
1391 newStatus = oldStatus;
1396 if ( oldStatus != newStatus )
1397 selectable->setStatus( newStatus );
1409 yuiMilestone() << count <<
" pkgs found for update" << std::endl;
1411 if ( count >= GLOBAL_UPDATE_CONFIRMATION_THRESHOLD )
1413 if ( QMessageBox::question(
this,
"",
1415 _(
"%1 packages will be updated" ).arg( count ),
1416 _(
"&Continue" ), _(
"C&ancel" ),
1428 if ( _statusFilterView )
1430 _filters->
showPage( _statusFilterView );
1431 _statusFilterView->
clear();
1433 _statusFilterView->
filter();
1440 zypp::ResPool::repository_iterator it;
1441 _repoUpgradeLabel->setText(
"");
1442 _repoUpgradingLabel->setText(
"");
1446 for ( it = zypp::getZYpp()->pool().knownRepositoriesBegin();
1447 it != zypp::getZYpp()->pool().knownRepositoriesEnd();
1450 zypp::Repository repo(*it);
1453 if ( zypp::getZYpp()->resolver()->upgradingRepo(repo) )
1455 _repoUpgradingLabel->setText(_repoUpgradingLabel->text() + _(
"<p><small><a href=\"repoupgraderemove:///%1\">Cancel switching</a> system packages to versions in repository %2</small></p>")
1456 .arg(fromUTF8(repo.alias().c_str()))
1457 .arg(fromUTF8(repo.name().c_str()))
1462 for ( it = zypp::getZYpp()->pool().knownRepositoriesBegin();
1463 it != zypp::getZYpp()->pool().knownRepositoriesEnd();
1466 zypp::Repository repo(*it);
1470 if ( ! zypp::getZYpp()->resolver()->upgradingRepo(repo) &&
1471 ! repo.isSystemRepo() &&
1474 _repoUpgradeLabel->setText(_repoUpgradeLabel->text() + _(
"<p><a href=\"repoupgradeadd:///%1\">Switch system packages</a> to the versions in this repository (%2)</p>")
1475 .arg(fromUTF8(repo.alias().c_str()))
1476 .arg(fromUTF8(repo.name().c_str()))
1480 _repoUpgradeLabel->setVisible(!_repoUpgradeLabel->text().isEmpty() &&
1481 _repoFilterView->isVisible() );
1482 _repoUpgradingLabel->setVisible(!_repoUpgradingLabel->text().isEmpty());
1488 yuiDebug() <<
"link " << link <<
" clicked on label" << std::endl;
1491 if (url.scheme() ==
"repoupgradeadd")
1493 yuiDebug() <<
"looking for repo " << url.path() << std::endl;
1494 std::string alias(url.path().remove(0,1).toStdString());
1495 zypp::Repository repo(zypp::getZYpp()->pool().reposFind(alias));
1496 yuiDebug() << repo << std::endl;
1498 if ( repo != zypp::Repository::noRepository )
1499 zypp::getZYpp()->resolver()->addUpgradeRepo(repo);
1501 else if (url.scheme() ==
"repoupgraderemove")
1503 std::string alias(url.path().remove(0,1).toStdString());
1504 zypp::Repository repo(zypp::getZYpp()->pool().reposFind(alias));
1506 if ( repo != zypp::Repository::noRepository )
1507 zypp::getZYpp()->resolver()->removeUpgradeRepo(repo);
1510 yuiDebug() <<
"unknown link operation " << url.scheme() << std::endl;
1553 if ( _optionsMenu && _pkgList )
1555 if ( _excludeDebugInfoPkgs )
1556 _excludeDebugInfoPkgs->
enable( ! on );
1564 YQPackageSelector::pkgExcludeDevelChanged(
bool on )
1566 if ( _optionsMenu && _pkgList )
1568 if ( _excludeDevelPkgs )
1569 _excludeDevelPkgs->
enable( ! on );
1577 YQPackageSelector::pkgVerifySytemModeChanged(
bool on )
1579 zypp::getZYpp()->resolver()->setSystemVerification( on );
1583 YQPackageSelector::pkgIgnoreAlreadyRecommendedChanged(
bool on )
1585 zypp::getZYpp()->resolver()->setIgnoreAlreadyRecommended( on );
1590 YQPackageSelector::pkgCleanDepsOnRemoveChanged(
bool on )
1592 zypp::getZYpp()->resolver()->setCleandepsOnRemove( on );
1598 YQPackageSelector::pkgAllowVendorChangeChanged(
bool on )
1600 zypp::getZYpp()->resolver()->setAllowVendorChange( on );
1611 QMap<QString, ZyppSel> subPkgs;
1613 for ( ZyppPoolIterator it = zyppPkgBegin();
1617 QString name = (*it)->name().c_str();
1619 if ( name.endsWith( suffix ) || name.endsWith( suffix +
"-32bit" ) )
1621 subPkgs[ name ] = *it;
1623 yuiDebug() <<
"Found subpackage: " << name << std::endl;
1630 for ( ZyppPoolIterator it = zyppPkgBegin();
1634 QString name = (*it)->name().c_str();
1636 if ( subPkgs.contains( name + suffix ) )
1638 QString subPkgName( name + suffix );
1639 ZyppSel subPkg = subPkgs[ subPkgName ];
1641 switch ( (*it)->status() )
1649 yuiMilestone() <<
"Ignoring unwanted subpackage " << subPkgName << std::endl;
1654 case S_KeepInstalled:
1658 if ( ! subPkg->installedObj() )
1660 subPkg->setStatus( S_Install );
1661 yuiMilestone() <<
"Installing subpackage " << subPkgName << std::endl;
1671 if ( ! subPkg->installedObj() )
1673 subPkg->setStatus( S_Install );
1674 yuiMilestone() <<
"Installing subpackage " << subPkgName << std::endl;
1678 subPkg->setStatus( S_Update );
1679 yuiMilestone() <<
"Updating subpackage " << subPkgName << std::endl;
1690 if ( _filters && _statusFilterView )
1692 _filters->
showPage( _statusFilterView );
1693 _statusFilterView->
filter();
1697 _(
"Added Subpackages:" ),
1698 QRegExp(
".*" + suffix +
"$" ),
1701 YQPkgChangesDialog::FilterAutomatic,
1702 YQPkgChangesDialog::OptionNone );
1708 QString settingsName =
"YQPackageSelector";
1709 if ( onlineUpdateMode() ) settingsName =
"YQOnlineUpdate";
1710 if ( updateMode() ) settingsName =
"YQSystemUpdate";
1712 QSettings settings( QSettings::UserScope, SETTINGS_DIR, settingsName );
1714 _autoDependenciesAction->setChecked( settings.value(
"Options/AutocheckDependencies",
1715 AUTO_CHECK_DEPENDENCIES_DEFAULT ).toBool() ) ;
1717 _showDevelAction->setChecked(settings.value(
"Options/showDevelPackages",
true).toBool());
1718 pkgExcludeDevelChanged(_showDevelAction->isChecked());
1720 _showDebugAction->setChecked(settings.value(
"Options/showDebugPackages",
true).toBool());
1723 _verifySystemModeAction->setChecked( settings.value(
"Options/systemVerificationMode",
1724 zypp::getZYpp()->resolver()->systemVerification() ).toBool() );
1725 pkgVerifySytemModeChanged ( _verifySystemModeAction->isChecked() );
1727 _ignoreAlreadyRecommendAction->setChecked(
1728 settings.value(
"Options/IgnoreRecommendedPackagesForAlreadyInstalledPackages",
1730 pkgIgnoreAlreadyRecommendedChanged(_ignoreAlreadyRecommendAction->isChecked());
1733 _cleanDepsOnRemoveAction->setChecked( settings.value(
"Options/CleanupWhenDeletingPackages",
1734 zypp::getZYpp()->resolver()->cleandepsOnRemove()).toBool() );
1735 pkgCleanDepsOnRemoveChanged(_cleanDepsOnRemoveAction->isChecked());
1737 _allowVendorChangeAction->setChecked( settings.value(
"Options/AllowVendorChange",
1738 zypp::getZYpp()->resolver()->allowVendorChange() ).toBool() );
1739 pkgAllowVendorChangeChanged(_allowVendorChangeAction->isChecked());
1748 QString settingsName =
"YQPackageSelector";
1749 if ( onlineUpdateMode() ) settingsName =
"YQOnlineUpdate";
1750 if ( updateMode() ) settingsName =
"YQSystemUpdate";
1752 QSettings settings( QSettings::UserScope, SETTINGS_DIR, settingsName );
1754 settings.setValue(
"Options/AutocheckDependencies", _autoDependenciesAction->isChecked() );
1755 settings.setValue(
"Options/showDevelPackages", _showDevelAction->isChecked() );
1756 settings.setValue(
"Options/showDebugPackages", _showDebugAction->isChecked() );
1757 settings.setValue(
"Options/systemVerificationMode", _verifySystemModeAction->isChecked() );
1758 settings.setValue(
"Options/IgnoreRecommendedPackagesForAlreadyInstalledPackages", _ignoreAlreadyRecommendAction->isChecked() );
1759 settings.setValue(
"Options/CleanupWhenDeletingPackages", _cleanDepsOnRemoveAction->isChecked() );
1760 settings.setValue(
"Options/AllowVendorChange", _allowVendorChangeAction->isChecked() );
1764 #include "YQPackageSelector.moc"