libyui-qt-pkg  2.44.7
 All Classes Functions Variables Enumerations
YQPkgRpmGroupTagsFilterView.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: YQPkgRpmGroupTagsFilterView.h
35 
36  Author: Stefan Hundhammer <sh@suse.de>
37 
38 /-*/
39 
40 
41 #ifndef YQPkgRpmGroupTagsFilterView_h
42 #define YQPkgRpmGroupTagsFilterView_h
43 
44 #include "YQZypp.h"
45 #include <QTreeWidget>
46 #include <YRpmGroupsTree.h>
47 
48 
49 using std::string;
50 
51 class YQPkgRpmGroupTag;
52 
53 
54 /**
55  * @short RPM group tags filter view: Display the RPM group tags tree and emit
56  * signals if any group tag is selected so a package list can be filled or
57  * updated.
58  **/
59 class YQPkgRpmGroupTagsFilterView : public QTreeWidget
60 {
61  Q_OBJECT
62 
63 public:
64 
65  /**
66  * Constructor
67  **/
68  YQPkgRpmGroupTagsFilterView( QWidget * parent );
69 
70  /**
71  * Destructor
72  **/
74 
75  /**
76  * Returns the currently selected item or 0 if there is none.
77  **/
78  YQPkgRpmGroupTag * selection() const;
79 
80  /**
81  * Check if 'pkg' matches the selected RPM group.
82  * Returns true if there is a match, false otherwise.
83  **/
84  bool check( ZyppSel selectable,
85  ZyppPkg pkg );
86 
87  /**
88  * Returns the (untranslated!) currently selected RPM group as string.
89  * Special case: "*" is returned if "zzz_All" is selected.
90  **/
91  const string & selectedRpmGroup() const { return _selectedRpmGroup; }
92 
93 
94 public slots:
95 
96  /**
97  * Filter according to the view's rules and current selection.
98  * Emits those signals:
99  * filterStart()
100  * filterMatch() for each pkg that matches the filter
101  * filterFinished()
102  **/
103  void filter();
104 
105  /**
106  * Same as filter(), but only if this widget is currently visible.
107  **/
108  void filterIfVisible();
109 
110  /**
111  * Select a list entry (if there is any).
112  * Usually this will be the first list entry, but don't rely on that - this
113  * might change without notice. Emits signal currentItemChanged().
114  **/
115  void selectSomething();
116 
117  /**
118  * Returns the internal RPM groups tree and fills it
119  * if it doesn't exist yet.
120  **/
121  static YRpmGroupsTree * rpmGroupsTree();
122 
123 
124 signals:
125 
126  /**
127  * Emitted when the filtering starts. Use this to clear package lists
128  * etc. prior to adding new entries.
129  **/
130  void filterStart();
131 
132  /**
133  * Emitted during filtering for each pkg that matches the filter.
134  **/
135  void filterMatch( ZyppSel selectable,
136  ZyppPkg pkg );
137 
138  /**
139  * Emitted when filtering is finished.
140  **/
141  void filterFinished();
142 
143 
144 protected slots:
145 
146  /**
147  * Update _selectedRpmGroup and filter data
148  **/
149  void slotSelectionChanged( QTreeWidgetItem * newSelection );
150 
151 
152 protected:
153 
154  /**
155  * Fill the internal RPM groups tree with RPM groups of all packages
156  * currently in the pool
157  **/
158  static void fillRpmGroupsTree();
159 
160  /**
161  * Recursively clone the RPM group tag tree for the QListView widget:
162  * Make a deep copy of the tree starting at 'parentRpmGroup' and
163  * 'parentClone'.
164  **/
165  void cloneTree( YStringTreeItem * parentRpmGroup,
166  YQPkgRpmGroupTag * parentClone = 0 );
167 
168  //
169  // Data members
170  //
171 
172  string _selectedRpmGroup;
173 
174  static YRpmGroupsTree * _rpmGroupsTree;
175 };
176 
177 
178 
179 class YQPkgRpmGroupTag: public QTreeWidgetItem
180 {
181 public:
182 
183  /**
184  * Constructor for toplevel RPM group tags
185  **/
186  YQPkgRpmGroupTag( YQPkgRpmGroupTagsFilterView * parentFilterView,
187  YStringTreeItem * rpmGroup );
188 
189  /**
190  * Constructor for RPM group tags that have a parent
191  **/
192  YQPkgRpmGroupTag( YQPkgRpmGroupTagsFilterView * parentFilterView,
193  YQPkgRpmGroupTag * parentGroupTag,
194  YStringTreeItem * rpmGroup );
195 
196  /**
197  * Constructor for toplevel RPM group tags via STL string
198  * ( for special cases like "zzz All" )
199  **/
200  YQPkgRpmGroupTag( YQPkgRpmGroupTagsFilterView * parentFilterView,
201  const QString & rpmGroupName,
202  YStringTreeItem * rpmGroup );
203 
204  /**
205  * Destructor
206  **/
207  virtual ~YQPkgRpmGroupTag();
208 
209 
210  /**
211  * Returns the parent filter view
212  **/
213  YQPkgRpmGroupTagsFilterView * filterView() const { return _filterView; }
214 
215  /**
216  * Returns the original tree item
217  **/
218  const YStringTreeItem * rpmGroup() const { return _rpmGroup; }
219 
220 
221 private:
222 
223  // Data members
224 
225  YQPkgRpmGroupTagsFilterView * _filterView;
226  YStringTreeItem * _rpmGroup;
227 };
228 
229 
230 #endif // ifndef YQPkgRpmGroupTagsFilterView_h
virtual ~YQPkgRpmGroupTag()
Destructor.
RPM group tags filter view: Display the RPM group tags tree and emit signals if any group tag is sele...
bool check(ZyppSel selectable, ZyppPkg pkg)
Check if 'pkg' matches the selected RPM group.
YQPkgRpmGroupTagsFilterView * filterView() const
Returns the parent filter view.
void filterFinished()
Emitted when filtering is finished.
void filter()
Filter according to the view's rules and current selection.
void filterStart()
Emitted when the filtering starts.
void slotSelectionChanged(QTreeWidgetItem *newSelection)
Update _selectedRpmGroup and filter data.
YQPkgRpmGroupTag(YQPkgRpmGroupTagsFilterView *parentFilterView, YStringTreeItem *rpmGroup)
Constructor for toplevel RPM group tags.
void selectSomething()
Select a list entry (if there is any).
static void fillRpmGroupsTree()
Fill the internal RPM groups tree with RPM groups of all packages currently in the pool...
void cloneTree(YStringTreeItem *parentRpmGroup, YQPkgRpmGroupTag *parentClone=0)
Recursively clone the RPM group tag tree for the QListView widget: Make a deep copy of the tree start...
YQPkgRpmGroupTagsFilterView(QWidget *parent)
Constructor.
const YStringTreeItem * rpmGroup() const
Returns the original tree item.
void filterMatch(ZyppSel selectable, ZyppPkg pkg)
Emitted during filtering for each pkg that matches the filter.
static YRpmGroupsTree * rpmGroupsTree()
Returns the internal RPM groups tree and fills it if it doesn't exist yet.
const string & selectedRpmGroup() const
Returns the (untranslated!) currently selected RPM group as string.
YQPkgRpmGroupTag * selection() const
Returns the currently selected item or 0 if there is none.
virtual ~YQPkgRpmGroupTagsFilterView()
Destructor.
void filterIfVisible()
Same as filter(), but only if this widget is currently visible.