libyui-qt-pkg  2.45.18
YQPackageSelector.cc
1 /**************************************************************************
2 Copyright (C) 2000 - 2010 Novell, Inc.
3 All Rights Reserved.
4 
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9 
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14 
15 You should have received a copy of the GNU General Public License along
16 with this program; if not, write to the Free Software Foundation, Inc.,
17 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 
19 **************************************************************************/
20 
21 
22 /*---------------------------------------------------------------------\
23 | |
24 | __ __ ____ _____ ____ |
25 | \ \ / /_ _/ ___|_ _|___ \ |
26 | \ V / _` \___ \ | | __) | |
27 | | | (_| |___) || | / __/ |
28 | |_|\__,_|____/ |_| |_____| |
29 | |
30 | core system |
31 | (C) SuSE GmbH |
32 \----------------------------------------------------------------------/
33 
34  File: YQPackageSelector.cc
35  See also: YQPackageSelectorHelp.cc
36 
37  Author: Stefan Hundhammer <sh@suse.de>
38 
39  Textdomain "qt-pkg"
40 
41  /-*/
42 
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
53 
54 
55 #include <fstream>
56 #include <boost/bind.hpp>
57 
58 #include <QHBoxLayout>
59 #include <QVBoxLayout>
60 #include <QAction>
61 #include <QShortcut>
62 #include <QApplication>
63 #include <QCheckBox>
64 #include <QDialog>
65 #include <QFileDialog>
66 #include <QLabel>
67 #include <QMap>
68 #include <QMenuBar>
69 #include <QMessageBox>
70 #include <QPushButton>
71 #include <QSplitter>
72 #include <QTabWidget>
73 #include <QTimer>
74 #include <QMenu>
75 #include <QSettings>
76 
77 #define YUILogComponent "qt-pkg"
78 #include "YUILog.h"
79 
80 #include "QY2LayoutUtils.h"
81 
82 #include "YQZypp.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"
111 
112 #include "zypp/SysContent.h"
113 #include "zypp/base/String.h"
114 #include "zypp/base/Sysconfig.h"
115 
116 #include "QY2ComboTabWidget.h"
117 #include "YQDialog.h"
118 #include "YQApplication.h"
119 #include "utf8.h"
120 #include "YQUI.h"
121 #include "YEvent.h"
122 #include "YQi18n.h"
123 
124 
125 
126 using std::max;
127 using std::string;
128 using std::map;
129 using std::pair;
130 
131 #define DEFAULT_EXPORT_FILE_NAME "user-packages.xml"
132 #define FAST_SOLVER 1
133 
134 #define SETTINGS_DIR "YaST2"
135 #define PATH_TO_YAST_SYSCONFIG "/etc/sysconfig/yast2"
136 #define OPTION_VERIFY "PKGMGR_VERIFY_SYSTEM"
137 #define OPTION_AUTO_CHECK "PKGMGR_AUTO_CHECK"
138 #define OPTION_RECOMMENDED "PKGMGR_RECOMMENDED"
139 
140 
141 YQPackageSelector::YQPackageSelector( YWidget * parent,
142  long modeFlags )
143  : YQPackageSelectorBase( parent, modeFlags )
144 {
145  _showChangesDialog = true;
146  _autoDependenciesAction = 0;
147  _detailsViews = 0;
148  _filters = 0;
149  _langList = 0;
150  _packageKitGroupsFilterView = 0;
151  _patchFilterView = 0;
152  _patchList = 0;
153  _patternList = 0;
154  _pkgChangeLogView = 0;
155  _pkgDependenciesView = 0;
156  _pkgDescriptionView = 0;
157  _pkgFileListView = 0;
158  _pkgList = 0;
159  _pkgTechnicalDetailsView = 0;
160  _pkgVersionsView = 0;
161  _repoFilterView = 0;
162  _rpmGroupTagsFilterView = 0;
163  _searchFilterView = 0;
164  _statusFilterView = 0;
165  _updateProblemFilterView = 0;
166  _excludeDevelPkgs = 0;
167  _excludeDebugInfoPkgs = 0;
168 
169  yuiMilestone() << "This is libyui-qt-pkg " << VERSION << std::endl;
170 
171  if ( onlineUpdateMode() ) yuiMilestone() << "Online update mode" << std::endl;
172  if ( updateMode() ) yuiMilestone() << "Update mode" << std::endl;
173 
174  basicLayout();
175  addMenus(); // Only after all widgets are created!
176  loadSettings(); // Only after menus are created!
177  makeConnections();
178  emit loadData();
179 
180  _filters->loadSettings();
181  bool pagesRestored = _filters->tabCount() > 0;
182 
183  if ( _pkgList )
184  _pkgList->clear();
185 
186  if ( ! pagesRestored )
187  {
188  yuiDebug() << "No page configuration saved, using fallbacks" << std::endl;
189 
190  //
191  // Add a number of default tabs in the desired order
192  //
193 
194  if ( _searchFilterView ) _filters->showPage( _searchFilterView );
195 
196  if ( ! searchMode() && ! summaryMode()
197  && _patternList ) _filters->showPage( _patternList );
198  else if ( _rpmGroupTagsFilterView ) _filters->showPage( _rpmGroupTagsFilterView );
199 
200  if ( _statusFilterView ) _filters->showPage( _statusFilterView );
201  }
202 
203 
204  //
205  // Move the desired tab to the foreground
206  //
207 
208  if ( _patchFilterView && onlineUpdateMode() )
209  {
210  if ( _patchFilterView && _patchList )
211  {
212  _filters->showPage( _patchFilterView );
213  _patchList->filter();
214  }
215  }
216  else if ( _repoFilterView && repoMode() )
217  {
219  {
220  _filters->showPage( _repoFilterView );
221  _repoFilterView->filter();
222  }
223  }
224  else if ( _updateProblemFilterView )
225  {
226  _filters->showPage( _updateProblemFilterView );
227  _updateProblemFilterView->filter();
228  }
229  else if ( searchMode() && _searchFilterView )
230  {
231  _filters->showPage( _searchFilterView );
232  _searchFilterView->filter();
233  QTimer::singleShot( 0, _searchFilterView, SLOT( setFocus() ) );
234  }
235  else if ( summaryMode() && _statusFilterView )
236  {
237  _filters->showPage( _statusFilterView );
238  _statusFilterView->filter();
239  _pkgList->selectNextItem();
240  }
241  else if ( _patternList )
242  {
243  _filters->showPage( _patternList );
244  _patternList->filter();
245  }
246 
247 
248  if ( _filters->diskUsageList() )
249  _filters->diskUsageList()->updateDiskUsage();
250 
251  yuiMilestone() << "PackageSelector init done" << std::endl;
252 
253 
254 #if CHECK_DEPENDENCIES_ON_STARTUP
255 
256  if ( ! testMode() )
257  {
258  // Fire up the first dependency check in the main loop.
259  // Don't do this right away - wait until all initializations are finished.
260  QTimer::singleShot( 0, this, SLOT( resolveDependencies() ) );
261 
262  }
263 #endif
264 
265 }
266 
267 
268 std::string
269 YQPackageSelector::iconPath( const std::string &name, int size )
270 {
271  // FIXME
272  #define PREFIX "/usr/"
273  return zypp::str::form("%s/share/icons/hicolor/%dx%d/apps/%s.png",
274  PREFIX, size, size, name.c_str() );
275 }
276 
277 
278 void
279 YQPackageSelector::basicLayout()
280 {
281  QVBoxLayout *layout = new QVBoxLayout();
282  setLayout( layout );
283  layout->setContentsMargins( MARGIN, // left
284  0, // top
285  MARGIN, // right
286  MARGIN ); // bottom
287  layout->setSpacing( SPACING_BELOW_MENU_BAR );
288  layoutMenuBar( this );
289 
290  QString settingsName = "YQPackageSelector";
291 
292  if ( onlineUpdateMode() ) settingsName = "YQOnlineUpdate";
293  if ( updateMode() ) settingsName = "YQSystemUpdate";
294 
295  _filters = new YQPkgFilterTab( this, settingsName );
296  YUI_CHECK_NEW( _filters );
297 
298  layout->addWidget( _filters );
299  layoutFilters( this );
300  layoutRightPane( _filters->rightPane() );
301 }
302 
303 
304 void
305 YQPackageSelector::layoutFilters( QWidget *parent )
306 {
307  //
308  // Update problem view
309  //
310 
311  if ( updateMode() )
312  {
314  || testMode() )
315  {
316  _updateProblemFilterView = new YQPkgUpdateProblemFilterView( parent );
317  YUI_CHECK_NEW( _updateProblemFilterView );
318  _filters->addPage( _( "&Update Problems" ), _updateProblemFilterView, "update_problems" );
319  }
320  }
321 
322 
323  //
324  // Patches view
325  //
326 
327  if ( onlineUpdateMode()
328 #if ALWAYS_SHOW_PATCHES_VIEW_IF_PATCHES_AVAILABLE
329  || ! zyppPool().empty<zypp::Patch>()
330 #endif
331  )
332  {
334  }
335 
336 
337  //
338  // Patterns view
339  //
340 
341  if ( ! zyppPool().empty<zypp::Pattern>() || testMode() )
342  {
343  _patternList = new YQPkgPatternList( parent, true );
344  YUI_CHECK_NEW( _patternList );
345  _filters->addPage( _( "Patter&ns" ), _patternList, "patterns" );
346 
347  connect( _patternList, SIGNAL( statusChanged() ),
348  this, SLOT ( autoResolveDependencies() ) );
349 
350  connect( this, SIGNAL( refresh() ),
351  _patternList, SLOT ( updateItemStates() ) );
352 
353  if ( _pkgConflictDialog )
354  {
355  connect( _pkgConflictDialog, SIGNAL( updatePackages() ),
356  _patternList, SLOT ( updateItemStates() ) );
357  }
358  }
359 
360 
361  //
362  // PackageKit group view
363  //
364 
365  _packageKitGroupsFilterView = new YQPkgPackageKitGroupsFilterView( parent );
366  YUI_CHECK_NEW( _packageKitGroupsFilterView );
367  _filters->addPage( _( "Package &Groups" ), _packageKitGroupsFilterView, "package_groups" );
368 
369  connect( this, SIGNAL( loadData() ),
370  _packageKitGroupsFilterView, SLOT ( filter() ) );
371 
372 
373  //
374  // RPM group tags view
375  //
376 
377  _rpmGroupTagsFilterView = new YQPkgRpmGroupTagsFilterView( parent );
378  YUI_CHECK_NEW( _rpmGroupTagsFilterView );
379  _filters->addPage( _( "&RPM Groups" ), _rpmGroupTagsFilterView, "rpm_groups" );
380 
381  connect( this, SIGNAL( loadData() ),
382  _rpmGroupTagsFilterView, SLOT ( filter() ) );
383 
384 
385  //
386  // Languages view
387  //
388 
389  _langList = new YQPkgLangList( parent );
390  YUI_CHECK_NEW( _langList );
391 
392  _filters->addPage( _( "&Languages" ), _langList, "languages" );
393  _langList->setSizePolicy( QSizePolicy( QSizePolicy::Ignored, QSizePolicy::Ignored ) ); // hor/vert
394 
395  connect( _langList, SIGNAL( statusChanged() ),
396  this, SLOT ( autoResolveDependencies() ) );
397 
398  connect( this, SIGNAL( refresh() ),
399  _langList, SLOT ( updateItemStates() ) );
400 
401 
402  //
403  // Repository view
404  //
405 
406  _repoFilterView = new YQPkgRepoFilterView( parent );
407  YUI_CHECK_NEW( _repoFilterView );
408  _filters->addPage( _( "&Repositories" ), _repoFilterView, "repos" );
409  // hide and show the upgrade label when tabs change, or when the user
410  // selects repositories
411  connect(_repoFilterView, SIGNAL(filterStart()), this, SLOT(updateRepositoryUpgradeLabel()));
412  connect(this, SIGNAL(refresh()), this, SLOT(updateRepositoryUpgradeLabel()));
413  connect(_filters, &YQPkgFilterTab::currentChanged,
415 
416  //
417  // Package search view
418  //
419 
420  _searchFilterView = new YQPkgSearchFilterView( parent );
421  YUI_CHECK_NEW( _searchFilterView );
422  _filters->addPage( _( "S&earch" ), _searchFilterView, "search" );
423 
424 
425 
426 #if 0
427  // DEBUG
428 
429  _filters->addPage( _( "&Keywords" ), new QLabel( "Keywords\nfilter\n\nfor future use", this ), "keywords" );
430 #endif
431 
432  //
433  // Status change view
434  //
435 
436  _statusFilterView = new YQPkgStatusFilterView( parent );
437  YUI_CHECK_NEW( _statusFilterView );
438  _filters->addPage( _( "&Installation Summary" ), _statusFilterView, "inst_summary" );
439 }
440 
441 
442 YQPackageSelector::~YQPackageSelector()
443 {
444  saveSettings();
445 }
446 
447 QWidget *
448 YQPackageSelector::layoutRightPane( QWidget *parent )
449 {
450  QVBoxLayout *layout = new QVBoxLayout( parent );
451  YUI_CHECK_NEW( layout );
452  layout->setContentsMargins( SPLITTER_HALF_SPACING, // left
453  0, // top
454  0, // right
455  0 ); // bottom
456 
457  QSplitter * splitter = new QSplitter( Qt::Vertical, parent );
458  YUI_CHECK_NEW( splitter );
459  layout->addWidget(splitter);
460 
461  layoutPkgList( splitter );
462  layoutDetailsViews( splitter );
463  layoutButtons( parent );
464 
465  return parent;
466 }
467 
468 
469 void
470 YQPackageSelector::layoutPkgList( QWidget *parent )
471 {
472  // this is made visible when activating the repository
473  // filter
474  QWidget *_notificationsContainer = new QWidget(parent);
475  QVBoxLayout *layout = new QVBoxLayout(_notificationsContainer);
476 
477  _repoUpgradingLabel = new QLabel(_notificationsContainer);
478  _repoUpgradingLabel->setTextFormat(Qt::RichText);
479  _repoUpgradingLabel->setWordWrap(true);
480  _repoUpgradingLabel->setVisible(false);
481 
482  _repoUpgradeLabel = new QLabel(_notificationsContainer);
483  _repoUpgradeLabel->setTextFormat(Qt::RichText);
484  _repoUpgradeLabel->setWordWrap(true);
485  _repoUpgradeLabel->setVisible(false);
486  _repoUpgradeLabel->setObjectName( "RepoUpgradeLabel");
487 
488  layout->addWidget(_repoUpgradingLabel);
489  layout->addWidget(_repoUpgradeLabel);
490 
491  // if the user clicks on a link on the label, we have to check
492  // which repository upgrade job to add or remove, for that
493  // we will encode the links as repoupgradeadd://alias and
494  // repoupgraderemove:://alias
495  connect( _repoUpgradeLabel, SIGNAL( linkActivated ( QString ) ),
496  this, SLOT( slotRepoUpgradeLabelLinkClicked( QString ) ) );
497 
498  connect(_repoUpgradingLabel, SIGNAL( linkActivated( QString ) ),
499  this, SLOT( slotRepoUpgradeLabelLinkClicked( QString ) ) );
500 
502 
503  _pkgList= new YQPkgList( parent );
504  YUI_CHECK_NEW( _pkgList );
505 
506  connect( _pkgList, SIGNAL( statusChanged() ),
507  this, SLOT ( autoResolveDependencies() ) );
508 }
509 
510 void
511 YQPackageSelector::layoutDetailsViews( QWidget *parent )
512 {
513  bool haveInstalledPkgs = YQPkgList::haveInstalledPkgs();
514 
515 
516  _detailsViews = new QTabWidget( parent );
517  YUI_CHECK_NEW( _detailsViews );
518 
519  //
520  // Description
521  //
522 
523  _pkgDescriptionView = new YQPkgDescriptionView( _detailsViews, confirmUnsupported() );
524  YUI_CHECK_NEW( _pkgDescriptionView );
525 
526  _detailsViews->addTab( _pkgDescriptionView, _( "D&escription" ) );
527  _detailsViews->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) ); // hor/vert
528 
529  connect( _pkgList, SIGNAL( currentItemChanged ( ZyppSel ) ),
530  _pkgDescriptionView, SLOT ( showDetailsIfVisible( ZyppSel ) ) );
531 
532  //
533  // Technical details
534  //
535 
536  _pkgTechnicalDetailsView = new YQPkgTechnicalDetailsView( _detailsViews );
537  YUI_CHECK_NEW( _pkgTechnicalDetailsView );
538 
539  _detailsViews->addTab( _pkgTechnicalDetailsView, _( "&Technical Data" ) );
540 
541  connect( _pkgList, SIGNAL( currentItemChanged ( ZyppSel ) ),
542  _pkgTechnicalDetailsView, SLOT ( showDetailsIfVisible( ZyppSel ) ) );
543 
544 
545  //
546  // Dependencies
547  //
548 
549  _pkgDependenciesView = new YQPkgDependenciesView( _detailsViews );
550  YUI_CHECK_NEW( _pkgDependenciesView );
551 
552  _detailsViews->addTab( _pkgDependenciesView, _( "Dependencies" ) );
553  _detailsViews->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) ); // hor/vert
554 
555  connect( _pkgList, SIGNAL( currentItemChanged ( ZyppSel ) ),
556  _pkgDependenciesView, SLOT ( showDetailsIfVisible( ZyppSel ) ) );
557 
558 
559 
560  //
561  // Versions
562  //
563 
564  _pkgVersionsView = new YQPkgVersionsView( _detailsViews );
565  YUI_CHECK_NEW( _pkgVersionsView );
566 
567  _detailsViews->addTab( _pkgVersionsView, _( "&Versions" ) );
568 
569  connect( _pkgList, SIGNAL( currentItemChanged ( ZyppSel ) ),
570  _pkgVersionsView, SLOT ( showDetailsIfVisible( ZyppSel ) ) );
571 
572  connect( _pkgList, SIGNAL( statusChanged() ),
573  _pkgVersionsView, SIGNAL( statusChanged() ) );
574 
575 
576  //
577  // File List
578  //
579 
580  if ( haveInstalledPkgs ) // file list information is only available for installed pkgs
581  {
582  _pkgFileListView = new YQPkgFileListView( _detailsViews );
583  YUI_CHECK_NEW( _pkgFileListView );
584 
585  _detailsViews->addTab( _pkgFileListView, _( "File List" ) );
586  _detailsViews->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) ); // hor/vert
587 
588  connect( _pkgList, SIGNAL( currentItemChanged ( ZyppSel ) ),
589  _pkgFileListView, SLOT ( showDetailsIfVisible( ZyppSel ) ) );
590  }
591 
592 
593  //
594  // Change Log
595  //
596 
597  if ( haveInstalledPkgs ) // change log information is only available for installed pkgs
598  {
599  _pkgChangeLogView = new YQPkgChangeLogView( _detailsViews );
600  YUI_CHECK_NEW( _pkgChangeLogView );
601 
602  _detailsViews->addTab( _pkgChangeLogView, _( "Change Log" ) );
603  _detailsViews->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) ); // hor/vert
604 
605  connect( _pkgList, SIGNAL( currentItemChanged ( ZyppSel ) ),
606  _pkgChangeLogView, SLOT ( showDetailsIfVisible( ZyppSel ) ) );
607  }
608 }
609 
610 
611 void
612 YQPackageSelector::layoutButtons( QWidget *parent )
613 {
614  QWidget * button_box = new QWidget( parent );
615  YUI_CHECK_NEW( button_box );
616  parent->layout()->addWidget( button_box );
617 
618  QHBoxLayout * layout = new QHBoxLayout( button_box );
619  YUI_CHECK_NEW( layout );
620 
621  button_box->setLayout( layout );
622  layout->setContentsMargins( 2, // left
623  2, // top
624  2, // right
625  2 ); // bottom
626 
627  layout->addStretch();
628 
629  QPushButton * cancel_button = new QPushButton( _( "&Cancel" ), button_box );
630  YUI_CHECK_NEW( cancel_button );
631  layout->addWidget(cancel_button);
632 
633  cancel_button->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ) ); // hor/vert
634 
635  connect( cancel_button, SIGNAL( clicked() ),
636  this, SLOT ( reject() ) );
637 
638 
639  QPushButton * accept_button = new QPushButton( _( "&Accept" ), button_box );
640  YUI_CHECK_NEW( accept_button );
641  layout->addWidget(accept_button);
642  accept_button->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ) ); // hor/vert
643 
644  connect( accept_button, SIGNAL( clicked() ),
645  this, SLOT ( accept() ) );
646 
647  button_box->setFixedHeight( button_box->sizeHint().height() );
648 }
649 
650 
651 void
652 YQPackageSelector::layoutMenuBar( QWidget *parent )
653 {
654  _menuBar = new QMenuBar( parent );
655  YUI_CHECK_NEW( _menuBar );
656  parent->layout()->addWidget(_menuBar);
657 
658  _fileMenu = 0;
659  _optionsMenu = 0;
660  _pkgMenu = 0;
661  _patchMenu = 0;
662  _extrasMenu = 0;
663  _configMenu = 0;
664  _dependencyMenu = 0;
665  _helpMenu = 0;
666 
667 }
668 
669 
670 void
672 {
673 
674 
675  //
676  // File menu
677  //
678 
679  _fileMenu = new QMenu( _menuBar );
680  YUI_CHECK_NEW( _fileMenu );
681  QAction * action = _menuBar->addMenu( _fileMenu );
682  action->setText( _( "&File" ));
683 
684  _fileMenu->addAction( _( "&Import..." ), this, SLOT( pkgImport() ) );
685  _fileMenu->addAction( _( "&Export..." ), this, SLOT( pkgExport() ) );
686 
687  _fileMenu->addSeparator();
688 
689  _fileMenu->addAction( _( "E&xit -- Discard Changes" ), this, SLOT( reject() ) );
690  _fileMenu->addAction( _( "&Quit -- Save Changes" ), this, SLOT( accept() ) );
691 
692 
693  if ( _pkgList )
694  {
695  //
696  // Package menu
697  //
698 
699  _pkgMenu = new QMenu( _menuBar );
700  YUI_CHECK_NEW( _pkgMenu );
701  action = _menuBar->addMenu( _pkgMenu );
702  action->setText(_( "&Package" ));
703 
704  _pkgMenu->addAction(_pkgList->actionSetCurrentInstall);
705  _pkgMenu->addAction(_pkgList->actionSetCurrentDontInstall);
706  _pkgMenu->addAction(_pkgList->actionSetCurrentKeepInstalled);
707  _pkgMenu->addAction(_pkgList->actionSetCurrentDelete);
708  _pkgMenu->addAction(_pkgList->actionSetCurrentUpdate);
709  _pkgMenu->addAction(_pkgList->actionSetCurrentUpdateForce);
710  _pkgMenu->addAction(_pkgList->actionSetCurrentTaboo);
711 
712 #if ENABLE_SOURCE_RPMS
713  _pkgMenu->addSeparator();
714 
715  _pkgMenu->addAction(_pkgList->actionInstallSourceRpm);
716  _pkgMenu->addAction(_pkgList->actionDontInstallSourceRpm);
717 #endif
718 
719  _pkgMenu->addSeparator();
720  QMenu * submenu = _pkgList->addAllInListSubMenu( _pkgMenu );
721  YUI_CHECK_NEW( submenu );
722 
723 #if ENABLE_SOURCE_RPMS
724  submenu->addSeparator();
725 
726  _pkgMenu->addAction(_pkgList->actionInstallListSourceRpms);
727  _pkgMenu->addAction(_pkgList->actionDontInstallListSourceRpms);
728 #endif
729 
730  //
731  // Submenu for all packages
732  //
733 
734  submenu = new QMenu( _pkgMenu );
735  YUI_CHECK_NEW( submenu );
736 
737  // Translators: Unlike the "all in this list" submenu, this submenu
738  // refers to all packages globally, not only to those that are
739  // currently visible in the packages list.
740  action = _pkgMenu->addMenu( submenu );
741  action->setText(_( "All Packages" ));
742 
743  submenu->addAction( _( "Update if newer version available" ),
744  this, SLOT( globalUpdatePkg() ) );
745 
746  submenu->addAction( _( "Update unconditionally" ),
747  this, SLOT( globalUpdatePkgForce() ) );
748  }
749 
750 
751  if ( _patchList )
752  {
753  //
754  // Patch menu
755  //
756 
757  _patchMenu = new QMenu( _menuBar );
758  YUI_CHECK_NEW( _patchMenu );
759  action = _menuBar->addMenu( _patchMenu );
760  action->setText(_( "&Patch" ));
761 
762  _patchMenu->addAction(_patchList->actionSetCurrentInstall);
763  _patchMenu->addAction(_patchList->actionSetCurrentDontInstall);
764  _patchMenu->addAction(_patchList->actionSetCurrentKeepInstalled);
765 
766 #if ENABLE_DELETING_PATCHES
767  _patchMenu->addAction(_patchList->actionSetCurrentDelete);
768 #endif
769  _patchMenu->addAction(_patchList->actionSetCurrentUpdate);
770  _patchMenu->addAction(_patchList->actionSetCurrentUpdateForce);
771  _patchMenu->addAction(_patchList->actionSetCurrentTaboo);
772 
773  _patchMenu->addSeparator();
774  _patchList->addAllInListSubMenu( _patchMenu );
775  }
776 
777 
778  //
779  // Configuration menu
780  //
781 
782  if ( repoMgrEnabled() )
783  {
784  _configMenu = new QMenu( _menuBar );
785  YUI_CHECK_NEW( _configMenu );
786  action = _menuBar->addMenu( _configMenu );
787  action->setText(_( "Confi&guration" ));
788  _configMenu->addAction( _( "&Repositories..." ), this, SLOT( repoManager() ), Qt::CTRL + Qt::Key_R );
789  _configMenu->addAction( _( "&Online Update..." ), this, SLOT( onlineUpdateConfiguration() ), Qt::CTRL + Qt::Key_O );
790  }
791 
792  //
793  // Dependency menu
794  //
795 
796  _dependencyMenu = new QMenu( _menuBar );
797  YUI_CHECK_NEW( _dependencyMenu );
798  action = _menuBar->addMenu( _dependencyMenu );
799  action->setText(_( "&Dependencies" ));
800 
801  _dependencyMenu->addAction( _( "&Check Now" ), this, SLOT( manualResolvePackageDependencies() ) );
802 
803  _autoDependenciesAction = new QAction( _( "&Autocheck" ), this );
804  _autoDependenciesAction->setCheckable( true );
805  _dependencyMenu->addAction( _autoDependenciesAction );
806 
807  _installRecommendedAction = _dependencyMenu->addAction(
808  _("Install &Recommended Packages"),
809  this, SLOT (pkgInstallRecommendedChanged(bool)));
810  _installRecommendedAction->setCheckable( true );
811 
812 
813  //
814  // View menu
815  //
816 
817  _optionsMenu = new QMenu( _menuBar );
818  YUI_CHECK_NEW( _optionsMenu );
819  action = _menuBar->addMenu( _optionsMenu );
820  // Translators: Menu for view options (Use a noun, not a verb!)
821  action->setText(_( "&Options" ));
822 
823  // Translators: This is about packages ending in "-devel", so don't translate that "-devel"!
824  _showDevelAction = _optionsMenu->addAction( _( "Show -de&vel Packages" ),
825  this, SLOT( pkgExcludeDevelChanged( bool ) ), Qt::Key_F7 );
826  _showDevelAction->setCheckable(true);
827 
828  _excludeDevelPkgs = new YQPkgObjList::ExcludeRule( _pkgList, QRegExp( ".*(\\d+bit)?-devel(-\\d+bit)?$" ), _pkgList->nameCol() );
829  YUI_CHECK_NEW( _excludeDevelPkgs );
830  _excludeDevelPkgs->enable( false );
831 
832  // Translators: This is about packages ending in "-debuginfo", so don't translate that "-debuginfo"!
833  _showDebugAction = _optionsMenu->addAction( _( "Show -&debuginfo/-debugsource Packages" ),
834  this, SLOT( pkgExcludeDebugChanged( bool ) ), Qt::Key_F8 );
835  _showDebugAction->setCheckable(true);
836  _excludeDebugInfoPkgs = new YQPkgObjList::ExcludeRule( _pkgList, QRegExp( ".*(-\\d+bit)?-(debuginfo|debugsource)(-32bit)?$" ), _pkgList->nameCol() );
837  YUI_CHECK_NEW( _excludeDebugInfoPkgs );
838  _excludeDebugInfoPkgs->enable( false );
839 
840 
841  _verifySystemModeAction = _optionsMenu->addAction( _( "&System Verification Mode" ),
842  this, SLOT( pkgVerifySytemModeChanged( bool ) ) );
843  _verifySystemModeAction->setCheckable(true);
844 
845 
846  _cleanDepsOnRemoveAction = _optionsMenu->addAction( _( "&Cleanup when deleting packages" ),
847  this, SLOT( pkgCleanDepsOnRemoveChanged( bool ) ) );
848  _cleanDepsOnRemoveAction->setCheckable(true);
849 
850  _allowVendorChangeAction = _optionsMenu->addAction( _( "&Allow vendor change" ),
851  this, SLOT( pkgAllowVendorChangeChanged( bool ) ) );
852  _allowVendorChangeAction->setCheckable(true);
853 
854 
855 
856  //
857  // Extras menu
858  //
859 
860  _extrasMenu = new QMenu( _menuBar );
861  YUI_CHECK_NEW( _extrasMenu );
862  action = _menuBar->addMenu( _extrasMenu );
863  action->setText(_( "E&xtras" ));
864 
865  _extrasMenu->addAction( _( "Show &Products" ), this, SLOT( showProducts() ) );
866  _extrasMenu->addAction( _( "Show P&ackage Changes" ), this, SLOT( showAutoPkgList() ), Qt::CTRL + Qt::Key_A );
867  _extrasMenu->addAction( _( "Show &History" ), this, SLOT( showHistory() ) );
868 
869  _extrasMenu->addSeparator();
870 
871 #if BRAINDEAD_LIB_NAMING_SCHEME
872  // See bug #434042: libcddb2 vs. libcddb-devel
873 #else
874  // Translators: This is about packages ending in "-devel", so don't translate that "-devel"!
875  _extrasMenu->addAction( _( "Install All Matching -&devel Packages" ), this, SLOT( installDevelPkgs() ) );
876 #endif
877 
878  // Translators: This is about packages ending in "-debuginfo", so don't translate that "-debuginfo"!
879  _extrasMenu->addAction( _( "Install All Matching -de&buginfo Packages" ), this, SLOT( installDebugInfoPkgs() ) );
880 
881  // Translators: This is about packages ending in "-debugsource", so don't translate that "-debugsource"!
882  _extrasMenu->addAction( _( "Install All Matching -debug&source Packages" ), this, SLOT( installDebugSourcePkgs() ) );
883 
884  _extrasMenu->addAction( _( "Install All Matching &Recommended Packages" ),
885  this, SLOT( installRecommendedPkgs() ) );
886 
887  _extrasMenu->addSeparator();
888 
889  if ( _pkgConflictDialog )
890  _extrasMenu->addAction( _( "Generate Dependency Resolver &Test Case" ),
891  _pkgConflictDialog, SLOT( askCreateSolverTestCase() ) );
892 
893  if ( _actionResetIgnoredDependencyProblems )
894  _extrasMenu->addAction(_actionResetIgnoredDependencyProblems);
895 
896 #ifdef FIXME
897  if ( _patchList )
898  _extrasMenu->addAction(_patchList->actionShowRawPatchInfo);
899 #endif
900 
901 
902  //
903  // Help menu
904  //
905 
906  _helpMenu = new QMenu( _menuBar );
907  YUI_CHECK_NEW( _helpMenu );
908  _menuBar->addSeparator();
909  action = _menuBar->addMenu( _helpMenu );
910  action->setText(_( "&Help" ));
911 
912  // Note: The help functions and their texts are moved out
913  // to a separate source file YQPackageSelectorHelp.cc
914 
915  // Menu entry for help overview
916  _helpMenu->addAction( _( "&Overview" ), this, SLOT( help() ), Qt::Key_F1 );
917 
918  // Menu entry for help about used symbols ( icons )
919  _helpMenu->addAction( _( "&Symbols" ), this, SLOT( symbolHelp() ), Qt::SHIFT + Qt::Key_F1 );
920 
921  // Menu entry for keyboard help
922  _helpMenu->addAction( _( "&Keys" ), this, SLOT( keyboardHelp() ) );
923 }
924 
925 
926 void
928  QWidget * pkgList,
929  bool hasUpdateSignal )
930 {
931  if ( ! filter ) return;
932  if ( ! pkgList ) return;
933 
934  if ( _filters )
935  {
936  connect( _filters, SIGNAL( currentChanged(QWidget *) ),
937  filter, SLOT ( filterIfVisible() ) );
938  }
939 
940  connect( this, SIGNAL( refresh() ),
941  filter, SLOT ( filterIfVisible() ) );
942 
943  connect( filter, SIGNAL( filterStart() ),
944  pkgList, SLOT ( clear() ) );
945 
946  connect( filter, SIGNAL( filterMatch( ZyppSel, ZyppPkg ) ),
947  pkgList, SLOT ( addPkgItem ( ZyppSel, ZyppPkg ) ) );
948 
949  connect( filter, SIGNAL( filterFinished() ),
950  pkgList, SLOT ( resort() ) );
951 
952  connect( filter, SIGNAL( filterFinished() ),
953  pkgList, SLOT ( selectSomething() ) );
954 
955  connect( filter, SIGNAL( filterFinished() ),
956  pkgList, SLOT ( logExcludeStatistics() ) );
957 
958  connect( filter, SIGNAL( filterFinished() ),
959  pkgList, SLOT ( setFocus() ) );
960 
961 
962  if ( hasUpdateSignal && _filters->diskUsageList() )
963  {
964  connect( filter, SIGNAL( updatePackages() ),
965  pkgList, SLOT ( updateItemStates() ) );
966 
967  if ( _filters->diskUsageList() )
968  {
969  connect( filter, SIGNAL( updatePackages() ),
970  _filters->diskUsageList(), SLOT ( updateDiskUsage() ) );
971  }
972  }
973 }
974 
975 
976 void
978 {
979  connectFilter( _updateProblemFilterView, _pkgList, false );
980  connectFilter( _patternList, _pkgList );
981  connectFilter( _langList, _pkgList );
982  connectFilter( _repoFilterView, _pkgList, false );
983  connectFilter( _packageKitGroupsFilterView, _pkgList, false );
984  connectFilter( _rpmGroupTagsFilterView, _pkgList, false );
985  connectFilter( _statusFilterView, _pkgList, false );
986  connectFilter( _searchFilterView, _pkgList, false );
987 
988  // FIXME
989  // connectFilter( _langList, _pkgList );
990 
991  if ( _searchFilterView && _pkgList )
992  {
993  connect( _searchFilterView, SIGNAL( message( const QString & ) ),
994  _pkgList, SLOT ( message( const QString & ) ) );
995  }
996 
997  if ( _repoFilterView && _pkgList )
998  {
999  connect( _repoFilterView, SIGNAL( filterNearMatch ( ZyppSel, ZyppPkg ) ),
1000  _pkgList, SLOT ( addPkgItemDimmed ( ZyppSel, ZyppPkg ) ) );
1001  }
1002 
1003  if ( _pkgList && _filters->diskUsageList() )
1004  {
1005 
1006  connect( _pkgList, SIGNAL( statusChanged() ),
1007  _filters->diskUsageList(), SLOT ( updateDiskUsage() ) );
1008  }
1009 
1010  connectPatchList();
1011 
1012 
1013 
1014  //
1015  // Connect package conflict dialog
1016  //
1017 
1018  if ( _pkgConflictDialog )
1019  {
1020  if (_pkgList )
1021  {
1022  connect( _pkgConflictDialog, SIGNAL( updatePackages() ),
1023  _pkgList, SLOT ( updateItemStates() ) );
1024  }
1025 
1026  if ( _patternList )
1027  {
1028  connect( _pkgConflictDialog, SIGNAL( updatePackages() ),
1029  _patternList, SLOT ( updateItemStates() ) );
1030  }
1031 
1032 
1033  if ( _filters->diskUsageList() )
1034  {
1035  connect( _pkgConflictDialog, SIGNAL( updatePackages() ),
1036  _filters->diskUsageList(), SLOT ( updateDiskUsage() ) );
1037  }
1038  }
1039 
1040 
1041  //
1042  // Connect package versions view
1043  //
1044 
1045  if ( _pkgVersionsView && _pkgList )
1046  {
1047  connect( _pkgVersionsView, SIGNAL( candidateChanged( ZyppObj ) ),
1048  _pkgList, SLOT ( updateItemData() ) );
1049 
1050  connect( _pkgVersionsView, SIGNAL( statusChanged() ),
1051  _pkgList, SLOT ( updateItemData() ) );
1052  }
1053 
1054 
1055  //
1056  // Hotkey to enable "patches" filter view on the fly
1057  //
1058 
1059  QShortcut * accel = new QShortcut( Qt::Key_F2, this, SLOT( hotkeyInsertPatchFilterView() ) );
1060  YUI_CHECK_NEW( accel );
1061 
1062  //
1063  // Update actions just before opening menus
1064  //
1065 
1066  if ( _pkgMenu && _pkgList )
1067  {
1068  connect( _pkgMenu, SIGNAL( aboutToShow() ),
1069  _pkgList, SLOT ( updateActions() ) );
1070  }
1071 
1072  if ( _patchMenu && _patchList )
1073  {
1074  connect( _patchMenu, SIGNAL( aboutToShow() ),
1075  _patchList, SLOT ( updateActions() ) );
1076  }
1077 }
1078 
1079 
1080 void
1082 {
1083  if ( _autoDependenciesAction && ! _autoDependenciesAction->isChecked() )
1084  return;
1085 
1087 }
1088 
1089 
1090 int
1092 {
1093  if ( ! _pkgConflictDialog )
1094  {
1095  yuiError() << "No package conflict dialog existing" << std::endl;
1096  return QDialog::Accepted;
1097  }
1098 
1099  YQUI::ui()->busyCursor();
1100  int result = _pkgConflictDialog->solveAndShowConflicts();
1101  YQUI::ui()->normalCursor();
1102 
1103 #if DEPENDENCY_FEEDBACK_IF_OK
1104 
1105  if ( result == QDialog::Accepted )
1106  {
1107  QMessageBox::information( this, "",
1108  _( "All package dependencies are OK." ),
1109  QMessageBox::Ok );
1110  }
1111 #endif
1112 
1113  return result;
1114 }
1115 
1116 
1117 void
1119 {
1120  if ( ! _patchFilterView )
1121  {
1122  _patchFilterView = new YQPkgPatchFilterView( this );
1123  YUI_CHECK_NEW( _patchFilterView );
1124  _filters->addPage( _( "P&atches" ), _patchFilterView, "patches" );
1125 
1126  _patchList = _patchFilterView->patchList();
1127  YUI_CHECK_PTR( _patchList );
1128 
1129  connectPatchList();
1130  }
1131 }
1132 
1133 
1134 void
1136 {
1137  if ( ! _patchFilterView )
1138  {
1139  yuiMilestone() << "Activating patches filter view" << std::endl;
1140 
1142  connectPatchList();
1143 
1144  _filters->showPage( _patchFilterView );
1145  _pkgList->clear();
1146  _patchList->filter();
1147  }
1148  else
1149  {
1150  _filters->showPage( _patchFilterView );
1151  }
1152 }
1153 
1154 
1155 void
1157 {
1158  if ( _pkgList && _patchList )
1159  {
1160  connectFilter( _patchList, _pkgList );
1161 
1162  connect( _patchList, SIGNAL( filterMatch ( const QString &, const QString &, FSize ) ),
1163  _pkgList, SLOT ( addPassiveItem( const QString &, const QString &, FSize ) ) );
1164 
1165  connect( _patchList, SIGNAL( statusChanged() ),
1166  this, SLOT ( autoResolveDependencies() ) );
1167 
1168  if ( _pkgConflictDialog )
1169  {
1170  connect( _pkgConflictDialog,SIGNAL( updatePackages() ),
1171  _patchList, SLOT ( updateItemStates() ) );
1172  }
1173 
1174  connect( this, SIGNAL( refresh() ),
1175  _patchList, SLOT ( updateItemStates() ) );
1176 
1177  }
1178 }
1179 
1180 
1181 void
1183 {
1184  QString filename = YQApplication::askForSaveFileName( QString( DEFAULT_EXPORT_FILE_NAME ), // startsWith
1185  QString( "*.xml;;*" ), // filter
1186  _( "Save Package List" ) );
1187 
1188  if ( ! filename.isEmpty() )
1189  {
1190  zypp::syscontent::Writer writer;
1191  const zypp::ResPool & pool = zypp::getZYpp()->pool();
1192 
1193  // The ZYPP obfuscated C++ contest proudly presents:
1194 
1195  for_each( pool.begin(), pool.end(),
1196  boost::bind( &zypp::syscontent::Writer::addIf,
1197  boost::ref( writer ),
1198  _1 ) );
1199  // Yuck. What a mess.
1200  //
1201  // Does anybody seriously believe this kind of thing is easier to read,
1202  // let alone use? Get real. This is an argument in favour of all C++
1203  // haters. And it's one that is really hard to counter.
1204  //
1205  // -sh 2006-12-13
1206 
1207  try
1208  {
1209  std::ofstream exportFile( toUTF8( filename ).c_str() );
1210  exportFile.exceptions( std::ios_base::badbit | std::ios_base::failbit );
1211  exportFile << writer;
1212 
1213  yuiMilestone() << "Package list exported to " << filename << std::endl;
1214  }
1215  catch ( std::exception & exception )
1216  {
1217  yuiWarning() << "Error exporting package list to " << filename << std::endl;
1218 
1219  // The export might have left over a partially written file.
1220  // Try to delete it. Don't care if it doesn't exist and unlink() fails.
1221  QFile::remove(filename);
1222 
1223  // Post error popup
1224  QMessageBox::warning( this, // parent
1225  _( "Error" ), // caption
1226  _( "Error exporting package list to %1" ).arg( filename ),
1227  QMessageBox::Ok | QMessageBox::Default, // button0
1228  Qt::NoButton, // button1
1229  Qt::NoButton ); // button2
1230  }
1231  }
1232 }
1233 
1234 
1235 void
1237 {
1238  QString filename = QFileDialog::getOpenFileName( this, _( "Load Package List" ), DEFAULT_EXPORT_FILE_NAME,
1239  "*.xml+;;*"// filter
1240  );
1241 
1242  if ( ! filename.isEmpty() )
1243  {
1244  yuiMilestone() << "Importing package list from " << filename << std::endl;
1245 
1246  try
1247  {
1248  std::ifstream importFile( toUTF8( filename ).c_str() );
1249  zypp::syscontent::Reader reader( importFile );
1250 
1251  //
1252  // Put reader contents into maps
1253  //
1254 
1255  typedef zypp::syscontent::Reader::Entry ZyppReaderEntry;
1256  typedef std::pair<string, ZyppReaderEntry> ImportMapPair;
1257 
1258  map<string, ZyppReaderEntry> importPkg;
1259  map<string, ZyppReaderEntry> importPatterns;
1260 
1261  for ( zypp::syscontent::Reader::const_iterator it = reader.begin();
1262  it != reader.end();
1263  ++ it )
1264  {
1265  string kind = it->kind();
1266 
1267  if ( kind == "package" ) importPkg.insert ( ImportMapPair( it->name(), *it ) );
1268  else if ( kind == "pattern" ) importPatterns.insert( ImportMapPair( it->name(), *it ) );
1269  }
1270 
1271  yuiDebug() << "Found " << importPkg.size()
1272  <<" packages and " << importPatterns.size()
1273  << " patterns in " << filename
1274  << std::endl;
1275 
1276 
1277  //
1278  // Set status of all patterns and packages according to import map
1279  //
1280 
1281  for ( ZyppPoolIterator it = zyppPatternsBegin();
1282  it != zyppPatternsEnd();
1283  ++it )
1284  {
1285  ZyppSel selectable = *it;
1286  importSelectable( *it, importPatterns.find( selectable->name() ) != importPatterns.end(), "pattern" );
1287  }
1288 
1289  for ( ZyppPoolIterator it = zyppPkgBegin();
1290  it != zyppPkgEnd();
1291  ++it )
1292  {
1293  ZyppSel selectable = *it;
1294  importSelectable( *it, importPkg.find( selectable->name() ) != importPkg.end(), "package" );
1295  }
1296 
1297 
1298  //
1299  // Display result
1300  //
1301 
1302  emit refresh();
1303 
1304  if ( _statusFilterView )
1305  {
1306  // Switch to "Installation Summary" filter view
1307 
1308  _filters->showPage( _statusFilterView );
1309  _statusFilterView->filter();
1310  }
1311 
1312  }
1313  catch ( const zypp::Exception & exception )
1314  {
1315  yuiWarning() << "Error reading package list from " << filename << std::endl;
1316 
1317  // Post error popup
1318  QMessageBox::warning( this, // parent
1319  _( "Error" ), // caption
1320  _( "Error loading package list from %1" ).arg( filename ),
1321  QMessageBox::Ok | QMessageBox::Default, // button0
1322  QMessageBox::NoButton, // button1
1323  QMessageBox::NoButton ); // button2
1324  }
1325  }
1326 }
1327 
1328 
1329 void
1331  bool isWanted,
1332  const char * kind )
1333 {
1334  ZyppStatus oldStatus = selectable->status();
1335  ZyppStatus newStatus = oldStatus;
1336 
1337  if ( isWanted )
1338  {
1339  //
1340  // Make sure this selectable does not get installed
1341  //
1342 
1343  switch ( oldStatus )
1344  {
1345  case S_Install:
1346  case S_AutoInstall:
1347  case S_KeepInstalled:
1348  case S_Protected:
1349  case S_Update:
1350  case S_AutoUpdate:
1351  newStatus = oldStatus;
1352  break;
1353 
1354  case S_Del:
1355  case S_AutoDel:
1356  newStatus = S_KeepInstalled;
1357  yuiDebug() << "Keeping " << kind << " " << selectable->name() << std::endl;
1358  break;
1359 
1360  case S_NoInst:
1361  case S_Taboo:
1362 
1363  if ( selectable->hasCandidateObj() )
1364  {
1365  newStatus = S_Install;
1366  yuiDebug() << "Adding " << kind << " " << selectable->name() << std::endl;
1367  }
1368  else
1369  {
1370  yuiDebug() << "Can't add " << kind << " " << selectable->name()
1371  << ": No candidate" << std::endl;
1372  }
1373  break;
1374  }
1375  }
1376  else // ! isWanted
1377  {
1378  //
1379  // Make sure this selectable does not get installed
1380  //
1381 
1382  switch ( oldStatus )
1383  {
1384  case S_Install:
1385  case S_AutoInstall:
1386  case S_KeepInstalled:
1387  case S_Protected:
1388  case S_Update:
1389  case S_AutoUpdate:
1390  newStatus = S_Del;
1391  yuiDebug() << "Deleting " << kind << " " << selectable->name() << std::endl;
1392  break;
1393 
1394  case S_Del:
1395  case S_AutoDel:
1396  case S_NoInst:
1397  case S_Taboo:
1398  newStatus = oldStatus;
1399  break;
1400  }
1401  }
1402 
1403  if ( oldStatus != newStatus )
1404  selectable->setStatus( newStatus );
1405 }
1406 
1407 
1408 void
1410 {
1411  if ( ! _pkgList )
1412  return;
1413 
1414  int count = _pkgList->globalSetPkgStatus( S_Update, force,
1415  true ); // countOnly
1416  yuiMilestone() << count << " pkgs found for update" << std::endl;
1417 
1418  if ( count >= GLOBAL_UPDATE_CONFIRMATION_THRESHOLD )
1419  {
1420  if ( QMessageBox::question( this, "", // caption
1421  // Translators: %1 is the number of affected packages
1422  _( "%1 packages will be updated" ).arg( count ),
1423  _( "&Continue" ), _( "C&ancel" ),
1424  0, // defaultButtonNumber (from 0)
1425  1 ) // escapeButtonNumber
1426  == 1 ) // "Cancel"?
1427  {
1428  return;
1429  }
1430  }
1431 
1432  (void) _pkgList->globalSetPkgStatus( S_Update, force,
1433  false ); // countOnly
1434 
1435  if ( _statusFilterView )
1436  {
1437  _filters->showPage( _statusFilterView );
1438  _statusFilterView->clear();
1439  _statusFilterView->showTransactions();
1440  _statusFilterView->filter();
1441  }
1442 }
1443 
1444 void
1446 {
1447  zypp::ResPool::repository_iterator it;
1448  _repoUpgradeLabel->setText("");
1449  _repoUpgradingLabel->setText("");
1450 
1451  // we iterate twice to show first the repo upgrades that
1452  // can be cancelled, and then the repo that can be added
1453  for ( it = zypp::getZYpp()->pool().knownRepositoriesBegin();
1454  it != zypp::getZYpp()->pool().knownRepositoriesEnd();
1455  ++it )
1456  {
1457  zypp::Repository repo(*it);
1458  // add the option to cancel the upgrade job against this
1459  // repository if there is a job for it
1460  if ( zypp::getZYpp()->resolver()->upgradingRepo(repo) )
1461  {
1462  _repoUpgradingLabel->setText(_repoUpgradingLabel->text() + _("<p><small><a href=\"repoupgraderemove:///%1\">Cancel switching</a> system packages to versions in repository %2</small></p>")
1463  .arg(fromUTF8(repo.alias().c_str()))
1464  .arg(fromUTF8(repo.name().c_str()))
1465  );
1466  }
1467  }
1468 
1469  for ( it = zypp::getZYpp()->pool().knownRepositoriesBegin();
1470  it != zypp::getZYpp()->pool().knownRepositoriesEnd();
1471  ++it )
1472  {
1473  zypp::Repository repo(*it);
1474  // add the option to upgrade to this repo packages if it is not the system
1475  // repository and there is no upgrade job in the solver for it
1476  // and the repo is the one selected right now
1477  if ( ! zypp::getZYpp()->resolver()->upgradingRepo(repo) &&
1478  ! repo.isSystemRepo() &&
1479  _repoFilterView->selectedRepo() == repo )
1480  {
1481  _repoUpgradeLabel->setText(_repoUpgradeLabel->text() + _("<p><a href=\"repoupgradeadd:///%1\">Switch system packages</a> to the versions in this repository (%2)</p>")
1482  .arg(fromUTF8(repo.alias().c_str()))
1483  .arg(fromUTF8(repo.name().c_str()))
1484  );
1485  }
1486  }
1487  _repoUpgradeLabel->setVisible(!_repoUpgradeLabel->text().isEmpty() &&
1488  _repoFilterView->isVisible() );
1489  _repoUpgradingLabel->setVisible(!_repoUpgradingLabel->text().isEmpty());
1490 }
1491 
1492 void
1494 {
1495  yuiDebug() << "link " << link << " clicked on label" << std::endl;
1496 
1497  QUrl url(link);
1498  if (url.scheme() == "repoupgradeadd")
1499  {
1500  yuiDebug() << "looking for repo " << url.path() << std::endl;
1501  std::string alias(url.path().remove(0,1).toStdString());
1502  zypp::Repository repo(zypp::getZYpp()->pool().reposFind(alias));
1503  yuiDebug() << repo << std::endl;
1504 
1505  if ( repo != zypp::Repository::noRepository )
1506  zypp::getZYpp()->resolver()->addUpgradeRepo(repo);
1507  }
1508  else if (url.scheme() == "repoupgraderemove")
1509  {
1510  std::string alias(url.path().remove(0,1).toStdString());
1511  zypp::Repository repo(zypp::getZYpp()->pool().reposFind(alias));
1512 
1513  if ( repo != zypp::Repository::noRepository )
1514  zypp::getZYpp()->resolver()->removeUpgradeRepo(repo);
1515  }
1516  else
1517  yuiDebug() << "unknown link operation " << url.scheme() << std::endl;
1518 
1520  emit refresh();
1521 }
1522 
1523 void
1525 {
1527 }
1528 
1529 
1530 void
1532 {
1534 }
1535 
1536 void
1538 {
1539  installSubPkgs( "-devel" );
1540 }
1541 
1542 
1543 void
1545 {
1546  installSubPkgs( "-debuginfo" );
1547 }
1548 
1549 
1550 void
1552 {
1553  installSubPkgs( "-debugsource" );
1554 }
1555 
1556 
1557 void
1559 {
1560  zypp::getZYpp()->resolver()->setIgnoreAlreadyRecommended( false );
1562 
1563  if ( _filters && _statusFilterView )
1564  {
1565  _filters->showPage( _statusFilterView );
1566  _statusFilterView->filter();
1567  }
1568 
1570  _( "Added Subpackages:" ),
1571  _( "&OK" ),
1572  QString::null, // rejectButtonLabel
1573  YQPkgChangesDialog::FilterAutomatic,
1574  YQPkgChangesDialog::OptionNone ); // showIfEmpty
1575 }
1576 
1577 
1578 void
1580 {
1581  if ( _optionsMenu && _pkgList )
1582  {
1583  if ( _excludeDebugInfoPkgs )
1584  _excludeDebugInfoPkgs->enable( ! on );
1585 
1586  _pkgList->applyExcludeRules();
1587  }
1588 }
1589 
1590 
1591 void
1592 YQPackageSelector::pkgExcludeDevelChanged( bool on )
1593 {
1594  if ( _optionsMenu && _pkgList )
1595  {
1596  if ( _excludeDevelPkgs )
1597  _excludeDevelPkgs->enable( ! on );
1598 
1599  _pkgList->applyExcludeRules();
1600  }
1601 }
1602 
1603 
1604 void
1605 YQPackageSelector::pkgVerifySytemModeChanged( bool on )
1606 {
1607  zypp::getZYpp()->resolver()->setSystemVerification( on );
1608 }
1609 
1610 void
1611 YQPackageSelector::pkgInstallRecommendedChanged( bool on )
1612 {
1613  zypp::getZYpp()->resolver()->setOnlyRequires( !on );
1615 }
1616 
1617 void
1618 YQPackageSelector::pkgCleanDepsOnRemoveChanged( bool on )
1619 {
1620  zypp::getZYpp()->resolver()->setCleandepsOnRemove( on );
1622 }
1623 
1624 
1625 void
1626 YQPackageSelector::pkgAllowVendorChangeChanged( bool on )
1627 {
1628  zypp::getZYpp()->resolver()->setAllowVendorChange( on );
1630 }
1631 
1632 
1633 
1634 void
1635 YQPackageSelector::installSubPkgs( const QString & suffix )
1636 {
1637  // Find all matching packages and put them into a QMap
1638 
1639  QMap<QString, ZyppSel> subPkgs;
1640 
1641  for ( ZyppPoolIterator it = zyppPkgBegin();
1642  it != zyppPkgEnd();
1643  ++it )
1644  {
1645  QString name = (*it)->name().c_str();
1646 
1647  if ( name.endsWith( suffix ) || name.endsWith( suffix + "-32bit" ) )
1648  {
1649  subPkgs[ name ] = *it;
1650 
1651  yuiDebug() << "Found subpackage: " << name << std::endl;
1652  }
1653  }
1654 
1655 
1656  // Now go through all packages and look if there is a corresponding subpackage in the QMap
1657 
1658  for ( ZyppPoolIterator it = zyppPkgBegin();
1659  it != zyppPkgEnd();
1660  ++it )
1661  {
1662  QString name = (*it)->name().c_str();
1663 
1664  if ( subPkgs.contains( name + suffix ) )
1665  {
1666  QString subPkgName( name + suffix );
1667  ZyppSel subPkg = subPkgs[ subPkgName ];
1668 
1669  switch ( (*it)->status() )
1670  {
1671  case S_AutoDel:
1672  case S_NoInst:
1673  case S_Protected:
1674  case S_Taboo:
1675  case S_Del:
1676  // Don't install the subpackage
1677  yuiMilestone() << "Ignoring unwanted subpackage " << subPkgName << std::endl;
1678  break;
1679 
1680  case S_AutoInstall:
1681  case S_Install:
1682  case S_KeepInstalled:
1683 
1684  // Install the subpackage, but don't try to update it
1685 
1686  if ( ! subPkg->installedObj() )
1687  {
1688  subPkg->setStatus( S_Install );
1689  yuiMilestone() << "Installing subpackage " << subPkgName << std::endl;
1690  }
1691  break;
1692 
1693 
1694  case S_Update:
1695  case S_AutoUpdate:
1696 
1697  // Install or update the subpackage
1698 
1699  if ( ! subPkg->installedObj() )
1700  {
1701  subPkg->setStatus( S_Install );
1702  yuiMilestone() << "Installing subpackage " << subPkgName << std::endl;
1703  }
1704  else
1705  {
1706  subPkg->setStatus( S_Update );
1707  yuiMilestone() << "Updating subpackage " << subPkgName << std::endl;
1708  }
1709  break;
1710 
1711  // Intentionally omitting 'default' branch so the compiler can
1712  // catch unhandled enum states
1713  }
1714  }
1715  }
1716 
1717 
1718  if ( _filters && _statusFilterView )
1719  {
1720  _filters->showPage( _statusFilterView );
1721  _statusFilterView->filter();
1722  }
1723 
1725  _( "Added Subpackages:" ),
1726  QRegExp( ".*" + suffix + "$" ),
1727  _( "&OK" ),
1728  QString::null, // rejectButtonLabel
1729  YQPkgChangesDialog::FilterAutomatic,
1730  YQPkgChangesDialog::OptionNone ); // showIfEmpty
1731 }
1732 
1733 void
1735 {
1736  QString settingsName = "YQPackageSelector";
1737  if ( onlineUpdateMode() ) settingsName = "YQOnlineUpdate";
1738  if ( updateMode() ) settingsName = "YQSystemUpdate";
1739 
1740  QSettings settings( QSettings::UserScope, SETTINGS_DIR, settingsName );
1741 
1742  _showDevelAction->setChecked(settings.value("Options/showDevelPackages", true).toBool());
1743  pkgExcludeDevelChanged(_showDevelAction->isChecked());
1744 
1745  _showDebugAction->setChecked(settings.value("Options/showDebugPackages", true).toBool());
1746  pkgExcludeDebugChanged(_showDebugAction->isChecked());
1747 
1748  loadCommonSettings();
1749 }
1750 
1751 void
1752 YQPackageSelector::loadCommonSettings()
1753 {
1754  map<string, string> sysconfig = zypp::base::sysconfig::read(PATH_TO_YAST_SYSCONFIG);
1755 
1756  bool auto_check = AUTO_CHECK_DEPENDENCIES_DEFAULT;
1757  auto it = sysconfig.find(OPTION_AUTO_CHECK);
1758  if (it != sysconfig.end())
1759  {
1760  auto_check = it->second == "yes";
1761  }
1762  _autoDependenciesAction->setChecked(auto_check);
1763 
1764  bool verify_system = zypp::getZYpp()->resolver()->systemVerification();
1765  it = sysconfig.find(OPTION_VERIFY);
1766  if (it != sysconfig.end())
1767  {
1768  verify_system = it->second == "yes";
1769  }
1770  _verifySystemModeAction->setChecked(verify_system);
1771  pkgVerifySytemModeChanged(verify_system);
1772 
1773  bool install_recommended = ! zypp::getZYpp()->resolver()->onlyRequires();
1774  it = sysconfig.find(OPTION_RECOMMENDED);
1775  if (it != sysconfig.end())
1776  {
1777  install_recommended = it->second == "yes";
1778  }
1779  _installRecommendedAction->setChecked(install_recommended);
1780  pkgInstallRecommendedChanged(install_recommended);
1781 
1782  bool allow_vendor_change = zypp::getZYpp()->resolver()->allowVendorChange();
1783  _allowVendorChangeAction->setChecked(allow_vendor_change);
1784  pkgAllowVendorChangeChanged(allow_vendor_change);
1785 
1786  bool clean_deps_on_remove = zypp::getZYpp()->resolver()->cleandepsOnRemove();
1787  _cleanDepsOnRemoveAction->setChecked(clean_deps_on_remove);
1788  pkgCleanDepsOnRemoveChanged(clean_deps_on_remove);
1789 }
1790 
1791 void
1793 {
1794  QString settingsName = "YQPackageSelector";
1795  if ( onlineUpdateMode() ) settingsName = "YQOnlineUpdate";
1796  if ( updateMode() ) settingsName = "YQSystemUpdate";
1797 
1798  QSettings settings( QSettings::UserScope, SETTINGS_DIR, settingsName );
1799 
1800  settings.setValue("Options/showDevelPackages", _showDevelAction->isChecked() );
1801  settings.setValue("Options/showDebugPackages", _showDebugAction->isChecked() );
1802 
1803  saveCommonSettings();
1804 }
1805 
1806 void
1807 YQPackageSelector::saveCommonSettings()
1808 {
1809  try
1810  {
1811  zypp::base::sysconfig::writeStringVal(
1812  PATH_TO_YAST_SYSCONFIG,
1813  OPTION_AUTO_CHECK,
1814  ( _autoDependenciesAction->isChecked() ? "yes" : "no"),
1815  "Automatic dependency checking");
1816  zypp::base::sysconfig::writeStringVal(
1817  PATH_TO_YAST_SYSCONFIG,
1818  OPTION_VERIFY,
1819  (_verifySystemModeAction->isChecked() ? "yes" : "no"),
1820  "System verification mode");
1821  zypp::base::sysconfig::writeStringVal(
1822  PATH_TO_YAST_SYSCONFIG,
1823  OPTION_RECOMMENDED,
1824  (_installRecommendedAction->isChecked() ? "yes" : "no"),
1825  "Install recommended packages");
1826  }
1827  catch( const std::exception &e )
1828  {
1829  yuiError() << "Writing " << PATH_TO_YAST_SYSCONFIG << " failed" << std::endl;
1830  }
1831 }
1832 
1833 #include "YQPackageSelector.moc"
Display the description of a ZyppObj derived object along with its name and summary.
void onlineUpdateConfiguration()
Close processing and request start of the online update configuration.
void addPatchFilterView()
Add the "Patches" filter view, if it is not already there.
void showPage(QWidget *page)
Show a page.
int globalSetPkgStatus(ZyppStatus newStatus, bool force, bool countOnly)
Set the status of all packages in the pool to a new value.
Definition: YQPkgList.cc:676
void loadData()
Emitted once (!) when the dialog is about to be shown, when all widgets are created and all signal/sl...
RPM group tags filter view: Display the RPM group tags tree and emit signals if any group tag is sele...
void globalUpdatePkg()
Set the status of all installed packages (all in the pool, not only those currently displayed in the ...
void connectFilter(QWidget *filter, QWidget *pkgList, bool hasUpdateSignal=true)
Connect a filter view that provides the usual signals with a package list.
void addPage(const QString &pageLabel, QWidget *pageContent, const QString &internalName)
Add a page with a user-visible "pageLabel", a widget with the page content and an internal name (or I...
zypp::Repository selectedRepo() const
Current selected repository, or if nothing is selected.
Filter view for PackageKit groups.
static int countEnabledRepositories()
Returns the number of enabled repositories.
YQPkgPatchList * patchList() const
Returns this view&#39;s selections list.
void showProducts()
Show all products in a popup dialog.
Filter view for packages that made problems during update.
void filter()
Filter according to the view&#39;s rules and current selection.
Widget for "tabbed browsing" in packages:
static bool haveInstalledPkgs()
Returns &#39;true&#39; if there are any installed packages.
Definition: YQPkgList.cc:178
void importSelectable(ZyppSel selectable, bool isWanted, const char *kind)
Import one selectable: Set its status according to &#39;isWanted&#39; based on its old status.
void updateRepositoryUpgradeLabel()
hides or shows the repository upgrade message
YQPkgDiskUsageList * diskUsageList() const
Return the disk usage list widget or 0 if there is none.
QWidget * rightPane() const
Return the right pane.
void currentChanged(QWidget *newPageContent)
Emitted when the current page changes.
void saveSettings()
saves settings of the checkboxes in the option menu
int manualResolvePackageDependencies()
Resolve package dependencies manually.
void keyboardHelp()
Display online help about magic keys.
void enable(bool enable=true)
Enable or disable this exclude rule.
void accept()
Close processing and accept changes.
Display a list of zypp::Patch objects and ( below ) details about the currently selected patch...
void slotRepoUpgradeLabelLinkClicked(const QString &link)
a link in the repo upgrade label was clicked
void repoManager()
Close processing and request start of the repository manager.
Display a pkg&#39;s file list.
static std::string iconPath(const std::string &name, int size)
returns the full path for an icon of a given size
Display a list of zypp::Package objects.
Definition: YQPkgList.h:54
Display a list of zypp::Pattern objects.
Filter view for searching within packages.
void symbolHelp()
Display online help about symbols (package status icons).
void installDebugInfoPkgs()
Install available -debuginfo packages for packages that are installed or marked for installation...
void connectPatchList()
Connect the patch list.
Display technical details (very much like &#39;rpm -qi&#39;) for a ZYPP object - the installed instance...
void clear()
Clears the tree-widgets content, resets the optimal column width values.
Definition: YQPkgList.cc:432
void pkgExport()
Export all current selection/package states.
void applyExcludeRules()
Apply all exclude rules of this list to all items, including those that are currently excluded...
Filter view for packages that made problems during update.
void help()
Display (generic) online help.
Package version selector: Display a list of available versions from all the different installation so...
void autoResolveDependencies()
Automatically resolve package dependencies if desired (if the "auto check" checkbox is on)...
static bool haveProblematicPackages()
Check if there are any problematic packages at all, i.e.
void addMenus()
Add pulldown menus to the menu bar.
Display a list of zypp::Selection objects.
Definition: YQPkgLangList.h:52
void clear()
Reset all check boxes (set them all to "off")
void installDevelPkgs()
Install any -devel package for packages that are installed or marked for installation.
void loadSettings()
loads settings for the checkboxes in the option menu
static void showHistoryDialog(QWidget *parent=0)
Static convenience method: Post a History dialog for pkg &#39;pkgName&#39;.
static bool showChangesDialog(QWidget *parent, const QString &message, const QString &acceptButtonLabel, const QString &rejectButtonLabel=QString::null, Filters f=FilterAutomatic, Options o=OptionAutoAcceptIfEmpty)
Static convenience method: Post a changes dialog with text &#39;message&#39;, a list of changed packages and ...
void showTransactions()
Set up the check boxes so all pending transactions are displayed.
void refresh()
Emitted when the internal data base might have changed and a refresh of all displayed data might be n...
virtual QMenu * addAllInListSubMenu(QMenu *menu)
Add a submenu "All in this list..." to &#39;menu&#39;.
void installDebugSourcePkgs()
Install available -debugsource packages for packages that are installed or marked for installation...
virtual QMenu * addAllInListSubMenu(QMenu *menu)
Add a submenu "All in this list..." to &#39;menu&#39;.
Definition: YQPkgList.cc:499
Abstract base class for package selectors.
static void showProductDialog(QWidget *parent=0)
Static convenience method: Post a dialog with all products.
void filter()
Filter according to the view&#39;s rules and current selection.
void hotkeyInsertPatchFilterView()
Add the "Patches" filter view upon hotkey (F2).
void installSubPkgs(const QString &suffix)
Install any subpackage that ends with &#39;suffix&#39; for packages that are installed or marked for installa...
void installRecommendedPkgs()
Install recommended packages for packages that are installed.
void makeConnections()
Establish Qt signal / slot connections.
Display technical details ( very much like &#39;rpm -qi&#39; ) for a zypp::Package object - the installed ins...
void showHistory()
Show dialog for pkgmgr history.
void showAutoPkgList()
Display a list of automatically selected packages (excluding packages contained in any selections tha...
void pkgImport()
Import selection/package states.
bool reject()
Close processing and abandon changes.
int resolveDependencies()
Resolve dependencies (unconditionally) for all resolvables.
void pkgExcludeDebugChanged(bool on)
Enable or disable the package exclude rules (show or suppress -debuginfo or -devel packages) accordin...
int solveAndShowConflicts()
Run the package dependency solver for the current package set and open the conflict dialog if there a...
void globalUpdatePkgForce()
Set the status of all installed packages (all in the pool, not only those currently displayed in the ...
Display a pkg&#39;s file list.