]> icculus.org git repositories - duncan/yast2-qt4.git/blob - src/pkg/YQPkgChangesDialog.h
don't create QObjects in ycp thread - make timeouts work
[duncan/yast2-qt4.git] / src / pkg / YQPkgChangesDialog.h
1 /*---------------------------------------------------------------------\
2 |                                                                      |
3 |                      __   __    ____ _____ ____                      |
4 |                      \ \ / /_ _/ ___|_   _|___ \                     |
5 |                       \ V / _` \___ \ | |   __) |                    |
6 |                        | | (_| |___) || |  / __/                     |
7 |                        |_|\__,_|____/ |_| |_____|                    |
8 |                                                                      |
9 |                               core system                            |
10 |                                                        (C) SuSE GmbH |
11 \----------------------------------------------------------------------/
12
13   File:       YQPkgChangesDialog.h
14
15   Author:     Stefan Hundhammer <sh@suse.de>
16
17 /-*/
18
19
20 #ifndef YQPkgChangesDialog_h
21 #define YQPkgChangesDialog_h
22
23 #include <qdialog.h>
24 #include <qregexp.h>
25
26
27 class YQPkgList;
28
29
30 /**
31  * Changes dialog: Show a dialog with a list of packages that are changed.
32  * By default, only packages with an "auto" status ( not set via selections )
33  * are displayed.
34  **/
35 class YQPkgChangesDialog : public QDialog
36 {
37     Q_OBJECT
38
39 public:
40
41     /**
42      * Static convenience method: Post a changes dialog with text
43      * 'message', a list of changed packages and one ( default ) or two buttons.
44      *
45      * Returns 'true' if the user accepted ( i.e. clicked the 'accept' button )
46      * and 'false' if the user rejected ( i.e. clicked the 'reject' button or
47      * the window manager close button ).
48      *
49      * If the list is empty ( i.e., there are no packages with an "auto"
50      * status ), the dialog is not shown at all ( and returns 'true' ) - unless
51      *'showIfListEmpty' is 'true'.
52      **/
53     static bool showChangesDialog( const QString &      message,
54                                    const QString &      acceptButtonLabel,
55                                    const QString &      rejectButtonLabel = QString::null,
56                                    bool                 showIfListEmpty   = false       );
57
58
59     /**
60      * Static convenience method: Post a changes dialog with text 'message', a
61      * list of changed packages whose names match the specified regular
62      * expression 'regexp' and one ( default ) or two buttons.
63      *
64      * Returns 'true' if the user accepted ( i.e. clicked the 'accept' button )
65      * and 'false' if the user rejected ( i.e. clicked the 'reject' button or
66      * the window manager close button ).
67      *
68      * If the list is empty ( i.e., there are no packages with an "auto"
69      * status ), the dialog is not shown at all ( and returns 'true' ) - unless
70      *'showIfListEmpty' is 'true'.
71      **/
72     static bool showChangesDialog( const QString &      message,
73                                    const QRegExp &      regexp,
74                                    const QString &      acceptButtonLabel,
75                                    const QString &      rejectButtonLabel = QString::null,
76                                    bool                 showIfListEmpty   = false       );
77
78     /**
79      * Returns the preferred size.
80      *
81      * Reimplemented from QWidget to limit the dialog to the screen dimensions.
82      **/
83     virtual QSize sizeHint () const;
84
85 protected:
86
87     /**
88      * Constructor: Creates a changes dialog with text 'message' on
89      * top, a list packages with an "auto" status that is not set via selections
90      * and one ( default ) or two buttons.
91      *
92      * Not meant for public use. Applications should use the static
93      * 'showChangesDialog' method instead.
94      *
95      * This constructor does not call filter() yet - this is the caller's
96      * responsibility.
97      **/
98     YQPkgChangesDialog( QWidget *               parent,
99                         const QString &         message,
100                         const QString &         acceptButtonLabel,
101                         const QString &         rejectButtonLabel = QString::null );
102
103     /**
104      * Apply the filter criteria: Fill the pkg list with pkgs that have a
105      * "modify" status ( install, update, delete ) set by automatic ( i.e. via the
106      * dependency solver ), by application ( i.e. via software selections ) or
107      * manually by the user.
108      **/
109     void filter( bool byAuto    = true,
110                  bool byApp     = false,
111                  bool byUser    = false );
112
113     /**
114      * Apply the filter criteria: Fill the pkg list with pkgs that have a
115      * "modify" status ( install, update, delete ) set by automatic ( i.e. via the
116      * dependency solver ), by application ( i.e. via software selections ) or
117      * manually by the user and whose name matches 'regexp'.
118      **/
119     void filter( const QRegExp & regexp,
120                  bool byAuto    = true,
121                  bool byApp     = false,
122                  bool byUser    = false );
123
124     /**
125      * Returns 'true' if the pkg list is empty.
126      * This is only meaningful after calling 'filter()' !
127      **/
128     bool isEmpty() const;
129
130
131     // Data members
132
133     YQPkgList *         _pkgList;
134 };
135
136
137 #endif // ifndef YQPkgChangesDialog_h