libyui-qt-pkg  2.42.5
 All Classes Functions Variables Enumerations
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 
57 
58 /**
59  * @short Package version selector: Display a list of available versions from
60  * all the different installation sources and let the user change the candidate
61  * version for installation / update.
62  **/
63 class YQPkgVersionsView : public QScrollArea
64 {
65  Q_OBJECT
66 
67 public:
68 
69  /**
70  * Constructor.
71  *
72  * 'userCanSwitchVersions' specifies whether or not the user is allowed to
73  * switch between package versions - e.g. in patch mode, he can't.
74  **/
75  YQPkgVersionsView( QWidget * parent, bool userCanSwitchVersions );
76 
77  /**
78  * Destructor
79  **/
80  virtual ~YQPkgVersionsView();
81 
82  /**
83  * Returns the minimum size required for this widget.
84  * Inherited from QWidget.
85  **/
86  virtual QSize minimumSizeHint() const;
87 
88 
89 public slots:
90 
91  /**
92  * Show details for the specified package.
93  * Delayed ( optimized ) display if this is embedded into a QTabWidget
94  * parent: In this case, wait until this page becomes visible.
95  **/
96  void showDetailsIfVisible( ZyppSel selectable );
97 
98  // slot clear() inherited from QListView
99 
100 
101  /**
102  * Show data for the last package.
103  **/
104  void reload( QWidget * newCurrent );
105 
106  void slotRefreshDetails();
107 
108 signals:
109 
110  /**
111  * Emitted when the user changes the
112  **/
113  void candidateChanged( ZyppObj newCandidate );
114  void multiversionSelectionChanged( );
115 
116 
117 
118 protected slots:
119 
120  /**
121  * Check for changed candidates
122  **/
124 
125 
126 protected:
127 
128  /**
129  * Show details for the specified package.
130  **/
131  void showDetails( ZyppSel selectable );
132 
133 
134  // Data members
135 
136  QWidget * _content;
137  QTabWidget * _parentTab;
138  ZyppSel _selectable;
139  bool _userCanSwitch;
140  QButtonGroup * _buttons;
141  QList<QWidget*> _installed;
142  QVBoxLayout * _layout;
143 };
144 
145 
146 class YQPkgVersion : public QRadioButton
147 {
148 public:
149 
150  /**
151  * Constructor. Creates a YQPkgVersion item that corresponds to the package
152  * manager object that 'pkg' refers to.
153  **/
154  YQPkgVersion( QWidget * parent,
155  ZyppSel selectable,
156  ZyppObj zyppObj,
157  bool enabled = true );
158 
159  /**
160  * Destructor
161  **/
162  virtual ~YQPkgVersion();
163 
164  /**
165  * Returns the original ZYPP object
166  **/
167  ZyppObj zyppObj() const { return _zyppObj; }
168 
169  /**
170  * Returns the original ZYPP selectable
171  **/
172  ZyppSel selectable() const { return _selectable; }
173 
174  /**
175  * Returns a tool tip text for a specific column of this item.
176  * 'column' is -1 if the mouse pointer is in the tree indentation area.
177  *
178  * Reimplemented from QY2CheckListItem.
179  **/
180  virtual QString toolTip( int column );
181 
182 
183 protected:
184 
185  // Data members
186 
187  ZyppSel _selectable;
188  ZyppObj _zyppObj;
189 };
190 
191 
192 
193 class YQPkgMultiVersion: public QCheckBox
194 {
195  Q_OBJECT
196 
197 public:
198 
199  /**
200  * Constructor. Creates a YQPkgVersion item that corresponds to the package
201  * manager object that 'pkg' refers to.
202  **/
203  YQPkgMultiVersion( QWidget * parent,
204  ZyppSel selectable,
205  ZyppPoolItem zyppPoolItem,
206  bool enabled = true );
207 
208  /**
209  * Destructor
210  **/
211  virtual ~YQPkgMultiVersion();
212 
213  /**
214  * Returns the original ZYPP selectable
215  **/
216  ZyppSel selectable() const { return _selectable; }
217 
218  /**
219  * Paints checkboxes with status icons instead of a checkmark
220  **/
221  void paintEvent(QPaintEvent *);
222 
223 
224 protected:
225 
226  /**
227  * Cycle the package status to the next valid value.
228  **/
229  void cycleStatus();
230 
231  void setStatus( ZyppStatus newStatus );
232  QPixmap statusIcon( ZyppStatus status );
233 
234  // Data members
235 
236  ZyppSel _selectable;
237  ZyppPoolItem _zyppPoolItem;
238 
239 
240 protected slots:
241  void slotIconClicked();
242 
243 
244 signals:
245  void statusChanged();
246 
247 
248 };
249 
250 
251 
252 
253 #endif // ifndef YQPkgVersionsView_h