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