libyui-qt-pkg  2.45.27
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( 16, 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 
398  actionSetCurrentUpdateForce = createAction( _( "Update unconditionally" ),
399  statusIcon( S_Update, true ),
400  statusIcon( S_Update, false ) ,
401  "",
402  true ) ;
403 
404 
405 
406  actionSetCurrentTaboo = createAction( S_Taboo, "[!]" );
407  actionSetCurrentProtected = createAction( S_Protected, "[*]" );
408 
409  actionSetListInstall = createAction( S_Install, "", true );
410  actionSetListDontInstall = createAction( S_NoInst, "", true );
411  actionSetListKeepInstalled = createAction( S_KeepInstalled, "", true );
412  actionSetListDelete = createAction( S_Del, "", true );
413  actionSetListProtected = createAction( S_Protected, "", true );
414 
415  actionSetListUpdate = createAction( _( "Update if newer version available" ),
416  statusIcon( S_Update, true ),
417  statusIcon( S_Update, false ),
418  "",
419  true );
420 
421  actionSetListUpdateForce = createAction( _( "Update unconditionally" ),
422  statusIcon( S_Update, true ),
423  statusIcon( S_Update, false ),
424  "",
425  true );
426 
427  actionSetListTaboo = createAction( S_Taboo, "", true );
428 
429  connect( actionSetCurrentInstall, &QAction::triggered, this, &YQPkgObjList::setCurrentInstall );
430  connect( actionSetCurrentDontInstall, &QAction::triggered, this, &YQPkgObjList::setCurrentDontInstall );
431  connect( actionSetCurrentKeepInstalled, &QAction::triggered, this, &YQPkgObjList::setCurrentKeepInstalled );
432  connect( actionSetCurrentDelete, &QAction::triggered, this, &YQPkgObjList::setCurrentDelete );
433  connect( actionSetCurrentUpdate, &QAction::triggered, this, &YQPkgObjList::setCurrentUpdate );
434  connect( actionSetCurrentUpdateForce, &QAction::triggered, this, &YQPkgObjList::setCurrentUpdateForce );
435  connect( actionSetCurrentTaboo, &QAction::triggered, this, &YQPkgObjList::setCurrentTaboo );
436  connect( actionSetCurrentProtected, &QAction::triggered, this, &YQPkgObjList::setCurrentProtected );
437  connect( actionSetListInstall, &QAction::triggered, this, &YQPkgObjList::setListInstall );
438  connect( actionSetListDontInstall, &QAction::triggered, this, &YQPkgObjList::setListDontInstall );
439  connect( actionSetListKeepInstalled, &QAction::triggered, this, &YQPkgObjList::setListKeepInstalled );
440  connect( actionSetListDelete, &QAction::triggered, this, &YQPkgObjList::setListDelete );
441  connect( actionSetListUpdate, &QAction::triggered, this, &YQPkgObjList::setListUpdate );
442  connect( actionSetListUpdateForce, &QAction::triggered, this, &YQPkgObjList::setListUpdateForce );
443  connect( actionSetListTaboo, &QAction::triggered, this, &YQPkgObjList::setListTaboo );
444  connect( actionSetListProtected, &QAction::triggered, this, &YQPkgObjList::setListProtected );
445 }
446 
447 
448 
449 QAction *
450 YQPkgObjList::createAction( ZyppStatus status, const QString & key, bool enabled )
451 {
452  return createAction( statusText( status ),
453  statusIcon( status, true ),
454  statusIcon( status, false ),
455  key,
456  enabled );
457 }
458 
459 
460 QAction *
461 YQPkgObjList::createAction( const QString & text,
462  const QPixmap & icon,
463  const QPixmap & insensitiveIcon,
464  const QString & key,
465  bool enabled )
466 {
467  QString label = text;
468 
469  if ( ! key.isEmpty() )
470  label += "\t" + key;
471 
472 
473  QIcon iconSet ( icon );
474 
475  if ( ! insensitiveIcon.isNull() )
476  {
477  iconSet.addPixmap( insensitiveIcon,
478  QIcon::Disabled );
479  }
480 
481  QAction * action = new QAction( label, // text
482  this ); // parent
483  Q_CHECK_PTR( action );
484  action->setEnabled( enabled );
485  action->setIcon( iconSet );
486 
487  return action;
488 }
489 
490 
491 void
493 {
494  _notInstalledContextMenu = new QMenu( this );
495  Q_CHECK_PTR( _notInstalledContextMenu );
496 
497  _notInstalledContextMenu->addAction( actionSetCurrentInstall );
498  _notInstalledContextMenu->addAction( actionSetCurrentDontInstall );
499  _notInstalledContextMenu->addAction( actionSetCurrentTaboo );
500 
501  addAllInListSubMenu( _notInstalledContextMenu );
502 }
503 
504 
505 void
507 {
508  _installedContextMenu = new QMenu( this );
509  Q_CHECK_PTR( _installedContextMenu );
510 
511  _installedContextMenu->addAction( actionSetCurrentKeepInstalled );
512  _installedContextMenu->addAction( actionSetCurrentDelete );
513  _installedContextMenu->addAction( actionSetCurrentUpdate );
514  _installedContextMenu->addAction( actionSetCurrentUpdateForce );
515 
516  addAllInListSubMenu( _installedContextMenu );
517 }
518 
519 
520 QMenu *
522 {
523  QMenu * submenu = new QMenu( menu );
524  Q_CHECK_PTR( submenu );
525 
526  submenu->addAction( actionSetListInstall );
527  submenu->addAction( actionSetListDontInstall );
528  submenu->addAction( actionSetListKeepInstalled );
529  submenu->addAction( actionSetListDelete );
530  submenu->addAction( actionSetListUpdate );
531  submenu->addAction( actionSetListUpdateForce );
532  submenu->addAction( actionSetListTaboo );
533 
534  QAction *action = menu->addMenu( submenu );
535  action->setText( _( "&All in This List" ) );
536 
537  return submenu;
538 }
539 
540 
541 QMenu *
543 {
544  if ( ! _notInstalledContextMenu )
546 
547  return _notInstalledContextMenu;
548 }
549 
550 
551 QMenu *
553 {
554  if ( ! _installedContextMenu )
556 
557  return _installedContextMenu;
558 }
559 
560 
561 void
563 {
564  if ( !item)
565  item = dynamic_cast<YQPkgObjListItem *> ( currentItem() );
566 
567  if ( item )
568  {
569  ZyppSel selectable = item->selectable();
570 
571  if ( selectable->hasInstalledObj() )
572  {
573  actionSetCurrentInstall->setEnabled( false );
574  actionSetCurrentDontInstall->setEnabled( false );
575  actionSetCurrentTaboo->setEnabled( false );
576  actionSetCurrentProtected->setEnabled( true );
577 
578  actionSetCurrentKeepInstalled->setEnabled( true );
579  actionSetCurrentDelete->setEnabled( true );
580  actionSetCurrentUpdate->setEnabled( selectable->hasCandidateObj() );
581  actionSetCurrentUpdateForce->setEnabled( selectable->hasCandidateObj() );
582  }
583  else
584  {
585  actionSetCurrentInstall->setEnabled( selectable->hasCandidateObj() );
586  actionSetCurrentDontInstall->setEnabled( true );
587  actionSetCurrentTaboo->setEnabled( true );
588  actionSetCurrentProtected->setEnabled( false );
589 
590  actionSetCurrentKeepInstalled->setEnabled( false );
591  actionSetCurrentDelete->setEnabled( false );
592  actionSetCurrentUpdate->setEnabled( false );
593  actionSetCurrentUpdateForce->setEnabled( false );
594  }
595  }
596  else // ! item
597  {
598  actionSetCurrentInstall->setEnabled( false );
599  actionSetCurrentDontInstall->setEnabled( false );
600  actionSetCurrentTaboo->setEnabled( false );
601 
602  actionSetCurrentKeepInstalled->setEnabled( false );
603  actionSetCurrentDelete->setEnabled( false );
604  actionSetCurrentUpdate->setEnabled( false );
605  actionSetCurrentUpdateForce->setEnabled( false );
606  actionSetCurrentProtected->setEnabled( false );
607 
608  }
609 }
610 
611 
612 void
613 YQPkgObjList::keyPressEvent( QKeyEvent * event )
614 {
615  if ( event )
616  {
617  Qt::KeyboardModifiers special_combo = ( Qt::ControlModifier | Qt::ShiftModifier | Qt::AltModifier );
618 
619  if ( ( event->modifiers() & special_combo ) == special_combo )
620  {
621  if ( event->key() == Qt::Key_Q )
622  {
623  _debug= ! _debug;
624  yuiMilestone() << "Debug mode: " << _debug << endl;
625  }
626 
627  }
628  QTreeWidgetItem * selectedListViewItem = currentItem();
629 
630  if ( selectedListViewItem )
631  {
632  YQPkgObjListItem * item = dynamic_cast<YQPkgObjListItem *> (selectedListViewItem);
633 
634  if ( item )
635  {
636  bool installed;
637 
638  if ( item->selectable() )
639  installed = item->selectable()->hasInstalledObj();
640  else
641  installed = false;
642 
643  ZyppStatus status = item->status();
644 
645  switch( event->key() )
646  {
647  case Qt::Key_Space: // Cycle
648  item->cycleStatus();
649  event->accept();
650  return;
651 
652  case Qt::Key_Plus: // Grab everything - install or update
653 
654  if ( installed )
655  {
656  ZyppStatus newStatus = S_KeepInstalled;
657 
658  if ( item->candidateIsNewer() )
659  newStatus = S_Update;
660 
661  setCurrentStatus( newStatus );
662  }
663  else
664  setCurrentStatus( S_Install );
665  event->accept();
666  return;
667 
668  case Qt::Key_Minus: // Get rid of everything - don't install or delete
669  setCurrentStatus( installed ? S_Del : S_NoInst );
670  event->accept();
671  return;
672 
673  case Qt::Key_Exclam: // Taboo
674 
675  if ( ! installed )
676  setCurrentStatus( S_Taboo );
677  event->accept();
678  return;
679 
680  case Qt::Key_Asterisk: // Protected
681 
682  if ( installed )
683  setCurrentStatus( S_Protected );
684  event->accept();
685  return;
686 
687  case Qt::Key_Greater: // Update what is worth to be updated
688 
689  if ( installed && item->candidateIsNewer() )
690  setCurrentStatus( S_Update );
691  event->accept();
692  return;
693 
694  case Qt::Key_Less: // Revert update
695 
696  if ( status == S_Update ||
697  status == S_AutoUpdate )
698  {
699  setCurrentStatus( S_KeepInstalled );
700  }
701  event->accept();
702  return;
703 
704  case Qt::Key_B: // Toggle debugIsBroken flag
705 
706  if ( _debug )
707  {
708  item->toggleDebugIsBroken();
709  item->setStatusIcon();
710  }
711  event->accept();
712  break;
713 
714  case Qt::Key_S: // Toggle debugIsSatisfied flag
715 
716  if ( _debug )
717  {
718  item->toggleDebugIsSatisfied();
719  item->setStatusIcon();
720  }
721  event->accept();
722  break;
723  }
724  }
725  }
726  }
727  QY2ListView::keyPressEvent( event );
728 }
729 
730 
731 void
732 YQPkgObjList::message( const QString & text )
733 {
734  QY2ListViewItem * item = new QY2ListViewItem( this );
735  Q_CHECK_PTR( item );
736 
737  item->setText( nameCol() >= 0 ? nameCol() : 0, text );
738 }
739 
740 
741 void
743 {
744  _excludeRules.push_back( rule );
745 }
746 
747 
748 void
750 {
751  // yuiDebug() << "Applying exclude rules" << endl;
752  QTreeWidgetItemIterator listView_it( this );
753 
754  while ( *listView_it )
755  {
756  QTreeWidgetItem * current_item = *listView_it;
757 
758  // Advance iterator now so it remains valid even if there are changes
759  // to the QListView, e.g., if the current item is excluded and thus
760  // removed from the QListView
761  ++listView_it;
762 
763  applyExcludeRules( current_item );
764  }
765 
766  ExcludedItems::iterator excluded_it = _excludedItems->begin();
767 
768  while ( excluded_it != _excludedItems->end() )
769  {
770  QTreeWidgetItem * current_item = (*excluded_it).first;
771 
772  // Advance iterator now so it remains valid even if there are changes
773  // to the excluded items, e.g., if the current item is un-excluded and thus
774  // removed from the excluded items
775  ++excluded_it;
776 
777  applyExcludeRules( current_item );
778  }
779 
781 }
782 
783 
784 void
786 {
787  if ( _excludedItems->size() > 0 )
788  {
789  yuiMilestone() << _excludedItems->size() << " packages excluded" << endl;
790 
791  for ( ExcludeRuleList::iterator rule_it = _excludeRules.begin();
792  rule_it != _excludeRules.end();
793  ++rule_it )
794  {
795  ExcludeRule * rule = *rule_it;
796 
797  if ( rule->isEnabled() )
798  {
799  yuiMilestone() << "Active exclude rule: \""
800  << rule->regexp().pattern() << "\""
801  << endl;
802  }
803  }
804  }
805 }
806 
807 
808 void
809 YQPkgObjList::applyExcludeRules( QTreeWidgetItem * listViewItem )
810 {
811  YQPkgObjListItem * item = dynamic_cast<YQPkgObjListItem *>( listViewItem );
812 
813  if ( item )
814  {
815  bool exclude = false;
816 #if VERBOSE_EXCLUDE_RULES
817  ExcludeRule * matchingRule = 0;
818 #endif
819 
820  for ( ExcludeRuleList::iterator rule_it = _excludeRules.begin();
821  rule_it != _excludeRules.end() && ! exclude;
822  ++rule_it )
823  {
824  ExcludeRule * rule = *rule_it;
825 
826  if ( rule->match( item ) )
827  {
828  exclude = true;
829 #if VERBOSE_EXCLUDE_RULES
830  matchingRule = rule;
831 #endif
832  }
833  }
834 
835  if ( exclude != item->isExcluded() ) // change exclude status?
836  {
837  this->exclude( item, exclude );
838 
839 #if VERBOSE_EXCLUDE_RULES
840  if ( exclude )
841  {
842  yuiDebug() << "Rule \"" << matchingRule->regexp().pattern()
843  << "\" matches: Excluding " << item->zyppObj()->name()
844  << endl;
845  }
846  else
847  {
848  yuiDebug() << "Un-excluding " << item->zyppObj()->name() << endl;
849  }
850 #endif
851  }
852  }
853 }
854 
855 
856 void
858 {
859  if ( exclude == item->isExcluded() )
860  return;
861 
862  item->setExcluded( exclude );
863 
864  QTreeWidgetItem * parentItem = item->parent();
865 
866  if ( parentItem )
867  parentItem->setHidden(exclude);
868  else
869  item->setHidden(exclude);
870 
871  _excludedItems->add( item, parentItem );
872 }
873 
874 
875 
876 
878  ZyppSel selectable,
879  ZyppObj zyppObj )
880  : QY2ListViewItem( pkgObjList )
881  , _pkgObjList( pkgObjList )
882  , _selectable( selectable )
883  , _zyppObj( zyppObj )
884  , _editable( true )
885  , _excluded( false )
886 {
887  init();
888 }
889 
890 
892  QY2ListViewItem * parent,
893  ZyppSel selectable,
894  ZyppObj zyppObj )
895  : QY2ListViewItem( parent )
896  , _pkgObjList( pkgObjList )
897  , _selectable( selectable )
898  , _zyppObj( zyppObj )
899  , _editable( true )
900  , _excluded( false )
901 {
902  init();
903 }
904 
905 
907  : QY2ListViewItem( pkgObjList )
908  , _pkgObjList( pkgObjList )
909  , _selectable( 0 )
910  , _zyppObj( 0 )
911  , _editable( true )
912  , _excluded( false )
913 {
914 }
915 
916 
918 {
919  // NOP
920 }
921 
922 
923 void
925 {
926  if ( _zyppObj == 0 && _selectable )
927  _zyppObj = _selectable->theObj();
928 
929  _debugIsBroken = false;
930  _debugIsSatisfied = false;
931  _candidateIsNewer = false;
932  _installedIsNewer = false;
933 
934  const ZyppObj candidate = selectable()->candidateObj();
935  const ZyppObj installed = selectable()->installedObj();
936 
937  if ( candidate && installed )
938  {
939  if ( candidate->edition() < installed->edition() )
940  _installedIsNewer = true;
941  else if ( installed->edition() < candidate->edition() )
942  _candidateIsNewer = true;
943  }
944 
945  if ( installed && ! candidate )
946  _installedIsNewer = true;
947 
948  if ( nameCol() >= 0 ) setText( nameCol(), zyppObj()->name() );
949  if ( summaryCol() >= 0 ) setText( summaryCol(), zyppObj()->summary() );
950 
951  if ( sizeCol() >= 0 )
952  {
953  zypp::ByteCount size = zyppObj()->installSize();
954 
955  if ( size > 0L )
956  setText( sizeCol(), size.asString() );
957  }
958 
959  if ( versionCol() == instVersionCol() ) // Display both versions in the same column: 1.2.3 (1.2.4)
960  {
961  if ( versionCol() >= 0 )
962  {
963  if ( installed )
964  {
965  if ( zyppObj() != installed &&
966  zyppObj() != candidate )
967  {
968  setText( versionCol(), QString().sprintf( "%s", zyppObj()->edition().c_str() ) );
969  }
970  else
971  {
972  if ( candidate && installed->edition() != candidate->edition() )
973  {
974  setText( versionCol(),
975  QString().sprintf( "%s (%s)",
976  installed->edition().c_str(),
977  candidate->edition().c_str() ) );
978  }
979  else // no candidate or both versions are the same anyway
980  {
981  setText( versionCol(),
982  QString().sprintf( "%s", installed->edition().c_str() ) );
983  }
984  }
985  }
986  else
987  {
988  if ( candidate )
989  setText( versionCol(), QString().sprintf( "(%s)", candidate->edition().c_str() ) );
990  else
991  setText( versionCol(), zyppObj()->edition() );
992  }
993 
994  if ( _installedIsNewer )
995  setTextColor( versionCol(), Qt::red);
996  else if ( _candidateIsNewer )
997  setTextColor( versionCol(), Qt::blue);
998  }
999  }
1000  else // separate columns for installed and available versions
1001  {
1002  if ( instVersionCol() >= 0 )
1003  {
1004  if ( installed )
1005  {
1006  setText( instVersionCol(), installed->edition() );
1007 
1008  if ( _installedIsNewer )
1009  setTextColor( instVersionCol(), Qt::red);
1010  else if ( _candidateIsNewer )
1011  setTextColor( instVersionCol(), Qt::blue);
1012  }
1013  }
1014 
1015  if ( versionCol() >= 0 )
1016  {
1017  if ( zyppObj() != installed &&
1018  zyppObj() != candidate )
1019  {
1020  setText( versionCol(), zyppObj()->edition() );
1021  }
1022  else if ( candidate )
1023  {
1024  setText( versionCol(), candidate->edition() );
1025 
1026  if ( _installedIsNewer )
1027  setTextColor( versionCol(), Qt::red);
1028  else if ( _candidateIsNewer )
1029  setTextColor( versionCol(), Qt::blue);
1030  }
1031  }
1032  }
1033 
1034  setStatusIcon();
1035 }
1036 
1037 
1038 void
1040 {
1041  init();
1042 }
1043 
1044 
1045 void
1046 YQPkgObjListItem::setText( int column, const string text )
1047 {
1048  QTreeWidgetItem::setText( column, fromUTF8( text.c_str() ) );
1049 }
1050 
1051 
1052 void
1053 YQPkgObjListItem::setText( int column, const zypp::Edition & edition )
1054 {
1055  setText( column, edition.asString() );
1056 }
1057 
1058 
1059 ZyppStatus
1061 {
1062  if ( ! selectable() )
1063  {
1064  yuiError() << "No selectable" << endl;
1065  return S_NoInst;
1066  }
1067 
1068  return selectable()->status();
1069 }
1070 
1071 
1072 bool
1074 {
1075  zypp::ResStatus::TransactByValue modifiedBy = selectable()->modifiedBy();
1076 
1077  return ( modifiedBy == zypp::ResStatus::APPL_LOW ||
1078  modifiedBy == zypp::ResStatus::APPL_HIGH );
1079 }
1080 
1081 
1082 
1083 void
1084 YQPkgObjListItem::setStatus( ZyppStatus newStatus, bool sendSignals )
1085 {
1086  ZyppStatus oldStatus = selectable()->status();
1087  selectable()->setStatus( newStatus );
1088 
1089  if ( oldStatus != selectable()->status() )
1090  {
1091  applyChanges();
1092 
1093  if ( sendSignals )
1094  {
1095  _pkgObjList->updateItemStates();
1096  _pkgObjList->sendUpdatePackages();
1097  }
1098  }
1099 
1100  setStatusIcon();
1101 }
1102 
1103 
1104 void
1106 {
1107  zypp::getZYpp()->resolver()->resolvePool();
1108 }
1109 
1110 
1111 
1112 void
1114 {
1115  setStatusIcon();
1116 }
1117 
1118 
1119 void
1121 {
1122  if ( statusCol() >= 0 )
1123  {
1124  bool enabled = editable() && _pkgObjList->editable();
1125  setIcon( statusCol(), _pkgObjList->statusIcon( status(), enabled, bySelection() ) );
1126  }
1127 
1128 
1129  if ( brokenIconCol() >= 0 )
1130  {
1131  // Reset this icon now - it might be the same column as satisfiedIconCol()
1132  setIcon( brokenIconCol(), QPixmap() );
1133  }
1134 
1135  if ( satisfiedIconCol() >= 0 )
1136  {
1137  // Set special icon for zyppObjs that are not marked as installed,
1138  // but satisfied anyway (e.g. for patches or patterns where the user
1139  // selected all required packages manually)
1140 
1141  setIcon( satisfiedIconCol(), isSatisfied() ? YQIconPool::pkgSatisfied() : QPixmap() );
1142  }
1143 
1144  if ( brokenIconCol() >= 0 )
1145  {
1146  // Set special icon for zyppObjs that are installed, but broken
1147  // (dependencies no longer satisfied, e.g. for patches or patterns)
1148 
1149  if ( isBroken() )
1150  {
1151  setIcon( brokenIconCol(), YQIconPool::warningSign() );
1152 
1153  yuiWarning() << "Broken object: " << _selectable->theObj()->name()
1154  << " - " << _selectable->theObj()->summary()
1155  << endl;
1156  }
1157  }
1158 }
1159 
1160 
1161 bool
1163 {
1164  if ( _debugIsSatisfied )
1165  return true;
1166 
1167  if ( _selectable->hasInstalledObj() )
1168  return false;
1169 
1170  return _selectable->candidateObj().isSatisfied();
1171 }
1172 
1173 
1175 {
1176  if ( _debugIsBroken )
1177  return true;
1178 
1179  if ( ! _selectable->hasInstalledObj() )
1180  return false; // can't be broken if not installed
1181 
1182  switch ( status() )
1183  {
1184  case S_KeepInstalled:
1185  case S_Protected:
1186 
1187  return _selectable->installedObj().isBroken();
1188 
1189  case S_Update: // will be fixed by updating
1190  case S_AutoUpdate:
1191  case S_Del: // will no longer be relevant after deleting
1192  case S_AutoDel:
1193 
1194  return false;
1195 
1196  case S_NoInst: // should not happen - no installed obj
1197  case S_Install:
1198  case S_AutoInstall:
1199  case S_Taboo:
1200 
1201  yuiError() << "Expected uninstalled zyppObj" << endl;
1202  return false;
1203  }
1204 
1205  yuiError() << "Should never get here" << endl;
1206  return false;
1207 }
1208 
1209 
1210 void
1212 {
1213  if ( ! _editable || ! _pkgObjList->editable() )
1214  return;
1215 
1216  ZyppStatus oldStatus = status();
1217  ZyppStatus newStatus = oldStatus;
1218 
1219  switch ( oldStatus )
1220  {
1221  case S_Install:
1222  newStatus = S_NoInst;
1223  break;
1224 
1225  case S_Protected:
1226  newStatus = selectable()->hasCandidateObj() ?
1227  S_KeepInstalled: S_NoInst;
1228  break;
1229 
1230  case S_Taboo:
1231  newStatus = selectable()->hasInstalledObj() ?
1232  S_KeepInstalled : S_NoInst;
1233  break;
1234 
1235  case S_KeepInstalled:
1236  newStatus = selectable()->hasCandidateObj() ?
1237  S_Update : S_Del;
1238  break;
1239 
1240  case S_Update:
1241  newStatus = S_Del;
1242  break;
1243 
1244  case S_AutoUpdate:
1245  newStatus = S_KeepInstalled;
1246  break;
1247 
1248  case S_Del:
1249  case S_AutoDel:
1250  newStatus = S_KeepInstalled;
1251  break;
1252 
1253  case S_NoInst:
1254  if ( selectable()->hasCandidateObj() )
1255  {
1256  newStatus = S_Install;
1257  }
1258  else
1259  {
1260  yuiWarning() << "No candidate for " << selectable()->theObj()->name() << endl;
1261  newStatus = S_NoInst;
1262  }
1263  break;
1264 
1265  case S_AutoInstall:
1266  // this used to be taboo before, but now ZYpp supports
1267  // saving weak locks (unselected packages)
1268  newStatus = S_NoInst;
1269  break;
1270  }
1271 
1272  if ( oldStatus != newStatus )
1273  {
1274  setStatus( newStatus );
1275 
1276  if ( showLicenseAgreement() )
1277  {
1278  showNotifyTexts( newStatus );
1279  }
1280  else // License not confirmed?
1281  {
1282  // Status is now S_Taboo or S_Del - update status icon
1283  setStatusIcon();
1284  }
1285 
1286  _pkgObjList->sendStatusChanged();
1287  }
1288 }
1289 
1290 
1291 void
1293 {
1294  // just return if no selectable
1295  if ( ! selectable() )
1296  return;
1297 
1298  string text;
1299 
1300  switch ( status )
1301  {
1302  case S_Install:
1303  if ( selectable()->hasCandidateObj() )
1304  text = selectable()->candidateObj()->insnotify();
1305  break;
1306 
1307  case S_NoInst:
1308  case S_Del:
1309  case S_Taboo:
1310  if ( selectable()->hasCandidateObj() )
1311  text = selectable()->candidateObj()->delnotify();
1312  break;
1313 
1314  default: break;
1315  }
1316 
1317  if ( ! text.empty() )
1318  {
1319  yuiDebug() << "Showing notify text" << endl;
1320  YQPkgTextDialog::showText( _pkgObjList, selectable(), text );
1321  }
1322 }
1323 
1324 
1325 bool
1327 {
1328  return showLicenseAgreement( selectable() );
1329 }
1330 
1331 
1332 bool
1334 {
1335  // if we have a subclass with no selectable
1336  // confirming the license should be just always
1337  // true
1338  if ( ! sel )
1339  return true;
1340 
1341  string licenseText;
1342 
1343  switch ( sel->status() )
1344  {
1345  case S_Install:
1346  case S_AutoInstall:
1347  case S_Update:
1348  case S_AutoUpdate:
1349 
1350  if ( sel->hasLicenceConfirmed() )
1351  return true;
1352 
1353  if ( sel->candidateObj() )
1354  licenseText = sel->candidateObj()->licenseToConfirm();
1355  break;
1356 
1357  default: return true;
1358  }
1359 
1360  if ( licenseText.empty() )
1361  return true;
1362 
1363  yuiDebug() << "Showing license agreement for " << sel->name() << endl;
1364 
1365  bool confirmed = YQPkgTextDialog::confirmText( (QWidget *) YDialog::currentDialog()->widgetRep(),
1366  sel, licenseText );
1367 
1368  if ( confirmed )
1369  {
1370  yuiMilestone() << "User confirmed license agreement for " << sel->name() << endl;
1371  sel->setLicenceConfirmed( true );
1372  }
1373  else
1374  {
1375  // The user rejected the license agreement -
1376  // make sure the package gets unselected.
1377 
1378  switch ( sel->status() )
1379  {
1380  case S_Install:
1381  case S_AutoInstall:
1382 
1383  yuiWarning() << "User rejected license agreement for " << sel->name()
1384  << " - setting to TABOO"
1385  << endl;
1386 
1387  sel->setStatus( S_Taboo );
1388  break;
1389 
1390 
1391  case S_Update:
1392  case S_AutoUpdate:
1393 
1394  yuiWarning() << "User rejected license agreement for " << sel->name()
1395  << " - setting to PROTECTED"
1396  << endl;
1397 
1398  sel->setStatus( S_Protected );
1399  // S_Keep wouldn't be good enough: The next solver run might
1400  // set it to S_AutoUpdate again
1401  break;
1402 
1403  default: break;
1404  }
1405  }
1406 
1407  return confirmed;
1408 }
1409 
1410 
1411 QString
1413 {
1414  if ( col == statusCol() )
1415  {
1416  QString tip = _pkgObjList->statusText( status() );
1417 
1418  switch ( status() )
1419  {
1420  case S_AutoDel:
1421  case S_AutoInstall:
1422  case S_AutoUpdate:
1423 
1424  if ( bySelection() )
1425  // Translators: Additional hint what caused an auto-status
1426  tip += "\n" + _( "(by a software selection)" );
1427  else
1428  tip += "\n" + _( "(by dependencies)" );
1429 
1430  break;
1431 
1432  default:
1433  break;
1434  }
1435 
1436  return tip;
1437  }
1438 
1439  if ( col == brokenIconCol() )
1440  {
1441  if ( isBroken() )
1442  // Translators: tool tip for patches / patterns that are installed,
1443  // but whose dependencies are broken (no longer satisfied)
1444  return _( "Dependencies broken" );
1445  }
1446 
1447  // don't use "else if" here, it might be the same colum as another one!
1448 
1449  if ( col == satisfiedIconCol() )
1450  {
1451  if ( isSatisfied() )
1452  // Translators: tool tip for patches / patterns that are not installed,
1453  // but whose dependencies are satisfied
1454  return _( "All dependencies satisfied" );
1455  }
1456 
1457  return QString::null;
1458 }
1459 
1460 
1461 
1462 bool YQPkgObjListItem::operator<( const QTreeWidgetItem & otherListViewItem ) const
1463 {
1464  const YQPkgObjListItem * other = dynamic_cast<const YQPkgObjListItem *> (&otherListViewItem);
1465  int col = treeWidget()->sortColumn();
1466 
1467  if ( other )
1468  {
1469  if ( col == nameCol() )
1470  {
1471  return ( strcasecmp( this->zyppObj()->name().c_str(), other->zyppObj()->name().c_str() ) < 0 );
1472  }
1473  if ( col == summaryCol() )
1474  {
1475  // locale aware sort
1476  return ( strcoll( this->zyppObj()->summary().c_str(), other->zyppObj()->summary().c_str() ) < 0 );
1477  }
1478  if ( col == sizeCol() )
1479  {
1480  // Numeric sort by size
1481 
1482  return ( this->zyppObj()->installSize() < other->zyppObj()->installSize() );
1483  }
1484  else if ( col == statusCol() )
1485  {
1486  // Sorting by status depends on the numeric value of the
1487  // ZyppStatus enum, thus it is important to insert new
1488  // package states there where they make most sense. We want to show
1489  // dangerous or noteworthy states first - e.g., "taboo" which should
1490  // seldeom occur, but when it does, it is important.
1491 
1492  bool b = ( this->status() < other->status() );
1493  if ( !b && this->status() == other->status() )
1494  b = this->zyppObj()->name() < other->zyppObj()->name();
1495  return b;
1496  }
1497  else if ( col == instVersionCol() ||
1498  col == versionCol() )
1499  {
1500  // Sorting by version numbers doesn't make too much sense, so let's
1501  // sort by package relation:
1502  // - Installed newer than candidate (red)
1503  // - Candidate newer than installed (blue) - worthwhile updating
1504  // - Installed
1505  // - Not installed, but candidate available
1506  //
1507  // Within these categories, sort versions by ASCII - OK, it's
1508  // pretty random, but predictable.
1509 
1510  int thisPoints = this->versionPoints();
1511  int otherPoints = other->versionPoints();
1512 
1513  if (thisPoints == otherPoints )
1514  return ( QString (this->zyppObj()->edition().c_str() ) <
1515  QString (other->zyppObj()->edition().c_str() ) );
1516  else
1517  return ( thisPoints < otherPoints );
1518  }
1519  }
1520 
1521  // Fallback: Use parent class method
1522  return QY2ListViewItem::operator<( otherListViewItem );
1523 }
1524 
1525 
1526 int
1528 {
1529  int points = 0;
1530 
1531  if ( installedIsNewer() ) points += 1000;
1532  if ( candidateIsNewer() ) points += 100;
1533  if ( selectable()->hasInstalledObj() ) points += 10;
1534  if ( selectable()->hasCandidateObj() ) points += 1;
1535 
1536  return points;
1537 }
1538 
1539 
1540 void
1542 {
1543  _excluded = excl;
1544 }
1545 
1547  const QRegExp & regexp,
1548  int column )
1549  : _parent( parent )
1550  , _regexp( regexp )
1551  , _column( column )
1552  , _enabled( true )
1553 {
1554  _parent->addExcludeRule( this );
1555 }
1556 
1557 
1558 void
1560 {
1561  _enabled = enable;
1562 
1563 #if VERBOSE_EXCLUDE_RULES
1564  yuiDebug() << ( enable ? "Enabling" : "Disabling" )
1565  << " exclude rule " << _regexp.pattern()
1566  << endl;
1567 #endif
1568 }
1569 
1570 
1571 void
1572 YQPkgObjList::ExcludeRule::setRegexp( const QRegExp & regexp )
1573 {
1574  _regexp = regexp;
1575 }
1576 
1577 
1578 void
1580 {
1581  _column = column;
1582 }
1583 
1584 
1585 bool
1586 YQPkgObjList::ExcludeRule::match( QTreeWidgetItem * item )
1587 {
1588  if ( ! _enabled )
1589  return false;
1590 
1591  QString text = item->text( _column );
1592 
1593  if ( text.isEmpty() )
1594  return false;
1595 
1596  return _regexp.exactMatch( text );
1597 }
1598 
1599 
1600 
1601 
1602 
1603 
1605  : _pkgObjList( parent )
1606 {
1607 }
1608 
1609 
1611 {
1612  clear();
1613 }
1614 
1615 
1616 void YQPkgObjList::ExcludedItems::add( QTreeWidgetItem * item, QTreeWidgetItem * oldParent )
1617 {
1618  _excludeMap.insert( ItemPair( item, oldParent ) );
1619 }
1620 
1621 
1622 void YQPkgObjList::ExcludedItems::remove( QTreeWidgetItem * item )
1623 {
1624  ItemMap::iterator it = _excludeMap.find( item );
1625 
1626  if ( it != _excludeMap.end() )
1627  {
1628  _excludeMap.erase( it );
1629  }
1630 }
1631 
1632 
1634 {
1635  for ( ItemMap::iterator it = _excludeMap.begin();
1636  it != _excludeMap.end();
1637  ++it )
1638  {
1639  delete it->first;
1640  }
1641 
1642  _excludeMap.clear();
1643 }
1644 
1645 
1646 bool YQPkgObjList::ExcludedItems::contains( QTreeWidgetItem * item )
1647 {
1648  return ( _excludeMap.find( item ) != _excludeMap.end() );
1649 }
1650 
1652 {
1653  YQPkgObjListItem * item = dynamic_cast<YQPkgObjListItem *> ( currentItem() );
1654 
1655  if ( item && editable() && item->editable() )
1656  {
1657  updateActions( item );
1658 
1659  if ( ! item->selectable() )
1660  return;
1661 
1662  QMenu * contextMenu =
1663  ! item->selectable()->installedEmpty() ?
1665 
1666  if ( contextMenu )
1667  contextMenu->popup( viewport()->mapToGlobal( pos ) );
1668  }
1669 }
1670 
1671 
1672 QTreeWidgetItem * YQPkgObjList::ExcludedItems::oldParentItem( QTreeWidgetItem * item )
1673 {
1674  ItemMap::iterator it = _excludeMap.find( item );
1675 
1676  if ( it == _excludeMap.end() )
1677  return 0;
1678 
1679  return it->second;
1680 }
1681 
1682 
1683 
bool installedIsNewer() const
Check if the installed version is newer than the candidate.
Definition: YQPkgObjList.h:519
bool candidateIsNewer() const
Check if the candidate is newer than the installed version.
Definition: YQPkgObjList.h:514
bool isExcluded() const
Returns 'true' if this item is excluded.
Definition: YQPkgObjList.h:594
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'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 'enabled' is 'true' 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 setAllItemStatus(ZyppStatus newStatus, bool force=false)
Sets the status of all (toplevel) list items to 'newStatus', if possible.
virtual QMenu * notInstalledContextMenu()
Returns the context menu for items that are installed.
bool showLicenseAgreement()
Display this item'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'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'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.
QRegExp regexp() const
Returns the regexp.
Definition: YQPkgObjList.h:732
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.
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:466
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's time to update displayed package information, e.g., package states.
iterator end()
Returns an iterator that points after the last excluded item.
Definition: YQPkgObjList.h:827
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 'OK'.
bool editable() const
Return whether or not items in this list are generally editable, i.e.
Definition: YQPkgObjList.h:108
void clear()
Clear the excluded items.
ExcludedItems(YQPkgObjList *parent)
Constructor.
virtual void applyChanges()
Apply changes hook.
Definition: YQPkgObjList.h:643
void applyExcludeRules()
Apply all exclude rules of this list to all items, including those that are currently excluded.
bool contains(QTreeWidgetItem *item)
Returns 'true' 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.
int size() const
Returns the number of items.
Definition: YQPkgObjList.h:817
virtual QMenu * addAllInListSubMenu(QMenu *menu)
Add a submenu "All in this list..." to 'menu'.
ZyppSel selectable() const
Returns the original selectable within the package manager backend.
Definition: YQPkgObjList.h:454
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.
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'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 'true' if this selectable's status is set by a selection (rather than by the user or by the d...
bool isEnabled() const
Returns 'true' if this exclude rule is enabled, 'false' otherwise.
Definition: YQPkgObjList.h:722
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,...
virtual ~YQPkgObjList()
Destructor.
void showNotifyTexts(ZyppStatus status)
Display this item'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.
static bool showLicenseAgreement(ZyppSel sel)
Display a selectable'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.
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's status.
ZyppObj zyppObj() const
Returns the original object within the package manager backend.
Definition: YQPkgObjList.h:459
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.