libyui-qt-pkg  2.45.28
YQPkgChangesDialog.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 | \ \ / /_ _/ ___|_ _|___ \ |
27 | \ V / _` \___ \ | | __) | |
28 | | | (_| |___) || | / __/ |
29 | |_|\__,_|____/ |_| |_____| |
30 | |
31 | core system |
32 | (C) SuSE GmbH |
33 \----------------------------------------------------------------------/
34 
35  File: YQPkgChangesDialog.h
36 
37  Author: Stefan Hundhammer <sh@suse.de>
38 
39 /-*/
40 
41 
42 #ifndef YQPkgChangesDialog_h
43 #define YQPkgChangesDialog_h
44 
45 #include <QDialog>
46 #include <QComboBox>
47 #include <QRegExp>
48 #include <QFlags>
49 
50 class YQPkgList;
51 
52 /**
53  * Changes dialog: Show a dialog with a list of packages that are changed.
54  * By default, only packages with an "auto" status ( not set via selections )
55  * are displayed.
56  **/
57 class YQPkgChangesDialog : public QDialog
58 {
59  Q_OBJECT
60 
61 public:
62 
63  /**
64  * filter combobox entries
65  */
67  {
68  FilterIndexAll = 0,
69  FilterIndexUser = 1,
70  FilterIndexAutomatic = 2
71  };
72 
73  /**
74  * Filters
75  */
76  enum Filter
77  {
78  FilterNone = 0x0,
79  FilterUser = 0x1,
80  FilterAutomatic = 0x2,
81  FilterAll = 0x1 | 0x2
82  };
83  Q_DECLARE_FLAGS(Filters, Filter);
84 
85  /**
86  * Options
87  */
88  enum Option
89  {
90  OptionNone = 0x0,
91  OptionAutoAcceptIfEmpty = 0x1
92  };
93  Q_DECLARE_FLAGS(Options, Option);
94 
95  /**
96  * Set the current filter
97  * This will change the combo box current selected
98  * filter and update the list
99  */
100  void setFilter( Filters f );
101 
102  /**
103  * Set the current filter
104  * This will change the combo box current selected
105  * filter and update the list
106  */
107  void setFilter( const QRegExp &regexp, Filters f );
108 
109  /**
110  * Static convenience method: Post a changes dialog with text
111  * 'message', a list of changed packages and one ( default ) or two buttons.
112  *
113  * Returns 'true' if the user accepted ( i.e. clicked the 'accept' button )
114  * and 'false' if the user rejected ( i.e. clicked the 'reject' button or
115  * the window manager close button ).
116  *
117  * If the list is empty ( i.e., there are no packages with an "auto"
118  * status ), the dialog is not shown at all ( and returns 'true' ) - unless
119  *'showIfListEmpty' is 'true'.
120  **/
121  static bool showChangesDialog( QWidget * parent,
122  const QString & message,
123  const QString & acceptButtonLabel,
124  const QString & rejectButtonLabel = QString::null,
125  Filters f = FilterAutomatic,
126  Options o = OptionAutoAcceptIfEmpty );
127 
128  /**
129  * Static convenience method: Post a changes dialog with text 'message', a
130  * list of changed packages whose names match the specified regular
131  * expression 'regexp' and one ( default ) or two buttons.
132  *
133  * Returns 'true' if the user accepted ( i.e. clicked the 'accept' button )
134  * and 'false' if the user rejected ( i.e. clicked the 'reject' button or
135  * the window manager close button ).
136  *
137  * If the list is empty ( i.e., there are no packages with an "auto"
138  * status ), the dialog is not shown at all ( and returns 'true' ) - unless
139  *'showIfListEmpty' is 'true'.
140  **/
141  static bool showChangesDialog( QWidget * parent,
142  const QString & message,
143  const QRegExp & regexp,
144  const QString & acceptButtonLabel,
145  const QString & rejectButtonLabel = QString::null,
146  Filters f = FilterAutomatic,
147  Options o = OptionAutoAcceptIfEmpty );
148 
149  /**
150  * Returns the preferred size.
151  *
152  * Reimplemented from QWidget to limit the dialog to the screen dimensions.
153  **/
154  virtual QSize sizeHint () const;
155 
156 protected slots:
157  /**
158  * called when the filter is changed
159  */
160  void slotFilterChanged( int index );
161 
162 protected:
163  /**
164  * Constructor: Creates a changes dialog with text 'message' on
165  * top, a list packages with an "auto" status that is not set via selections
166  * and one ( default ) or two buttons.
167  *
168  * Not meant for public use. Applications should use the static
169  * 'showChangesDialog' method instead.
170  *
171  * This constructor does not call filter() yet - this is the caller's
172  * responsibility.
173  **/
174  YQPkgChangesDialog( QWidget * parent,
175  const QString & message,
176  const QString & acceptButtonLabel,
177  const QString & rejectButtonLabel = QString::null );
178 
179  /**
180  * Apply the filter criteria: Fill the pkg list with pkgs that have a
181  * "modify" status ( install, update, delete ) set by automatic ( i.e. via the
182  * dependency solver ), by application ( i.e. via software selections ) or
183  * manually by the user.
184  **/
185  void filter( Filters f = FilterAutomatic );
186 
187  /**
188  * Apply the filter criteria: Fill the pkg list with pkgs that have a
189  * "modify" status ( install, update, delete ) set by automatic ( i.e. via the
190  * dependency solver ), by application ( i.e. via software selections ) or
191  * manually by the user and whose name matches 'regexp'.
192  **/
193  void filter( const QRegExp & regexp, Filters f = FilterAutomatic );
194 
195  /**
196  * extra filter for child classes
197  */
198  virtual bool extraFilter( ZyppSel sel, ZyppPkg pkg );
199 
200  /**
201  * Returns 'true' if the pkg list is empty.
202  * This is only meaningful after calling 'filter()' !
203  **/
204  bool isEmpty() const;
205 
206 
207  // Data members
208  QComboBox *_filter;
209  YQPkgList * _pkgList;
210 };
211 
212 Q_DECLARE_OPERATORS_FOR_FLAGS(YQPkgChangesDialog::Filters);
213 Q_DECLARE_METATYPE(YQPkgChangesDialog::Filters);
214 
215 
217 {
218 public:
219  /**
220  * Constructor: Creates a changes dialog with text 'message' on
221  * top, a list packages with an "auto" status that is not set via selections
222  * and one ( default ) or two buttons.
223  *
224  * Not meant for public use. Applications should use the static
225  * 'showChangesDialog' method instead.
226  *
227  * This constructor does not call filter() yet - this is the caller's
228  * responsibility.
229  **/
230  YQPkgUnsupportedPackagesDialog( QWidget * parent,
231  const QString &message,
232  const QString &acceptButtonLabel,
233  const QString &rejectButtonLabel = QString::null );
234 
235  /**
236  * Static convenience method: Post a changes dialog with text
237  * 'message', a list of changed packages and one ( default ) or two buttons.
238  *
239  * Returns 'true' if the user accepted ( i.e. clicked the 'accept' button )
240  * and 'false' if the user rejected ( i.e. clicked the 'reject' button or
241  * the window manager close button ).
242  *
243  * If the list is empty ( i.e., there are no packages with an "auto"
244  * status ), the dialog is not shown at all ( and returns 'true' ) - unless
245  *'showIfListEmpty' is 'true'.
246  **/
247  static bool showUnsupportedPackagesDialog( QWidget * parent,
248  const QString & message,
249  const QString & acceptButtonLabel,
250  const QString & rejectButtonLabel = QString::null,
251  Filters f = FilterAutomatic,
252  Options o = OptionAutoAcceptIfEmpty );
253 protected:
254  /**
255  * leave supported packages out.
256  */
257  virtual bool extraFilter( ZyppSel sel, ZyppPkg pkg );
258 
259 };
260 
261 
262 #endif // ifndef YQPkgChangesDialog_h
void setFilter(Filters f)
Set the current filter This will change the combo box current selected filter and update the list...
FilterIndex
filter combobox entries
virtual bool extraFilter(ZyppSel sel, ZyppPkg pkg)
extra filter for child classes
void slotFilterChanged(int index)
called when the filter is changed
Changes dialog: Show a dialog with a list of packages that are changed.
bool isEmpty() const
Returns &#39;true&#39; if the pkg list is empty.
virtual QSize sizeHint() const
Returns the preferred size.
Display a list of zypp::Package objects.
Definition: YQPkgList.h:54
YQPkgUnsupportedPackagesDialog(QWidget *parent, const QString &message, const QString &acceptButtonLabel, const QString &rejectButtonLabel=QString::null)
Constructor: Creates a changes dialog with text &#39;message&#39; on top, a list packages with an "auto" stat...
YQPkgChangesDialog(QWidget *parent, const QString &message, const QString &acceptButtonLabel, const QString &rejectButtonLabel=QString::null)
Constructor: Creates a changes dialog with text &#39;message&#39; on top, a list packages with an "auto" stat...
virtual bool extraFilter(ZyppSel sel, ZyppPkg pkg)
leave supported packages out.
static bool showChangesDialog(QWidget *parent, const QString &message, const QString &acceptButtonLabel, const QString &rejectButtonLabel=QString::null, Filters f=FilterAutomatic, Options o=OptionAutoAcceptIfEmpty)
Static convenience method: Post a changes dialog with text &#39;message&#39;, a list of changed packages and ...
static bool showUnsupportedPackagesDialog(QWidget *parent, const QString &message, const QString &acceptButtonLabel, const QString &rejectButtonLabel=QString::null, Filters f=FilterAutomatic, Options o=OptionAutoAcceptIfEmpty)
Static convenience method: Post a changes dialog with text &#39;message&#39;, a list of changed packages and ...
void filter(Filters f=FilterAutomatic)
Apply the filter criteria: Fill the pkg list with pkgs that have a "modify" status ( install...