libyui-qt-pkg  2.45.13.1
YQPkgRepoFilterView.cc
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: YQPkgRepoFilterView.cc
35 
36  Author: Stefan Hundhammer <sh@suse.de>
37 
38  Textdomain "qt-pkg"
39 
40 /-*/
41 
42 
43 #define YUILogComponent "qt-pkg"
44 #include <YUILog.h>
45 #include <YUIException.h>
46 
47 #include <QVBoxLayout>
48 #include <QSplitter>
49 #include <QFrame>
50 
51 #include "QY2ComboTabWidget.h"
52 #include "QY2LayoutUtils.h"
53 #include "YQPkgRepoFilterView.h"
54 #include "YQPkgRepoList.h"
55 #include "YQPkgRpmGroupTagsFilterView.h"
56 #include "YQPkgSearchFilterView.h"
57 #include "YQPkgStatusFilterView.h"
58 #include "YQi18n.h"
59 
60 
62  : QWidget( parent )
63 {
64  QHBoxLayout *layout = new QHBoxLayout(this);
65  layout->setContentsMargins(0,0,0,0);
66 
67  QSplitter * splitter = new QSplitter( Qt::Vertical, this );
68  YUI_CHECK_NEW( splitter );
69 
70  layout->addWidget( splitter );
71 
72  _repoList = new YQPkgRepoList( this );
73  splitter->addWidget(_repoList);
74 
75  YUI_CHECK_NEW( _repoList );
76  _repoList->setSizePolicy( QSizePolicy( QSizePolicy::Ignored, QSizePolicy::Expanding ) );// hor/vert
77 
78  // Directly propagate signals filterStart() and filterFinished()
79  // from primary filter to the outside
80 
81  connect( _repoList, SIGNAL( filterStart() ),
82  this, SIGNAL( filterStart() ) );
83 
84  connect( _repoList, SIGNAL( filterFinished() ),
85  this, SIGNAL( filterFinished() ) );
86 
87 
88  // Redirect filterMatch() and filterNearMatch() signals to secondary filter
89 
90  connect( _repoList, SIGNAL( filterMatch ( ZyppSel, ZyppPkg ) ),
91  this, SLOT ( primaryFilterMatch ( ZyppSel, ZyppPkg ) ) );
92 
93  connect( _repoList, SIGNAL( filterNearMatch ( ZyppSel, ZyppPkg ) ),
94  this, SLOT ( primaryFilterNearMatch ( ZyppSel, ZyppPkg ) ) );
95 
96  layoutSecondaryFilters( splitter );
97 
98  splitter->setStretchFactor(0, 5);
99  splitter->setStretchFactor(1, 1);
100  splitter->setStretchFactor(2, 3);
101 
102 
103 }
104 
105 
107 {
108  // NOP
109 }
110 
111 ZyppRepo
113 {
114  YQPkgRepoListItem *selection = _repoList->selection();
115  if ( selection && selection->zyppRepo() )
116  return selection->zyppRepo();
117  return zypp::Repository::noRepository;
118 }
119 
120 QWidget *
122 {
123  QWidget *vbox = new QWidget( parent );
124  YUI_CHECK_NEW( vbox );
125 
126  QVBoxLayout *layout = new QVBoxLayout();
127  YUI_CHECK_NEW( layout );
128 
129  vbox->setLayout( layout );
130  layout->setContentsMargins( 0, 0, 0, 0 );
131 
132  // Translators: This is a combo box where the user can apply a secondary filter
133  // in addition to the primary filter by repository - one of
134  // "All packages", "RPM groups", "search", "summary"
135  //
136  // And yes, the colon really belongs there since this is one of the very
137  // few cases where a combo box label is left to the combo box rather than
138  // above it.
139  _secondaryFilters = new QY2ComboTabWidget( _( "&Secondary Filter:" ));
140  YUI_CHECK_NEW( _secondaryFilters );
141  layout->addWidget(_secondaryFilters);
142 
143  //
144  // All Packages
145  //
146 
147  _allPackages = new QWidget( this );
148  YUI_CHECK_NEW( _allPackages );
149  _secondaryFilters->addPage( _( "All Packages" ), _allPackages );
150 
151 
152  // Unmaintaned packages: Packages that are not provided in any of
153  // the configured repositories
154 
155  _unmaintainedPackages = new QWidget( this );
156  YUI_CHECK_NEW( _unmaintainedPackages );
157  _secondaryFilters->addPage( _( "Unmaintained Packages" ), _unmaintainedPackages );
158 
159  //
160  // RPM Groups
161  //
162 
163  _rpmGroupTagsFilterView = new YQPkgRpmGroupTagsFilterView( this );
164  YUI_CHECK_NEW( _rpmGroupTagsFilterView );
165  _secondaryFilters->addPage( _( "Package Groups" ), _rpmGroupTagsFilterView );
166 
167  connect( _rpmGroupTagsFilterView, SIGNAL( filterStart() ),
168  _repoList, SLOT ( filter() ) );
169 
170 
171  //
172  // Package search view
173  //
174 
175  _searchFilterView = new YQPkgSearchFilterView( this );
176  YUI_CHECK_NEW( _searchFilterView );
177  _secondaryFilters->addPage( _( "Search" ), _searchFilterView );
178 
179  connect( _searchFilterView, SIGNAL( filterStart() ),
180  _repoList, SLOT ( filter() ) );
181 
182  connect( _secondaryFilters, &QY2ComboTabWidget::currentChanged,
184 
185 
186  //
187  // Status change view
188  //
189 
190  _statusFilterView = new YQPkgStatusFilterView( parent );
191  YUI_CHECK_NEW( _statusFilterView );
192  _secondaryFilters->addPage( _( "Installation Summary" ), _statusFilterView );
193 
194  connect( _statusFilterView, SIGNAL( filterStart() ),
195  _repoList, SLOT ( filter() ) );
196 
197 
198  return _secondaryFilters;
199 }
200 
201 
203 {
204  _repoList->filter();
205 }
206 
207 
209 {
210  _repoList->filterIfVisible();
211 }
212 
213 
215  ZyppPkg pkg )
216 {
217  if ( secondaryFilterMatch( selectable, pkg ) )
218  emit filterMatch( selectable, pkg );
219 }
220 
221 
223  ZyppPkg pkg )
224 {
225  if ( secondaryFilterMatch( selectable, pkg ) )
226  emit filterNearMatch( selectable, pkg );
227 }
228 
229 
230 bool
232  ZyppPkg pkg )
233 {
234  if ( _allPackages->isVisible() )
235  {
236  return true;
237  }
238  else if ( _unmaintainedPackages->isVisible() )
239  {
240  return ( selectable->availableSize() == 0 );
241  }
242  else if ( _rpmGroupTagsFilterView->isVisible() )
243  {
244  return _rpmGroupTagsFilterView->check( selectable, pkg );
245  }
246  else if ( _searchFilterView->isVisible() )
247  {
248  return _searchFilterView->check( selectable, pkg );
249  }
250  else if ( _statusFilterView->isVisible() )
251  {
252  return _statusFilterView->check( selectable, pkg );
253  }
254  else
255  {
256  return true;
257  }
258 }
259 
260 
261 
262 
263 
264 
265 #include "YQPkgRepoFilterView.moc"
RPM group tags filter view: Display the RPM group tags tree and emit signals if any group tag is sele...
bool check(ZyppSel selectable, ZyppPkg pkg)
Check if &#39;pkg&#39; matches the selected RPM group.
void filter()
Filter according to the view&#39;s rules and current selection.
void filterNearMatch(ZyppSel selectable, ZyppPkg pkg)
Emitted during filtering for each pkg that matches the filter and the candidate package does not come...
void filterFinished()
Emitted when filtering is finished.
bool check(ZyppSel selectable, ZyppObj zyppObj)
Check one ResObject against the currently selected values.
QWidget * layoutSecondaryFilters(QWidget *parent)
Widget layout for the secondary filters.
YQPkgRepoFilterView(QWidget *parent)
Constructor.
YQPkgRepoListItem * selection() const
Returns the currently selected item or 0 if there is none.
void filterIfVisible()
Same as filter(), but only if this widget is currently visible.
Filter view for searching within packages.
void filter()
Filter according to the view&#39;s rules and current selection.
Filter view for packages that made problems during update.
Display a list of zypp::Selection objects.
Definition: YQPkgRepoList.h:58
bool secondaryFilterMatch(ZyppSel selectable, ZyppPkg pkg)
Check if pkg matches the the currently selected secondary filter.
ZyppRepo zyppRepo() const
Returns the ZYPP repository this item corresponds to.
void primaryFilterMatch(ZyppSel selectable, ZyppPkg pkg)
Propagate a filter match from the primary filter and appy any selected secondary filter(s) to it...
void filterMatch(ZyppSel selectable, ZyppPkg pkg)
Emitted during filtering for each pkg that matches the filter and the candidate package comes from th...
void primaryFilterNearMatch(ZyppSel selectable, ZyppPkg pkg)
Propagate a filter near match from the primary filter and appy any selected secondary filter(s) to it...
void filterStart()
Emitted when the filtering starts.
void filterIfVisible()
Same as filter(), but only if this widget is currently visible.
virtual ~YQPkgRepoFilterView()
Destructor.
bool check(ZyppSel selectable, ZyppObj pkg)
Check if pkg matches the filter criteria.
zypp::Repository selectedRepo() const
Current selected repository, or if nothing is selected.