libyui-qt-pkg
YQPkgPatternList.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: YQPkgPatternList.h
35 
36  Author: Stefan Hundhammer <shundhammer.de>
37 
38 /-*/
39 
40 
41 #ifndef YQPkgPatternList_h
42 #define YQPkgPatternList_h
43 
44 #include "YQPkgObjList.h"
45 #include <QMap>
46 
47 
50 
51 
56 {
57  Q_OBJECT
58 
59 public:
60 
71  YQPkgPatternList( QWidget * parent, bool autoFill = true, bool autoFilter = true );
72 
76  virtual ~YQPkgPatternList();
77 
78 public slots:
79 
87  void filter();
88 
92  void filterIfVisible();
93 
94 
100  void addPatternItem( ZyppSel selectable,
101  ZyppPattern pattern );
102 
106  void fillList();
107 
114  virtual void pkgObjClicked( int button,
115  QTreeWidgetItem * item,
116  int col,
117  const QPoint & pos );
118 
124  virtual void selectSomething();
125 
126 
127 public:
128 
133 
134  int howmanyCol() const { return _howmanyCol; }
135 signals:
136 
141  void filterStart();
142 
146  void filterMatch( ZyppSel selectable,
147  ZyppPkg pkg );
148 
152  void filterFinished();
153 
154 protected:
155 
161  YQPkgPatternCategoryItem * category( const QString & categoryName );
162 
163 
164  //
165  // Data members
166  //
167 
168  QMap<QString, YQPkgPatternCategoryItem*> _categories;
169  int _howmanyCol;
170 };
171 
172 
173 
175 {
176 public:
177 
181  YQPkgPatternListItem( YQPkgPatternList * patternList,
182  ZyppSel selectable,
183  ZyppPattern zyppPattern );
184 
188  YQPkgPatternListItem( YQPkgPatternList * patternList,
189  YQPkgPatternCategoryItem * parentCategory,
190  ZyppSel selectable,
191  ZyppPattern zyppPattern );
192 
196  virtual ~YQPkgPatternListItem();
197 
201  ZyppPattern zyppPattern() const { return _zyppPattern; }
202 
207  virtual void cycleStatus();
208 
212  virtual bool operator< ( const QTreeWidgetItem & other ) const;
213 
214  // Columns
215 
216  int statusCol() const { return _patternList->statusCol(); }
217  int summaryCol() const { return _patternList->summaryCol(); }
218 
219  int totalPackages() const { return _total; }
220  int installedPackages() const { return _installed; }
221 
222  // setters for installed and total packages values
223  void setTotalPackages(int v) { _total = v; }
224  void setInstalledPackages(int v) { _installed = v; }
225 
229  void resetToolTip();
230 
231 protected:
232 
236  void init();
237 
244  virtual void applyChanges();
245 
246 
247  // Data members
248 
249  YQPkgPatternList * _patternList;
250  ZyppPattern _zyppPattern;
251  // cache for total and installed packages
252  int _total;
253  int _installed;
254 };
255 
256 
257 
258 class YQPkgPatternCategoryItem: public QY2ListViewItem
259 {
260 public:
261 
266  const QString & category );
267 
271  virtual ~YQPkgPatternCategoryItem();
272 
276  ZyppPattern firstPattern() const { return _firstPattern; }
277 
281  void addPattern( ZyppPattern pattern );
282 
286  virtual bool operator< ( const QTreeWidgetItem & other ) const;
287 
288  /*
289  * Open or close this subtree
290  *
291  * Reimplemented from QListViewItem to force categories open at all times
292  **/
293  virtual void setExpanded( bool open );
294 
295 
296 protected:
297 
307  void setTreeIcon( void );
308  //
309  // Data members
310  //
311 
312  YQPkgPatternList * _patternList;
313  ZyppPattern _firstPattern;
314 };
315 
316 
317 #endif // ifndef YQPkgPatternList_h
virtual void selectSomething()
Definition: YQPkgPatternList.cc:423
void setTreeIcon(void)
Definition: YQPkgPatternList.cc:637
ZyppPattern firstPattern() const
Definition: YQPkgPatternList.h:276
void init()
Definition: YQPkgPatternList.cc:473
Abstract base class to display a list of zypp::ResObjects. Handles most generic stuff like setting st...
Definition: YQPkgObjList.h:68
virtual void applyChanges()
Definition: YQPkgPatternList.cc:568
virtual ~YQPkgPatternCategoryItem()
Definition: YQPkgPatternList.cc:607
Definition: YQPkgPatternList.h:258
YQPkgPatternCategoryItem * category(const QString &categoryName)
Definition: YQPkgPatternList.cc:284
Definition: YQPkgPatternList.h:174
void fillList()
Definition: YQPkgPatternList.cc:247
YQPkgPatternListItem(YQPkgPatternList *patternList, ZyppSel selectable, ZyppPattern zyppPattern)
Definition: YQPkgPatternList.cc:446
virtual ~YQPkgPatternListItem()
Definition: YQPkgPatternList.cc:495
void filterMatch(ZyppSel selectable, ZyppPkg pkg)
virtual ~YQPkgPatternList()
Definition: YQPkgPatternList.cc:240
void filterIfVisible()
Definition: YQPkgPatternList.cc:306
void filter()
Definition: YQPkgPatternList.cc:314
YQPkgPatternCategoryItem(YQPkgPatternList *patternList, const QString &category)
Definition: YQPkgPatternList.cc:595
Display a list of zypp::Pattern objects.
Definition: YQPkgPatternList.h:55
YQPkgPatternList(QWidget *parent, bool autoFill=true, bool autoFilter=true)
Definition: YQPkgPatternList.cc:159
virtual bool operator<(const QTreeWidgetItem &other) const
Definition: YQPkgPatternList.cc:574
ZyppPattern zyppPattern() const
Definition: YQPkgPatternList.h:201
ZyppSel selectable() const
Definition: YQPkgObjList.h:454
Definition: YQPkgObjList.h:414
virtual void cycleStatus()
Definition: YQPkgPatternList.cc:502
virtual bool operator<(const QTreeWidgetItem &other) const
Definition: YQPkgPatternList.cc:647
void addPattern(ZyppPattern pattern)
Definition: YQPkgPatternList.cc:614
virtual void pkgObjClicked(int button, QTreeWidgetItem *item, int col, const QPoint &pos)
Definition: YQPkgPatternList.cc:396
void addPatternItem(ZyppSel selectable, ZyppPattern pattern)
Definition: YQPkgPatternList.cc:354
void resetToolTip()
Definition: YQPkgPatternList.cc:553
YQPkgPatternListItem * selection() const
Definition: YQPkgPatternList.cc:384