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