libyui-qt-pkg  2.45.19
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  _debug = false;
107 
108  _excludedItems = new YQPkgObjList::ExcludedItems( this );
109 
110  createActions();
111 
112  connect( this, SIGNAL( columnClicked ( int, QTreeWidgetItem *, int, const QPoint & ) ),
113  this, SLOT ( pkgObjClicked ( int, QTreeWidgetItem *, int, const QPoint & ) ) );
114 
115  connect( this, SIGNAL( columnDoubleClicked ( int, QTreeWidgetItem *, int, const QPoint & ) ),
116  this, SLOT ( pkgObjClicked ( int, QTreeWidgetItem *, int, const QPoint & ) ) );
117 
118  connect( this, SIGNAL( currentItemChanged ( QTreeWidgetItem *, QTreeWidgetItem * ) ),
119  this, SLOT ( currentItemChangedInternal( QTreeWidgetItem * ) ) );
120 
121  connect( this, SIGNAL(customContextMenuRequested(const QPoint &)),
122  this, SLOT (slotCustomContextMenu(const QPoint&)));
123 
124  setIconSize( QSize( 22, 16 ) );
125 
126  setContextMenuPolicy(Qt::CustomContextMenu);
127 
128 }
129 
130 
131 
132 
134 {
135  if ( _excludedItems )
136  delete _excludedItems;
137 }
138 
139 
140 void
141 YQPkgObjList::addPkgObjItem( ZyppSel selectable, ZyppObj zyppObj )
142 {
143  if ( ! selectable )
144  {
145  yuiError() << "Null zypp::ui::Selectable!" << endl;
146  return;
147  }
148 
149  YQPkgObjListItem * item = new YQPkgObjListItem( this, selectable, zyppObj );
150  applyExcludeRules( item );
151 }
152 
153 
154 void
155 YQPkgObjList::addPassiveItem( const QString & name,
156  const QString & summary,
157  FSize size )
158 {
159  QY2ListViewItem * item = new QY2ListViewItem( this, QString::null );
160 
161  if ( item )
162  {
163  if ( nameCol() >= 0 && ! name.isEmpty() ) item->setText( nameCol(), name );
164  if ( summaryCol() >= 0 && ! summary.isEmpty() ) item->setText( summaryCol(), summary );
165  if ( sizeCol() >= 0 && size > 0L )
166  {
167  QString sizeStr = size.form().c_str();
168  item->setText( sizeCol(), sizeStr );
169  }
170  }
171 }
172 
173 
174 void
176  QTreeWidgetItem * listViewItem,
177  int col,
178  const QPoint & pos )
179 {
180  YQPkgObjListItem * item = dynamic_cast<YQPkgObjListItem *> (listViewItem);
181 
182  if ( item )
183  {
184  //y2internal("CLICKED: %s", item->zyppObj()->name().c_str());
185  if ( button == Qt::LeftButton )
186  {
187  if ( col == statusCol() )
188  // || col == nameCol() )
189  {
190  if ( editable() && item->editable() )
191  item->cycleStatus();
192  }
193  }
194  // context menus are handled in slotCustomContextMenu()
195  }
196 }
197 
198 
199 void
200 YQPkgObjList::currentItemChangedInternal( QTreeWidgetItem * listViewItem )
201 {
202  YQPkgObjListItem * item = dynamic_cast<YQPkgObjListItem *> (listViewItem);
203 
204  emit currentItemChanged( item ? item->selectable() : ZyppSel() );
205 }
206 
207 
208 void
210 {
211  emit currentItemChanged( ZyppSel() );
212 
213  _excludedItems->clear();
214  QY2ListView::clear();
215 }
216 
217 
218 QPixmap
219 YQPkgObjList::statusIcon( ZyppStatus status, bool enabled, bool bySelection )
220 {
221  QPixmap icon = YQIconPool::pkgNoInst();
222 
223  if ( enabled )
224  {
225  switch ( status )
226  {
227  case S_Del: icon = YQIconPool::pkgDel(); break;
228  case S_Install: icon = YQIconPool::pkgInstall(); break;
229  case S_KeepInstalled: icon = YQIconPool::pkgKeepInstalled(); break;
230  case S_NoInst: icon = YQIconPool::pkgNoInst(); break;
231  case S_Protected: icon = YQIconPool::pkgProtected(); break;
232  case S_Taboo: icon = YQIconPool::pkgTaboo(); break;
233  case S_Update: icon = YQIconPool::pkgUpdate(); break;
234 
235  case S_AutoDel: icon = YQIconPool::pkgAutoDel(); break;
236  case S_AutoInstall: icon = YQIconPool::pkgAutoInstall(); break;
237  case S_AutoUpdate: icon = YQIconPool::pkgAutoUpdate(); break;
238 
239  // Intentionally omitting 'default' branch so the compiler can
240  // catch unhandled enum states
241  }
242  }
243  else
244  {
245  switch ( status )
246  {
247  case S_Del: icon = YQIconPool::disabledPkgDel(); break;
248  case S_Install: icon = YQIconPool::disabledPkgInstall(); break;
249  case S_KeepInstalled: icon = YQIconPool::disabledPkgKeepInstalled(); break;
250  case S_NoInst: icon = YQIconPool::disabledPkgNoInst(); break;
251  case S_Protected: icon = YQIconPool::disabledPkgProtected(); break;
252  case S_Taboo: icon = YQIconPool::disabledPkgTaboo(); break;
253  case S_Update: icon = YQIconPool::disabledPkgUpdate(); break;
254 
255  case S_AutoDel: icon = YQIconPool::disabledPkgAutoDel(); break;
256  case S_AutoInstall: icon = YQIconPool::disabledPkgAutoInstall(); break;
257  case S_AutoUpdate: icon = YQIconPool::disabledPkgAutoUpdate(); break;
258 
259  // Intentionally omitting 'default' branch so the compiler can
260  // catch unhandled enum states
261  }
262  }
263 
264  return icon;
265 }
266 
267 
268 QString
269 YQPkgObjList::statusText( ZyppStatus status ) const
270 {
271  switch ( status )
272  {
273  case S_AutoDel: return _( "Autodelete" );
274  case S_AutoInstall: return _( "Autoinstall" );
275  case S_AutoUpdate: return _( "Autoupdate" );
276  case S_Del: return _( "Delete" );
277  case S_Install: return _( "Install" );
278  case S_KeepInstalled: return _( "Keep" );
279  case S_NoInst: return _( "Do Not Install" );
280  case S_Protected: return _( "Protected -- Do Not Modify" );
281  case S_Taboo: return _( "Taboo -- Never Install" );
282  case S_Update: return _( "Update" );
283  }
284 
285  return QString::null;
286 }
287 
288 
289 void
290 YQPkgObjList::setCurrentStatus( ZyppStatus newStatus, bool doSelectNextItem, bool ifNewerOnly )
291 {
292  QTreeWidgetItem * listViewItem = currentItem();
293 
294  if ( ! listViewItem )
295  return;
296 
297  YQPkgObjListItem * item = dynamic_cast<YQPkgObjListItem *> (listViewItem);
298 
299  if ( item && item->editable() && _editable && ( item->candidateIsNewer() || !ifNewerOnly ) )
300  {
301  if ( newStatus != item->status() )
302  {
303  item->setStatus( newStatus );
304 
305  if ( item->showLicenseAgreement() )
306  {
307  item->showNotifyTexts( newStatus );
308  }
309  else // License not confirmed?
310  {
311  // Status is now S_Taboo or S_Del - update status icon
312  item->setStatusIcon();
313  }
314 
315  emit statusChanged();
316  }
317  }
318 
319  if ( doSelectNextItem )
320  selectNextItem();
321 }
322 
323 
324 void
325 YQPkgObjList::setAllItemStatus( ZyppStatus newStatus, bool force )
326 {
327  if ( ! _editable )
328  return;
329 
330  YQUI::ui()->busyCursor();
331  QTreeWidgetItemIterator it( this );
332 
333  while ( *it )
334  {
335  YQPkgObjListItem * item = dynamic_cast<YQPkgObjListItem *> (*it);
336 
337  if ( item && item->editable() && newStatus != item->status() )
338  {
339  if ( newStatus == S_Update )
340  {
341  if ( force )
342  {
343  item->setStatus( newStatus,
344  false ); // sendSignals
345  }
346  else
347  {
348  if ( item->selectable()->installedObj() && item->status() != S_Protected && item->selectable()->updateCandidateObj() )
349  {
350  item->selectable()->setOnSystem( item->selectable()->updateCandidateObj() );
351  }
352  }
353  }
354  else
355  {
356  item->setStatus( newStatus,
357  false ); // sendSignals
358  }
359  }
360 
361  ++it;
362  }
363 
364  emit updateItemStates();
365  emit updatePackages();
366 
367  YQUI::ui()->normalCursor();
368  emit statusChanged();
369 }
370 
371 
372 void
374 {
375  QTreeWidgetItemIterator it(this);
376  QTreeWidgetItem * item;
377 
378  while ( (item = *it) != NULL )
379  {
380  ++it;
381  //item->setSelected( false ); // Doesn't emit signals
382  scrollToItem( *it ); // Scroll if necessary
383  setCurrentItem( *it ); // Emits signals
384 
385  }
386 }
387 
388 
389 void
391 {
392  actionSetCurrentInstall = createAction( S_Install, "[+]" );
393  actionSetCurrentDontInstall = createAction( S_NoInst, "[-]" );
394  actionSetCurrentKeepInstalled = createAction( S_KeepInstalled, "[<], [-]" );
395  actionSetCurrentDelete = createAction( S_Del, "[-]" );
396  actionSetCurrentUpdate = createAction( S_Update, "[>], [+]" );
397  actionSetCurrentUpdateForce = createAction( _( "Update unconditionally" ), statusIcon( S_Update, true ) ,statusIcon( S_Update, false ) , "", 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  // yuiDebug() << "Applying exclude rules" << endl;
747  QTreeWidgetItemIterator listView_it( this );
748 
749  while ( *listView_it )
750  {
751  QTreeWidgetItem * current_item = *listView_it;
752 
753  // Advance iterator now so it remains valid even if there are changes
754  // to the QListView, e.g., if the current item is excluded and thus
755  // removed from the QListView
756  ++listView_it;
757 
758  applyExcludeRules( current_item );
759  }
760 
761  ExcludedItems::iterator excluded_it = _excludedItems->begin();
762 
763  while ( excluded_it != _excludedItems->end() )
764  {
765  QTreeWidgetItem * current_item = (*excluded_it).first;
766 
767  // Advance iterator now so it remains valid even if there are changes
768  // to the excluded items, e.g., if the current item is un-excluded and thus
769  // removed from the excluded items
770  ++excluded_it;
771 
772  applyExcludeRules( current_item );
773  }
774 
776 }
777 
778 
779 void
781 {
782  if ( _excludedItems->size() > 0 )
783  {
784  yuiMilestone() << _excludedItems->size() << " packages excluded" << endl;
785 
786  for ( ExcludeRuleList::iterator rule_it = _excludeRules.begin();
787  rule_it != _excludeRules.end();
788  ++rule_it )
789  {
790  ExcludeRule * rule = *rule_it;
791 
792  if ( rule->isEnabled() )
793  {
794  yuiMilestone() << "Active exclude rule: \""
795  << rule->regexp().pattern() << "\""
796  << endl;
797  }
798  }
799  }
800 }
801 
802 void
803 YQPkgObjList::applyExcludeRules( QTreeWidgetItem * listViewItem )
804 {
805  YQPkgObjListItem * item = dynamic_cast<YQPkgObjListItem *>( listViewItem );
806 
807  if ( item )
808  {
809  bool exclude = false;
810 #if VERBOSE_EXCLUDE_RULES
811  ExcludeRule * matchingRule = 0;
812 #endif
813 
814  for ( ExcludeRuleList::iterator rule_it = _excludeRules.begin();
815  rule_it != _excludeRules.end() && ! exclude;
816  ++rule_it )
817  {
818  ExcludeRule * rule = *rule_it;
819 
820  if ( rule->match( item ) )
821  {
822  exclude = true;
823 #if VERBOSE_EXCLUDE_RULES
824  matchingRule = rule;
825 #endif
826  }
827  }
828 
829  if ( exclude != item->isExcluded() ) // change exclude status?
830  {
831  this->exclude( item, exclude );
832 
833 #if VERBOSE_EXCLUDE_RULES
834  if ( exclude )
835  {
836  yuiDebug() << "Rule \"" << matchingRule->regexp().pattern()
837  << "\" matches: Excluding " << item->zyppObj()->name()
838  << endl;
839  }
840  else
841  {
842  yuiDebug() << "Un-excluding " << item->zyppObj()->name() << endl;
843  }
844 #endif
845  }
846  }
847 }
848 
849 
850 void
852 {
853  if ( exclude == item->isExcluded() )
854  return;
855 
856  item->setExcluded( exclude );
857 
858  QTreeWidgetItem * parentItem = item->parent();
859 
860  if ( parentItem )
861  parentItem->setHidden(exclude);
862  else
863  item->setHidden(exclude);
864 
865  _excludedItems->add( item, parentItem );
866 }
867 
868 
869 
870 
872  ZyppSel selectable,
873  ZyppObj zyppObj )
874  : QY2ListViewItem( pkgObjList )
875  , _pkgObjList( pkgObjList )
876  , _selectable( selectable )
877  , _zyppObj( zyppObj )
878  , _editable( true )
879  , _excluded( false )
880 {
881  init();
882 }
883 
884 
886  QY2ListViewItem * parent,
887  ZyppSel selectable,
888  ZyppObj zyppObj )
889  : QY2ListViewItem( parent )
890  , _pkgObjList( pkgObjList )
891  , _selectable( selectable )
892  , _zyppObj( zyppObj )
893  , _editable( true )
894  , _excluded( false )
895 {
896  init();
897 }
898 
899 
901  : QY2ListViewItem( pkgObjList )
902  , _pkgObjList( pkgObjList )
903  , _selectable( 0 )
904  , _zyppObj( 0 )
905  , _editable( true )
906  , _excluded( false )
907 {
908 }
909 
910 
912 {
913  // NOP
914 }
915 
916 
917 void
919 {
920  if ( _zyppObj == 0 && _selectable )
921  _zyppObj = _selectable->theObj();
922 
923  _debugIsBroken = false;
924  _debugIsSatisfied = false;
925  _candidateIsNewer = false;
926  _installedIsNewer = false;
927 
928  const ZyppObj candidate = selectable()->candidateObj();
929  const ZyppObj installed = selectable()->installedObj();
930 
931  if ( candidate && installed )
932  {
933  if ( candidate->edition() < installed->edition() )
934  _installedIsNewer = true;
935  else if ( installed->edition() < candidate->edition() )
936  _candidateIsNewer = true;
937  }
938 
939  if ( installed && ! candidate )
940  _installedIsNewer = true;
941 
942  if ( nameCol() >= 0 ) setText( nameCol(), zyppObj()->name() );
943  if ( summaryCol() >= 0 ) setText( summaryCol(), zyppObj()->summary() );
944 
945  if ( sizeCol() >= 0 )
946  {
947  zypp::ByteCount size = zyppObj()->installSize();
948 
949  if ( size > 0L )
950  setText( sizeCol(), size.asString() );
951  }
952 
953  if ( versionCol() == instVersionCol() ) // Display both versions in the same column: 1.2.3 (1.2.4)
954  {
955  if ( versionCol() >= 0 )
956  {
957  if ( installed )
958  {
959  if ( zyppObj() != installed &&
960  zyppObj() != candidate )
961  {
962  setText( versionCol(), QString().sprintf( "%s", zyppObj()->edition().c_str() ) );
963  }
964  else
965  {
966  if ( candidate && installed->edition() != candidate->edition() )
967  {
968  setText( versionCol(),
969  QString().sprintf( "%s (%s)",
970  installed->edition().c_str(),
971  candidate->edition().c_str() ) );
972  }
973  else // no candidate or both versions are the same anyway
974  {
975  setText( versionCol(),
976  QString().sprintf( "%s", installed->edition().c_str() ) );
977  }
978  }
979  }
980  else
981  {
982  if ( candidate )
983  setText( versionCol(), QString().sprintf( "(%s)", candidate->edition().c_str() ) );
984  else
985  setText( versionCol(), zyppObj()->edition() );
986  }
987 
988  if ( _installedIsNewer )
989  setTextColor( versionCol(), Qt::red);
990  else if ( _candidateIsNewer )
991  setTextColor( versionCol(), Qt::blue);
992  }
993  }
994  else // separate columns for installed and available versions
995  {
996  if ( instVersionCol() >= 0 )
997  {
998  if ( installed )
999  {
1000  setText( instVersionCol(), installed->edition() );
1001 
1002  if ( _installedIsNewer )
1003  setTextColor( instVersionCol(), Qt::red);
1004  else if ( _candidateIsNewer )
1005  setTextColor( instVersionCol(), Qt::blue);
1006  }
1007  }
1008 
1009  if ( versionCol() >= 0 )
1010  {
1011  if ( zyppObj() != installed &&
1012  zyppObj() != candidate )
1013  {
1014  setText( versionCol(), zyppObj()->edition() );
1015  }
1016  else if ( candidate )
1017  {
1018  setText( versionCol(), candidate->edition() );
1019 
1020  if ( _installedIsNewer )
1021  setTextColor( versionCol(), Qt::red);
1022  else if ( _candidateIsNewer )
1023  setTextColor( versionCol(), Qt::blue);
1024  }
1025  }
1026  }
1027 
1028  setStatusIcon();
1029 }
1030 
1031 
1032 void
1034 {
1035  init();
1036 }
1037 
1038 
1039 void
1040 YQPkgObjListItem::setText( int column, const string text )
1041 {
1042  QTreeWidgetItem::setText( column, fromUTF8( text.c_str() ) );
1043 }
1044 
1045 
1046 void
1047 YQPkgObjListItem::setText( int column, const zypp::Edition & edition )
1048 {
1049  setText( column, edition.asString() );
1050 }
1051 
1052 
1053 ZyppStatus
1055 {
1056  if ( ! selectable() )
1057  {
1058  yuiError() << "No selectable" << endl;
1059  return S_NoInst;
1060  }
1061 
1062  return selectable()->status();
1063 }
1064 
1065 
1066 bool
1068 {
1069  zypp::ResStatus::TransactByValue modifiedBy = selectable()->modifiedBy();
1070 
1071  return ( modifiedBy == zypp::ResStatus::APPL_LOW ||
1072  modifiedBy == zypp::ResStatus::APPL_HIGH );
1073 }
1074 
1075 
1076 
1077 void
1078 YQPkgObjListItem::setStatus( ZyppStatus newStatus, bool sendSignals )
1079 {
1080  ZyppStatus oldStatus = selectable()->status();
1081  selectable()->setStatus( newStatus );
1082 
1083  if ( oldStatus != selectable()->status() )
1084  {
1085  applyChanges();
1086 
1087  if ( sendSignals )
1088  {
1089  _pkgObjList->updateItemStates();
1090  _pkgObjList->sendUpdatePackages();
1091  }
1092  }
1093 
1094  setStatusIcon();
1095 }
1096 
1097 
1098 void
1100 {
1101  zypp::getZYpp()->resolver()->resolvePool();
1102 }
1103 
1104 
1105 
1106 void
1108 {
1109  setStatusIcon();
1110 }
1111 
1112 
1113 void
1115 {
1116  if ( statusCol() >= 0 )
1117  {
1118  bool enabled = editable() && _pkgObjList->editable();
1119  setIcon( statusCol(), _pkgObjList->statusIcon( status(), enabled, bySelection() ) );
1120  }
1121 
1122 
1123  if ( brokenIconCol() >= 0 )
1124  {
1125  // Reset this icon now - it might be the same column as satisfiedIconCol()
1126  setIcon( brokenIconCol(), QPixmap() );
1127  }
1128 
1129  if ( satisfiedIconCol() >= 0 )
1130  {
1131  // Set special icon for zyppObjs that are not marked as installed,
1132  // but satisfied anyway (e.g. for patches or patterns where the user
1133  // selected all required packages manually)
1134 
1135  setIcon( satisfiedIconCol(), isSatisfied() ? YQIconPool::pkgSatisfied() : QPixmap() );
1136  }
1137 
1138  if ( brokenIconCol() >= 0 )
1139  {
1140  // Set special icon for zyppObjs that are installed, but broken
1141  // (dependencies no longer satisfied, e.g. for patches or patterns)
1142 
1143  if ( isBroken() )
1144  {
1145  setIcon( brokenIconCol(), YQIconPool::warningSign() );
1146 
1147  yuiWarning() << "Broken object: " << _selectable->theObj()->name()
1148  << " - " << _selectable->theObj()->summary()
1149  << endl;
1150  }
1151  }
1152 }
1153 
1154 
1155 bool
1157 {
1158  if ( _debugIsSatisfied )
1159  return true;
1160 
1161  if ( _selectable->hasInstalledObj() )
1162  return false;
1163 
1164  return _selectable->candidateObj().isSatisfied();
1165 }
1166 
1167 
1169 {
1170  if ( _debugIsBroken )
1171  return true;
1172 
1173  if ( ! _selectable->hasInstalledObj() )
1174  return false; // can't be broken if not installed
1175 
1176  switch ( status() )
1177  {
1178  case S_KeepInstalled:
1179  case S_Protected:
1180 
1181  return _selectable->installedObj().isBroken();
1182 
1183  case S_Update: // will be fixed by updating
1184  case S_AutoUpdate:
1185  case S_Del: // will no longer be relevant after deleting
1186  case S_AutoDel:
1187 
1188  return false;
1189 
1190  case S_NoInst: // should not happen - no installed obj
1191  case S_Install:
1192  case S_AutoInstall:
1193  case S_Taboo:
1194 
1195  yuiError() << "Expected uninstalled zyppObj" << endl;
1196  return false;
1197  }
1198 
1199  yuiError() << "Should never get here" << endl;
1200  return false;
1201 }
1202 
1203 
1204 void
1206 {
1207  if ( ! _editable || ! _pkgObjList->editable() )
1208  return;
1209 
1210  ZyppStatus oldStatus = status();
1211  ZyppStatus newStatus = oldStatus;
1212 
1213  switch ( oldStatus )
1214  {
1215  case S_Install:
1216  newStatus = S_NoInst;
1217  break;
1218 
1219  case S_Protected:
1220  newStatus = selectable()->hasCandidateObj() ?
1221  S_KeepInstalled: S_NoInst;
1222  break;
1223 
1224  case S_Taboo:
1225  newStatus = selectable()->hasInstalledObj() ?
1226  S_KeepInstalled : S_NoInst;
1227  break;
1228 
1229  case S_KeepInstalled:
1230  newStatus = selectable()->hasCandidateObj() ?
1231  S_Update : S_Del;
1232  break;
1233 
1234  case S_Update:
1235  newStatus = S_Del;
1236  break;
1237 
1238  case S_AutoUpdate:
1239  newStatus = S_KeepInstalled;
1240  break;
1241 
1242  case S_Del:
1243  case S_AutoDel:
1244  newStatus = S_KeepInstalled;
1245  break;
1246 
1247  case S_NoInst:
1248  if ( selectable()->hasCandidateObj() )
1249  {
1250  newStatus = S_Install;
1251  }
1252  else
1253  {
1254  yuiWarning() << "No candidate for " << selectable()->theObj()->name() << endl;
1255  newStatus = S_NoInst;
1256  }
1257  break;
1258 
1259  case S_AutoInstall:
1260  // this used to be taboo before, but now ZYpp supports
1261  // saving weak locks (unselected packages)
1262  newStatus = S_NoInst;
1263  break;
1264  }
1265 
1266  if ( oldStatus != newStatus )
1267  {
1268  setStatus( newStatus );
1269 
1270  if ( showLicenseAgreement() )
1271  {
1272  showNotifyTexts( newStatus );
1273  }
1274  else // License not confirmed?
1275  {
1276  // Status is now S_Taboo or S_Del - update status icon
1277  setStatusIcon();
1278  }
1279 
1280  _pkgObjList->sendStatusChanged();
1281  }
1282 }
1283 
1284 
1285 void
1287 {
1288  // just return if no selectable
1289  if ( ! selectable() )
1290  return;
1291 
1292  string text;
1293 
1294  switch ( status )
1295  {
1296  case S_Install:
1297  if ( selectable()->hasCandidateObj() )
1298  text = selectable()->candidateObj()->insnotify();
1299  break;
1300 
1301  case S_NoInst:
1302  case S_Del:
1303  case S_Taboo:
1304  if ( selectable()->hasCandidateObj() )
1305  text = selectable()->candidateObj()->delnotify();
1306  break;
1307 
1308  default: break;
1309  }
1310 
1311  if ( ! text.empty() )
1312  {
1313  yuiDebug() << "Showing notify text" << endl;
1314  YQPkgTextDialog::showText( _pkgObjList, selectable(), text );
1315  }
1316 }
1317 
1318 
1319 bool
1321 {
1322  return showLicenseAgreement( selectable() );
1323 }
1324 
1325 
1326 bool
1328 {
1329  // if we have a subclass with no selectable
1330  // confirming the license should be just always
1331  // true
1332  if ( ! sel )
1333  return true;
1334 
1335  string licenseText;
1336 
1337  switch ( sel->status() )
1338  {
1339  case S_Install:
1340  case S_AutoInstall:
1341  case S_Update:
1342  case S_AutoUpdate:
1343 
1344  if ( sel->hasLicenceConfirmed() )
1345  return true;
1346 
1347  if ( sel->candidateObj() )
1348  licenseText = sel->candidateObj()->licenseToConfirm();
1349  break;
1350 
1351  default: return true;
1352  }
1353 
1354  if ( licenseText.empty() )
1355  return true;
1356 
1357  yuiDebug() << "Showing license agreement for " << sel->name() << endl;
1358 
1359  bool confirmed = YQPkgTextDialog::confirmText( (QWidget *) YDialog::currentDialog()->widgetRep(),
1360  sel, licenseText );
1361 
1362  if ( confirmed )
1363  {
1364  yuiMilestone() << "User confirmed license agreement for " << sel->name() << endl;
1365  sel->setLicenceConfirmed( true );
1366  }
1367  else
1368  {
1369  // The user rejected the license agreement -
1370  // make sure the package gets unselected.
1371 
1372  switch ( sel->status() )
1373  {
1374  case S_Install:
1375  case S_AutoInstall:
1376 
1377  yuiWarning() << "User rejected license agreement for " << sel->name()
1378  << " - setting to TABOO"
1379  << endl;
1380 
1381  sel->setStatus( S_Taboo );
1382  break;
1383 
1384 
1385  case S_Update:
1386  case S_AutoUpdate:
1387 
1388  yuiWarning() << "User rejected license agreement for " << sel->name()
1389  << " - setting to PROTECTED"
1390  << endl;
1391 
1392  sel->setStatus( S_Protected );
1393  // S_Keep wouldn't be good enough: The next solver run might
1394  // set it to S_AutoUpdate again
1395  break;
1396 
1397  default: break;
1398  }
1399  }
1400 
1401  return confirmed;
1402 }
1403 
1404 
1405 QString
1407 {
1408  if ( col == statusCol() )
1409  {
1410  QString tip = _pkgObjList->statusText( status() );
1411 
1412  switch ( status() )
1413  {
1414  case S_AutoDel:
1415  case S_AutoInstall:
1416  case S_AutoUpdate:
1417 
1418  if ( bySelection() )
1419  // Translators: Additional hint what caused an auto-status
1420  tip += "\n" + _( "(by a software selection)" );
1421  else
1422  tip += "\n" + _( "(by dependencies)" );
1423 
1424  break;
1425 
1426  default:
1427  break;
1428  }
1429 
1430  return tip;
1431  }
1432 
1433  if ( col == brokenIconCol() )
1434  {
1435  if ( isBroken() )
1436  // Translators: tool tip for patches / patterns that are installed,
1437  // but whose dependencies are broken (no longer satisfied)
1438  return _( "Dependencies broken" );
1439  }
1440 
1441  // don't use "else if" here, it might be the same colum as another one!
1442 
1443  if ( col == satisfiedIconCol() )
1444  {
1445  if ( isSatisfied() )
1446  // Translators: tool tip for patches / patterns that are not installed,
1447  // but whose dependencies are satisfied
1448  return _( "All dependencies satisfied" );
1449  }
1450 
1451  return QString::null;
1452 }
1453 
1454 
1455 
1456 bool YQPkgObjListItem::operator<( const QTreeWidgetItem & otherListViewItem ) const
1457 {
1458  const YQPkgObjListItem * other = dynamic_cast<const YQPkgObjListItem *> (&otherListViewItem);
1459  int col = treeWidget()->sortColumn();
1460 
1461  if ( other )
1462  {
1463  if ( col == nameCol() )
1464  {
1465  return ( strcasecmp( this->zyppObj()->name().c_str(), other->zyppObj()->name().c_str() ) < 0 );
1466  }
1467  if ( col == summaryCol() )
1468  {
1469  // locale aware sort
1470  return ( strcoll( this->zyppObj()->summary().c_str(), other->zyppObj()->summary().c_str() ) < 0 );
1471  }
1472  if ( col == sizeCol() )
1473  {
1474  // Numeric sort by size
1475 
1476  return ( this->zyppObj()->installSize() < other->zyppObj()->installSize() );
1477  }
1478  else if ( col == statusCol() )
1479  {
1480  // Sorting by status depends on the numeric value of the
1481  // ZyppStatus enum, thus it is important to insert new
1482  // package states there where they make most sense. We want to show
1483  // dangerous or noteworthy states first - e.g., "taboo" which should
1484  // seldeom occur, but when it does, it is important.
1485 
1486  bool b = ( this->status() < other->status() );
1487  if ( !b && this->status() == other->status() )
1488  b = this->zyppObj()->name() < other->zyppObj()->name();
1489  return b;
1490  }
1491  else if ( col == instVersionCol() ||
1492  col == versionCol() )
1493  {
1494  // Sorting by version numbers doesn't make too much sense, so let's
1495  // sort by package relation:
1496  // - Installed newer than candidate (red)
1497  // - Candidate newer than installed (blue) - worthwhile updating
1498  // - Installed
1499  // - Not installed, but candidate available
1500  //
1501  // Within these categories, sort versions by ASCII - OK, it's
1502  // pretty random, but predictable.
1503 
1504  int thisPoints = this->versionPoints();
1505  int otherPoints = other->versionPoints();
1506 
1507  if (thisPoints == otherPoints )
1508  return ( QString (this->zyppObj()->edition().c_str() ) <
1509  QString (other->zyppObj()->edition().c_str() ) );
1510  else
1511  return ( thisPoints < otherPoints );
1512  }
1513  }
1514 
1515  // Fallback: Use parent class method
1516  return QY2ListViewItem::operator<( otherListViewItem );
1517 }
1518 
1519 
1520 int
1522 {
1523  int points = 0;
1524 
1525  if ( installedIsNewer() ) points += 1000;
1526  if ( candidateIsNewer() ) points += 100;
1527  if ( selectable()->hasInstalledObj() ) points += 10;
1528  if ( selectable()->hasCandidateObj() ) points += 1;
1529 
1530  return points;
1531 }
1532 
1533 
1534 void
1536 {
1537  _excluded = excl;
1538 }
1539 
1541  const QRegExp & regexp,
1542  int column )
1543  : _parent( parent )
1544  , _regexp( regexp )
1545  , _column( column )
1546  , _enabled( true )
1547 {
1548  _parent->addExcludeRule( this );
1549 }
1550 
1551 
1552 void
1554 {
1555  _enabled = enable;
1556 
1557 #if VERBOSE_EXCLUDE_RULES
1558  yuiDebug() << ( enable ? "Enabling" : "Disabling" )
1559  << " exclude rule " << _regexp.pattern()
1560  << endl;
1561 #endif
1562 }
1563 
1564 
1565 void
1567 {
1568  _regexp = regexp;
1569 }
1570 
1571 
1572 void
1574 {
1575  _column = column;
1576 }
1577 
1578 
1579 bool
1580 YQPkgObjList::ExcludeRule::match( QTreeWidgetItem * item )
1581 {
1582  if ( ! _enabled )
1583  return false;
1584 
1585  QString text = item->text( _column );
1586 
1587  if ( text.isEmpty() )
1588  return false;
1589 
1590  return _regexp.exactMatch( text );
1591 }
1592 
1593 
1594 
1595 
1596 
1597 
1599  : _pkgObjList( parent )
1600 {
1601 }
1602 
1603 
1605 {
1606  clear();
1607 }
1608 
1609 
1610 void YQPkgObjList::ExcludedItems::add( QTreeWidgetItem * item, QTreeWidgetItem * oldParent )
1611 {
1612  _excludeMap.insert( ItemPair( item, oldParent ) );
1613 }
1614 
1615 
1616 void YQPkgObjList::ExcludedItems::remove( QTreeWidgetItem * item )
1617 {
1618  ItemMap::iterator it = _excludeMap.find( item );
1619 
1620  if ( it != _excludeMap.end() )
1621  {
1622  _excludeMap.erase( it );
1623  }
1624 }
1625 
1626 
1628 {
1629  for ( ItemMap::iterator it = _excludeMap.begin();
1630  it != _excludeMap.end();
1631  ++it )
1632  {
1633  delete it->first;
1634  }
1635 
1636  _excludeMap.clear();
1637 }
1638 
1639 
1640 bool YQPkgObjList::ExcludedItems::contains( QTreeWidgetItem * item )
1641 {
1642  return ( _excludeMap.find( item ) != _excludeMap.end() );
1643 }
1644 
1646 {
1647  YQPkgObjListItem * item = dynamic_cast<YQPkgObjListItem *> ( currentItem() );
1648 
1649  if ( item && editable() && item->editable() )
1650  {
1651  updateActions( item );
1652 
1653  if ( ! item->selectable() )
1654  return;
1655 
1656  QMenu * contextMenu =
1657  ! item->selectable()->installedEmpty() ?
1659 
1660  if ( contextMenu )
1661  contextMenu->popup( viewport()->mapToGlobal( pos ) );
1662  }
1663 }
1664 
1665 
1666 QTreeWidgetItem * YQPkgObjList::ExcludedItems::oldParentItem( QTreeWidgetItem * item )
1667 {
1668  ItemMap::iterator it = _excludeMap.find( item );
1669 
1670  if ( it == _excludeMap.end() )
1671  return 0;
1672 
1673  return it->second;
1674 }
1675 
1676 
1677 
1678 #include "YQPkgObjList.moc"
ZyppSel selectable() const
Returns the original selectable within the package manager backend.
Definition: YQPkgObjList.h:454
int size() const
Returns the number of items.
Definition: YQPkgObjList.h:817
ZyppObj zyppObj() const
Returns the original object within the package manager backend.
Definition: YQPkgObjList.h:459
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 ...
void addExcludeRule(YQPkgObjList::ExcludeRule *rule)
Add an exclude rule to this list.
virtual void createInstalledContextMenu()
Create the context menu for installed items.
void setAllItemStatus(ZyppStatus newStatus, bool force=false)
Sets the status of all (toplevel) list items to &#39;newStatus&#39;, if possible.
bool candidateIsNewer() const
Check if the candidate is newer than the installed version.
Definition: YQPkgObjList.h:514
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...
iterator begin()
Returns an iterator that points to the first excluded item.
Definition: YQPkgObjList.h:822
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.
void addPassiveItem(const QString &name, const QString &summary=QString::null, FSize size=-1)
Add a purely passive list item that has a name and optional summary and size.
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.
QAction * createAction(ZyppStatus status, const QString &key=QString::null, bool enabled=false)
Create an action based on a zypp::ResObject status - automatically retrieve the corresponding status ...
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.
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.
bool editable() const
Return whether or not items in this list are generally editable, i.e.
Definition: YQPkgObjList.h:108
int versionPoints() const
Calculate a numerical value to compare versions, based on version relations:
void selectNextItem()
Select the next item, i.e.
bool isExcluded() const
Returns &#39;true&#39; if this item is excluded.
Definition: YQPkgObjList.h:594
void updatePackages()
Emitted when it&#39;s time to update displayed package information, e.g., package states.
virtual bool operator<(const QTreeWidgetItem &other) const
sorting function
iterator end()
Returns an iterator that points after the last excluded item.
Definition: YQPkgObjList.h:827
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;.
void clear()
Clear the excluded items.
ExcludedItems(YQPkgObjList *parent)
Constructor.
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...
virtual void applyChanges()
Apply changes hook.
Definition: YQPkgObjList.h:643
QRegExp regexp() const
Returns the regexp.
Definition: YQPkgObjList.h:732
void applyExcludeRules()
Apply all exclude rules of this list to all items, including those that are currently excluded...
bool contains(QTreeWidgetItem *item)
Returns &#39;true&#39; if the specified item is in the excluded items.
void setRegexp(const QRegExp &regexp)
Change the regular expression after creation.
QTreeWidgetItem * oldParentItem(QTreeWidgetItem *item)
Returns the old parent of this item so it can be reparented or 0 if it was a root item...
virtual QMenu * addAllInListSubMenu(QMenu *menu)
Add a submenu "All in this list..." to &#39;menu&#39;.
bool isBroken() const
Check if this item is "broken": If it is installed, but any of its dependencies are no longer satisfi...
virtual QString statusText(ZyppStatus status) const
Returns a short (one line) descriptive text for a zypp::ResObject status.
void currentItemChanged(ZyppSel selectable)
Emitted when a zypp::ui::Selectable is selected.
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
YQPkgObjList * parent() const
Returns this exclude rule&#39;s parent YQPkgObjList.
Definition: YQPkgObjList.h:747
virtual void createNotInstalledContextMenu()
Create the context menu for items that are not installed.
bool isSatisfied() const
Check if this item is satisfied, even though it is not installed.
virtual QMenu * installedContextMenu()
Returns the context menu for items that are not installed.
bool installedIsNewer() const
Check if the installed version is newer than the candidate.
Definition: YQPkgObjList.h:519
int column() const
Returns the column number.
Definition: YQPkgObjList.h:742
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
virtual ~ExcludedItems()
Destructor.
virtual ZyppStatus status() const
Returns the (binary RPM) package status.
bool isEnabled() const
Returns &#39;true&#39; if this exclude rule is enabled, &#39;false&#39; otherwise.
Definition: YQPkgObjList.h:722
static bool showLicenseAgreement(ZyppSel sel)
Display a selectable&#39;s license agreement (if there is any) that corresponds to its current status (S_...
void add(QTreeWidgetItem *item, QTreeWidgetItem *oldParent)
Add a list item to the excluded items and transfer ownership to this class.
virtual ~YQPkgObjListItem()
Destructor.
virtual void setStatusIcon()
Set a status icon according to the package&#39;s status.
virtual void cycleStatus()
Cycle the package status to the next valid value.
void init()
Initialize internal data and set fields accordingly.
void remove(QTreeWidgetItem *item)
Remove a list item from the excluded items and transfer ownership back to the caller.
bool editable() const
Return whether or not this items is editable, i.e.
Definition: YQPkgObjList.h:466