1 /*---------------------------------------------------------------------\
3 | __ __ ____ _____ ____ |
4 | \ \ / /_ _/ ___|_ _|___ \ |
5 | \ V / _` \___ \ | | __) | |
6 | | | (_| |___) || | / __/ |
7 | |_|\__,_|____/ |_| |_____| |
11 \----------------------------------------------------------------------/
15 Author: Stefan Hundhammer <sh@suse.de>
23 #include <YQPkgObjList.h>
31 * @short Display a list of zypp::Package objects.
33 class YQPkgList : public YQPkgObjList
42 YQPkgList( QWidget * parent );
52 int srpmStatusCol() const { return _srpmStatusCol; }
55 * Save the pkg list to a file.
57 * Posts error popups if 'interactive' is 'true' ( only log entries
60 void exportList( const QString filename, bool interactive ) const;
63 * Add a submenu "All in this list..." to 'menu'.
64 * Returns the newly created submenu.
66 * Reimplemented from YQPkgObjList.
68 virtual QMenu * addAllInListSubMenu( QMenu * menu );
71 * Returns 'true' if there are any installed packages.
73 static bool haveInstalledPkgs();
76 * Set the status of all packages in the pool to a new value.
77 * This is not restricted to the current content of this package list.
78 * All selectables in the ZYPP pool are affected.
80 * 'force' indicates if it should be done even if it is not very useful,
81 * e.g., if packages should be updated even if there is no newer version.
83 * If 'countOnly' is 'true', the status is not actually changed, only the
84 * number of packages that would be affected is return.
86 * Return value: The number of status changes
88 int globalSetPkgStatus( ZyppStatus newStatus, bool force, bool countOnly );
94 * Add a pkg to the list. Connect a filter's filterMatch() signal to this
95 * slot. Remember to connect filterStart() to clear() (inherited from
98 void addPkgItem ( ZyppSel selectable,
102 * Add a pkg to the list, but display it dimmed (grey text foreground
103 * rather than normal black).
105 void addPkgItemDimmed( ZyppSel selectable,
109 * Add a pkg to the list
111 void addPkgItem ( ZyppSel selectable,
117 * Dispatcher slot for mouse click: Take care of source RPM status.
118 * Let the parent class handle the normal status.
119 * Reimplemented from YQPkgObjList.
121 virtual void pkgObjClicked( int button,
122 QTreeWidgetItem * item,
124 const QPoint & pos );
127 * Update the internal actions: What actions are available for 'item'?
129 * Reimplemented from YQPkgObjList
131 virtual void updateActions( YQPkgObjListItem * item );
134 * Reimplemented from QListView / QWidget:
135 * Reserve a reasonable amount of space.
137 virtual QSize sizeHint() const;
140 * Ask for a file name and save the current pkg list to file.
142 void askExportList() const;
145 // Direct access to some states for menu actions
147 void setInstallCurrentSourceRpm() { setInstallCurrentSourceRpm( true ); }
148 void setDontInstallCurrentSourceRpm() { setInstallCurrentSourceRpm( false ); }
150 void setInstallListSourceRpms() { setInstallListSourceRpms( true ); }
151 void setDontInstallListSourceRpms() { setInstallListSourceRpms( false ); }
154 // No separate currentItemChanged( ZyppPkg ) signal:
155 // Use YQPkgObjList::currentItemChanged( ZyppObj ) instead
156 // and dynamic_cast to ZyppPkg if required.
157 // This saves duplicating a lot of code.
163 * Create ( additional ) actions for the context menus.
165 void createActions();
168 * Create the context menu for items that are not installed.
170 * Reimplemented from YQPkgObjList.
172 virtual void createNotInstalledContextMenu();
175 * Create the context menu for installed items.
177 * Reimplemented from YQPkgObjList.
179 virtual void createInstalledContextMenu();
182 * Create context menu for source RPMs.
184 void createSourceRpmContextMenu();
187 * Sets the currently selected item's source RPM status.
188 * Automatically selects the next item if 'selectNextItem' is 'true'.
190 void setInstallCurrentSourceRpm( bool inst, bool selectNextItem = false );
193 * Sets the source RPM status of all items in this list.
195 void setInstallListSourceRpms( bool inst );
201 QMenu * _sourceRpmContextMenu;
206 QAction * actionInstallSourceRpm;
207 QAction * actionDontInstallSourceRpm;
208 QAction * actionInstallListSourceRpms;
209 QAction * actionDontInstallListSourceRpms;
214 class YQPkgListItem: public YQPkgObjListItem
219 * Constructor. Creates a YQPkgList item that corresponds to the package
220 * manager object that 'pkg' refers to.
222 YQPkgListItem( YQPkgList * pkgList,
229 virtual ~YQPkgListItem();
232 * Returns the parent package list.
234 YQPkgList * pkgList() { return _pkgList; }
237 * Returns the original object within the package manager backend.
239 ZyppPkg zyppPkg() const { return _zyppPkg; }
242 * Returns the source RPM package status:
243 * Should the source RPM be installed?
245 bool installSourceRpm() const;
248 * Set the source RPM status
250 void setInstallSourceRpm( bool installSourceRpm );
253 * Cycle the source package status to the next valid value.
255 void toggleSourceRpmStatus();
258 * Returns whether or not a source RPM is available for this package.
260 bool hasSourceRpm() const;
264 * Comparison function used for sorting the list.
270 * Reimplemented from QListViewItem
272 virtual int compare( QTreeWidgetItem * other,
274 bool ascending ) const;
278 * Update this item's data completely.
279 * Triggered by QY2ListView::updateAllItemData().
281 * Reimplemented from YQPkgObjList.
283 virtual void updateData();
286 * Returns a tool tip text for a specific column of this item.
287 * 'column' is -1 if the mouse pointer is in the tree indentation area.
289 * Reimplemented from YQPkgObjList.
291 virtual QString toolTip( int column );
294 * Returns true if this package is to be displayed dimmed,
295 * i.e. with grey text foreground rather than the normal black.
297 bool isDimmed() const { return _dimmed; }
300 * Set the 'dimmed' flag.
302 void setDimmed( bool d = true ) { _dimmed = d; }
307 int srpmStatusCol() const { return _pkgList->srpmStatusCol(); }
313 * Set the suitable icon for the source RPM status.
315 void setSourceRpmIcon();
318 * Paint method. Reimplemented from @ref QListViewItem so different
319 * colors can be used.
321 * Reimplemented from QListViewItem.
323 virtual void paintCell( QPainter * painter,
324 const QColorGroup & colorGroup,
331 YQPkgList * _pkgList;
337 #endif // ifndef YQPkgList_h