]> icculus.org git repositories - duncan/yast2-qt4.git/blob - src/pkg/YQPkgSearchFilterView.h
don't create QObjects in ycp thread - make timeouts work
[duncan/yast2-qt4.git] / src / pkg / YQPkgSearchFilterView.h
1 /*---------------------------------------------------------------------\
2 |                                                                      |
3 |                      __   __    ____ _____ ____                      |
4 |                      \ \ / /_ _/ ___|_   _|___ \                     |
5 |                       \ V / _` \___ \ | |   __) |                    |
6 |                        | | (_| |___) || |  / __/                     |
7 |                        |_|\__,_|____/ |_| |_____|                    |
8 |                                                                      |
9 |                               core system                            |
10 |                                                        (C) SuSE GmbH |
11 \----------------------------------------------------------------------/
12
13   File:       YQPkgSearchFilterView.h
14
15   Author:     Stefan Hundhammer <sh@suse.de>
16
17 /-*/
18
19
20 #ifndef YQPkgSearchFilterView_h
21 #define YQPkgSearchFilterView_h
22
23 #include "YQZypp.h"
24 #include <QWidget>
25 #include <QRegExp>
26 #include <QEvent>
27
28
29 class QComboBox;
30 class QCheckBox;
31 class QPushButton;
32 class QRadioButton;
33
34 using std::list;
35 using std::string;
36
37
38 /**
39  * @short Filter view for searching within packages
40  **/
41 class YQPkgSearchFilterView : public QWidget
42 {
43     Q_OBJECT
44
45 public:
46
47     /**
48      * Constructor
49      **/
50     YQPkgSearchFilterView( QWidget * parent );
51
52     /**
53      * Destructor
54      **/
55     virtual ~YQPkgSearchFilterView();
56
57     /**
58      * Returns the minimum size required for this widget.
59      * Inherited from QWidget.
60      **/
61     virtual QSize minimumSizeHint() const;
62
63     /**
64      * Check one ResObject against the currently selected values.
65      * Returns true if the package matches, false if not.
66      **/
67     bool check( ZyppSel selectable,
68                 ZyppObj zyppObj );
69
70
71 public slots:
72
73     /**
74      * Filter according to the view's rules and current selection.
75      * Emits those signals:
76      *    filterStart()
77      *    filterMatch() for each pkg that matches the filter
78      *    filterFinished()
79      **/
80     void filter();
81
82     /**
83      * Same as filter(), but only if this widget is currently visible.
84      **/
85     void filterIfVisible();
86
87     /**
88      * Set the keyboard focus into this view's input field.
89      **/
90     void setFocus();
91
92
93 signals:
94
95     /**
96      * Emitted when the filtering starts. Use this to clear package lists
97      * etc. prior to adding new entries.
98      **/
99     void filterStart();
100
101     /**
102      * Emitted during filtering for each pkg that matches the filter.
103      **/
104     void filterMatch( ZyppSel   selectable,
105                       ZyppPkg   pkg );
106
107     /**
108      * Emitted when filtering is finished.
109      **/
110     void filterFinished();
111
112     /**
113      * Send a short message about unsuccessful searches.
114      **/
115     void message( const QString & text );
116
117
118 protected:
119
120     // Caution: Enum order must match corresponding message strings in combo box!
121     typedef enum SearchMode
122     {
123         Contains = 0,
124         BeginsWith,
125         ExactMatch,
126         UseWildcards,
127         UseRegExp
128     };
129
130     
131     /**
132      * Check if pkg matches the search criteria.
133      **/
134     bool check( ZyppSel selectable,
135                 ZyppObj         zyppObj,
136                 const QRegExp &                 regexp );
137
138     /**
139      * Check if a single pkg attribute matches the search criteria.
140      **/
141     bool check( const string & attribute, const QRegExp & regexp );
142
143     /**
144      * Check capability like
145      * zypp::Resolvable::dep( zypp::Dep::PROVIDES ),
146      * zypp::Resolvable::dep( zypp::Dep::REQUIRES )
147      **/
148     bool check( const zypp::CapSet & capSet, const QRegExp & regexp );
149
150     /**
151      * Key press event: Execute search upon 'Return'
152      * Reimplemented from QVBox / QWidget.
153      **/
154     virtual void keyPressEvent( QKeyEvent * event );
155
156
157     // Data members
158
159     QComboBox *         _searchText;
160     QPushButton *       _searchButton;
161
162     QCheckBox *         _searchInName;
163     QCheckBox *         _searchInSummary;
164     QCheckBox *         _searchInDescription;
165     QCheckBox *         _searchInRequires;
166     QCheckBox *         _searchInProvides;
167
168     QComboBox *         _searchMode;
169     QCheckBox *         _caseSensitive;
170
171     int                 _matchCount;
172 };
173
174
175
176 #endif // ifndef YQPkgSearchFilterView_h