]> icculus.org git repositories - duncan/yast2-qt4.git/blob - src/pkg/YQPkgSelList.h
restart qt4 porting
[duncan/yast2-qt4.git] / src / pkg / YQPkgSelList.h
1 /*---------------------------------------------------------------------\
2 |                                                                      |
3 |                      __   __    ____ _____ ____                      |
4 |                      \ \ / /_ _/ ___|_   _|___ \                     |
5 |                       \ V / _` \___ \ | |   __) |                    |
6 |                        | | (_| |___) || |  / __/                     |
7 |                        |_|\__,_|____/ |_| |_____|                    |
8 |                                                                      |
9 |                               core system                            |
10 |                                                        (C) SuSE GmbH |
11 \----------------------------------------------------------------------/
12
13   File:       YQPkgSelList.h
14
15   Author:     Stefan Hundhammer <sh@suse.de>
16
17 /-*/
18
19
20 #ifndef YQPkgSelList_h
21 #define YQPkgSelList_h
22
23 #include <YQPkgObjList.h>
24
25
26 class YQPkgSelListItem;
27
28
29 /**
30  * @short Display a list of zypp::Selection objects.
31  **/
32 class YQPkgSelList : public YQPkgObjList
33 {
34     Q_OBJECT
35
36 public:
37
38     /**
39      * Constructor.
40      *
41      * Set 'autoFill' to 'false' if you don't want the list to be filled in the
42      * constructor. In that case, use fillList() (e.g., when connections are
43      * set up).
44      *
45      * Set 'autoFilter' to 'false' if there is no need to do (expensive)
46      * filtering because the 'filterMatch' signal is not connected anyway.
47      **/
48     YQPkgSelList( QWidget * parent, bool autoFill = true, bool autoFilter = true );
49
50     /**
51      * Destructor
52      **/
53     virtual ~YQPkgSelList();
54
55
56 public slots:
57
58     /**
59      * Filter according to the view's rules and current selection.
60      * Emits those signals:
61      *    filterStart()
62      *    filterMatch() for each pkg that matches the filter
63      *    filterFinished()
64      **/
65     void filter();
66
67     /**
68      * Same as filter(), but only if this widget is currently visible.
69      **/
70     void filterIfVisible();
71
72
73     /**
74      * Add a selection to the list. Connect a filter's filterMatch() signal to
75      * this slot. Remember to connect filterStart() to clear() (inherited from
76      * QListView).
77      **/
78     void addPkgSelItem( ZyppSel         selectable,
79                         ZyppSelection   selection );
80
81     /**
82      * Fill the selection list.
83      **/
84     void fillList();
85
86 public:
87
88     /**
89      * Returns the currently selected item or 0 if there is none.
90      **/
91     YQPkgSelListItem * selection() const;
92
93
94 signals:
95
96     /**
97      * Emitted when the filtering starts. Use this to clear package lists
98      * etc. prior to adding new entries.
99      **/
100     void filterStart();
101
102     /**
103      * Emitted during filtering for each pkg that matches the filter.
104      **/
105     void filterMatch( ZyppSel   selectable,
106                       ZyppPkg   pkg );
107
108     /**
109      * Emitted when filtering is finished.
110      **/
111     void filterFinished();
112 };
113
114
115
116 class YQPkgSelListItem: public YQPkgObjListItem
117 {
118 public:
119
120     /**
121      * Constructor
122      **/
123     YQPkgSelListItem( YQPkgSelList *    pkgSelList,
124                       ZyppSel           selectable,
125                       ZyppSelection     zyppSelection );
126
127     /**
128      * Destructor
129      **/
130     virtual ~YQPkgSelListItem();
131
132     /**
133      * Returns the original object within the package manager backend.
134      **/
135     ZyppSelection zyppSelection() const { return _zyppSelection; }
136
137     /**
138      * Comparison function used for sorting the list.
139      * Returns:
140      * -1 if this <  other
141      *  0 if this == other
142      * +1 if this >  other
143      *
144      * Reimplemented from QListViewItem:
145      * Sort by zypp::Selection::order() only.
146      **/
147     virtual int compare( QListViewItem *        other,
148                          int                    col,
149                          bool                   ascending ) const;
150
151     // Columns
152
153     int statusCol()     const   { return _pkgSelList->statusCol();      }
154     int summaryCol()    const   { return _pkgSelList->summaryCol();     }
155
156
157 protected:
158
159     /**
160      * Propagate status changes in this list to other lists:
161      * Have the solver transact all selections.
162      *
163      * Reimplemented from YQPkgObjListItem.
164      **/
165     virtual void applyChanges();
166
167     
168     // Data members
169
170     YQPkgSelList *      _pkgSelList;
171     ZyppSelection       _zyppSelection;
172 };
173
174
175 #endif // ifndef YQPkgSelList_h