libyui-qt-pkg  2.47.5
YQPkgVersionsView.h
1 /**************************************************************************
2 Copyright (C) 2000 - 2010 Novell, Inc.
3 All Rights Reserved.
4 
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9 
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14 
15 You should have received a copy of the GNU General Public License along
16 with this program; if not, write to the Free Software Foundation, Inc.,
17 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 
19 **************************************************************************/
20 
21 
22 /*---------------------------------------------------------------------\
23 | |
24 | __ __ ____ _____ ____ |
25 | \ \ / /_ _/ ___|_ _|___ \ |
26 | \ V / _` \___ \ | | __) | |
27 | | | (_| |___) || | / __/ |
28 | |_|\__,_|____/ |_| |_____| |
29 | |
30 | core system |
31 | (C) SuSE GmbH |
32 \----------------------------------------------------------------------/
33 
34  File: YQPkgVersionsView.h
35 
36  Author: Stefan Hundhammer <sh@suse.de>
37 
38 /-*/
39 
40 
41 #ifndef YQPkgVersionsView_h
42 #define YQPkgVersionsView_h
43 
44 #include <QScrollArea>
45 #include <QRadioButton>
46 #include <QCheckBox>
47 #include <QButtonGroup>
48 #include <QBoxLayout>
49 #include <QLabel>
50 #include <QList>
51 
52 #include "YQZypp.h"
53 
54 
55 class QTabWidget;
56 class YQPkgMultiVersion;
57 class YQPkgVersion;
58 
59 
60 /**
61  * @short Package version selector: Display a list of available versions from
62  * all the different installation sources and let the user change the candidate
63  * version for installation / update.
64  **/
65 class YQPkgVersionsView: public QScrollArea
66 {
67  Q_OBJECT
68 
69 public:
70 
71  /**
72  * Constructor.
73  **/
74  YQPkgVersionsView( QWidget * parent );
75 
76  /**
77  * Destructor
78  **/
79  virtual ~YQPkgVersionsView();
80 
81  /**
82  * Returns the minimum size required for this widget.
83  * Inherited from QWidget.
84  **/
85  virtual QSize minimumSizeHint() const;
86 
87  /**
88  * Return 'true' if 'selectable' has mixed multiversion flags,
89  * 'false' if all its pool items are of the same kind
90  * (all multiversion or all non-multiversion).
91  **/
92  static bool isMixedMultiVersion( ZyppSel selectable );
93 
94  /**
95  * Return the cached value for the current selectable.
96  **/
97  bool isMixedMultiVersion() const { return _isMixedMultiVersion; }
98 
99  /**
100  * Negotiate between multiversion and non-multiversion packages if there
101  * are both kinds in that selectable. 'newSelected' is the item the user
102  * chose to install.
103  *
104  * This returns 'true' if status setting etc. is already handled inside
105  * this function, 'false' otherwise.
106  **/
107  bool handleMixedMultiVersion( YQPkgMultiVersion * newSelected );
108 
109  /**
110  * Return the selectable of this details view.
111  **/
112  ZyppSel selectable() const { return _selectable; }
113 
114  /**
115  * Set the colors of a widget for a retracted zyppObj.
116  **/
117  static void setRetractedColor( QWidget * widget );
118 
119  /**
120  * Return 'true' if 'installed' is retraced, i.e. if there is an available
121  * ZyppObj with the same edition, architeture and vendor that has the
122  * 'retracted' flag set.
123  **/
124  static bool installedIsRetracted( ZyppSel selectable, ZyppObj installed );
125 
126 
127 public slots:
128 
129  /**
130  * Show details for the specified package.
131  * Delayed ( optimized ) display if this is embedded into a QTabWidget
132  * parent: In this case, wait until this page becomes visible.
133  **/
134  void showDetailsIfVisible( ZyppSel selectable );
135 
136  // slot clear() inherited from QListView
137 
138 
139  /**
140  * Show data for the current package.
141  **/
142  void reload( int newCurrent );
143 
144 
145 signals:
146 
147  /**
148  * Emitted when the user changes the candidate.
149  **/
150  void candidateChanged( ZyppObj newCandidate );
151 
152  /**
153  * Emitted when the status of any package changed.
154  **/
155  void statusChanged();
156 
157 
158 protected slots:
159 
160  /**
161  * Check for changed candidates
162  **/
164 
165 
166 protected:
167 
168  /**
169  * Show details for the specified package.
170  **/
171  void showDetails( ZyppSel selectable );
172 
173  /**
174  * Ask user if he really wants to install incompatible package versions.
175  * Return 'true' if he hits [Continue], 'false' if [Cancel].
176  **/
177  bool mixedMultiVersionPopup( bool multiversion ) const;
178 
179  /**
180  * Check if any package version is marked for installation where its
181  * 'multiversion' flag is set to 'multiversion'.
182  **/
183  bool anyMultiVersionToInstall( bool multiversion ) const;
184 
185  /**
186  * Unselect all multiversion package versions.
187  **/
189 
190  // Data members
191 
192  QTabWidget * _parentTab;
193  ZyppSel _selectable;
194  bool _isMixedMultiVersion;
195  QButtonGroup * _buttonGroup;
196  QVBoxLayout * _layout;
197 };
198 
199 
200 class YQPkgVersion: public QRadioButton
201 {
202 public:
203 
204  /**
205  * Constructor. Creates a YQPkgVersion item that corresponds to the package
206  * manager object that 'pkg' refers to.
207  **/
208  YQPkgVersion( QWidget * parent,
209  ZyppSel selectable,
210  ZyppObj zyppObj );
211 
212  /**
213  * Destructor
214  **/
215  virtual ~YQPkgVersion();
216 
217  /**
218  * Returns the original ZYPP object
219  **/
220  ZyppObj zyppObj() const { return _zyppObj; }
221 
222  /**
223  * Returns the original ZYPP selectable
224  **/
225  ZyppSel selectable() const { return _selectable; }
226 
227  /**
228  * Returns a tool tip text for a specific column of this item.
229  * 'column' is -1 if the mouse pointer is in the tree indentation area.
230  *
231  * Reimplemented from QY2CheckListItem.
232  **/
233  virtual QString toolTip( int column );
234 
235 
236 protected:
237 
238  // Data members
239 
240  ZyppSel _selectable;
241  ZyppObj _zyppObj;
242 };
243 
244 
245 
246 class YQPkgMultiVersion: public QCheckBox
247 {
248  Q_OBJECT
249 
250 public:
251 
252  /**
253  * Constructor.
254  **/
256  ZyppSel selectable,
257  ZyppPoolItem zyppPoolItem );
258 
259  /**
260  * Destructor
261  **/
262  virtual ~YQPkgMultiVersion();
263 
264  /**
265  * Returns the original ZYPP object
266  **/
267  ZyppPoolItem zyppPoolItem() const { return _zyppPoolItem; }
268 
269  /**
270  * Returns the original ZYPP selectable
271  **/
272  ZyppSel selectable() const { return _selectable; }
273 
274  /**
275  * Paints checkboxes with status icons instead of a checkmark
276  **/
277  void paintEvent(QPaintEvent *);
278 
279 signals:
280 
281  /**
282  * Emitted when the status of this package version is changed.
283  **/
284  void statusChanged();
285 
286 
287 protected slots:
288  void slotIconClicked();
289 
290 
291 protected:
292 
293  /**
294  * Cycle the package status to the next valid value.
295  **/
296  void cycleStatus();
297 
298  void setStatus( ZyppStatus newStatus );
299  QPixmap statusIcon( ZyppStatus status );
300 
301  //
302  // Data members
303  //
304 
305  YQPkgVersionsView * _parent;
306  ZyppSel _selectable;
307  ZyppPoolItem _zyppPoolItem;
308 };
309 
310 
311 
312 
313 #endif // ifndef YQPkgVersionsView_h
static void setRetractedColor(QWidget *widget)
Set the colors of a widget for a retracted zyppObj.
ZyppPoolItem zyppPoolItem() const
Returns the original ZYPP object.
ZyppObj zyppObj() const
Returns the original ZYPP object.
virtual QString toolTip(int column)
Returns a tool tip text for a specific column of this item.
bool isMixedMultiVersion() const
Return the cached value for the current selectable.
YQPkgMultiVersion(YQPkgVersionsView *parent, ZyppSel selectable, ZyppPoolItem zyppPoolItem)
Constructor.
YQPkgVersion(QWidget *parent, ZyppSel selectable, ZyppObj zyppObj)
Constructor.
void showDetailsIfVisible(ZyppSel selectable)
Show details for the specified package.
virtual ~YQPkgVersion()
Destructor.
virtual ~YQPkgMultiVersion()
Destructor.
YQPkgVersionsView(QWidget *parent)
Constructor.
Package version selector: Display a list of available versions from all the different installation so...
virtual QSize minimumSizeHint() const
Returns the minimum size required for this widget.
ZyppSel selectable() const
Return the selectable of this details view.
void paintEvent(QPaintEvent *)
Paints checkboxes with status icons instead of a checkmark.
void checkForChangedCandidate()
Check for changed candidates.
bool anyMultiVersionToInstall(bool multiversion) const
Check if any package version is marked for installation where its &#39;multiversion&#39; flag is set to &#39;mult...
bool mixedMultiVersionPopup(bool multiversion) const
Ask user if he really wants to install incompatible package versions.
void unselectAllMultiVersion()
Unselect all multiversion package versions.
ZyppSel selectable() const
Returns the original ZYPP selectable.
void candidateChanged(ZyppObj newCandidate)
Emitted when the user changes the candidate.
virtual ~YQPkgVersionsView()
Destructor.
bool handleMixedMultiVersion(YQPkgMultiVersion *newSelected)
Negotiate between multiversion and non-multiversion packages if there are both kinds in that selectab...
ZyppSel selectable() const
Returns the original ZYPP selectable.
void statusChanged()
Emitted when the status of this package version is changed.
void cycleStatus()
Cycle the package status to the next valid value.
static bool installedIsRetracted(ZyppSel selectable, ZyppObj installed)
Return &#39;true&#39; if &#39;installed&#39; is retraced, i.e.
void statusChanged()
Emitted when the status of any package changed.
void reload(int newCurrent)
Show data for the current package.
void showDetails(ZyppSel selectable)
Show details for the specified package.