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