libyui-qt-pkg  2.45.6
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 
58 
59 /**
60  * @short Package version selector: Display a list of available versions from
61  * all the different installation sources and let the user change the candidate
62  * version for installation / update.
63  **/
64 class YQPkgVersionsView: public QScrollArea
65 {
66  Q_OBJECT
67 
68 public:
69 
70  /**
71  * Constructor.
72  **/
73  YQPkgVersionsView( QWidget * parent );
74 
75  /**
76  * Destructor
77  **/
78  virtual ~YQPkgVersionsView();
79 
80  /**
81  * Returns the minimum size required for this widget.
82  * Inherited from QWidget.
83  **/
84  virtual QSize minimumSizeHint() const;
85 
86  /**
87  * Return 'true' if 'selectable' has mixed multiversion flags,
88  * 'false' if all its pool items are of the same kind
89  * (all multiversion or all non-multiversion).
90  **/
91  static bool isMixedMultiVersion( ZyppSel selectable );
92 
93  /**
94  * Return the cached value for the current selectable.
95  **/
96  bool isMixedMultiVersion() const { return _isMixedMultiVersion; }
97 
98  /**
99  * Negotiate between multiversion and non-multiversion packages if there
100  * are both kinds in that selectable. 'newSelected' is the item the user
101  * chose to install.
102  *
103  * This returns 'true' if status setting etc. is already handled inside
104  * this function, 'false' otherwise.
105  **/
106  bool handleMixedMultiVersion( YQPkgMultiVersion * newSelected );
107 
108  ZyppSel selectable() const { return _selectable; }
109 
110 
111 public slots:
112 
113  /**
114  * Show details for the specified package.
115  * Delayed ( optimized ) display if this is embedded into a QTabWidget
116  * parent: In this case, wait until this page becomes visible.
117  **/
118  void showDetailsIfVisible( ZyppSel selectable );
119 
120  // slot clear() inherited from QListView
121 
122 
123  /**
124  * Show data for the current package.
125  **/
126  void reload( int newCurrent );
127 
128 
129 signals:
130 
131  /**
132  * Emitted when the user changes the candidate.
133  **/
134  void candidateChanged( ZyppObj newCandidate );
135 
136  /**
137  * Emitted when the status of any package changed.
138  **/
139  void statusChanged();
140 
141 
142 protected slots:
143 
144  /**
145  * Check for changed candidates
146  **/
148 
149 
150 protected:
151 
152  /**
153  * Show details for the specified package.
154  **/
155  void showDetails( ZyppSel selectable );
156 
157  /**
158  * Ask user if he really wants to install incompatible package versions.
159  * Return 'true' if he hits [Continue], 'false' if [Cancel].
160  **/
161  bool mixedMultiVersionPopup( bool multiversion ) const;
162 
163  /**
164  * Check if any package version is marked for installation where its
165  * 'multiversion' flag is set to 'multiversion'.
166  **/
167  bool anyMultiVersionToInstall( bool multiversion ) const;
168 
169  /**
170  * Unselect all multiversion package versions.
171  **/
173 
174  // Data members
175 
176  QWidget * _content;
177  QTabWidget * _parentTab;
178  ZyppSel _selectable;
179  bool _isMixedMultiVersion;
180  QButtonGroup * _buttons;
181  QList<QWidget*> _installed;
182  QVBoxLayout * _layout;
183 };
184 
185 
186 class YQPkgVersion: public QRadioButton
187 {
188 public:
189 
190  /**
191  * Constructor. Creates a YQPkgVersion item that corresponds to the package
192  * manager object that 'pkg' refers to.
193  **/
194  YQPkgVersion( QWidget * parent,
195  ZyppSel selectable,
196  ZyppObj zyppObj );
197 
198  /**
199  * Destructor
200  **/
201  virtual ~YQPkgVersion();
202 
203  /**
204  * Returns the original ZYPP object
205  **/
206  ZyppObj zyppObj() const { return _zyppObj; }
207 
208  /**
209  * Returns the original ZYPP selectable
210  **/
211  ZyppSel selectable() const { return _selectable; }
212 
213  /**
214  * Returns a tool tip text for a specific column of this item.
215  * 'column' is -1 if the mouse pointer is in the tree indentation area.
216  *
217  * Reimplemented from QY2CheckListItem.
218  **/
219  virtual QString toolTip( int column );
220 
221 
222 protected:
223 
224  // Data members
225 
226  ZyppSel _selectable;
227  ZyppObj _zyppObj;
228 };
229 
230 
231 
232 class YQPkgMultiVersion: public QCheckBox
233 {
234  Q_OBJECT
235 
236 public:
237 
238  /**
239  * Constructor.
240  **/
242  ZyppSel selectable,
243  ZyppPoolItem zyppPoolItem );
244 
245  /**
246  * Destructor
247  **/
248  virtual ~YQPkgMultiVersion();
249 
250  /**
251  * Returns the original ZYPP object
252  **/
253  ZyppPoolItem zyppPoolItem() const { return _zyppPoolItem; }
254 
255  /**
256  * Returns the original ZYPP selectable
257  **/
258  ZyppSel selectable() const { return _selectable; }
259 
260  /**
261  * Paints checkboxes with status icons instead of a checkmark
262  **/
263  void paintEvent(QPaintEvent *);
264 
265 signals:
266 
267  /**
268  * Emitted when the status of this package version is changed.
269  **/
270  void statusChanged();
271 
272 
273 protected slots:
274  void slotIconClicked();
275 
276 
277 protected:
278 
279  /**
280  * Cycle the package status to the next valid value.
281  **/
282  void cycleStatus();
283 
284  void setStatus( ZyppStatus newStatus );
285  QPixmap statusIcon( ZyppStatus status );
286 
287  //
288  // Data members
289  //
290 
291  YQPkgVersionsView * _parent;
292  ZyppSel _selectable;
293  ZyppPoolItem _zyppPoolItem;
294 };
295 
296 
297 
298 
299 #endif // ifndef YQPkgVersionsView_h
virtual QSize minimumSizeHint() const
Returns the minimum size required for this widget.
ZyppSel selectable() const
Returns the original ZYPP selectable.
void showDetailsIfVisible(ZyppSel selectable)
Show details for the specified package.
bool mixedMultiVersionPopup(bool multiversion) const
Ask user if he really wants to install incompatible package versions.
bool isMixedMultiVersion() const
Return the cached value for the current selectable.
ZyppSel selectable() const
Returns the original ZYPP selectable.
YQPkgVersionsView(QWidget *parent)
Constructor.
Package version selector: Display a list of available versions from all the different installation so...
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...
void checkForChangedCandidate()
Check for changed candidates.
void unselectAllMultiVersion()
Unselect all multiversion package versions.
void candidateChanged(ZyppObj newCandidate)
Emitted when the user changes the candidate.
ZyppObj zyppObj() const
Returns the original ZYPP object.
virtual ~YQPkgVersionsView()
Destructor.
bool handleMixedMultiVersion(YQPkgMultiVersion *newSelected)
Negotiate between multiversion and non-multiversion packages if there are both kinds in that selectab...
void statusChanged()
Emitted when the status of any package changed.
void reload(int newCurrent)
Show data for the current package.
ZyppPoolItem zyppPoolItem() const
Returns the original ZYPP object.
void showDetails(ZyppSel selectable)
Show details for the specified package.