libyui-qt-pkg  2.42.5
 All Classes Functions Variables Enumerations
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 
178  _searchFilterView->setSizePolicy( QSizePolicy::Minimum, // horizontal
179  QSizePolicy::Minimum ); // vertical
180  _secondaryFilters->addPage( _( "Search" ), _searchFilterView );
181 
182  connect( _searchFilterView, SIGNAL( filterStart() ),
183  _repoList, SLOT ( filter() ) );
184 
185  connect( _secondaryFilters, SIGNAL( currentChanged( QWidget * ) ),
186  this, SLOT ( filter() ) );
187 
188 
189  //
190  // Status change view
191  //
192 
193  _statusFilterView = new YQPkgStatusFilterView( parent );
194  YUI_CHECK_NEW( _statusFilterView );
195 
196  _searchFilterView->setSizePolicy( QSizePolicy::Minimum, // horizontal
197  QSizePolicy::Minimum ); // vertical
198 
199  _secondaryFilters->addPage( _( "Installation Summary" ), _statusFilterView );
200 
201  connect( _statusFilterView, SIGNAL( filterStart() ),
202  _repoList, SLOT ( filter() ) );
203 
204 
205  return _secondaryFilters;
206 }
207 
208 
210 {
211  _repoList->filter();
212 }
213 
214 
216 {
217  _repoList->filterIfVisible();
218 }
219 
220 
222  ZyppPkg pkg )
223 {
224  if ( secondaryFilterMatch( selectable, pkg ) )
225  emit filterMatch( selectable, pkg );
226 }
227 
228 
230  ZyppPkg pkg )
231 {
232  if ( secondaryFilterMatch( selectable, pkg ) )
233  emit filterNearMatch( selectable, pkg );
234 }
235 
236 
237 bool
239  ZyppPkg pkg )
240 {
241  if ( _allPackages->isVisible() )
242  {
243  return true;
244  }
245  else if ( _unmaintainedPackages->isVisible() )
246  {
247  return ( selectable->availableSize() == 0 );
248  }
249  else if ( _rpmGroupTagsFilterView->isVisible() )
250  {
251  return _rpmGroupTagsFilterView->check( selectable, pkg );
252  }
253  else if ( _searchFilterView->isVisible() )
254  {
255  return _searchFilterView->check( selectable, pkg );
256  }
257  else if ( _statusFilterView->isVisible() )
258  {
259  return _statusFilterView->check( selectable, pkg );
260  }
261  else
262  {
263  return true;
264  }
265 }
266 
267 
268 
269 
270 
271 
272 #include "YQPkgRepoFilterView.moc"