1 /*---------------------------------------------------------------------\
3 | __ __ ____ _____ ____ |
4 | \ \ / /_ _/ ___|_ _|___ \ |
5 | \ V / _` \___ \ | | __) | |
6 | | | (_| |___) || | / __/ |
7 | |_|\__,_|____/ |_| |_____| |
11 \----------------------------------------------------------------------/
15 Author: Stefan Hundhammer <sh@suse.de>
23 #include <YQPkgObjList.h>
30 * @short Display a list of zypp::Package objects.
32 class YQPkgList : public YQPkgObjList
41 YQPkgList( QWidget * parent );
51 int srpmStatusCol() const { return _srpmStatusCol; }
54 * Save the pkg list to a file.
56 * Posts error popups if 'interactive' is 'true' ( only log entries
59 void exportList( const QString filename, bool interactive ) const;
62 * Add a submenu "All in this list..." to 'menu'.
63 * Returns the newly created submenu.
65 * Reimplemented from YQPkgObjList.
67 virtual QMenu * addAllInListSubMenu( QMenu * menu );
70 * Returns 'true' if there are any installed packages.
72 static bool haveInstalledPkgs();
75 * Set the status of all packages in the pool to a new value.
76 * This is not restricted to the current content of this package list.
77 * All selectables in the ZYPP pool are affected.
79 * 'force' indicates if it should be done even if it is not very useful,
80 * e.g., if packages should be updated even if there is no newer version.
82 * If 'countOnly' is 'true', the status is not actually changed, only the
83 * number of packages that would be affected is return.
85 * Return value: The number of status changes
87 int globalSetPkgStatus( ZyppStatus newStatus, bool force, bool countOnly );
93 * Add a pkg to the list. Connect a filter's filterMatch() signal to this
94 * slot. Remember to connect filterStart() to clear() (inherited from
97 void addPkgItem ( ZyppSel selectable,
101 * Add a pkg to the list, but display it dimmed (grey text foreground
102 * rather than normal black).
104 void addPkgItemDimmed( ZyppSel selectable,
108 * Add a pkg to the list
110 void addPkgItem ( ZyppSel selectable,
116 * Dispatcher slot for mouse click: Take care of source RPM status.
117 * Let the parent class handle the normal status.
118 * Reimplemented from YQPkgObjList.
120 virtual void pkgObjClicked( int button,
121 QTreeWidgetItem * item,
123 const QPoint & pos );
126 * Update the internal actions: What actions are available for 'item'?
128 * Reimplemented from YQPkgObjList
130 virtual void updateActions( YQPkgObjListItem * item );
133 * Reimplemented from QListView / QWidget:
134 * Reserve a reasonable amount of space.
136 virtual QSize sizeHint() const;
139 * Ask for a file name and save the current pkg list to file.
141 void askExportList() const;
144 // Direct access to some states for menu actions
146 void setInstallCurrentSourceRpm() { setInstallCurrentSourceRpm( true ); }
147 void setDontInstallCurrentSourceRpm() { setInstallCurrentSourceRpm( false ); }
149 void setInstallListSourceRpms() { setInstallListSourceRpms( true ); }
150 void setDontInstallListSourceRpms() { setInstallListSourceRpms( false ); }
153 // No separate currentItemChanged( ZyppPkg ) signal:
154 // Use YQPkgObjList::currentItemChanged( ZyppObj ) instead
155 // and dynamic_cast to ZyppPkg if required.
156 // This saves duplicating a lot of code.
162 * Create ( additional ) actions for the context menus.
164 void createActions();
167 * Create the context menu for items that are not installed.
169 * Reimplemented from YQPkgObjList.
171 virtual void createNotInstalledContextMenu();
174 * Create the context menu for installed items.
176 * Reimplemented from YQPkgObjList.
178 virtual void createInstalledContextMenu();
181 * Create context menu for source RPMs.
183 void createSourceRpmContextMenu();
186 * Sets the currently selected item's source RPM status.
187 * Automatically selects the next item if 'selectNextItem' is 'true'.
189 void setInstallCurrentSourceRpm( bool inst, bool selectNextItem = false );
192 * Sets the source RPM status of all items in this list.
194 void setInstallListSourceRpms( bool inst );
200 QMenu * _sourceRpmContextMenu;
205 QAction * actionInstallSourceRpm;
206 QAction * actionDontInstallSourceRpm;
207 QAction * actionInstallListSourceRpms;
208 QAction * actionDontInstallListSourceRpms;
213 class YQPkgListItem: public YQPkgObjListItem
218 * Constructor. Creates a YQPkgList item that corresponds to the package
219 * manager object that 'pkg' refers to.
221 YQPkgListItem( YQPkgList * pkgList,
228 virtual ~YQPkgListItem();
231 * Returns the parent package list.
233 YQPkgList * pkgList() { return _pkgList; }
236 * Returns the original object within the package manager backend.
238 ZyppPkg zyppPkg() const { return _zyppPkg; }
241 * Returns the source RPM package status:
242 * Should the source RPM be installed?
244 bool installSourceRpm() const;
247 * Set the source RPM status
249 void setInstallSourceRpm( bool installSourceRpm );
252 * Cycle the source package status to the next valid value.
254 void toggleSourceRpmStatus();
257 * Returns whether or not a source RPM is available for this package.
259 bool hasSourceRpm() const;
264 virtual bool operator< ( const QTreeWidgetItem & other ) const;
267 * Update this item's data completely.
268 * Triggered by QY2ListView::updateAllItemData().
270 * Reimplemented from YQPkgObjList.
272 virtual void updateData();
275 * Returns a tool tip text for a specific column of this item.
276 * 'column' is -1 if the mouse pointer is in the tree indentation area.
278 * Reimplemented from YQPkgObjList.
280 virtual QString toolTip( int column );
283 * Returns true if this package is to be displayed dimmed,
284 * i.e. with grey text foreground rather than the normal black.
286 bool isDimmed() const { return _dimmed; }
289 * Set the 'dimmed' flag.
291 void setDimmed( bool d = true ) { _dimmed = d; }
296 int srpmStatusCol() const { return _pkgList->srpmStatusCol(); }
302 * Set the suitable icon for the source RPM status.
304 void setSourceRpmIcon();
309 YQPkgList * _pkgList;
315 #endif // ifndef YQPkgList_h