libyui-qt-pkg  2.45.6
 All Classes Functions Variables Enumerations
YQPkgObjList.h
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.h
35 
36  Author: Stefan Hundhammer <sh@suse.de>
37 
38 /-*/
39 
40 
41 #ifndef YQPkgObjList_h
42 #define YQPkgObjList_h
43 
44 #include <QPixmap>
45 #include <QRegExp>
46 #include <QMenu>
47 #include <QEvent>
48 #include <map>
49 #include <list>
50 #include <QY2ListView.h>
51 #include "YQZypp.h"
52 #include <zypp/Edition.h>
53 #include <FSize.h>
54 
55 #include "YQZyppSolverDialogPluginStub.h"
56 
57 class YQPkgObjListItem;
58 class QAction;
59 class QMenu;
60 using std::string;
61 using std::list;
62 
63 
64 /**
65  * @short Abstract base class to display a list of zypp::ResObjects.
66  * Handles most generic stuff like setting status etc.
67  **/
68 class YQPkgObjList : public QY2ListView
69 {
70  Q_OBJECT
71 
72 protected:
73  /**
74  * Constructor. Does not add any QListView columns!
75  **/
76  YQPkgObjList( QWidget * parent );
77 
78  /**
79  * Destructor
80  **/
81  virtual ~YQPkgObjList();
82 
83  // avoiding warning about virtuals
84  using QTreeWidget::currentItemChanged;
85 
86 public:
87 
88  // make it public
89  QTreeWidgetItem * itemFromIndex ( const QModelIndex & index ) const
90  { return QY2ListView::itemFromIndex(index); }
91 
92  // Column numbers
93 
94  int iconCol() const { return _iconCol; }
95  int statusCol() const { return _statusCol; }
96  int nameCol() const { return _nameCol; }
97  int summaryCol() const { return _summaryCol; }
98  int sizeCol() const { return _sizeCol; }
99  int versionCol() const { return _versionCol; }
100  int instVersionCol() const { return _instVersionCol; }
101  int brokenIconCol() const { return _brokenIconCol; }
102  int satisfiedIconCol() const { return _satisfiedIconCol; }
103 
104  /**
105  * Return whether or not items in this list are generally editable,
106  * i.e. the user can change their status. Note that individual items can be
107  * set to non-editable even if the list is generally editable.
108  * Lists are editable by default.
109  **/
110  bool editable() const { return _editable; }
111 
112  /**
113  * Set the list's editable status.
114  **/
115  void setEditable( bool editable = true ) { _editable = editable; }
116 
117  /**
118  * Sets the currently selected item's status.
119  * Automatically selects the next item if 'selectNextItem' is 'true'.
120  **/
121  void setCurrentStatus( ZyppStatus newStatus,
122  bool selectNextItem = false,
123  bool ifNewerOnly = false );
124 
125 
126  /**
127  * Show solver information about the current selected item
128  **/
129  void showSolverInfo();
130 
131  /**
132  * Sets the status of all (toplevel) list items to 'newStatus', if possible.
133  * Only one single statusChanged() signal is emitted.
134  *
135  * 'force' overrides sensible defaults like setting only zypp::ResObjects to
136  * 'update' that really come with a newer version.
137  **/
138  void setAllItemStatus( ZyppStatus newStatus, bool force = false );
139 
140  /**
141  * Add a submenu "All in this list..." to 'menu'.
142  * Returns the newly created submenu.
143  **/
144  virtual QMenu * addAllInListSubMenu( QMenu * menu );
145 
146  /**
147  * Returns the suitable icon for a zypp::ResObject status - the regular
148  * icon if 'enabled' is 'true' or the insensitive icon if 'enabled' is
149  * 'false. 'bySelection' is relevant only for auto-states: This uses the
150  * icon for 'auto-by-selection" rather than the default auto-icon.
151  **/
152  virtual QPixmap statusIcon( ZyppStatus status,
153  bool enabled = true,
154  bool bySelection = false );
155 
156  /**
157  * Returns a short (one line) descriptive text for a zypp::ResObject status.
158  **/
159  virtual QString statusText( ZyppStatus status ) const;
160 
161 
162  class ExcludeRule;
163 
164  /**
165  * Add an exclude rule to this list.
166  **/
168 
169  /**
170  * Apply all exclude rules of this list to all items,
171  * including those that are currently excluded.
172  **/
173  void applyExcludeRules();
174 
175  /**
176  * Apply all exclude rules of this list to one item.
177  **/
178  void applyExcludeRules( QTreeWidgetItem * );
179 
180  /**
181  * Exclude or include an item, i.e. remove it from the visible items
182  * and add it to the internal exclude list or vice versa.
183  **/
184  void exclude( YQPkgObjListItem * item, bool exclude );
185 
186 
187 public slots:
188 
189  /**
190  * Add a zypp::ResObject to the list. Connect a filter's filterMatch()
191  * signal to this slot. Remember to connect filterStart() to clear()
192  * (inherited from QListView).
193  *
194  * 'zyppObj' has to be one of the objects of 'selectable'. If it is 0,
195  * selectable->theObject() will be used.
196  *
197  * Intentionally NOT named addItem() so the calling class cannot confuse
198  * this method with overlaid methods of the same name that were simply
199  * forgotten to implement!
200  **/
201  void addPkgObjItem( ZyppSel selectable,
202  ZyppObj zyppObj = 0 );
203 
204  /**
205  * Add a purely passive list item that has a name and optional summary and
206  * size.
207  **/
208  void addPassiveItem( const QString & name,
209  const QString & summary = QString::null,
210  FSize size = -1 );
211 
212  /**
213  * Dispatcher slot for mouse click: cycle status depending on column.
214  **/
215  virtual void pkgObjClicked( int button,
216  QTreeWidgetItem * item,
217  int col,
218  const QPoint & pos );
219 
220  /**
221  * Reimplemented from QY2ListView:
222  * Emit currentItemChanged() signal after clearing the list.
223  **/
224  virtual void clear();
225 
226  /**
227  * Update the internal actions for the currently selected item ( if any ).
228  * This only calls updateActions( YQPkgObjListItem * ) with the currently
229  * selected item as argument, so there is normally no need to reimplement
230  * this method, too, if the other one is reimplemented.
231  **/
232  virtual void updateActions( YQPkgObjListItem * item = 0);
233 
234  /**
235  * Emit an updatePackages() signal.
236  **/
238 
239  /**
240  * Select the next item, i.e. move the selection one item further down the
241  * list.
242  **/
243  void selectNextItem();
244 
245  /**
246  * Emit a statusChanged() signal for the specified zypp::ResObject.
247  **/
248  void sendStatusChanged() { emit statusChanged(); }
249 
250  /**
251  * Display a one-line message in the list.
252  **/
253  virtual void message( const QString & text );
254 
255  /**
256  * Write statistics about excluded items to the log, if there are any.
257  **/
258  void logExcludeStatistics();
259 
260 
261  // Direct access to some states for menu actions
262 
263  void setCurrentInstall() { setCurrentStatus( S_Install ); }
264  void setCurrentDontInstall() { setCurrentStatus( S_NoInst ); }
265  void setCurrentKeepInstalled() { setCurrentStatus( S_KeepInstalled ); }
266  void setCurrentDelete() { setCurrentStatus( S_Del ); }
267  void setCurrentUpdate() { setCurrentStatus( S_Update, false, true ); }
268  void setCurrentUpdateForce() { setCurrentStatus( S_Update ); }
269  void setCurrentTaboo() { setCurrentStatus( S_Taboo ); }
270  void setCurrentProtected() { setCurrentStatus( S_Protected ); }
271 
272  void showCurrentSolverInfo() { showSolverInfo (); }
273 
274  void setListInstall() { setAllItemStatus( S_Install ); }
275  void setListDontInstall() { setAllItemStatus( S_NoInst ); }
276  void setListKeepInstalled() { setAllItemStatus( S_KeepInstalled ); }
277  void setListDelete() { setAllItemStatus( S_Del ); }
278  void setListUpdate() { setAllItemStatus( S_Update ); }
279  void setListUpdateForce() { setAllItemStatus( S_Update, true ); }
280  void setListTaboo() { setAllItemStatus( S_Taboo ); }
281  void setListProtected() { setAllItemStatus( S_Protected ); }
282 
283 
284 protected slots:
285 
286  /**
287  * Dispatcher slot for selection change - internal only.
288  **/
289  virtual void currentItemChangedInternal( QTreeWidgetItem * item );
290 
291  /**
292  * slot that shows context menu when requested
293  **/
294  void slotCustomContextMenu(const QPoint& pos);
295 
296 
297 signals:
298 
299 
300  /**
301  * Emitted when a zypp::ui::Selectable is selected.
302  * May be called with a null poiner if no zypp::ResObject is selected.
303  **/
304  void currentItemChanged( ZyppSel selectable );
305 
306  /**
307  * Emitted when the status of a zypp::ResObject is changed.
308  **/
309  void statusChanged();
310 
311  /**
312  * Emitted when it's time to update displayed package information,
313  * e.g., package states.
314  **/
315  void updatePackages();
316 
317 
318 protected:
319 
320  /**
321  * Event handler for keyboard input.
322  * Only very special keys are processed here.
323  *
324  * Reimplemented from QListView / QWidget.
325  **/
326  virtual void keyPressEvent( QKeyEvent * ev );
327 
328  /**
329  * Returns the context menu for items that are not installed.
330  * Creates the menu upon the first call.
331  **/
332  virtual QMenu * installedContextMenu();
333 
334  /**
335  * Returns the context menu for items that are installed.
336  * Creates the menu upon the first call.
337  **/
338  virtual QMenu * notInstalledContextMenu();
339 
340  /**
341  * Create the context menu for items that are not installed.
342  **/
343  virtual void createNotInstalledContextMenu();
344 
345  /**
346  * Create the context menu for installed items.
347  **/
348  virtual void createInstalledContextMenu();
349 
350  /**
351  * Create the actions for the context menus.
352  * Note: This is intentionally not virtual!
353  **/
354  void createActions();
355 
356  /**
357  * Create an action based on a zypp::ResObject status - automatically
358  * retrieve the corresponding status icons (both sensitive and insensitive)
359  * and text. 'key' is only a descriptive text, no true accelerator.
360  **/
361  QAction * createAction( ZyppStatus status,
362  const QString & key = QString::null,
363  bool enabled = false );
364 
365  /**
366  * Low-level: Create an action.
367  * 'key' is only a descriptive text, no true accelerator.
368  **/
369  QAction * createAction( const QString & text,
370  const QPixmap & icon = QPixmap(),
371  const QPixmap & insensitiveIcon = QPixmap(),
372  const QString & key = QString::null,
373  bool enabled = false );
374 
375  class ExcludedItems;
376 
377  // Data members
378 
379  int _iconCol;
380  int _statusCol;
381  int _nameCol;
382  int _summaryCol;
383  int _sizeCol;
384  int _versionCol;
385  int _instVersionCol;
386  int _brokenIconCol;
387  int _satisfiedIconCol;
388  bool _editable;
389  bool _debug;
390 
391  typedef list<ExcludeRule *> ExcludeRuleList;
392 
393  ExcludeRuleList _excludeRules;
394  ExcludedItems * _excludedItems;
395 
396  QMenu * _installedContextMenu;
397  QMenu * _notInstalledContextMenu;
398 
399 
400 public:
401 
402  QAction * actionSetCurrentInstall;
403  QAction * actionSetCurrentDontInstall;
404  QAction * actionSetCurrentKeepInstalled;
405  QAction * actionSetCurrentDelete;
406  QAction * actionSetCurrentUpdate;
407  QAction * actionSetCurrentUpdateForce;
408  QAction * actionSetCurrentTaboo;
409  QAction * actionSetCurrentProtected;
410  QAction * actionShowCurrentSolverInfo;
411 
412  QAction * actionSetListInstall;
413  QAction * actionSetListDontInstall;
414  QAction * actionSetListKeepInstalled;
415  QAction * actionSetListDelete;
416  QAction * actionSetListUpdate;
417  QAction * actionSetListUpdateForce;
418  QAction * actionSetListTaboo;
419  QAction * actionSetListProtected;
420 
422 };
423 
424 
425 
426 class YQPkgObjListItem: public QY2ListViewItem
427 {
428 public:
429 
430  /**
431  * Constructor for root items: Creates a YQPkgObjList item that corresponds
432  * to the ZYPP selectable that 'selectable' refers to. 'zyppObj' has to be
433  * one object of 'selectable'. If it is 0, selectable->theObject() will be
434  * used.
435  **/
436  YQPkgObjListItem( YQPkgObjList * pkgObjList,
437  ZyppSel selectable,
438  ZyppObj zyppObj = 0 );
439 
440  /**
441  * Constructor for root items: Creates a YQPkgObjList item that does not
442  * correspond to a ZYPP selectable. You need to overload _AND RUN_ init
443  * yourself then.
444  **/
445  YQPkgObjListItem( YQPkgObjList * pkgObjList );
446 
447 protected:
448  /**
449  * Constructor for non-root items.
450  **/
451  YQPkgObjListItem( YQPkgObjList * pkgObjList,
452  QY2ListViewItem * parent,
453  ZyppSel selectable,
454  ZyppObj zyppObj = 0 );
455 
456 public:
457 
458  /**
459  * Destructor
460  **/
461  virtual ~YQPkgObjListItem();
462 
463  /**
464  * Returns the original selectable within the package manager backend.
465  **/
466  ZyppSel selectable() const { return _selectable; }
467 
468  /**
469  * Returns the original object within the package manager backend.
470  **/
471  ZyppObj zyppObj() const { return _zyppObj; }
472 
473  /**
474  * Return whether or not this items is editable, i.e. the user can change
475  * its status. This requires the corresponding list to be editable, too.
476  * Items are editable by default.
477  **/
478  bool editable() const { return _editable; }
479 
480  /**
481  * Set this item's editable status.
482  **/
483  void setEditable( bool editable = true ) { _editable = editable; }
484 
485  /**
486  * Returns the (binary RPM) package status
487  **/
488  virtual ZyppStatus status() const;
489 
490  /**
491  * Returns 'true' if this selectable's status is set by a selection
492  * (rather than by the user or by the dependency solver).
493  **/
494  virtual bool bySelection() const;
495 
496  /**
497  * Set the (binary RPM) package status.
498  *
499  * If 'sendSignals' is 'true' (default), the parent list will be requested
500  * to send update signals. List operations might want to use this for
501  * optimizations to send the signals only once after all changes are done.
502  **/
503  virtual void setStatus( ZyppStatus newStatus, bool sendSignals = true );
504 
505 
506  /**
507  * Set a status icon according to the package's status.
508  **/
509  virtual void setStatusIcon();
510 
511  /**
512  * Update this item's status.
513  * Triggered by QY2ListView::updateAllItemStates().
514  * Overwritten from QY2ListViewItem.
515  **/
516  virtual void updateStatus();
517 
518  /**
519  * Cycle the package status to the next valid value.
520  **/
521  virtual void cycleStatus();
522 
523  /**
524  * Check if the candidate is newer than the installed version.
525  **/
526  bool candidateIsNewer() const { return _candidateIsNewer; }
527 
528  /**
529  * Check if the installed version is newer than the candidate.
530  **/
531  bool installedIsNewer() const { return _installedIsNewer; }
532 
533  /**
534  * Check if this item is satisfied, even though it is not installed.
535  * This is useful for package collections, e.g., patterns and patches:
536  * 'true' is returned if all requirements are fulfilled, but the object
537  * itself is not installed.
538  **/
539  bool isSatisfied() const;
540 
541  /**
542  * Check if this item is "broken": If it is installed, but any of its
543  * dependencies are no longer satisfied.
544  * This is useful for package collections, e.g., patterns and patches.
545  **/
546  bool isBroken() const;
547 
548  /**
549  * Display this item's notify text (if there is any) that corresponds to
550  * the specified status (S_Install, S_Del) in a pop-up window.
551  **/
552  void showNotifyTexts( ZyppStatus status );
553 
554  /**
555  * Display a selectable's license agreement (if there is any) that
556  * corresponds to its current status (S_Install, S_Update) in a pop-up
557  * window.
558  *
559  * Returns 'true' if the user agreed to that license , 'false' otherwise.
560  * The item's status may have changed to S_Taboo, S_Proteced or S_Del if
561  * the user disagreed with the license.
562  **/
563  static bool showLicenseAgreement( ZyppSel sel );
564 
565  /**
566  * Display this item's license agreement (if there is any) that corresponds
567  * to its current status (S_Install, S_Update) in a pop-up window.
568  **/
569  bool showLicenseAgreement();
570 
571  /**
572  * sorting function
573  */
574  virtual bool operator< ( const QTreeWidgetItem & other ) const;
575 
576  /**
577  * Calculate a numerical value to compare versions, based on version
578  * relations:
579  *
580  * - Installed newer than candidate (red)
581  * - Candidate newer than installed (blue) - worthwhile updating
582  * - Installed
583  * - Not installed, but candidate available
584  **/
585  int versionPoints() const;
586 
587  /**
588  * Update this item's data completely.
589  * Triggered by QY2ListView::updateAllItemData().
590  *
591  * Reimplemented from QY2ListViewItem.
592  **/
593  virtual void updateData();
594 
595  /**
596  * Returns a tool tip text for a specific column of this item.
597  * 'column' is -1 if the mouse pointer is in the tree indentation area.
598  *
599  * Reimplemented from QY2ListViewItem.
600  **/
601  virtual QString toolTip( int column );
602 
603  /**
604  * Returns 'true' if this item is excluded.
605  **/
606  bool isExcluded() const { return _excluded; }
607 
608  /**
609  * Set this item's exclude flag.
610  * Note that this is just a marker. It is the caller's responsibility
611  * to add or remove it from exclude lists etc.
612  **/
613  void setExcluded( bool exclude = true );
614 
615 
616  // Handle Debug isBroken and isSatisfied flags
617 
618  bool debugIsBroken() const { return _debugIsBroken; }
619  bool debugIsSatisfied() const { return _debugIsSatisfied; }
620  void setDebugIsBroken ( bool val = true ) { _debugIsBroken = val; }
621  void setDebugIsSatisfied( bool val = true ) { _debugIsSatisfied = val; }
622  void toggleDebugIsBroken() { _debugIsBroken = ! _debugIsBroken; }
623  void toggleDebugIsSatisfied() { _debugIsSatisfied = ! _debugIsSatisfied; }
624 
625 
626  // Columns
627 
628  int statusCol() const { return _pkgObjList->statusCol(); }
629  int nameCol() const { return _pkgObjList->nameCol(); }
630  int summaryCol() const { return _pkgObjList->summaryCol(); }
631  int sizeCol() const { return _pkgObjList->sizeCol(); }
632  int versionCol() const { return _pkgObjList->versionCol(); }
633  int instVersionCol() const { return _pkgObjList->instVersionCol(); }
634  int brokenIconCol() const { return _pkgObjList->brokenIconCol(); }
635  int satisfiedIconCol() const { return _pkgObjList->satisfiedIconCol(); }
636 
637 
638 protected:
639 
640  /**
641  * Initialize internal data and set fields accordingly. Only works for items
642  * presenting selectables - see YQPkgObjListItem
643  **/
644  void init();
645 
646  /**
647  * Apply changes hook. This is called each time the user changes the status
648  * of a list item manually (if the old status is different from the new
649  * one). Insert code to propagate changes to other objects here, for
650  * example to trigger a "small" solver run (Resolver::transactObjKind()
651  * etc.).
652  *
653  * This default implementation does nothing.
654  **/
655  virtual void applyChanges() {}
656 
657  /**
658  * Do a "small" solver run for all "resolvable collections", i.e., for
659  * selections, patterns, languages, patches.
660  **/
662 
663  /**
664  * Set a column text via STL string.
665  * ( QListViewItem::setText() expects a QString! )
666  **/
667  void setText( int column, const string text );
668 
669  public:
670  /**
671  * Re-declare ordinary setText() method so the compiler doesn't get
672  * confused which one to use.
673  **/
674  void setText( int column, const QString & text )
675  { QTreeWidgetItem::setText( column, text ); }
676  protected:
677  /**
678  * Set a column text via Edition.
679  **/
680  void setText( int column, const zypp::Edition & edition );
681 
682 
683  //
684  // Data members
685  //
686 
687  YQPkgObjList * _pkgObjList;
688  ZyppSel _selectable;
689  ZyppObj _zyppObj;
690  bool _editable:1;
691  bool _candidateIsNewer:1;
692  bool _installedIsNewer:1;
693 
694  bool _debugIsBroken:1;
695  bool _debugIsSatisfied:1;
696  bool _excluded:1;
697 };
698 
699 
700 
702 {
703 public:
704 
705  /**
706  * Constructor: Creates a new exclude rule with a regular expression
707  * to check against the text of the specified column of each list
708  * entry.
709  *
710  * The parent YQPkgObjList will assume ownership of this exclude rule
711  * and destroy it when the parent is destroyed.
712  **/
713  ExcludeRule( YQPkgObjList * parent,
714  const QRegExp & regexp,
715  int column = 0 );
716 
717 
718  // Intentionally omitting virtual destructor:
719  // No allocated objects, no other virtual methods,
720  // no need to have a vtable for each instance of this class.
721  //
722  // virtual ~ExcludeRule();
723 
724  /**
725  * Enable or disable this exclude rule.
726  * New exclude rules are enabled by default.
727  **/
728  void enable( bool enable = true );
729 
730  /**
731  * Returns 'true' if this exclude rule is enabled,
732  * 'false' otherwise.
733  **/
734  bool isEnabled() const { return _enabled; }
735 
736  /**
737  * Change the regular expression after creation.
738  **/
739  void setRegexp( const QRegExp & regexp );
740 
741  /**
742  * Returns the regexp.
743  **/
744  QRegExp regexp() const { return _regexp; };
745 
746  /**
747  * Change the column number to check against after creation.
748  **/
749  void setColumn( int column = 0 );
750 
751  /**
752  * Returns the column number.
753  **/
754  int column() const { return _column; }
755 
756  /**
757  * Returns this exclude rule's parent YQPkgObjList.
758  **/
759  YQPkgObjList * parent() const { return _parent; }
760 
761  /**
762  * Check a list item against this exclude rule.
763  * Returns 'true' if the item matches this exclude rule,
764  * i.e. if it should be excluded.
765  **/
766  bool match( QTreeWidgetItem * item );
767 
768 private:
769 
770  YQPkgObjList * _parent;
771  QRegExp _regexp;
772  int _column;
773  bool _enabled;
774 };
775 
776 
778 {
779 public:
780 
781  typedef std::map <QTreeWidgetItem *, QTreeWidgetItem *> ItemMap;
782  typedef std::pair<QTreeWidgetItem *, QTreeWidgetItem *> ItemPair;
783  typedef ItemMap::iterator iterator;
784 
785  /**
786  * Constructor
787  **/
788  ExcludedItems( YQPkgObjList * parent );
789 
790  /**
791  * Destructor
792  **/
793  virtual ~ExcludedItems();
794 
795  /**
796  * Add a list item to the excluded items and transfer ownership to this
797  * class.
798  *
799  * oldParent is the previous parent item of this item
800  * or 0 if it was a root item.
801  **/
802  void add( QTreeWidgetItem * item, QTreeWidgetItem * oldParent );
803 
804  /**
805  * Remove a list item from the excluded items and transfer ownership back
806  * to the caller.
807  **/
808  void remove( QTreeWidgetItem * item );
809 
810  /**
811  * Clear the excluded items. Delete all items still excluded.
812  **/
813  void clear();
814 
815  /**
816  * Returns 'true' if the specified item is in the excluded items.
817  **/
818  bool contains( QTreeWidgetItem * item );
819 
820  /**
821  * Returns the old parent of this item so it can be reparented
822  * or 0 if it was a root item.
823  **/
824  QTreeWidgetItem * oldParentItem( QTreeWidgetItem * item );
825 
826  /**
827  * Returns the number of items
828  **/
829  int size() const { return (int) _excludeMap.size(); }
830 
831  /**
832  * Returns an iterator that points to the first excluded item.
833  **/
834  iterator begin() { return _excludeMap.begin(); }
835 
836  /**
837  * Returns an iterator that points after the last excluded item.
838  **/
839  iterator end() { return _excludeMap.end(); }
840 
841 private:
842  void updateActions();
843 
844  ItemMap _excludeMap;
845  YQPkgObjList * _pkgObjList;
846 };
847 
848 
849 #endif // ifndef YQPkgObjList_h
ZyppSel selectable() const
Returns the original selectable within the package manager backend.
Definition: YQPkgObjList.h:466
int size() const
Returns the number of items.
Definition: YQPkgObjList.h:829
ZyppObj zyppObj() const
Returns the original object within the package manager backend.
Definition: YQPkgObjList.h:471
Abstract base class to display a list of zypp::ResObjects.
Definition: YQPkgObjList.h:68
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 ...
void setEditable(bool editable=true)
Set this item's editable status.
Definition: YQPkgObjList.h:483
void addExcludeRule(YQPkgObjList::ExcludeRule *rule)
Add an exclude rule to this list.
virtual void createInstalledContextMenu()
Create the context menu for installed items.
void setAllItemStatus(ZyppStatus newStatus, bool force=false)
Sets the status of all (toplevel) list items to 'newStatus', if possible.
bool candidateIsNewer() const
Check if the candidate is newer than the installed version.
Definition: YQPkgObjList.h:526
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:834
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.
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.
QAction * createAction(ZyppStatus status, const QString &key=QString::null, bool enabled=false)
Create an action based on a zypp::ResObject status - automatically retrieve the corresponding status ...
virtual void pkgObjClicked(int button, QTreeWidgetItem *item, int col, const QPoint &pos)
Dispatcher slot for mouse click: cycle status depending on column.
void enable(bool enable=true)
Enable or disable this exclude rule.
void logExcludeStatistics()
Write statistics about excluded items to the log, if there are any.
virtual void currentItemChangedInternal(QTreeWidgetItem *item)
Dispatcher slot for selection change - internal only.
virtual void updateActions(YQPkgObjListItem *item=0)
Update the internal actions for the currently selected item ( if any ).
void showSolverInfo()
Show solver information about the current selected item.
void sendStatusChanged()
Emit a statusChanged() signal for the specified zypp::ResObject.
Definition: YQPkgObjList.h:248
void exclude(YQPkgObjListItem *item, bool exclude)
Exclude or include an item, i.e.
bool editable() const
Return whether or not items in this list are generally editable, i.e.
Definition: YQPkgObjList.h:110
int versionPoints() const
Calculate a numerical value to compare versions, based on version relations:
void selectNextItem()
Select the next item, i.e.
bool isExcluded() const
Returns 'true' if this item is excluded.
Definition: YQPkgObjList.h:606
void updatePackages()
Emitted when it's time to update displayed package information, e.g., package states.
void setText(int column, const QString &text)
Re-declare ordinary setText() method so the compiler doesn't get confused which one to use...
Definition: YQPkgObjList.h:674
void setEditable(bool editable=true)
Set the list's editable status.
Definition: YQPkgObjList.h:115
virtual bool operator<(const QTreeWidgetItem &other) const
sorting function
iterator end()
Returns an iterator that points after the last excluded item.
Definition: YQPkgObjList.h:839
bool match(QTreeWidgetItem *item)
Check a list item against this exclude rule.
void clear()
Clear the excluded items.
ExcludedItems(YQPkgObjList *parent)
Constructor.
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...
virtual void applyChanges()
Apply changes hook.
Definition: YQPkgObjList.h:655
QRegExp regexp() const
Returns the regexp.
Definition: YQPkgObjList.h:744
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...
virtual QMenu * addAllInListSubMenu(QMenu *menu)
Add a submenu "All in this list..." to 'menu'.
bool isBroken() const
Check if this item is "broken": If it is installed, but any of its dependencies are no longer satisfi...
virtual QString statusText(ZyppStatus status) const
Returns a short (one line) descriptive text for a zypp::ResObject status.
void currentItemChanged(ZyppSel selectable)
Emitted when a zypp::ui::Selectable is selected.
void slotCustomContextMenu(const QPoint &pos)
slot that shows context menu when requested
void setCurrentStatus(ZyppStatus newStatus, bool selectNextItem=false, bool ifNewerOnly=false)
Sets the currently selected item's status.
void sendUpdatePackages()
Emit an updatePackages() signal.
Definition: YQPkgObjList.h:237
YQPkgObjList * parent() const
Returns this exclude rule's parent YQPkgObjList.
Definition: YQPkgObjList.h:759
virtual void createNotInstalledContextMenu()
Create the context menu for items that are not installed.
bool isSatisfied() const
Check if this item is satisfied, even though it is not installed.
virtual QMenu * installedContextMenu()
Returns the context menu for items that are not installed.
bool installedIsNewer() const
Check if the installed version is newer than the candidate.
Definition: YQPkgObjList.h:531
int column() const
Returns the column number.
Definition: YQPkgObjList.h:754
virtual QString toolTip(int column)
Returns a tool tip text for a specific column of this item.
void solveResolvableCollections()
Do a "small" solver run for all "resolvable collections", i.e., for selections, patterns, languages, patches.
virtual ~YQPkgObjList()
Destructor.
void showNotifyTexts(ZyppStatus status)
Display this item's notify text (if there is any) that corresponds to the specified status (S_Install...
virtual void keyPressEvent(QKeyEvent *ev)
Event handler for keyboard input.
YQPkgObjList(QWidget *parent)
Constructor.
Definition: YQPkgObjList.cc:71
virtual ~ExcludedItems()
Destructor.
virtual ZyppStatus status() const
Returns the (binary RPM) package status.
bool isEnabled() const
Returns 'true' if this exclude rule is enabled, 'false' otherwise.
Definition: YQPkgObjList.h:734
void add(QTreeWidgetItem *item, QTreeWidgetItem *oldParent)
Add a list item to the excluded items and transfer ownership to this class.
virtual ~YQPkgObjListItem()
Destructor.
virtual void setStatusIcon()
Set a status icon according to the package's status.
virtual void cycleStatus()
Cycle the package status to the next valid value.
void init()
Initialize internal data and set fields accordingly.
bool editable() const
Return whether or not this items is editable, i.e.
Definition: YQPkgObjList.h:478