libyui-qt-pkg  2.45.27
YQPkgServiceFilterView.cc
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 Textdomain "qt-pkg"
20 
21 */
22 
23 #define YUILogComponent "qt-pkg"
24 #include <YUILog.h>
25 #include <YUIException.h>
26 
27 #include "YQZypp.h"
28 #include "YQPkgServiceFilterView.h"
29 #include "YQPkgServiceList.h"
30 
32  : YQPkgSecondaryFilterView( parent )
33 {
34  _serviceList = new YQPkgServiceList( this );
35  YUI_CHECK_NEW( _serviceList );
36  init(_serviceList);
37 }
38 
40 {
41  // NOP
42 }
43 
44 void YQPkgServiceFilterView::primaryFilter()
45 {
46  _serviceList->filter();
47 }
48 
49 void YQPkgServiceFilterView::primaryFilterIfVisible()
50 {
51  _serviceList->filterIfVisible();
52 }
53 
54 // check if a libzypp service is present
56 {
57  bool ret = std::any_of(ZyppRepositoriesBegin(), ZyppRepositoriesEnd(), [&](const zypp::Repository& repo) {
58  // if the repository does not belong to any service then the service name is empty
59  return !repo.info().service().empty();
60  });
61 
62  yuiMilestone() << "Found a libzypp service: " << ret << std::endl;
63  return ret;
64 }
65 
void filter()
Filter according to the view&#39;s rules and current selection.
static bool any_service()
Is any enabled libzypp service present?
YQPkgServiceFilterView(QWidget *parent)
Constructor.
void filterIfVisible()
Same as filter(), but only if this widget is currently visible.
virtual ~YQPkgServiceFilterView()
Destructor.
This is a base class for filter views containing a secondary filter.
void init(QWidget *primary_widget)
Initialize the primary widget.
A widget to display a list of libzypp services.