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 Q3Dict<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; }
190 * Comparison function used for sorting the list.
196 * Reimplemented from QListViewItem:
197 * Sort by zypp::Pattern::order() only.
199 virtual int compare( QTreeWidgetItem * other,
201 bool ascending ) const;
205 int statusCol() const { return _patternList->statusCol(); }
206 int summaryCol() const { return _patternList->summaryCol(); }
211 * Initialize things common to all constructors.
216 * Propagate status changes in this list to other lists:
217 * Have the solver transact all patterns.
219 * Reimplemented from YQPkgObjListItem.
221 virtual void applyChanges();
226 YQPkgPatternList * _patternList;
227 ZyppPattern _zyppPattern;
232 class YQPkgPatternCategoryItem: public QY2ListViewItem
239 YQPkgPatternCategoryItem( YQPkgPatternList * patternList,
240 const QString & category );
245 virtual ~YQPkgPatternCategoryItem();
248 * Returns the first pattern. This should be the first in sort order.
250 ZyppPattern firstPattern() const { return _firstPattern; }
253 * Add a pattern to this category. This method sets firstPattern() if necessary.
255 void addPattern( ZyppPattern pattern );
258 * Comparison function used for sorting the list.
264 * Reimplemented from QListViewItem:
265 * Sort by zypp::Pattern::order() only.
267 virtual int compare( QTreeWidgetItem * other,
269 bool ascending ) const;
272 * Open or close this subtree
274 * Reimplemented from QListViewItem to force categories open at all times
276 virtual void setOpen( bool open );
282 * Set a suitable tree open/close icon depending on this category's
285 * The default QListView plus/minus icons would require treeStepSize() to
286 * be set >0 and rootItemDecorated( true ), but that would look very ugly
287 * in this context, so the pattern categories paint their own tree open /
290 void setTreeIcon( void );
295 YQPkgPatternList * _patternList;
296 ZyppPattern _firstPattern;
300 #endif // ifndef YQPkgPatternList_h