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();
61 * Filter according to the view's rules and current selection.
62 * Emits those signals:
64 * filterMatch() for each pkg that matches the filter
70 * Same as filter(), but only if this widget is currently visible.
72 void filterIfVisible();
76 * Add a pattern to the list. Connect a filter's filterMatch() signal to
77 * this slot. Remember to connect filterStart() to clear() (inherited from
80 void addPatternItem( ZyppSel selectable,
81 ZyppPattern pattern );
84 * Fill the pattern list.
89 * Dispatcher slot for mouse click: cycle status depending on column.
90 * For pattern category items, emulate tree open / close behaviour.
92 * Reimplemented from YQPkgObjList.
94 virtual void pkgObjClicked( int button,
95 QTreeWidgetItem * item,
100 * Select the first selectable list entry that is not a pattern category.
102 * Reimplemented from QY2ListView.
104 virtual void selectSomething();
110 * Returns the currently selected item or 0 if there is none.
112 YQPkgPatternListItem * selection() const;
118 * Emitted when the filtering starts. Use this to clear package lists
119 * etc. prior to adding new entries.
124 * Emitted during filtering for each pkg that matches the filter.
126 void filterMatch( ZyppSel selectable,
130 * Emitted when filtering is finished.
132 void filterFinished();
138 * Returns the category item with the specified name. Creates such a
139 * category if it doesn't exist yet and categoryName is not empty. Returns
140 * 0 if categoryName is empty.
142 YQPkgPatternCategoryItem * category( const QString & categoryName );
149 Q3Dict<YQPkgPatternCategoryItem> _categories;
154 class YQPkgPatternListItem: public YQPkgObjListItem
159 * Constructor for root items
161 YQPkgPatternListItem( YQPkgPatternList * patternList,
163 ZyppPattern zyppPattern );
166 * Constructor for items that belong to a category
168 YQPkgPatternListItem( YQPkgPatternList * patternList,
169 YQPkgPatternCategoryItem * parentCategory,
171 ZyppPattern zyppPattern );
176 virtual ~YQPkgPatternListItem();
179 * Returns the original object within the package manager backend.
181 ZyppPattern zyppPattern() const { return _zyppPattern; }
184 * Comparison function used for sorting the list.
190 * Reimplemented from QListViewItem:
191 * Sort by zypp::Pattern::order() only.
193 virtual int compare( QTreeWidgetItem * other,
195 bool ascending ) const;
199 int statusCol() const { return _patternList->statusCol(); }
200 int summaryCol() const { return _patternList->summaryCol(); }
206 * Initialize things common to all constructors.
211 * Propagate status changes in this list to other lists:
212 * Have the solver transact all patterns.
214 * Reimplemented from YQPkgObjListItem.
216 virtual void applyChanges();
221 YQPkgPatternList * _patternList;
222 ZyppPattern _zyppPattern;
227 class YQPkgPatternCategoryItem: public QY2ListViewItem
234 YQPkgPatternCategoryItem( YQPkgPatternList * patternList,
235 const QString & category );
240 virtual ~YQPkgPatternCategoryItem();
243 * Returns the first pattern. This should be the first in sort order.
245 ZyppPattern firstPattern() const { return _firstPattern; }
248 * Add a pattern to this category. This method sets firstPattern() if necessary.
250 void addPattern( ZyppPattern pattern );
253 * Comparison function used for sorting the list.
259 * Reimplemented from QListViewItem:
260 * Sort by zypp::Pattern::order() only.
262 virtual int compare( QTreeWidgetItem * other,
264 bool ascending ) const;
267 * Open or close this subtree
269 * Reimplemented from QListViewItem to force categories open at all times
271 virtual void setOpen( bool open );
277 * Set a suitable tree open/close icon depending on this category's
280 * The default QListView plus/minus icons would require treeStepSize() to
281 * be set >0 and rootItemDecorated( true ), but that would look very ugly
282 * in this context, so the pattern categories paint their own tree open /
285 void setTreeIcon( void );
288 * Paint method. Reimplemented from @ref QListViewItem so a different
291 * Reimplemented from QY2ListViewItem.
293 virtual void paintCell( QPainter * painter,
294 const QColorGroup & colorGroup,
303 YQPkgPatternList * _patternList;
304 ZyppPattern _firstPattern;
308 #endif // ifndef YQPkgPatternList_h