libyui-qt-pkg  2.47.5
YQPkgObjList.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: YQPkgObjList.cc
35 
36  Author: Stefan Hundhammer <sh@suse.de>
37 
38  Textdomain "qt-pkg"
39 
40 /-*/
41 
42 #define YUILogComponent "qt-pkg"
43 #include "YUILog.h"
44 #include <QPixmap>
45 #include <QHeaderView>
46 #include <QMenu>
47 #include <QAction>
48 #include <QDebug>
49 #include <QKeyEvent>
50 
51 #include "utf8.h"
52 
53 #include "YDialog.h"
54 #include "YQPkgObjList.h"
55 #include "YQPkgTextDialog.h"
56 #include "YQi18n.h"
57 #include "YQIconPool.h"
58 #include "YQUI.h"
59 
60 #include "zypp/ZYppFactory.h"
61 
62 using std::endl;
63 using std::list;
64 using std::string;
65 
66 
67 #define VERBOSE_EXCLUDE_RULES 0
68 #define EXTRA_SOLVE_COLLECTIONS 0
69 
70 
71 YQPkgObjList::YQPkgObjList( QWidget * parent )
72  : QY2ListView( parent )
73  , _editable( true )
74  , _installedContextMenu(0)
75  , _notInstalledContextMenu(0)
76  , actionSetCurrentInstall(0)
77  , actionSetCurrentDontInstall(0)
78  , actionSetCurrentKeepInstalled(0)
79  , actionSetCurrentDelete(0)
80  , actionSetCurrentUpdate(0)
81  , actionSetCurrentUpdateForce(0)
82  , actionSetCurrentTaboo(0)
83  , actionSetCurrentProtected(0)
84  , actionSetListInstall(0)
85  , actionSetListDontInstall(0)
86  , actionSetListKeepInstalled(0)
87  , actionSetListDelete(0)
88  , actionSetListUpdate(0)
89  , actionSetListUpdateForce(0)
90  , actionSetListTaboo(0)
91  , actionSetListProtected(0)
92 {
93  // This class does not add any columns. This is the main reason why this is
94  // an abstract base class: It doesn't know which columns are desired and in
95  // what order.
96 
97  _iconCol = -42;
98  _statusCol = -42;
99  _nameCol = -42;
100  _versionCol = -42;
101  _instVersionCol = -42;
102  _summaryCol = -42;
103  _sizeCol = -42;
104  _brokenIconCol = -42;
105  _satisfiedIconCol = -42;
106  _excludedItemsCount = 0;
107  _debug = false;
108 
109  createActions();
110 
111  connect( this, SIGNAL( columnClicked ( int, QTreeWidgetItem *, int, const QPoint & ) ),
112  this, SLOT ( pkgObjClicked ( int, QTreeWidgetItem *, int, const QPoint & ) ) );
113 
114  connect( this, SIGNAL( columnDoubleClicked ( int, QTreeWidgetItem *, int, const QPoint & ) ),
115  this, SLOT ( pkgObjClicked ( int, QTreeWidgetItem *, int, const QPoint & ) ) );
116 
117  connect( this, SIGNAL( currentItemChanged ( QTreeWidgetItem *, QTreeWidgetItem * ) ),
118  this, SLOT ( currentItemChangedInternal( QTreeWidgetItem * ) ) );
119 
120  connect( this, SIGNAL(customContextMenuRequested(const QPoint &)),
121  this, SLOT (slotCustomContextMenu(const QPoint&)));
122 
123  setIconSize( QSize( 16, 16 ) );
124 
125  setContextMenuPolicy(Qt::CustomContextMenu);
126 
127 }
128 
129 
131 {
132 }
133 
134 
135 void
136 YQPkgObjList::addPkgObjItem( ZyppSel selectable, ZyppObj zyppObj )
137 {
138  if ( ! selectable )
139  {
140  yuiError() << "Null zypp::ui::Selectable!" << endl;
141  return;
142  }
143 
144  YQPkgObjListItem * item = new YQPkgObjListItem( this, selectable, zyppObj );
145  applyExcludeRules( item );
146 }
147 
148 
149 void
150 YQPkgObjList::addPassiveItem( const QString & name,
151  const QString & summary,
152  FSize size )
153 {
154  QY2ListViewItem * item = new QY2ListViewItem( this, QString() );
155 
156  if ( item )
157  {
158  if ( nameCol() >= 0 && ! name.isEmpty() ) item->setText( nameCol(), name );
159  if ( summaryCol() >= 0 && ! summary.isEmpty() ) item->setText( summaryCol(), summary );
160  if ( sizeCol() >= 0 && size > 0L )
161  {
162  QString sizeStr = size.form().c_str();
163  item->setText( sizeCol(), sizeStr );
164  }
165  }
166 }
167 
168 
169 void
171  QTreeWidgetItem * listViewItem,
172  int col,
173  const QPoint & pos )
174 {
175  YQPkgObjListItem * item = dynamic_cast<YQPkgObjListItem *> (listViewItem);
176 
177  if ( item )
178  {
179  //y2internal("CLICKED: %s", item->zyppObj()->name().c_str());
180  if ( button == Qt::LeftButton )
181  {
182  if ( col == statusCol() )
183  // || col == nameCol() )
184  {
185  if ( editable() && item->editable() )
186  item->cycleStatus();
187  }
188  }
189  // context menus are handled in slotCustomContextMenu()
190  }
191 }
192 
193 
194 void
195 YQPkgObjList::currentItemChangedInternal( QTreeWidgetItem * listViewItem )
196 {
197  YQPkgObjListItem * item = dynamic_cast<YQPkgObjListItem *> (listViewItem);
198 
199  emit currentItemChanged( item ? item->selectable() : ZyppSel() );
200 }
201 
202 
203 void
205 {
206  emit currentItemChanged( ZyppSel() );
207  _excludedItemsCount = 0;
208 
209  QY2ListView::clear();
210 }
211 
212 
213 QPixmap
214 YQPkgObjList::statusIcon( ZyppStatus status, bool enabled, bool bySelection )
215 {
216  QPixmap icon = YQIconPool::pkgNoInst();
217 
218  if ( enabled )
219  {
220  switch ( status )
221  {
222  case S_Del: icon = YQIconPool::pkgDel(); break;
223  case S_Install: icon = YQIconPool::pkgInstall(); break;
224  case S_KeepInstalled: icon = YQIconPool::pkgKeepInstalled(); break;
225  case S_NoInst: icon = YQIconPool::pkgNoInst(); break;
226  case S_Protected: icon = YQIconPool::pkgProtected(); break;
227  case S_Taboo: icon = YQIconPool::pkgTaboo(); break;
228  case S_Update: icon = YQIconPool::pkgUpdate(); break;
229 
230  case S_AutoDel: icon = YQIconPool::pkgAutoDel(); break;
231  case S_AutoInstall: icon = YQIconPool::pkgAutoInstall(); break;
232  case S_AutoUpdate: icon = YQIconPool::pkgAutoUpdate(); break;
233 
234  // Intentionally omitting 'default' branch so the compiler can
235  // catch unhandled enum states
236  }
237  }
238  else
239  {
240  switch ( status )
241  {
242  case S_Del: icon = YQIconPool::disabledPkgDel(); break;
243  case S_Install: icon = YQIconPool::disabledPkgInstall(); break;
244  case S_KeepInstalled: icon = YQIconPool::disabledPkgKeepInstalled(); break;
245  case S_NoInst: icon = YQIconPool::disabledPkgNoInst(); break;
246  case S_Protected: icon = YQIconPool::disabledPkgProtected(); break;
247  case S_Taboo: icon = YQIconPool::disabledPkgTaboo(); break;
248  case S_Update: icon = YQIconPool::disabledPkgUpdate(); break;
249 
250  case S_AutoDel: icon = YQIconPool::disabledPkgAutoDel(); break;
251  case S_AutoInstall: icon = YQIconPool::disabledPkgAutoInstall(); break;
252  case S_AutoUpdate: icon = YQIconPool::disabledPkgAutoUpdate(); break;
253 
254  // Intentionally omitting 'default' branch so the compiler can
255  // catch unhandled enum states
256  }
257  }
258 
259  return icon;
260 }
261 
262 
263 QString
264 YQPkgObjList::statusText( ZyppStatus status ) const
265 {
266  switch ( status )
267  {
268  case S_AutoDel: return _( "Autodelete" );
269  case S_AutoInstall: return _( "Autoinstall" );
270  case S_AutoUpdate: return _( "Autoupdate" );
271  case S_Del: return _( "Delete" );
272  case S_Install: return _( "Install" );
273  case S_KeepInstalled: return _( "Keep" );
274  case S_NoInst: return _( "Do Not Install" );
275  case S_Protected: return _( "Protected -- Do Not Modify" );
276  case S_Taboo: return _( "Taboo -- Never Install" );
277  case S_Update: return _( "Update" );
278  }
279 
280  return QString();
281 }
282 
283 
284 void
285 YQPkgObjList::setCurrentStatus( ZyppStatus newStatus, bool doSelectNextItem, bool ifNewerOnly )
286 {
287  QTreeWidgetItem * listViewItem = currentItem();
288 
289  if ( ! listViewItem )
290  return;
291 
292  YQPkgObjListItem * item = dynamic_cast<YQPkgObjListItem *> (listViewItem);
293 
294  if ( item && item->editable() && _editable && ( item->candidateIsNewer() || !ifNewerOnly ) )
295  {
296  if ( newStatus != item->status() )
297  {
298  item->setStatus( newStatus );
299 
300  if ( item->showLicenseAgreement() )
301  {
302  item->showNotifyTexts( newStatus );
303  }
304  else // License not confirmed?
305  {
306  // Status is now S_Taboo or S_Del - update status icon
307  item->setStatusIcon();
308  }
309 
310  emit statusChanged();
311  }
312  }
313 
314  if ( doSelectNextItem )
315  selectNextItem();
316 }
317 
318 
319 void
320 YQPkgObjList::setAllItemStatus( ZyppStatus newStatus, bool force )
321 {
322  if ( ! _editable )
323  return;
324 
325  YQUI::ui()->busyCursor();
326  QTreeWidgetItemIterator it( this );
327 
328  while ( *it )
329  {
330  YQPkgObjListItem * item = dynamic_cast<YQPkgObjListItem *> (*it);
331 
332  if ( item && item->editable() && newStatus != item->status() )
333  {
334  if ( newStatus == S_Update )
335  {
336  if ( force )
337  {
338  item->setStatus( newStatus,
339  false ); // sendSignals
340  }
341  else
342  {
343  if ( item->selectable()->installedObj() && item->status() != S_Protected && item->selectable()->updateCandidateObj() )
344  {
345  item->selectable()->setOnSystem( item->selectable()->updateCandidateObj() );
346  }
347  }
348  }
349  else
350  {
351  item->setStatus( newStatus,
352  false ); // sendSignals
353  }
354  }
355 
356  ++it;
357  }
358 
359  emit updateItemStates();
360  emit updatePackages();
361 
362  YQUI::ui()->normalCursor();
363  emit statusChanged();
364 }
365 
366 
367 void
369 {
370  QTreeWidgetItemIterator it(this);
371  QTreeWidgetItem * item;
372 
373  while ( (item = *it) != NULL )
374  {
375  ++it;
376  //item->setSelected( false ); // Doesn't emit signals
377  scrollToItem( *it ); // Scroll if necessary
378  setCurrentItem( *it ); // Emits signals
379 
380  }
381 }
382 
383 
384 void
386 {
387  actionSetCurrentInstall = createAction( S_Install, "[+]" );
388  actionSetCurrentDontInstall = createAction( S_NoInst, "[-]" );
389  actionSetCurrentKeepInstalled = createAction( S_KeepInstalled, "[<], [-]" );
390  actionSetCurrentDelete = createAction( S_Del, "[-]" );
391  actionSetCurrentUpdate = createAction( S_Update, "[>], [+]" );
392 
393  actionSetCurrentUpdateForce = createAction( _( "Update unconditionally" ),
394  statusIcon( S_Update, true ),
395  statusIcon( S_Update, false ) ,
396  "",
397  true ) ;
398 
399 
400 
401  actionSetCurrentTaboo = createAction( S_Taboo, "[!]" );
402  actionSetCurrentProtected = createAction( S_Protected, "[*]" );
403 
404  actionSetListInstall = createAction( S_Install, "", true );
405  actionSetListDontInstall = createAction( S_NoInst, "", true );
406  actionSetListKeepInstalled = createAction( S_KeepInstalled, "", true );
407  actionSetListDelete = createAction( S_Del, "", true );
408  actionSetListProtected = createAction( S_Protected, "", true );
409 
410  actionSetListUpdate = createAction( _( "Update if newer version available" ),
411  statusIcon( S_Update, true ),
412  statusIcon( S_Update, false ),
413  "",
414  true );
415 
416  actionSetListUpdateForce = createAction( _( "Update unconditionally" ),
417  statusIcon( S_Update, true ),
418  statusIcon( S_Update, false ),
419  "",
420  true );
421 
422  actionSetListTaboo = createAction( S_Taboo, "", true );
423 
424  connect( actionSetCurrentInstall, &QAction::triggered, this, &YQPkgObjList::setCurrentInstall );
425  connect( actionSetCurrentDontInstall, &QAction::triggered, this, &YQPkgObjList::setCurrentDontInstall );
426  connect( actionSetCurrentKeepInstalled, &QAction::triggered, this, &YQPkgObjList::setCurrentKeepInstalled );
427  connect( actionSetCurrentDelete, &QAction::triggered, this, &YQPkgObjList::setCurrentDelete );
428  connect( actionSetCurrentUpdate, &QAction::triggered, this, &YQPkgObjList::setCurrentUpdate );
429  connect( actionSetCurrentUpdateForce, &QAction::triggered, this, &YQPkgObjList::setCurrentUpdateForce );
430  connect( actionSetCurrentTaboo, &QAction::triggered, this, &YQPkgObjList::setCurrentTaboo );
431  connect( actionSetCurrentProtected, &QAction::triggered, this, &YQPkgObjList::setCurrentProtected );
432  connect( actionSetListInstall, &QAction::triggered, this, &YQPkgObjList::setListInstall );
433  connect( actionSetListDontInstall, &QAction::triggered, this, &YQPkgObjList::setListDontInstall );
434  connect( actionSetListKeepInstalled, &QAction::triggered, this, &YQPkgObjList::setListKeepInstalled );
435  connect( actionSetListDelete, &QAction::triggered, this, &YQPkgObjList::setListDelete );
436  connect( actionSetListUpdate, &QAction::triggered, this, &YQPkgObjList::setListUpdate );
437  connect( actionSetListUpdateForce, &QAction::triggered, this, &YQPkgObjList::setListUpdateForce );
438  connect( actionSetListTaboo, &QAction::triggered, this, &YQPkgObjList::setListTaboo );
439  connect( actionSetListProtected, &QAction::triggered, this, &YQPkgObjList::setListProtected );
440 }
441 
442 
443 
444 QAction *
445 YQPkgObjList::createAction( ZyppStatus status, const QString & key, bool enabled )
446 {
447  return createAction( statusText( status ),
448  statusIcon( status, true ),
449  statusIcon( status, false ),
450  key,
451  enabled );
452 }
453 
454 
455 QAction *
456 YQPkgObjList::createAction( const QString & text,
457  const QPixmap & icon,
458  const QPixmap & insensitiveIcon,
459  const QString & key,
460  bool enabled )
461 {
462  QString label = text;
463 
464  if ( ! key.isEmpty() )
465  label += "\t" + key;
466 
467 
468  QIcon iconSet ( icon );
469 
470  if ( ! insensitiveIcon.isNull() )
471  {
472  iconSet.addPixmap( insensitiveIcon,
473  QIcon::Disabled );
474  }
475 
476  QAction * action = new QAction( label, // text
477  this ); // parent
478  Q_CHECK_PTR( action );
479  action->setEnabled( enabled );
480  action->setIcon( iconSet );
481 
482  return action;
483 }
484 
485 
486 void
488 {
489  _notInstalledContextMenu = new QMenu( this );
490  Q_CHECK_PTR( _notInstalledContextMenu );
491 
492  _notInstalledContextMenu->addAction( actionSetCurrentInstall );
493  _notInstalledContextMenu->addAction( actionSetCurrentDontInstall );
494  _notInstalledContextMenu->addAction( actionSetCurrentTaboo );
495 
496  addAllInListSubMenu( _notInstalledContextMenu );
497 }
498 
499 
500 void
502 {
503  _installedContextMenu = new QMenu( this );
504  Q_CHECK_PTR( _installedContextMenu );
505 
506  _installedContextMenu->addAction( actionSetCurrentKeepInstalled );
507  _installedContextMenu->addAction( actionSetCurrentDelete );
508  _installedContextMenu->addAction( actionSetCurrentUpdate );
509  _installedContextMenu->addAction( actionSetCurrentUpdateForce );
510 
511  addAllInListSubMenu( _installedContextMenu );
512 }
513 
514 
515 QMenu *
517 {
518  QMenu * submenu = new QMenu( menu );
519  Q_CHECK_PTR( submenu );
520 
521  submenu->addAction( actionSetListInstall );
522  submenu->addAction( actionSetListDontInstall );
523  submenu->addAction( actionSetListKeepInstalled );
524  submenu->addAction( actionSetListDelete );
525  submenu->addAction( actionSetListUpdate );
526  submenu->addAction( actionSetListUpdateForce );
527  submenu->addAction( actionSetListTaboo );
528 
529  QAction *action = menu->addMenu( submenu );
530  action->setText( _( "&All in This List" ) );
531 
532  return submenu;
533 }
534 
535 
536 QMenu *
538 {
539  if ( ! _notInstalledContextMenu )
541 
542  return _notInstalledContextMenu;
543 }
544 
545 
546 QMenu *
548 {
549  if ( ! _installedContextMenu )
551 
552  return _installedContextMenu;
553 }
554 
555 
556 void
558 {
559  if ( !item)
560  item = dynamic_cast<YQPkgObjListItem *> ( currentItem() );
561 
562  if ( item )
563  {
564  ZyppSel selectable = item->selectable();
565 
566  if ( selectable->hasInstalledObj() )
567  {
568  actionSetCurrentInstall->setEnabled( false );
569  actionSetCurrentDontInstall->setEnabled( false );
570  actionSetCurrentTaboo->setEnabled( false );
571  actionSetCurrentProtected->setEnabled( true );
572 
573  actionSetCurrentKeepInstalled->setEnabled( true );
574  actionSetCurrentDelete->setEnabled( true );
575  actionSetCurrentUpdate->setEnabled( selectable->hasCandidateObj() );
576  actionSetCurrentUpdateForce->setEnabled( selectable->hasCandidateObj() );
577  }
578  else
579  {
580  actionSetCurrentInstall->setEnabled( selectable->hasCandidateObj() );
581  actionSetCurrentDontInstall->setEnabled( true );
582  actionSetCurrentTaboo->setEnabled( true );
583  actionSetCurrentProtected->setEnabled( false );
584 
585  actionSetCurrentKeepInstalled->setEnabled( false );
586  actionSetCurrentDelete->setEnabled( false );
587  actionSetCurrentUpdate->setEnabled( false );
588  actionSetCurrentUpdateForce->setEnabled( false );
589  }
590  }
591  else // ! item
592  {
593  actionSetCurrentInstall->setEnabled( false );
594  actionSetCurrentDontInstall->setEnabled( false );
595  actionSetCurrentTaboo->setEnabled( false );
596 
597  actionSetCurrentKeepInstalled->setEnabled( false );
598  actionSetCurrentDelete->setEnabled( false );
599  actionSetCurrentUpdate->setEnabled( false );
600  actionSetCurrentUpdateForce->setEnabled( false );
601  actionSetCurrentProtected->setEnabled( false );
602 
603  }
604 }
605 
606 
607 void
608 YQPkgObjList::keyPressEvent( QKeyEvent * event )
609 {
610  if ( event )
611  {
612  Qt::KeyboardModifiers special_combo = ( Qt::ControlModifier | Qt::ShiftModifier | Qt::AltModifier );
613 
614  if ( ( event->modifiers() & special_combo ) == special_combo )
615  {
616  if ( event->key() == Qt::Key_Q )
617  {
618  _debug= ! _debug;
619  yuiMilestone() << "Debug mode: " << _debug << endl;
620  }
621 
622  }
623  QTreeWidgetItem * selectedListViewItem = currentItem();
624 
625  if ( selectedListViewItem )
626  {
627  YQPkgObjListItem * item = dynamic_cast<YQPkgObjListItem *> (selectedListViewItem);
628 
629  if ( item )
630  {
631  bool installed;
632 
633  if ( item->selectable() )
634  installed = item->selectable()->hasInstalledObj();
635  else
636  installed = false;
637 
638  ZyppStatus status = item->status();
639 
640  switch( event->key() )
641  {
642  case Qt::Key_Space: // Cycle
643  item->cycleStatus();
644  event->accept();
645  return;
646 
647  case Qt::Key_Plus: // Grab everything - install or update
648 
649  if ( installed )
650  {
651  ZyppStatus newStatus = S_KeepInstalled;
652 
653  if ( item->candidateIsNewer() )
654  newStatus = S_Update;
655 
656  setCurrentStatus( newStatus );
657  }
658  else
659  setCurrentStatus( S_Install );
660  event->accept();
661  return;
662 
663  case Qt::Key_Minus: // Get rid of everything - don't install or delete
664  setCurrentStatus( installed ? S_Del : S_NoInst );
665  event->accept();
666  return;
667 
668  case Qt::Key_Exclam: // Taboo
669 
670  if ( ! installed )
671  setCurrentStatus( S_Taboo );
672  event->accept();
673  return;
674 
675  case Qt::Key_Asterisk: // Protected
676 
677  if ( installed )
678  setCurrentStatus( S_Protected );
679  event->accept();
680  return;
681 
682  case Qt::Key_Greater: // Update what is worth to be updated
683 
684  if ( installed && item->candidateIsNewer() )
685  setCurrentStatus( S_Update );
686  event->accept();
687  return;
688 
689  case Qt::Key_Less: // Revert update
690 
691  if ( status == S_Update ||
692  status == S_AutoUpdate )
693  {
694  setCurrentStatus( S_KeepInstalled );
695  }
696  event->accept();
697  return;
698 
699  case Qt::Key_B: // Toggle debugIsBroken flag
700 
701  if ( _debug )
702  {
703  item->toggleDebugIsBroken();
704  item->setStatusIcon();
705  }
706  event->accept();
707  break;
708 
709  case Qt::Key_S: // Toggle debugIsSatisfied flag
710 
711  if ( _debug )
712  {
713  item->toggleDebugIsSatisfied();
714  item->setStatusIcon();
715  }
716  event->accept();
717  break;
718  }
719  }
720  }
721  }
722  QY2ListView::keyPressEvent( event );
723 }
724 
725 
726 void
727 YQPkgObjList::message( const QString & text )
728 {
729  QY2ListViewItem * item = new QY2ListViewItem( this );
730  Q_CHECK_PTR( item );
731 
732  item->setText( nameCol() >= 0 ? nameCol() : 0, text );
733 }
734 
735 
736 void
738 {
739  _excludeRules.push_back( rule );
740 }
741 
742 
743 void
745 {
746  _excludedItemsCount = 0;
747  // yuiDebug() << "Applying exclude rules" << endl;
748  QTreeWidgetItemIterator listView_it( this );
749 
750  while ( *listView_it )
751  {
752  QTreeWidgetItem * current_item = *listView_it;
753 
754  // Advance iterator now so it remains valid even if there are changes
755  // to the QListView, e.g., if the current item is excluded and thus
756  // removed from the QListView
757  ++listView_it;
758 
759  applyExcludeRules( current_item );
760  }
761 }
762 
763 
764 void
766 {
767  if ( _excludedItemsCount > 0 )
768  {
769  yuiMilestone() << _excludedItemsCount << " packages excluded" << endl;
770 
771  for ( ExcludeRuleList::iterator rule_it = _excludeRules.begin();
772  rule_it != _excludeRules.end();
773  ++rule_it )
774  {
775  ExcludeRule * rule = *rule_it;
776 
777  if ( rule->isEnabled() )
778  {
779  yuiMilestone() << "Active exclude rule: \""
780  << rule->regexp().pattern() << "\""
781  << endl;
782  }
783  }
784  }
785 }
786 
787 
788 void
789 YQPkgObjList::applyExcludeRules( QTreeWidgetItem * listViewItem )
790 {
791  YQPkgObjListItem * item = dynamic_cast<YQPkgObjListItem *>( listViewItem );
792 
793  if ( item )
794  {
795  bool exclude = false;
796 #if VERBOSE_EXCLUDE_RULES
797  ExcludeRule * matchingRule = 0;
798 #endif
799 
800  for ( ExcludeRuleList::iterator rule_it = _excludeRules.begin();
801  rule_it != _excludeRules.end() && ! exclude;
802  ++rule_it )
803  {
804  ExcludeRule * rule = *rule_it;
805 
806  if ( rule->match( item ) )
807  {
808  exclude = true;
809 #if VERBOSE_EXCLUDE_RULES
810  matchingRule = rule;
811 #endif
812  }
813  }
814 
815  if ( exclude != item->isExcluded() ) // change exclude status?
816  {
817  this->exclude( item, exclude );
818 
819  if ( exclude )
820  _excludedItemsCount++;
821 
822 #if VERBOSE_EXCLUDE_RULES
823  if ( exclude )
824  {
825  yuiDebug() << "Rule \"" << matchingRule->regexp().pattern()
826  << "\" matches: Excluding " << item->zyppObj()->name()
827  << endl;
828  }
829  else
830  {
831  yuiDebug() << "Un-excluding " << item->zyppObj()->name() << endl;
832  }
833 #endif
834  }
835  }
836 }
837 
838 
839 void
841 {
842  if ( exclude == item->isExcluded() )
843  return;
844 
845  item->setExcluded( exclude );
846 
847  QTreeWidgetItem * parentItem = item->parent();
848 
849  if ( parentItem )
850  parentItem->setHidden( exclude );
851  else
852  item->setHidden( exclude );
853 }
854 
855 
856 
857 
859  ZyppSel selectable,
860  ZyppObj zyppObj )
861  : QY2ListViewItem( pkgObjList )
862  , _pkgObjList( pkgObjList )
863  , _selectable( selectable )
864  , _zyppObj( zyppObj )
865  , _editable( true )
866  , _excluded( false )
867 {
868  init();
869 }
870 
871 
873  QY2ListViewItem * parent,
874  ZyppSel selectable,
875  ZyppObj zyppObj )
876  : QY2ListViewItem( parent )
877  , _pkgObjList( pkgObjList )
878  , _selectable( selectable )
879  , _zyppObj( zyppObj )
880  , _editable( true )
881  , _excluded( false )
882 {
883  init();
884 }
885 
886 
888  : QY2ListViewItem( pkgObjList )
889  , _pkgObjList( pkgObjList )
890  , _selectable( 0 )
891  , _zyppObj( 0 )
892  , _editable( true )
893  , _excluded( false )
894 {
895 }
896 
897 
899 {
900  // NOP
901 }
902 
903 
904 void
906 {
907  if ( _zyppObj == 0 && _selectable )
908  _zyppObj = _selectable->theObj();
909 
910  _debugIsBroken = false;
911  _debugIsSatisfied = false;
912  _candidateIsNewer = false;
913  _installedIsNewer = false;
914 
915  const ZyppObj candidate = selectable()->candidateObj();
916  const ZyppObj installed = selectable()->installedObj();
917 
918  if ( candidate && installed )
919  {
920  if ( candidate->edition() < installed->edition() )
921  _installedIsNewer = true;
922  else if ( installed->edition() < candidate->edition() )
923  _candidateIsNewer = true;
924  }
925 
926  if ( installed && ! candidate )
927  _installedIsNewer = true;
928 
929  if ( nameCol() >= 0 ) setText( nameCol(), zyppObj()->name() );
930  if ( summaryCol() >= 0 ) setText( summaryCol(), zyppObj()->summary() );
931 
932  if ( sizeCol() >= 0 )
933  {
934  zypp::ByteCount size = zyppObj()->installSize();
935 
936  if ( size > 0L )
937  setText( sizeCol(), size.asString() );
938  }
939 
940  if ( versionCol() == instVersionCol() ) // Display both versions in the same column: 1.2.3 (1.2.4)
941  {
942  if ( versionCol() >= 0 )
943  {
944  if ( installed )
945  {
946  if ( zyppObj() != installed &&
947  zyppObj() != candidate )
948  {
949  setText( versionCol(), zyppObj()->edition());
950  }
951  else
952  {
953  if ( candidate && installed->edition() != candidate->edition() )
954  {
955  setText( versionCol(),
956  QString( "%1 (%2)" )
957  .arg( installed->edition().c_str() )
958  .arg( candidate->edition().c_str() ) );
959  }
960  else // no candidate or both versions are the same anyway
961  {
962  setText( versionCol(), installed->edition() );
963  }
964  }
965  }
966  else
967  {
968  if ( candidate )
969  setText( versionCol(), QString( "(%1)" ).arg( candidate->edition().c_str() ) );
970  else
971  setText( versionCol(), zyppObj()->edition() );
972  }
973 
974  if ( _installedIsNewer )
975  setForeground( versionCol(), Qt::red);
976  else if ( _candidateIsNewer )
977  setForeground( versionCol(), Qt::blue);
978  }
979  }
980  else // separate columns for installed and available versions
981  {
982  if ( instVersionCol() >= 0 )
983  {
984  if ( installed )
985  {
986  setText( instVersionCol(), installed->edition() );
987 
988  if ( _installedIsNewer )
989  setForeground( instVersionCol(), Qt::red);
990  else if ( _candidateIsNewer )
991  setForeground( instVersionCol(), Qt::blue);
992  }
993  }
994 
995  if ( versionCol() >= 0 )
996  {
997  if ( zyppObj() != installed &&
998  zyppObj() != candidate )
999  {
1000  setText( versionCol(), zyppObj()->edition() );
1001  }
1002  else if ( candidate )
1003  {
1004  setText( versionCol(), candidate->edition() );
1005 
1006  if ( _installedIsNewer )
1007  setForeground( versionCol(), Qt::red);
1008  else if ( _candidateIsNewer )
1009  setForeground( versionCol(), Qt::blue);
1010  }
1011  }
1012  }
1013 
1014  setStatusIcon();
1015 }
1016 
1017 
1018 void
1020 {
1021  init();
1022 }
1023 
1024 
1025 void
1026 YQPkgObjListItem::setText( int column, const string text )
1027 {
1028  QTreeWidgetItem::setText( column, fromUTF8( text.c_str() ) );
1029 }
1030 
1031 
1032 void
1033 YQPkgObjListItem::setText( int column, const zypp::Edition & edition )
1034 {
1035  setText( column, edition.asString() );
1036 }
1037 
1038 
1039 ZyppStatus
1041 {
1042  if ( ! selectable() )
1043  {
1044  yuiError() << "No selectable" << endl;
1045  return S_NoInst;
1046  }
1047 
1048  return selectable()->status();
1049 }
1050 
1051 
1052 bool
1054 {
1055  zypp::ResStatus::TransactByValue modifiedBy = selectable()->modifiedBy();
1056 
1057  return ( modifiedBy == zypp::ResStatus::APPL_LOW ||
1058  modifiedBy == zypp::ResStatus::APPL_HIGH );
1059 }
1060 
1061 
1062 
1063 void
1064 YQPkgObjListItem::setStatus( ZyppStatus newStatus, bool sendSignals )
1065 {
1066  ZyppStatus oldStatus = selectable()->status();
1067  selectable()->setStatus( newStatus );
1068 
1069  if ( oldStatus != selectable()->status() )
1070  {
1071  applyChanges();
1072 
1073  if ( sendSignals )
1074  {
1075  _pkgObjList->updateItemStates();
1076  _pkgObjList->sendUpdatePackages();
1077  }
1078  }
1079 
1080  setStatusIcon();
1081 }
1082 
1083 
1084 void
1086 {
1087  zypp::getZYpp()->resolver()->resolvePool();
1088 }
1089 
1090 
1091 
1092 void
1094 {
1095  setStatusIcon();
1096 }
1097 
1098 
1099 void
1101 {
1102  if ( statusCol() >= 0 )
1103  {
1104  bool enabled = editable() && _pkgObjList->editable();
1105  setIcon( statusCol(), _pkgObjList->statusIcon( status(), enabled, bySelection() ) );
1106  }
1107 
1108 
1109  if ( brokenIconCol() >= 0 )
1110  {
1111  // Reset this icon now - it might be the same column as satisfiedIconCol()
1112  setIcon( brokenIconCol(), QPixmap() );
1113  }
1114 
1115  if ( satisfiedIconCol() >= 0 )
1116  {
1117  // Set special icon for zyppObjs that are not marked as installed,
1118  // but satisfied anyway (e.g. for patches or patterns where the user
1119  // selected all required packages manually)
1120 
1121  setIcon( satisfiedIconCol(), isSatisfied() ? YQIconPool::pkgSatisfied() : QPixmap() );
1122  }
1123 
1124  if ( brokenIconCol() >= 0 )
1125  {
1126  // Set special icon for zyppObjs that are installed, but broken
1127  // (dependencies no longer satisfied, e.g. for patches or patterns)
1128 
1129  if ( isBroken() )
1130  {
1131  setIcon( brokenIconCol(), YQIconPool::warningSign() );
1132 
1133  yuiWarning() << "Broken object: " << _selectable->theObj()->name()
1134  << " - " << _selectable->theObj()->summary()
1135  << endl;
1136  }
1137  }
1138 }
1139 
1140 
1141 bool
1143 {
1144  if ( _debugIsSatisfied )
1145  return true;
1146 
1147  if ( _selectable->hasInstalledObj() )
1148  return false;
1149 
1150  return _selectable->candidateObj().isSatisfied();
1151 }
1152 
1153 
1155 {
1156  if ( _debugIsBroken )
1157  return true;
1158 
1159  if ( ! _selectable->hasInstalledObj() )
1160  return false; // can't be broken if not installed
1161 
1162  switch ( status() )
1163  {
1164  case S_KeepInstalled:
1165  case S_Protected:
1166 
1167  return _selectable->installedObj().isBroken();
1168 
1169  case S_Update: // will be fixed by updating
1170  case S_AutoUpdate:
1171  case S_Del: // will no longer be relevant after deleting
1172  case S_AutoDel:
1173 
1174  return false;
1175 
1176  case S_NoInst: // should not happen - no installed obj
1177  case S_Install:
1178  case S_AutoInstall:
1179  case S_Taboo:
1180 
1181  yuiError() << "Expected uninstalled zyppObj" << endl;
1182  return false;
1183  }
1184 
1185  yuiError() << "Should never get here" << endl;
1186  return false;
1187 }
1188 
1189 
1190 void
1192 {
1193  if ( ! _editable || ! _pkgObjList->editable() )
1194  return;
1195 
1196  ZyppStatus oldStatus = status();
1197  ZyppStatus newStatus = oldStatus;
1198 
1199  switch ( oldStatus )
1200  {
1201  case S_Install:
1202  newStatus = S_NoInst;
1203  break;
1204 
1205  case S_Protected:
1206  newStatus = selectable()->hasCandidateObj() ?
1207  S_KeepInstalled: S_NoInst;
1208  break;
1209 
1210  case S_Taboo:
1211  newStatus = selectable()->hasInstalledObj() ?
1212  S_KeepInstalled : S_NoInst;
1213  break;
1214 
1215  case S_KeepInstalled:
1216  newStatus = selectable()->hasCandidateObj() ?
1217  S_Update : S_Del;
1218  break;
1219 
1220  case S_Update:
1221  newStatus = S_Del;
1222  break;
1223 
1224  case S_AutoUpdate:
1225  newStatus = S_KeepInstalled;
1226  break;
1227 
1228  case S_Del:
1229  case S_AutoDel:
1230  newStatus = S_KeepInstalled;
1231  break;
1232 
1233  case S_NoInst:
1234  if ( selectable()->hasCandidateObj() )
1235  {
1236  newStatus = S_Install;
1237  }
1238  else
1239  {
1240  yuiWarning() << "No candidate for " << selectable()->theObj()->name() << endl;
1241  newStatus = S_NoInst;
1242  }
1243  break;
1244 
1245  case S_AutoInstall:
1246  // this used to be taboo before, but now ZYpp supports
1247  // saving weak locks (unselected packages)
1248  newStatus = S_NoInst;
1249  break;
1250  }
1251 
1252  if ( oldStatus != newStatus )
1253  {
1254  setStatus( newStatus );
1255 
1256  if ( showLicenseAgreement() )
1257  {
1258  showNotifyTexts( newStatus );
1259  }
1260  else // License not confirmed?
1261  {
1262  // Status is now S_Taboo or S_Del - update status icon
1263  setStatusIcon();
1264  }
1265 
1266  _pkgObjList->sendStatusChanged();
1267  }
1268 }
1269 
1270 
1271 void
1273 {
1274  // just return if no selectable
1275  if ( ! selectable() )
1276  return;
1277 
1278  string text;
1279 
1280  switch ( status )
1281  {
1282  case S_Install:
1283  if ( selectable()->hasCandidateObj() )
1284  text = selectable()->candidateObj()->insnotify();
1285  break;
1286 
1287  case S_NoInst:
1288  case S_Del:
1289  case S_Taboo:
1290  if ( selectable()->hasCandidateObj() )
1291  text = selectable()->candidateObj()->delnotify();
1292  break;
1293 
1294  default: break;
1295  }
1296 
1297  if ( ! text.empty() )
1298  {
1299  yuiDebug() << "Showing notify text" << endl;
1300  YQPkgTextDialog::showText( _pkgObjList, selectable(), text );
1301  }
1302 }
1303 
1304 
1305 bool
1307 {
1308  return showLicenseAgreement( selectable() );
1309 }
1310 
1311 
1312 bool
1314 {
1315  // if we have a subclass with no selectable
1316  // confirming the license should be just always
1317  // true
1318  if ( ! sel )
1319  return true;
1320 
1321  string licenseText;
1322 
1323  switch ( sel->status() )
1324  {
1325  case S_Install:
1326  case S_AutoInstall:
1327  case S_Update:
1328  case S_AutoUpdate:
1329 
1330  if ( sel->hasLicenceConfirmed() )
1331  return true;
1332 
1333  if ( sel->candidateObj() )
1334  licenseText = sel->candidateObj()->licenseToConfirm();
1335  break;
1336 
1337  default: return true;
1338  }
1339 
1340  if ( licenseText.empty() )
1341  return true;
1342 
1343  yuiDebug() << "Showing license agreement for " << sel->name() << endl;
1344 
1345  bool confirmed = YQPkgTextDialog::confirmText( (QWidget *) YDialog::currentDialog()->widgetRep(),
1346  sel, licenseText );
1347 
1348  if ( confirmed )
1349  {
1350  yuiMilestone() << "User confirmed license agreement for " << sel->name() << endl;
1351  sel->setLicenceConfirmed( true );
1352  }
1353  else
1354  {
1355  // The user rejected the license agreement -
1356  // make sure the package gets unselected.
1357 
1358  switch ( sel->status() )
1359  {
1360  case S_Install:
1361  case S_AutoInstall:
1362 
1363  yuiWarning() << "User rejected license agreement for " << sel->name()
1364  << " - setting to TABOO"
1365  << endl;
1366 
1367  sel->setStatus( S_Taboo );
1368  break;
1369 
1370 
1371  case S_Update:
1372  case S_AutoUpdate:
1373 
1374  yuiWarning() << "User rejected license agreement for " << sel->name()
1375  << " - setting to PROTECTED"
1376  << endl;
1377 
1378  sel->setStatus( S_Protected );
1379  // S_Keep wouldn't be good enough: The next solver run might
1380  // set it to S_AutoUpdate again
1381  break;
1382 
1383  default: break;
1384  }
1385  }
1386 
1387  return confirmed;
1388 }
1389 
1390 
1391 QString
1393 {
1394  if ( col == statusCol() )
1395  {
1396  QString tip = _pkgObjList->statusText( status() );
1397 
1398  switch ( status() )
1399  {
1400  case S_AutoDel:
1401  case S_AutoInstall:
1402  case S_AutoUpdate:
1403 
1404  if ( bySelection() )
1405  // Translators: Additional hint what caused an auto-status
1406  tip += "\n" + _( "(by a software selection)" );
1407  else
1408  tip += "\n" + _( "(by dependencies)" );
1409 
1410  break;
1411 
1412  default:
1413  break;
1414  }
1415 
1416  return tip;
1417  }
1418 
1419  if ( col == brokenIconCol() )
1420  {
1421  if ( isBroken() )
1422  // Translators: tool tip for patches / patterns that are installed,
1423  // but whose dependencies are broken (no longer satisfied)
1424  return _( "Dependencies broken" );
1425  }
1426 
1427  // don't use "else if" here, it might be the same colum as another one!
1428 
1429  if ( col == satisfiedIconCol() )
1430  {
1431  if ( isSatisfied() )
1432  // Translators: tool tip for patches / patterns that are not installed,
1433  // but whose dependencies are satisfied
1434  return _( "All dependencies satisfied" );
1435  }
1436 
1437  return QString();
1438 }
1439 
1440 
1441 
1442 bool YQPkgObjListItem::operator<( const QTreeWidgetItem & otherListViewItem ) const
1443 {
1444  const YQPkgObjListItem * other = dynamic_cast<const YQPkgObjListItem *> (&otherListViewItem);
1445  int col = treeWidget()->sortColumn();
1446 
1447  if ( other )
1448  {
1449  if ( col == nameCol() )
1450  {
1451  return ( strcasecmp( this->zyppObj()->name().c_str(), other->zyppObj()->name().c_str() ) < 0 );
1452  }
1453  if ( col == summaryCol() )
1454  {
1455  // locale aware sort
1456  return ( strcoll( this->zyppObj()->summary().c_str(), other->zyppObj()->summary().c_str() ) < 0 );
1457  }
1458  if ( col == sizeCol() )
1459  {
1460  // Numeric sort by size
1461 
1462  return ( this->zyppObj()->installSize() < other->zyppObj()->installSize() );
1463  }
1464  else if ( col == statusCol() )
1465  {
1466  // Sorting by status depends on the numeric value of the
1467  // ZyppStatus enum, thus it is important to insert new
1468  // package states there where they make most sense. We want to show
1469  // dangerous or noteworthy states first - e.g., "taboo" which should
1470  // seldeom occur, but when it does, it is important.
1471 
1472  bool b = ( this->status() < other->status() );
1473  if ( !b && this->status() == other->status() )
1474  b = this->zyppObj()->name() < other->zyppObj()->name();
1475  return b;
1476  }
1477  else if ( col == instVersionCol() ||
1478  col == versionCol() )
1479  {
1480  // Sorting by version numbers doesn't make too much sense, so let's
1481  // sort by package relation:
1482  // - Installed newer than candidate (red)
1483  // - Candidate newer than installed (blue) - worthwhile updating
1484  // - Installed
1485  // - Not installed, but candidate available
1486  //
1487  // Within these categories, sort versions by ASCII - OK, it's
1488  // pretty random, but predictable.
1489 
1490  int thisPoints = this->versionPoints();
1491  int otherPoints = other->versionPoints();
1492 
1493  if (thisPoints == otherPoints )
1494  return ( QString (this->zyppObj()->edition().c_str() ) <
1495  QString (other->zyppObj()->edition().c_str() ) );
1496  else
1497  return ( thisPoints < otherPoints );
1498  }
1499  }
1500 
1501  // Fallback: Use parent class method
1502  return QY2ListViewItem::operator<( otherListViewItem );
1503 }
1504 
1505 
1506 int
1508 {
1509  int points = 0;
1510 
1511  if ( installedIsNewer() ) points += 1000;
1512  if ( candidateIsNewer() ) points += 100;
1513  if ( selectable()->hasInstalledObj() ) points += 10;
1514  if ( selectable()->hasCandidateObj() ) points += 1;
1515 
1516  return points;
1517 }
1518 
1519 
1520 void
1522 {
1523  _excluded = excl;
1524 }
1525 
1527  const QRegExp & regexp,
1528  int column )
1529  : _parent( parent )
1530  , _regexp( regexp )
1531  , _column( column )
1532  , _enabled( true )
1533 {
1534  _parent->addExcludeRule( this );
1535 }
1536 
1537 
1538 void
1540 {
1541  _enabled = enable;
1542 
1543 #if VERBOSE_EXCLUDE_RULES
1544  yuiDebug() << ( enable ? "Enabling" : "Disabling" )
1545  << " exclude rule " << _regexp.pattern()
1546  << endl;
1547 #endif
1548 }
1549 
1550 
1551 void
1552 YQPkgObjList::ExcludeRule::setRegexp( const QRegExp & regexp )
1553 {
1554  _regexp = regexp;
1555 }
1556 
1557 
1558 void
1560 {
1561  _column = column;
1562 }
1563 
1564 
1565 bool
1566 YQPkgObjList::ExcludeRule::match( QTreeWidgetItem * item )
1567 {
1568  if ( ! _enabled )
1569  return false;
1570 
1571  QString text = item->text( _column );
1572 
1573  if ( text.isEmpty() )
1574  return false;
1575 
1576  return _regexp.exactMatch( text );
1577 }
1578 
1579 
1581 {
1582  YQPkgObjListItem * item = dynamic_cast<YQPkgObjListItem *> ( currentItem() );
1583 
1584  if ( item && editable() && item->editable() )
1585  {
1586  updateActions( item );
1587 
1588  if ( ! item->selectable() )
1589  return;
1590 
1591  QMenu * contextMenu =
1592  ! item->selectable()->installedEmpty() ?
1594 
1595  if ( contextMenu )
1596  contextMenu->popup( viewport()->mapToGlobal( pos ) );
1597  }
1598 }
1599 
1600 
bool installedIsNewer() const
Check if the installed version is newer than the candidate.
Definition: YQPkgObjList.h:517
bool candidateIsNewer() const
Check if the candidate is newer than the installed version.
Definition: YQPkgObjList.h:512
bool isExcluded() const
Returns &#39;true&#39; if this item is excluded.
Definition: YQPkgObjList.h:592
Abstract base class to display a list of zypp::ResObjects.
Definition: YQPkgObjList.h:66
void statusChanged()
Emitted when the status of a zypp::ResObject is changed.
void setText(int column, const string text)
Set a column text via STL string.
void setExcluded(bool exclude=true)
Set this item&#39;s exclude flag.
virtual QPixmap statusIcon(ZyppStatus status, bool enabled=true, bool bySelection=false)
Returns the suitable icon for a zypp::ResObject status - the regular icon if &#39;enabled&#39; is &#39;true&#39; or t...
void addPkgObjItem(ZyppSel selectable, ZyppObj zyppObj=0)
Add a zypp::ResObject to the list.
YQPkgObjListItem(YQPkgObjList *pkgObjList, ZyppSel selectable, ZyppObj zyppObj=0)
Constructor for root items: Creates a YQPkgObjList item that corresponds to the ZYPP selectable that ...
virtual bool operator<(const QTreeWidgetItem &other) const
sorting function
void addExcludeRule(YQPkgObjList::ExcludeRule *rule)
Add an exclude rule to this list.
virtual void createInstalledContextMenu()
Create the context menu for installed items.
virtual QString statusText(ZyppStatus status) const
Returns a short (one line) descriptive text for a zypp::ResObject status.
void addPassiveItem(const QString &name, const QString &summary=QString(), FSize size=-1)
Add a purely passive list item that has a name and optional summary and size.
void setAllItemStatus(ZyppStatus newStatus, bool force=false)
Sets the status of all (toplevel) list items to &#39;newStatus&#39;, if possible.
virtual QMenu * notInstalledContextMenu()
Returns the context menu for items that are installed.
bool showLicenseAgreement()
Display this item&#39;s license agreement (if there is any) that corresponds to its current status (S_Ins...
virtual void updateData()
Update this item&#39;s data completely.
virtual void clear()
Reimplemented from QY2ListView: Emit currentItemChanged() signal after clearing the list...
void setColumn(int column=0)
Change the column number to check against after creation.
virtual void message(const QString &text)
Display a one-line message in the list.
static bool confirmText(QWidget *parent, const QString &text, const QString &acceptButtonLabel, const QString &rejectButtonLabel)
Let the user confirm a text.
virtual void updateStatus()
Update this item&#39;s status.
ExcludeRule(YQPkgObjList *parent, const QRegExp &regexp, int column=0)
Constructor: Creates a new exclude rule with a regular expression to check against the text of the sp...
void createActions()
Create the actions for the context menus.
virtual void setStatus(ZyppStatus newStatus, bool sendSignals=true)
Set the (binary RPM) package status.
QRegExp regexp() const
Returns the regexp.
Definition: YQPkgObjList.h:730
virtual void pkgObjClicked(int button, QTreeWidgetItem *item, int col, const QPoint &pos)
Dispatcher slot for mouse click: cycle status depending on column.
void enable(bool enable=true)
Enable or disable this exclude rule.
void logExcludeStatistics()
Write statistics about excluded items to the log, if there are any.
virtual void currentItemChangedInternal(QTreeWidgetItem *item)
Dispatcher slot for selection change - internal only.
bool isBroken() const
Check if this item is "broken": If it is installed, but any of its dependencies are no longer satisfi...
bool editable() const
Return whether or not this items is editable, i.e.
Definition: YQPkgObjList.h:464
virtual void updateActions(YQPkgObjListItem *item=0)
Update the internal actions for the currently selected item ( if any ).
void sendStatusChanged()
Emit a statusChanged() signal for the specified zypp::ResObject.
Definition: YQPkgObjList.h:241
void exclude(YQPkgObjListItem *item, bool exclude)
Exclude or include an item, i.e.
void selectNextItem()
Select the next item, i.e.
void updatePackages()
Emitted when it&#39;s time to update displayed package information, e.g., package states.
virtual ZyppStatus status() const
Returns the (binary RPM) package status.
bool match(QTreeWidgetItem *item)
Check a list item against this exclude rule.
static void showText(QWidget *parent, const QString &text)
Show a text and wait until the user confirmed with &#39;OK&#39;.
bool editable() const
Return whether or not items in this list are generally editable, i.e.
Definition: YQPkgObjList.h:108
virtual void applyChanges()
Apply changes hook.
Definition: YQPkgObjList.h:641
void applyExcludeRules()
Apply all exclude rules of this list to all items, including those that are currently excluded...
void setRegexp(const QRegExp &regexp)
Change the regular expression after creation.
virtual QMenu * addAllInListSubMenu(QMenu *menu)
Add a submenu "All in this list..." to &#39;menu&#39;.
ZyppSel selectable() const
Returns the original selectable within the package manager backend.
Definition: YQPkgObjList.h:452
bool isSatisfied() const
Check if this item is satisfied, even though it is not installed.
void currentItemChanged(ZyppSel selectable)
Emitted when a zypp::ui::Selectable is selected.
QAction * createAction(ZyppStatus status, const QString &key=QString(), bool enabled=false)
Create an action based on a zypp::ResObject status - automatically retrieve the corresponding status ...
void slotCustomContextMenu(const QPoint &pos)
slot that shows context menu when requested
void setCurrentStatus(ZyppStatus newStatus, bool selectNextItem=false, bool ifNewerOnly=false)
Sets the currently selected item&#39;s status.
void sendUpdatePackages()
Emit an updatePackages() signal.
Definition: YQPkgObjList.h:230
virtual void createNotInstalledContextMenu()
Create the context menu for items that are not installed.
virtual QMenu * installedContextMenu()
Returns the context menu for items that are not installed.
virtual bool bySelection() const
Returns &#39;true&#39; if this selectable&#39;s status is set by a selection (rather than by the user or by the d...
bool isEnabled() const
Returns &#39;true&#39; if this exclude rule is enabled, &#39;false&#39; otherwise.
Definition: YQPkgObjList.h:720
virtual QString toolTip(int column)
Returns a tool tip text for a specific column of this item.
void solveResolvableCollections()
Do a "small" solver run for all "resolvable collections", i.e., for selections, patterns, languages, patches.
virtual ~YQPkgObjList()
Destructor.
void showNotifyTexts(ZyppStatus status)
Display this item&#39;s notify text (if there is any) that corresponds to the specified status (S_Install...
virtual void keyPressEvent(QKeyEvent *ev)
Event handler for keyboard input.
YQPkgObjList(QWidget *parent)
Constructor.
Definition: YQPkgObjList.cc:71
static bool showLicenseAgreement(ZyppSel sel)
Display a selectable&#39;s license agreement (if there is any) that corresponds to its current status (S_...
int versionPoints() const
Calculate a numerical value to compare versions, based on version relations:
virtual ~YQPkgObjListItem()
Destructor.
virtual void setStatusIcon()
Set a status icon according to the package&#39;s status.
ZyppObj zyppObj() const
Returns the original object within the package manager backend.
Definition: YQPkgObjList.h:457
virtual void cycleStatus()
Cycle the package status to the next valid value.
void init()
Initialize internal data and set fields accordingly.