libyui-qt-pkg  2.45.28
YQPkgPackageKitGroupsFilterView.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: YQPkgPackageKitGroupsFilterView.h
35 
36  Authors: Duncan Mac-Vicar Prett <duncan@suse.de>
37  Stefan Hundhammer <sh@suse.de>
38 
39 /-*/
40 
41 
42 #ifndef YQPkgPackageKitGroupsFilterView_h
43 #define YQPkgPackageKitGroupsFilterView_h
44 
45 #include <map>
46 #include "YQZypp.h"
47 #include "YRpmGroupsTree.h"
48 #include <QTreeWidget>
49 
50 using std::string;
51 
52 typedef enum
53 {
54  //
55  // PackageKit values
56  //
57 
58  PK_GROUP_ENUM_ACCESSIBILITY,
59  PK_GROUP_ENUM_ACCESSORIES,
60  PK_GROUP_ENUM_EDUCATION,
61  PK_GROUP_ENUM_GAMES,
62  PK_GROUP_ENUM_GRAPHICS,
63  PK_GROUP_ENUM_INTERNET,
64  PK_GROUP_ENUM_OFFICE,
65  PK_GROUP_ENUM_OTHER,
66  PK_GROUP_ENUM_PROGRAMMING,
67  PK_GROUP_ENUM_MULTIMEDIA,
68  PK_GROUP_ENUM_SYSTEM,
69  PK_GROUP_ENUM_DESKTOP_GNOME,
70  PK_GROUP_ENUM_DESKTOP_KDE,
71  PK_GROUP_ENUM_DESKTOP_XFCE,
72  PK_GROUP_ENUM_DESKTOP_OTHER,
73  PK_GROUP_ENUM_PUBLISHING,
74  PK_GROUP_ENUM_SERVERS,
75  PK_GROUP_ENUM_FONTS,
76  PK_GROUP_ENUM_ADMIN_TOOLS,
77  PK_GROUP_ENUM_LEGACY,
78  PK_GROUP_ENUM_LOCALIZATION,
79  PK_GROUP_ENUM_VIRTUALIZATION,
80  PK_GROUP_ENUM_SECURITY,
81  PK_GROUP_ENUM_POWER_MANAGEMENT,
82  PK_GROUP_ENUM_COMMUNICATION,
83  PK_GROUP_ENUM_NETWORK,
84  PK_GROUP_ENUM_MAPS,
85  PK_GROUP_ENUM_REPOS,
86  PK_GROUP_ENUM_UNKNOWN,
87 
88  //
89  // Other values
90  //
91 
92  YPKG_GROUP_SUGGESTED,
93  YPKG_GROUP_RECOMMENDED,
94  YPKG_GROUP_ORPHANED,
95  YPKG_GROUP_UNNEEDED,
96  YPKG_GROUP_MULTIVERSION,
97  YPKG_GROUP_ALL,
98 } YPkgGroupEnum;
99 
100 
102 
103 
104 /**
105  * Filter view for PackageKit groups. Uses the packages' RPM group tags and
106  * maps them to the corresponding PackageKit group.
107  **/
108 class YQPkgPackageKitGroupsFilterView : public QTreeWidget
109 {
110  Q_OBJECT
111 
112 public:
113 
114  /**
115  * Constructor
116  **/
117  YQPkgPackageKitGroupsFilterView( QWidget * parent );
118 
119  /**
120  * Destructor
121  **/
123 
124  /**
125  * Returns the currently selected item or 0 if there is none.
126  **/
128 
129  /**
130  * Check if 'pkg' matches the selected group.
131  * Returns true if there is a match, false otherwise.
132  **/
133  bool check( ZyppSel selectable,
134  ZyppPkg pkg );
135 
136  /**
137  * Returns the (untranslated!) currently selected group enum
138  **/
139  YPkgGroupEnum selectedGroup() const { return _selectedGroup; }
140 
141 public slots:
142 
143  /**
144  * Filter according to the view's rules and current selection.
145  * Emits those signals:
146  * filterStart()
147  * filterMatch() for each pkg that matches the filter
148  * filterFinished()
149  **/
150  void filter();
151 
152  /**
153  * Same as filter(), but only if this widget is currently visible.
154  **/
155  void filterIfVisible();
156 
157  /**
158  * Select a list entry (if there is any).
159  * Usually this will be the first list entry, but don't rely on that - this
160  * might change without notice. Emits signal currentItemChanged().
161  **/
162  void selectSomething();
163 
164 signals:
165 
166  /**
167  * Emitted when the filtering starts. Use this to clear package lists
168  * etc. prior to adding new entries.
169  **/
170  void filterStart();
171 
172  /**
173  * Emitted during filtering for each pkg that matches the filter.
174  **/
175  void filterMatch( ZyppSel selectable,
176  ZyppPkg pkg );
177 
178  /**
179  * Emitted when filtering is finished.
180  **/
181  void filterFinished();
182 
183 
184 protected slots:
185 
186  void slotSelectionChanged( QTreeWidgetItem * newSelection );
187 
188 
189 protected:
190 
191  void fillGroups();
192 
193  //
194  // Data members
195  //
196 
197  YPkgGroupEnum _selectedGroup;
198  std::map<YPkgGroupEnum, YQPkgPackageKitGroup *> _groupsMap;
199 
200  // map to cache converted groups
201  std::map<std::string, YPkgGroupEnum> _groupsCache;
202 };
203 
204 
205 class YQPkgPackageKitGroup: public QTreeWidgetItem
206 {
207 public:
208 
210  YPkgGroupEnum group );
211  virtual ~YQPkgPackageKitGroup();
212 
213  YQPkgPackageKitGroupsFilterView * filterView() const { return _filterView; }
214  YPkgGroupEnum group() const { return _group; }
215  virtual bool operator< ( const QTreeWidgetItem & otherListViewItem ) const;
216 
217 
218 private:
219 
220  // Data members
221 
222  YQPkgPackageKitGroupsFilterView * _filterView;
223  YPkgGroupEnum _group;
224 };
225 
226 
227 #endif // ifndef YQPkgPackageKitGroupsFilterView_h
void filterMatch(ZyppSel selectable, ZyppPkg pkg)
Emitted during filtering for each pkg that matches the filter.
YPkgGroupEnum selectedGroup() const
Returns the (untranslated!) currently selected group enum.
Filter view for PackageKit groups.
bool check(ZyppSel selectable, ZyppPkg pkg)
Check if &#39;pkg&#39; matches the selected group.
YQPkgPackageKitGroupsFilterView(QWidget *parent)
Constructor.
void filterStart()
Emitted when the filtering starts.
void filterIfVisible()
Same as filter(), but only if this widget is currently visible.
void filter()
Filter according to the view&#39;s rules and current selection.
YQPkgPackageKitGroup * selection() const
Returns the currently selected item or 0 if there is none.
void selectSomething()
Select a list entry (if there is any).
void filterFinished()
Emitted when filtering is finished.