1 /*---------------------------------------------------------------------\
3 | __ __ ____ _____ ____ |
4 | \ \ / /_ _/ ___|_ _|___ \ |
5 | \ V / _` \___ \ | | __) | |
6 | | | (_| |___) || | / __/ |
7 | |_|\__,_|____/ |_| |_____| |
11 \----------------------------------------------------------------------/
13 File: YQPkgPatternList.h
15 Author: Stefan Hundhammer <sh@suse.de>
20 #ifndef YQPkgPatternList_h
21 #define YQPkgPatternList_h
23 #include "YQPkgObjList.h"
27 class YQPkgPatternListItem;
28 class YQPkgPatternCategoryItem;
32 * @short Display a list of zypp::Pattern objects.
34 class YQPkgPatternList : public YQPkgObjList
43 * Set 'autoFill' to 'false' if you don't want the list to be filled in the
44 * constructor. In that case, use fillList() (e.g., when connections are
47 * Set 'autoFilter' to 'false' if there is no need to do (expensive)
48 * filtering because the 'filterMatch' signal is not connected anyway.
50 YQPkgPatternList( QWidget * parent, bool autoFill = true, bool autoFilter = true );
55 virtual ~YQPkgPatternList();
58 * Paint method. Reimplemented from @ref QTreeWidget so a different
61 * Reimplemented from QY2ListViewItem.
63 virtual void drawRow ( QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index ) const;
68 * Filter according to the view's rules and current selection.
69 * Emits those signals:
71 * filterMatch() for each pkg that matches the filter
77 * Same as filter(), but only if this widget is currently visible.
79 void filterIfVisible();
83 * Add a pattern to the list. Connect a filter's filterMatch() signal to
84 * this slot. Remember to connect filterStart() to clear() (inherited from
87 void addPatternItem( ZyppSel selectable,
88 ZyppPattern pattern );
91 * Fill the pattern list.
96 * Dispatcher slot for mouse click: cycle status depending on column.
97 * For pattern category items, emulate tree open / close behaviour.
99 * Reimplemented from YQPkgObjList.
101 virtual void pkgObjClicked( int button,
102 QTreeWidgetItem * item,
104 const QPoint & pos );
107 * Select the first selectable list entry that is not a pattern category.
109 * Reimplemented from QY2ListView.
111 virtual void selectSomething();
117 * Returns the currently selected item or 0 if there is none.
119 YQPkgPatternListItem * selection() const;
125 * Emitted when the filtering starts. Use this to clear package lists
126 * etc. prior to adding new entries.
131 * Emitted during filtering for each pkg that matches the filter.
133 void filterMatch( ZyppSel selectable,
137 * Emitted when filtering is finished.
139 void filterFinished();
144 * Returns the category item with the specified name. Creates such a
145 * category if it doesn't exist yet and categoryName is not empty. Returns
146 * 0 if categoryName is empty.
148 YQPkgPatternCategoryItem * category( const QString & categoryName );
155 QMap<QString, YQPkgPatternCategoryItem*> _categories;
160 class YQPkgPatternListItem: public YQPkgObjListItem
165 * Constructor for root items
167 YQPkgPatternListItem( YQPkgPatternList * patternList,
169 ZyppPattern zyppPattern );
172 * Constructor for items that belong to a category
174 YQPkgPatternListItem( YQPkgPatternList * patternList,
175 YQPkgPatternCategoryItem * parentCategory,
177 ZyppPattern zyppPattern );
182 virtual ~YQPkgPatternListItem();
185 * Returns the original object within the package manager backend.
187 ZyppPattern zyppPattern() const { return _zyppPattern; }
192 virtual bool operator< ( const QTreeWidgetItem & other ) const;
196 int statusCol() const { return _patternList->statusCol(); }
197 int summaryCol() const { return _patternList->summaryCol(); }
202 * Initialize things common to all constructors.
207 * Propagate status changes in this list to other lists:
208 * Have the solver transact all patterns.
210 * Reimplemented from YQPkgObjListItem.
212 virtual void applyChanges();
217 YQPkgPatternList * _patternList;
218 ZyppPattern _zyppPattern;
223 class YQPkgPatternCategoryItem: public QY2ListViewItem
230 YQPkgPatternCategoryItem( YQPkgPatternList * patternList,
231 const QString & category );
236 virtual ~YQPkgPatternCategoryItem();
239 * Returns the first pattern. This should be the first in sort order.
241 ZyppPattern firstPattern() const { return _firstPattern; }
244 * Add a pattern to this category. This method sets firstPattern() if necessary.
246 void addPattern( ZyppPattern pattern );
251 virtual bool operator< ( const QTreeWidgetItem & other ) const;
254 * Open or close this subtree
256 * Reimplemented from QListViewItem to force categories open at all times
258 virtual void setExpanded( bool open );
264 * Set a suitable tree open/close icon depending on this category's
267 * The default QListView plus/minus icons would require treeStepSize() to
268 * be set >0 and rootItemDecorated( true ), but that would look very ugly
269 * in this context, so the pattern categories paint their own tree open /
272 void setTreeIcon( void );
277 YQPkgPatternList * _patternList;
278 ZyppPattern _firstPattern;
282 #endif // ifndef YQPkgPatternList_h