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"
28 #include <q3popupmenu.h>
30 #define ENABLE_DELETING_PATCHES 1
34 class YQPkgPatchListItem;
37 enum YQPkgPatchCategory // This is also the sort order
41 YQPkgRecommendedPatch,
45 YQPkgUnknownPatchCategory = 9999
51 * @short Display a list of zypp::Patch objects.
53 class YQPkgPatchList : public YQPkgObjList
62 YQPkgPatchList( QWidget * parent );
67 virtual ~YQPkgPatchList();
72 RelevantPatches, // needed + broken
73 RelevantAndInstalledPatches, // needed + broken + installed
81 * Filter according to the view's rules and current selection.
82 * Emits those signals:
84 * filterMatch() for each pkg that matches the filter
90 * Same as filter(), but only if this widget is currently visible.
92 void filterIfVisible();
95 * Add a patch to the list. Connect a filter's filterMatch() signal to
96 * this slot. Remember to connect filterStart() to clear() (inherited from
99 void addPatchItem( ZyppSel selectable,
100 ZyppPatch zyppPatch );
103 * Fill the patch list according to filterCriteria().
108 * Display a one-line message in the list.
109 * Reimplemented from YQPkgObjList.
111 virtual void message( const QString & text );
117 * Set the filter criteria for fillList().
119 void setFilterCriteria( FilterCriteria filterCriteria );
122 * Returns the current filter criteria.
124 FilterCriteria filterCriteria() const { return _filterCriteria; }
127 * Returns the currently selected item or 0 if there is none.
129 YQPkgPatchListItem * selection() const;
132 * Returns the column for the patch category
134 int categoryCol() const { return _categoryCol; }
137 * Add a submenu "All in this list..." to 'menu'.
138 * Returns the newly created submenu.
140 * Reimplemented from YQPkgObjList.
142 virtual Q3PopupMenu * addAllInListSubMenu( Q3PopupMenu * menu );
145 * Delayed initialization after the dialog is fully created.
147 * Reimplemented from QWidget.
149 virtual void polish();
155 * Emitted when the filtering starts. Use this to clear package lists
156 * etc. prior to adding new entries.
161 * Emitted during filtering for each pkg that matches the filter.
163 void filterMatch( ZyppSel selectable,
167 * Emitted during filtering for non-pkg items:
168 * pre-script, post-script, files
170 void filterMatch( const QString & name,
171 const QString & summary,
175 * Emitted when filtering is finished.
177 void filterFinished();
183 * Create the context menu for items that are not installed.
185 * Reimplemented from YQPkgObjList.
187 virtual void createNotInstalledContextMenu();
190 * Create the context menu for installed items.
192 * Reimplemented from YQPkgObjList.
194 virtual void createInstalledContextMenu();
197 * Event handler for keyboard input.
198 * Only very special keys are processed here.
200 * Reimplemented from YQPkgObjList / QWidget.
202 virtual void keyPressEvent( QKeyEvent * ev );
208 YQPkgSelMapper _selMapper;
209 FilterCriteria _filterCriteria;
214 class YQPkgPatchListItem: public YQPkgObjListItem
219 * Constructor. Creates a YQPkgPatchList item that corresponds to
222 YQPkgPatchListItem( YQPkgPatchList * patchList,
224 ZyppPatch zyppPatch );
229 virtual ~YQPkgPatchListItem();
232 * Returns the original zyppPatch object.
234 ZyppPatch zyppPatch() const { return _zyppPatch; }
237 * Maps a string patch category to the corresponding enum.
239 static YQPkgPatchCategory patchCategory( QString category );
240 static YQPkgPatchCategory patchCategory( const string & category );
243 * Converts a patch category to a user-readable (translated) string.
245 static QString asString( YQPkgPatchCategory category );
248 * Returns the category of this patch (security, recommended, ...).
250 YQPkgPatchCategory patchCategory() const { return _patchCategory; }
253 * Cycle the package status to the next valid value.
254 * Reimplemented from YQPkgObjList.
256 virtual void cycleStatus();
259 * Returns a tool tip text for a specific column of this item.
260 * 'column' is -1 if the mouse pointer is in the tree indentation area.
262 * Reimplemented from YQPkgObjList.
264 virtual QString toolTip( int column );
267 * Comparison function used for sorting the list.
273 * Reimplemented from QListViewItem.
275 virtual int compare( Q3ListViewItem * other,
277 bool ascending ) const;
281 int statusCol() const { return _patchList->statusCol(); }
282 int summaryCol() const { return _patchList->summaryCol(); }
283 int categoryCol() const { return _patchList->categoryCol(); }
289 * Propagate status changes in this list to other lists:
290 * Have the solver transact all patches.
292 * Reimplemented from YQPkgObjListItem.
294 virtual void applyChanges();
299 YQPkgPatchList * _patchList;
300 ZyppPatch _zyppPatch;
301 YQPkgPatchCategory _patchCategory;
305 #endif // ifndef YQPkgPatchList_h