1 /*---------------------------------------------------------------------\
3 | __ __ ____ _____ ____ |
4 | \ \ / /_ _/ ___|_ _|___ \ |
5 | \ V / _` \___ \ | | __) | |
6 | | | (_| |___) || | / __/ |
7 | |_|\__,_|____/ |_| |_____| |
11 \----------------------------------------------------------------------/
13 File: YQPkgPatchList.h
15 Author: Stefan Hundhammer <sh@suse.de>
20 #ifndef YQPkgPatchList_h
21 #define YQPkgPatchList_h
24 #include "YQPkgObjList.h"
25 #include "YQPkgSelMapper.h"
27 #include <QTreeWidgetItem>
31 #define ENABLE_DELETING_PATCHES 1
35 class YQPkgPatchListItem;
38 enum YQPkgPatchCategory // This is also the sort order
42 YQPkgRecommendedPatch,
46 YQPkgUnknownPatchCategory = 9999
52 * @short Display a list of zypp::Patch objects.
54 class YQPkgPatchList : public YQPkgObjList
63 YQPkgPatchList( QWidget * parent );
68 virtual ~YQPkgPatchList();
73 RelevantPatches, // needed + broken
74 RelevantAndInstalledPatches, // needed + broken + installed
82 * Filter according to the view's rules and current selection.
83 * Emits those signals:
85 * filterMatch() for each pkg that matches the filter
91 * Same as filter(), but only if this widget is currently visible.
93 void filterIfVisible();
96 * Add a patch to the list. Connect a filter's filterMatch() signal to
97 * this slot. Remember to connect filterStart() to clear() (inherited from
100 void addPatchItem( ZyppSel selectable,
101 ZyppPatch zyppPatch );
104 * Fill the patch list according to filterCriteria().
109 * Display a one-line message in the list.
110 * Reimplemented from YQPkgObjList.
112 virtual void message( const QString & text );
118 * Set the filter criteria for fillList().
120 void setFilterCriteria( FilterCriteria filterCriteria );
123 * Returns the current filter criteria.
125 FilterCriteria filterCriteria() const { return _filterCriteria; }
128 * Returns the currently selected item or 0 if there is none.
130 YQPkgPatchListItem * selection() const;
133 * Returns the column for the patch category
135 int categoryCol() const { return _categoryCol; }
138 * Add a submenu "All in this list..." to 'menu'.
139 * Returns the newly created submenu.
141 * Reimplemented from YQPkgObjList.
143 virtual QMenu * addAllInListSubMenu( QMenu * menu );
146 * Delayed initialization after the dialog is fully created.
148 * Reimplemented from QWidget.
150 virtual void polish();
156 * Emitted when the filtering starts. Use this to clear package lists
157 * etc. prior to adding new entries.
162 * Emitted during filtering for each pkg that matches the filter.
164 void filterMatch( ZyppSel selectable,
168 * Emitted during filtering for non-pkg items:
169 * pre-script, post-script, files
171 void filterMatch( const QString & name,
172 const QString & summary,
176 * Emitted when filtering is finished.
178 void filterFinished();
184 * Create the context menu for items that are not installed.
186 * Reimplemented from YQPkgObjList.
188 virtual void createNotInstalledContextMenu();
191 * Create the context menu for installed items.
193 * Reimplemented from YQPkgObjList.
195 virtual void createInstalledContextMenu();
198 * Event handler for keyboard input.
199 * Only very special keys are processed here.
201 * Reimplemented from YQPkgObjList / QWidget.
203 virtual void keyPressEvent( QKeyEvent * ev );
209 YQPkgSelMapper _selMapper;
210 FilterCriteria _filterCriteria;
215 class YQPkgPatchListItem: public YQPkgObjListItem
220 * Constructor. Creates a YQPkgPatchList item that corresponds to
223 YQPkgPatchListItem( YQPkgPatchList * patchList,
225 ZyppPatch zyppPatch );
230 virtual ~YQPkgPatchListItem();
233 * Returns the original zyppPatch object.
235 ZyppPatch zyppPatch() const { return _zyppPatch; }
238 * Maps a string patch category to the corresponding enum.
240 static YQPkgPatchCategory patchCategory( QString category );
241 static YQPkgPatchCategory patchCategory( const string & category );
244 * Converts a patch category to a user-readable (translated) string.
246 static QString asString( YQPkgPatchCategory category );
249 * Returns the category of this patch (security, recommended, ...).
251 YQPkgPatchCategory patchCategory() const { return _patchCategory; }
254 * Cycle the package status to the next valid value.
255 * Reimplemented from YQPkgObjList.
257 virtual void cycleStatus();
260 * Returns a tool tip text for a specific column of this item.
261 * 'column' is -1 if the mouse pointer is in the tree indentation area.
263 * Reimplemented from YQPkgObjList.
265 virtual QString toolTip( int column );
268 * Comparison function used for sorting the list.
274 * Reimplemented from QListViewItem.
276 virtual int compare( QTreeWidgetItem * other,
278 bool ascending ) const;
282 int statusCol() const { return _patchList->statusCol(); }
283 int summaryCol() const { return _patchList->summaryCol(); }
284 int categoryCol() const { return _patchList->categoryCol(); }
290 * Propagate status changes in this list to other lists:
291 * Have the solver transact all patches.
293 * Reimplemented from YQPkgObjListItem.
295 virtual void applyChanges();
300 YQPkgPatchList * _patchList;
301 ZyppPatch _zyppPatch;
302 YQPkgPatchCategory _patchCategory;
306 #endif // ifndef YQPkgPatchList_h