]> icculus.org git repositories - duncan/yast2-qt4.git/blob - src/pkg/YQPkgRepoList.h
- Don't create layouts with parent. Qt 4.x automatically reparents
[duncan/yast2-qt4.git] / src / pkg / YQPkgRepoList.h
1 /*---------------------------------------------------------------------\
2 |                                                                      |
3 |                      __   __    ____ _____ ____                      |
4 |                      \ \ / /_ _/ ___|_   _|___ \                     |
5 |                       \ V / _` \___ \ | |   __) |                    |
6 |                        | | (_| |___) || |  / __/                     |
7 |                        |_|\__,_|____/ |_| |_____|                    |
8 |                                                                      |
9 |                               core system                            |
10 |                                                        (C) SuSE GmbH |
11 \----------------------------------------------------------------------/
12
13   File:       YQPkgRepoList.h
14
15   Author:     Stefan Hundhammer <sh@suse.de>
16
17 /-*/
18
19
20 #ifndef YQPkgRepoList_h
21 #define YQPkgRepoList_h
22
23 #include "YQZypp.h"
24 #include "QY2ListView.h"
25 #include <zypp/Repository.h>
26 #include <zypp/Product.h>
27
28
29 class YQPkgRepoListItem;
30
31 typedef zypp::Repository        ZyppRepo;
32
33
34 /**
35  * @short Display a list of zypp::Selection objects.
36  **/
37 class YQPkgRepoList : public QY2ListView
38 {
39     Q_OBJECT
40
41 public:
42
43     /**
44      * Constructor
45      **/
46     YQPkgRepoList( QWidget * parent );
47
48     /**
49      * Destructor
50      **/
51     virtual ~YQPkgRepoList();
52
53     /**
54      * Returns the number of enabled repositories.
55      **/
56     static int countEnabledRepositories();
57
58
59 public slots:
60
61     /**
62      * Filter according to the view's rules and current selection.
63      * Emits those signals:
64      *    filterStart()
65      *    filterMatch() for each pkg that matches the filter
66      *    filterFinished()
67      **/
68     void filter();
69
70     /**
71      * Same as filter(), but only if this widget is currently visible.
72      **/
73     void filterIfVisible();
74
75     /**
76      * Add a repository to the list.
77      **/
78     void addRepo( ZyppRepo repo );
79
80
81 public:
82
83     // Column numbers
84
85     int nameCol()       const   { return _nameCol;      }
86     int urlCol()        const   { return _urlCol;       }
87
88
89     /**
90      * Returns the currently selected item or 0 if there is none.
91      **/
92     YQPkgRepoListItem * selection() const;
93
94
95 signals:
96
97     /**
98      * Emitted when the filtering starts. Use this to clear package lists
99      * etc. prior to adding new entries.
100      **/
101     void filterStart();
102
103     /**
104      * Emitted during filtering for each pkg that matches the filter
105      * and the candidate package comes from the respective repository
106      **/
107     void filterMatch( ZyppSel   selectable,
108                       ZyppPkg   pkg );
109
110     /**
111      * Emitted during filtering for each pkg that matches the filter
112      * and the candidate package does not come from the respective repository
113      **/
114     void filterNearMatch( ZyppSel       selectable,
115                           ZyppPkg       pkg );
116
117     /**
118      * Emitted when filtering is finished.
119      **/
120     void filterFinished();
121
122
123 protected slots:
124
125     /**
126      * Fill the list.
127      **/
128     void fillList();
129
130
131 private:
132
133     //
134     // Data members
135     //
136
137     int _nameCol;
138     int _urlCol;
139
140 };
141
142
143
144 class YQPkgRepoListItem: public QY2ListViewItem
145 {
146 public:
147
148     /**
149      * Constructor
150      **/
151     YQPkgRepoListItem( YQPkgRepoList *parentList, ZyppRepo repo );
152
153     /**
154      * Destructor
155      **/
156     virtual ~YQPkgRepoListItem();
157
158     /**
159      * Returns the ZYPP repository this item corresponds to
160      **/
161     ZyppRepo zyppRepo() const { return _zyppRepo; }
162
163     /**
164      * Returns the parent list
165      **/
166     const YQPkgRepoList * repoList() const { return _repoList; }
167
168     /**
169      * Returns the product on a source if it has one single product
170      * or 0 if there are no or multiple products.
171      **/
172     static ZyppProduct singleProduct( ZyppRepo repo );
173
174
175     // Columns
176
177     int nameCol()       const   { return _repoList->nameCol();  }
178     int urlCol()        const   { return _repoList->urlCol();   }
179
180 protected:
181
182     // Data members
183
184     YQPkgRepoList *             _repoList;
185     ZyppRepo                    _zyppRepo;
186 };
187
188
189 #endif // ifndef YQPkgRepoList_h