libyui-qt-pkg  2.42.13
 All Classes Functions Variables Enumerations
YQPkgRepoList.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: YQPkgRepoList.h
35 
36  Author: Stefan Hundhammer <sh@suse.de>
37 
38 /-*/
39 
40 
41 #ifndef YQPkgRepoList_h
42 #define YQPkgRepoList_h
43 
44 #include "YQZypp.h"
45 #include "QY2ListView.h"
46 #include <zypp/Repository.h>
47 #include <zypp/Product.h>
48 
49 
50 class YQPkgRepoListItem;
51 
52 typedef zypp::Repository ZyppRepo;
53 
54 
55 /**
56  * @short Display a list of zypp::Selection objects.
57  **/
58 class YQPkgRepoList : public QY2ListView
59 {
60  Q_OBJECT
61 
62 public:
63 
64  /**
65  * Constructor
66  **/
67  YQPkgRepoList( QWidget * parent );
68 
69  /**
70  * Destructor
71  **/
72  virtual ~YQPkgRepoList();
73 
74  /**
75  * Returns the number of enabled repositories.
76  **/
77  static int countEnabledRepositories();
78 
79 
80 public slots:
81 
82  /**
83  * Filter according to the view's rules and current selection.
84  * Emits those signals:
85  * filterStart()
86  * filterMatch() for each pkg that matches the filter
87  * filterFinished()
88  **/
89  void filter();
90 
91  /**
92  * Same as filter(), but only if this widget is currently visible.
93  **/
94  void filterIfVisible();
95 
96  /**
97  * Add a repository to the list.
98  **/
99  void addRepo( ZyppRepo repo );
100 
101 
102 public:
103 
104  // Column numbers
105 
106  int nameCol() const { return _nameCol; }
107  int urlCol() const { return _urlCol; }
108 
109 
110  /**
111  * Returns the currently selected item or 0 if there is none.
112  **/
113  YQPkgRepoListItem * selection() const;
114 
115 
116 signals:
117 
118  /**
119  * Emitted when the filtering starts. Use this to clear package lists
120  * etc. prior to adding new entries.
121  **/
122  void filterStart();
123 
124  /**
125  * Emitted during filtering for each pkg that matches the filter
126  * and the candidate package comes from the respective repository
127  **/
128  void filterMatch( ZyppSel selectable,
129  ZyppPkg pkg );
130 
131  /**
132  * Emitted during filtering for each pkg that matches the filter
133  * and the candidate package does not come from the respective repository
134  **/
135  void filterNearMatch( 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  * Fill the list.
148  **/
149  void fillList();
150 
151 
152 private:
153 
154  //
155  // Data members
156  //
157 
158  int _nameCol;
159  int _urlCol;
160 
161 };
162 
163 
164 
165 class YQPkgRepoListItem: public QY2ListViewItem
166 {
167 public:
168 
169  /**
170  * Constructor
171  **/
172  YQPkgRepoListItem( YQPkgRepoList *parentList, ZyppRepo repo );
173 
174  /**
175  * Destructor
176  **/
177  virtual ~YQPkgRepoListItem();
178 
179  /**
180  * Returns the ZYPP repository this item corresponds to
181  **/
182  ZyppRepo zyppRepo() const { return _zyppRepo; }
183 
184  /**
185  * Returns the parent list
186  **/
187  const YQPkgRepoList * repoList() const { return _repoList; }
188 
189  /**
190  * Returns the product on a source if it has one single product
191  * or 0 if there are no or multiple products.
192  **/
193  static ZyppProduct singleProduct( ZyppRepo repo );
194 
195 
196  // Columns
197 
198  int nameCol() const { return _repoList->nameCol(); }
199  int urlCol() const { return _repoList->urlCol(); }
200 
201  virtual bool operator< ( const QTreeWidgetItem & other ) const;
202 protected:
203 
204  // Data members
205 
206  YQPkgRepoList * _repoList;
207  ZyppRepo _zyppRepo;
208 };
209 
210 
211 #endif // ifndef YQPkgRepoList_h
static int countEnabledRepositories()
YQPkgRepoList(QWidget *parent)
void filterNearMatch(ZyppSel selectable, ZyppPkg pkg)
void filterStart()
const YQPkgRepoList * repoList() const
virtual ~YQPkgRepoList()
YQPkgRepoListItem * selection() const
YQPkgRepoListItem(YQPkgRepoList *parentList, ZyppRepo repo)
void filterFinished()
void filterMatch(ZyppSel selectable, ZyppPkg pkg)
virtual ~YQPkgRepoListItem()
static ZyppProduct singleProduct(ZyppRepo repo)
Display a list of zypp::Selection objects.
Definition: YQPkgRepoList.h:58
ZyppRepo zyppRepo() const
void addRepo(ZyppRepo repo)
void filterIfVisible()