libyui-qt-pkg  2.47.2
YQPkgServiceList.h
1 /**************************************************************************
2 Copyright (C) 2018 SUSE LLC
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 #ifndef YQPkgServiceList_h
23 #define YQPkgServiceList_h
24 
25 #include <string>
26 #include "YQZypp.h"
27 #include "QY2ListView.h"
28 #include <zypp/Product.h>
29 
30 
32 namespace zypp {
33  class RepoManager;
34 }
35 
36 // just a service name
37 typedef std::string ZyppService;
38 
39 
40 /**
41  * @short A widget to display a list of libzypp services.
42  **/
43 class YQPkgServiceList : public QY2ListView
44 {
45  Q_OBJECT
46 
47 public:
48 
49  /**
50  * Constructor
51  **/
52  YQPkgServiceList( QWidget * parent );
53 
54  /**
55  * Destructor
56  **/
57  virtual ~YQPkgServiceList();
58 
59 
60 public slots:
61 
62  /**
63  * Filter according to the view's rules and current selection.
64  * Emits those signals:
65  * filterStart()
66  * filterMatch() for each pkg that matches the filter
67  * filterFinished()
68  **/
69  void filter();
70 
71  /**
72  * Same as filter(), but only if this widget is currently visible.
73  **/
74  void filterIfVisible();
75 
76  /**
77  * Add a service to the list.
78  **/
79  void addService( ZyppService service, const zypp::RepoManager &mgr );
80 
81 
82 public:
83 
84  // Column numbers
85  int nameCol() const { return _nameCol; }
86 
87  /**
88  * Returns the currently selected item or 0 if there is none.
89  **/
91 
92 
93 signals:
94 
95  /**
96  * Emitted when the filtering starts. Use this to clear package lists
97  * etc. prior to adding new entries.
98  **/
99  void filterStart();
100 
101  /**
102  * Emitted during filtering for each pkg that matches the filter
103  * and the candidate package comes from the respective repository
104  **/
105  void filterMatch( ZyppSel selectable,
106  ZyppPkg pkg );
107 
108  /**
109  * Emitted during filtering for each pkg that matches the filter
110  * and the candidate package does not come from the respective repository
111  **/
112  void filterNearMatch( ZyppSel selectable,
113  ZyppPkg pkg );
114 
115  /**
116  * Emitted when filtering is finished.
117  **/
118  void filterFinished();
119 
120 
121 protected slots:
122 
123  /**
124  * Fill the list.
125  **/
126  void fillList();
127 
128 
129 private:
130 
131  //
132  // Data members
133  //
134 
135  int _nameCol;
136 };
137 
138 
139 
140 class YQPkgServiceListItem: public QY2ListViewItem
141 {
142 public:
143 
144  /**
145  * Constructor
146  **/
147  YQPkgServiceListItem( YQPkgServiceList *parentList, ZyppService service, const zypp::RepoManager &mgr );
148 
149  /**
150  * Destructor
151  **/
152  virtual ~YQPkgServiceListItem();
153 
154  /**
155  * Returns the ZYPP service this item corresponds to (its alias)
156  **/
157  ZyppService zyppService() const { return _zyppService; }
158 
159  /**
160  * Returns the ZYPP service name this item corresponds to
161  **/
162  std::string zyppServiceName() const { return _zyppServiceName; }
163 
164  /**
165  * Returns the parent list
166  **/
167  const YQPkgServiceList * serviceList() const { return _serviceList; }
168 
169  /**
170  * Returns the product on a source if it has one single product
171  * or 0 if there are no or multiple products.
172  **/
173  static ZyppProduct singleProduct( ZyppService service );
174 
175 
176  // Columns
177 
178  int nameCol() const { return _serviceList->nameCol(); }
179 
180  virtual bool operator< ( const QTreeWidgetItem & other ) const;
181 protected:
182 
183  // Data members
184 
185  YQPkgServiceList * _serviceList;
186  // the zypp service
187  ZyppService _zyppService;
188  std::string _zyppServiceName;
189 };
190 
191 
192 #endif // ifndef YQPkgServiceList_h
YQPkgServiceList::filterStart
void filterStart()
Emitted when the filtering starts.
YQPkgServiceList::filterIfVisible
void filterIfVisible()
Same as filter(), but only if this widget is currently visible.
Definition: YQPkgServiceList.cc:110
YQPkgServiceList::filter
void filter()
Filter according to the view's rules and current selection.
Definition: YQPkgServiceList.cc:117
YQPkgServiceList::filterNearMatch
void filterNearMatch(ZyppSel selectable, ZyppPkg pkg)
Emitted during filtering for each pkg that matches the filter and the candidate package does not come...
YQPkgServiceList::filterFinished
void filterFinished()
Emitted when filtering is finished.
YQPkgServiceList::fillList
void fillList()
Fill the list.
Definition: YQPkgServiceList.cc:82
YQPkgServiceListItem::singleProduct
static ZyppProduct singleProduct(ZyppService service)
Returns the product on a source if it has one single product or 0 if there are no or multiple product...
Definition: YQPkgServiceList.cc:226
YQPkgServiceListItem::YQPkgServiceListItem
YQPkgServiceListItem(YQPkgServiceList *parentList, ZyppService service, const zypp::RepoManager &mgr)
Constructor.
Definition: YQPkgServiceList.cc:178
YQPkgServiceListItem::~YQPkgServiceListItem
virtual ~YQPkgServiceListItem()
Destructor.
Definition: YQPkgServiceList.cc:220
YQPkgServiceList::selection
YQPkgServiceListItem * selection() const
Returns the currently selected item or 0 if there is none.
Definition: YQPkgServiceList.cc:172
YQPkgServiceListItem::zyppServiceName
std::string zyppServiceName() const
Returns the ZYPP service name this item corresponds to.
Definition: YQPkgServiceList.h:161
YQPkgServiceList
A widget to display a list of libzypp services.
Definition: YQPkgServiceList.h:42
YQPkgServiceList::addService
void addService(ZyppService service, const zypp::RepoManager &mgr)
Add a service to the list.
Definition: YQPkgServiceList.cc:165
YQPkgServiceListItem::zyppService
ZyppService zyppService() const
Returns the ZYPP service this item corresponds to (its alias)
Definition: YQPkgServiceList.h:156
YQPkgServiceListItem::serviceList
const YQPkgServiceList * serviceList() const
Returns the parent list.
Definition: YQPkgServiceList.h:166
YQPkgServiceListItem
Definition: YQPkgServiceList.h:139
YQPkgServiceList::filterMatch
void filterMatch(ZyppSel selectable, ZyppPkg pkg)
Emitted during filtering for each pkg that matches the filter and the candidate package comes from th...
YQPkgServiceList::YQPkgServiceList
YQPkgServiceList(QWidget *parent)
Constructor.
Definition: YQPkgServiceList.cc:49
YQPkgServiceList::~YQPkgServiceList
virtual ~YQPkgServiceList()
Destructor.
Definition: YQPkgServiceList.cc:76