libyui-qt-pkg  2.45.5
 All Classes Functions Variables Enumerations
YQPkgSelList.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: YQPkgSelList.h
35 
36  Author: Stefan Hundhammer <sh@suse.de>
37 
38 /-*/
39 
40 
41 #ifndef YQPkgSelList_h
42 #define YQPkgSelList_h
43 
44 #include <YQPkgObjList.h>
45 
46 
47 class YQPkgSelListItem;
48 
49 
50 /**
51  * @short Display a list of zypp::Selection objects.
52  **/
53 class YQPkgSelList : public YQPkgObjList
54 {
55  Q_OBJECT
56 
57 public:
58 
59  /**
60  * Constructor.
61  *
62  * Set 'autoFill' to 'false' if you don't want the list to be filled in the
63  * constructor. In that case, use fillList() (e.g., when connections are
64  * set up).
65  *
66  * Set 'autoFilter' to 'false' if there is no need to do (expensive)
67  * filtering because the 'filterMatch' signal is not connected anyway.
68  **/
69  YQPkgSelList( QWidget * parent, bool autoFill = true, bool autoFilter = true );
70 
71  /**
72  * Destructor
73  **/
74  virtual ~YQPkgSelList();
75 
76 
77 public slots:
78 
79  /**
80  * Filter according to the view's rules and current selection.
81  * Emits those signals:
82  * filterStart()
83  * filterMatch() for each pkg that matches the filter
84  * filterFinished()
85  **/
86  void filter();
87 
88  /**
89  * Same as filter(), but only if this widget is currently visible.
90  **/
91  void filterIfVisible();
92 
93 
94  /**
95  * Add a selection to the list. Connect a filter's filterMatch() signal to
96  * this slot. Remember to connect filterStart() to clear() (inherited from
97  * QListView).
98  **/
99  void addPkgSelItem( ZyppSel selectable,
100  ZyppSelection selection );
101 
102  /**
103  * Fill the selection list.
104  **/
105  void fillList();
106 
107 public:
108 
109  /**
110  * Returns the currently selected item or 0 if there is none.
111  **/
112  YQPkgSelListItem * selection() const;
113 
114 
115 signals:
116 
117  /**
118  * Emitted when the filtering starts. Use this to clear package lists
119  * etc. prior to adding new entries.
120  **/
121  void filterStart();
122 
123  /**
124  * Emitted during filtering for each pkg that matches the filter.
125  **/
126  void filterMatch( ZyppSel selectable,
127  ZyppPkg pkg );
128 
129  /**
130  * Emitted when filtering is finished.
131  **/
132  void filterFinished();
133 };
134 
135 
136 
138 {
139 public:
140 
141  /**
142  * Constructor
143  **/
144  YQPkgSelListItem( YQPkgSelList * pkgSelList,
145  ZyppSel selectable,
146  ZyppSelection zyppSelection );
147 
148  /**
149  * Destructor
150  **/
151  virtual ~YQPkgSelListItem();
152 
153  /**
154  * Returns the original object within the package manager backend.
155  **/
156  ZyppSelection zyppSelection() const { return _zyppSelection; }
157 
158  /**
159  * Comparison function used for sorting the list.
160  * Returns:
161  * -1 if this < other
162  * 0 if this == other
163  * +1 if this > other
164  *
165  * Reimplemented from QListViewItem:
166  * Sort by zypp::Selection::order() only.
167  **/
168  virtual int compare( QTreeWidgetItem * other,
169  int col,
170  bool ascending ) const;
171 
172  // Columns
173 
174  int statusCol() const { return _pkgSelList->statusCol(); }
175  int summaryCol() const { return _pkgSelList->summaryCol(); }
176 
177 
178 protected:
179 
180  /**
181  * Propagate status changes in this list to other lists:
182  * Have the solver transact all selections.
183  *
184  * Reimplemented from YQPkgObjListItem.
185  **/
186  virtual void applyChanges();
187 
188 
189  // Data members
190 
191  YQPkgSelList * _pkgSelList;
192  ZyppSelection _zyppSelection;
193 };
194 
195 
196 #endif // ifndef YQPkgSelList_h
ZyppSel selectable() const
Returns the original selectable within the package manager backend.
Definition: YQPkgObjList.h:466
Abstract base class to display a list of zypp::ResObjects.
Definition: YQPkgObjList.h:68
void fillList()
Fill the selection list.
Definition: YQPkgSelList.cc:94
Display a list of zypp::Selection objects.
Definition: YQPkgSelList.h:53
void addPkgSelItem(ZyppSel selectable, ZyppSelection selection)
Add a selection to the list.
void filterMatch(ZyppSel selectable, ZyppPkg pkg)
Emitted during filtering for each pkg that matches the filter.
virtual void applyChanges()
Propagate status changes in this list to other lists: Have the solver transact all selections...
void filterStart()
Emitted when the filtering starts.
void filter()
Filter according to the view's rules and current selection.
virtual int compare(QTreeWidgetItem *other, int col, bool ascending) const
Comparison function used for sorting the list.
virtual ~YQPkgSelListItem()
Destructor.
void filterIfVisible()
Same as filter(), but only if this widget is currently visible.
virtual ~YQPkgSelList()
Destructor.
Definition: YQPkgSelList.cc:87
void filterFinished()
Emitted when filtering is finished.
ZyppSelection zyppSelection() const
Returns the original object within the package manager backend.
Definition: YQPkgSelList.h:156
YQPkgSelListItem * selection() const
Returns the currently selected item or 0 if there is none.
YQPkgSelList(QWidget *parent, bool autoFill=true, bool autoFilter=true)
Constructor.
Definition: YQPkgSelList.cc:56
YQPkgSelListItem(YQPkgSelList *pkgSelList, ZyppSel selectable, ZyppSelection zyppSelection)
Constructor.