libyui-qt-pkg  2.45.6
 All Classes Functions Variables Enumerations
YQPkgSearchFilterView.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: YQPkgSearchFilterView.h
35 
36  Author: Stefan Hundhammer <sh@suse.de>
37 
38 /-*/
39 
40 
41 #ifndef YQPkgSearchFilterView_h
42 #define YQPkgSearchFilterView_h
43 
44 #include "YQZypp.h"
45 #include <QWidget>
46 #include <QRegExp>
47 #include <QEvent>
48 #include <QScrollArea>
49 
50 
51 class QComboBox;
52 class QCheckBox;
53 class QPushButton;
54 class QRadioButton;
55 
56 using std::list;
57 using std::string;
58 
59 
60 /**
61  * @short Filter view for searching within packages
62  **/
63 class YQPkgSearchFilterView : public QScrollArea
64 {
65  Q_OBJECT
66 
67 public:
68 
69  /**
70  * Constructor
71  **/
72  YQPkgSearchFilterView( QWidget * parent );
73 
74  /**
75  * Destructor
76  **/
77  virtual ~YQPkgSearchFilterView();
78 
79  /**
80  * Returns the minimum size required for this widget.
81  * Inherited from QWidget.
82  **/
83  virtual QSize minimumSizeHint() const;
84 
85  /**
86  * Check one ResObject against the currently selected values.
87  * Returns true if the package matches, false if not.
88  **/
89  bool check( ZyppSel selectable,
90  ZyppObj zyppObj );
91 
92 
93 public slots:
94 
95  /**
96  * Filter according to the view's rules and current selection.
97  * Emits those signals:
98  * filterStart()
99  * filterMatch() for each pkg that matches the filter
100  * filterFinished()
101  **/
102  void filter();
103 
104  /**
105  * Same as filter(), but only if this widget is currently visible.
106  **/
107  void filterIfVisible();
108 
109  /**
110  * Set the keyboard focus into this view's input field.
111  **/
112  void setFocus();
113 
114 
115 signals:
116 
117  /**
118  * Emitted when the filtering starts. Use this to clear package lists
119  * etc. prior to adding new entries.
120  **/
121  void filterStart();
122 
123  /**
124  * Emitted during filtering for each pkg that matches the filter.
125  **/
126  void filterMatch( ZyppSel selectable,
127  ZyppPkg pkg );
128 
129  /**
130  * Emitted when filtering is finished.
131  **/
132  void filterFinished();
133 
134  /**
135  * Send a short message about unsuccessful searches.
136  **/
137  void message( const QString & text );
138 
139 
140 protected:
141 
142  // Caution: Enum order must match corresponding message strings in combo box!
143  enum SearchMode
144  {
145  Contains = 0,
146  BeginsWith,
147  ExactMatch,
148  UseWildcards,
149  UseRegExp
150  };
151 
152  /**
153  * Key press event: Execute search upon 'Return'
154  * Reimplemented from QVBox / QWidget.
155  **/
156  virtual void keyPressEvent( QKeyEvent * event );
157 
158  // THESE SHOULD BE DEPRECATED but still used in secondary
159  // filters
160  /**
161  * Check if pkg matches the search criteria.
162  **/
163  bool check( ZyppSel selectable,
164  ZyppObj zyppObj,
165  const QRegExp & regexp );
166 
167  /**
168  * Check if a single pkg attribute matches the search criteria.
169  **/
170  bool check( const string & attribute, const QRegExp & regexp );
171 
172  /**
173  * Check capability like
174  * zypp::Resolvable::dep( zypp::Dep::PROVIDES ),
175  * zypp::Resolvable::dep( zypp::Dep::REQUIRES )
176  **/
177  bool check( const zypp::Capabilities & capSet, const QRegExp & regexp );
178 
179  // Data members
180 
181  QComboBox * _searchText;
182  QPushButton * _searchButton;
183 
184  QCheckBox * _searchInName;
185  QCheckBox * _searchInKeywords;
186  QCheckBox * _searchInSummary;
187  QCheckBox * _searchInDescription;
188  QCheckBox * _searchInRequires;
189  QCheckBox * _searchInProvides;
190  QCheckBox * _searchInFileList;
191 
192  QComboBox * _searchMode;
193  QCheckBox * _caseSensitive;
194 
195  int _matchCount;
196 };
197 
198 
199 
200 #endif // ifndef YQPkgSearchFilterView_h
void filterMatch(ZyppSel selectable, ZyppPkg pkg)
Emitted during filtering for each pkg that matches the filter.
bool check(ZyppSel selectable, ZyppObj zyppObj)
Check one ResObject against the currently selected values.
void filterIfVisible()
Same as filter(), but only if this widget is currently visible.
Filter view for searching within packages.
YQPkgSearchFilterView(QWidget *parent)
Constructor.
virtual QSize minimumSizeHint() const
Returns the minimum size required for this widget.
void message(const QString &text)
Send a short message about unsuccessful searches.
void filterFinished()
Emitted when filtering is finished.
virtual ~YQPkgSearchFilterView()
Destructor.
virtual void keyPressEvent(QKeyEvent *event)
Key press event: Execute search upon 'Return' Reimplemented from QVBox / QWidget. ...
void filterStart()
Emitted when the filtering starts.
void setFocus()
Set the keyboard focus into this view's input field.
void filter()
Filter according to the view's rules and current selection.