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