libyui-qt-pkg  2.47.5
YQPkgClassFilterView.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: YQPkgClassFilterView.h
35 
36  Authors: Duncan Mac-Vicar Prett <duncan@suse.de>
37  Stefan Hundhammer <sh@suse.de>
38 
39 /-*/
40 
41 
42 #ifndef YQPkgClassFilterView_h
43 #define YQPkgClassFilterView_h
44 
45 #include "YQZypp.h"
46 #include <QTreeWidget>
47 
48 
49 typedef enum
50 {
51  YQPkgClassNone, // Not listed in the widget
52  YQPkgClassSuggested,
53  YQPkgClassRecommended,
54  YQPkgClassOrphaned,
55  YQPkgClassUnneeded,
56  YQPkgClassMultiversion,
57  YQPkgClassRetracted,
58  YQPkgClassRetractedInstalled,
59  YQPkgClassAll,
60 } YQPkgClass;
61 
62 
63 class YQPkgClassItem;
64 
65 
66 /**
67  * Filter view for package classes (categories) like suggested, recommended,
68  * orphaned etc. packages. See enum YPkgClass.
69  **/
70 class YQPkgClassFilterView : public QTreeWidget
71 {
72  Q_OBJECT
73 
74 public:
75 
76  /**
77  * Constructor
78  **/
79  YQPkgClassFilterView( QWidget * parent );
80 
81  /**
82  * Destructor
83  **/
84  virtual ~YQPkgClassFilterView();
85 
86  /**
87  * Check if 'pkg' matches the selected package class and send a filterMatch
88  * signal if it does.
89  *
90  * Returns 'true' if there is a match, 'false' otherwise.
91  **/
92  bool check( ZyppSel selectable, ZyppPkg pkg );
93 
94  /**
95  * Check if 'pkg' matches the selected package class.
96  * Returns 'true' if there is a match, 'false' otherwise.
97  **/
98  bool checkMatch( ZyppSel selectable, ZyppPkg pkg );
99 
100  /**
101  * Returns the currently selected YQPkgClass
102  **/
103  YQPkgClass selectedPkgClass() const;
104 
105  /**
106  * Show the specified package class, i.e. select that filter.
107  **/
108  void showPkgClass( YQPkgClass pkgClass );
109 
110 
111 public slots:
112 
113  /**
114  * Filter according to the view's rules and current selection.
115  * Emits those signals:
116  * filterStart()
117  * filterMatch() for each pkg that matches the filter
118  * filterFinished()
119  **/
120  void filter();
121 
122  /**
123  * Same as filter(), but only if this widget is currently visible.
124  **/
125  void filterIfVisible();
126 
127 
128 signals:
129 
130  /**
131  * Emitted when the filtering starts. Use this to clear package lists
132  * etc. prior to adding new entries.
133  **/
134  void filterStart();
135 
136  /**
137  * Emitted during filtering for each pkg that matches the filter.
138  **/
139  void filterMatch( ZyppSel selectable, ZyppPkg pkg );
140 
141  /**
142  * Emitted when filtering is finished.
143  **/
144  void filterFinished();
145 
146 
147 protected slots:
148 
149  void slotSelectionChanged( QTreeWidgetItem * newSelection );
150 
151 
152 protected:
153 
154  void fillPkgClasses();
155 
156 };
157 
158 
159 class YQPkgClassItem: public QTreeWidgetItem
160 {
161 public:
162 
163  YQPkgClassItem( YQPkgClassFilterView * parentFilterView,
164  YQPkgClass pkgClass );
165 
166  virtual ~YQPkgClassItem();
167 
168  YQPkgClass pkgClass() const { return _pkgClass; }
169 
170  virtual bool operator< ( const QTreeWidgetItem & otherListViewItem ) const;
171 
172 
173 private:
174 
175  // Data members
176 
177  YQPkgClass _pkgClass;
178 };
179 
180 
181 #endif // ifndef YQPkgClassFilterView_h
Filter view for package classes (categories) like suggested, recommended, orphaned etc...
void filterFinished()
Emitted when filtering is finished.
bool check(ZyppSel selectable, ZyppPkg pkg)
Check if &#39;pkg&#39; matches the selected package class and send a filterMatch signal if it does...
YQPkgClassFilterView(QWidget *parent)
Constructor.
void filter()
Filter according to the view&#39;s rules and current selection.
void filterStart()
Emitted when the filtering starts.
void filterMatch(ZyppSel selectable, ZyppPkg pkg)
Emitted during filtering for each pkg that matches the filter.
void showPkgClass(YQPkgClass pkgClass)
Show the specified package class, i.e.
YQPkgClass selectedPkgClass() const
Returns the currently selected YQPkgClass.
bool checkMatch(ZyppSel selectable, ZyppPkg pkg)
Check if &#39;pkg&#39; matches the selected package class.
void filterIfVisible()
Same as filter(), but only if this widget is currently visible.
virtual ~YQPkgClassFilterView()
Destructor.