1 /*---------------------------------------------------------------------\
3 | __ __ ____ _____ ____ |
4 | \ \ / /_ _/ ___|_ _|___ \ |
5 | \ V / _` \___ \ | | __) | |
6 | | | (_| |___) || | / __/ |
7 | |_|\__,_|____/ |_| |_____| |
11 \----------------------------------------------------------------------/
13 File: YQPkgRepoFilterView.cc
15 Author: Stefan Hundhammer <sh@suse.de>
17 Textdomain "packages-qt"
22 #define y2log_component "qt-pkg"
23 #include <ycp/y2log.h>
25 #include <qsplitter.h>
27 #include "QY2ComboTabWidget.h"
28 #include "QY2LayoutUtils.h"
29 #include <QVBoxLayout>
31 #include "YQPkgRepoFilterView.h"
32 #include "YQPkgRepoList.h"
33 #include "YQPkgRpmGroupTagsFilterView.h"
34 #include "YQPkgSearchFilterView.h"
35 #include "YQPkgStatusFilterView.h"
41 YQPkgRepoFilterView::YQPkgRepoFilterView( QWidget * parent )
44 QSplitter * splitter = new QSplitter( Qt::Vertical, this );
45 Q_CHECK_PTR( splitter );
47 //QVBoxLayout * upper_vbox = new QVBoxLayout( splitter );
49 _repoList = new YQPkgRepoList( this );
50 //upper_vbox->addWidget(_repoList);
51 splitter->addWidget(_repoList);
53 Q_CHECK_PTR( _repoList );
54 _repoList->setSizePolicy( QSizePolicy( QSizePolicy::Ignored, QSizePolicy::Expanding ) );// hor/vert
56 //addVSpacing( upper_vbox, MARGIN );
59 // Directly propagate signals filterStart() and filterFinished()
60 // from primary filter to the outside
62 connect( _repoList, SIGNAL( filterStart() ),
63 this, SIGNAL( filterStart() ) );
65 connect( _repoList, SIGNAL( filterFinished() ),
66 this, SIGNAL( filterFinished() ) );
69 // Redirect filterMatch() and filterNearMatch() signals to secondary filter
71 connect( _repoList, SIGNAL( filterMatch ( ZyppSel, ZyppPkg ) ),
72 this, SLOT ( primaryFilterMatch ( ZyppSel, ZyppPkg ) ) );
74 connect( _repoList, SIGNAL( filterNearMatch ( ZyppSel, ZyppPkg ) ),
75 this, SLOT ( primaryFilterNearMatch ( ZyppSel, ZyppPkg ) ) );
78 QWidget * secondary_filters =
80 layoutSecondaryFilters( splitter );
83 splitter->setResizeMode( _repoList, QSplitter::Stretch );
84 splitter->setResizeMode( secondary_filters, QSplitter::FollowSizeHint );
89 YQPkgRepoFilterView::~YQPkgRepoFilterView()
96 YQPkgRepoFilterView::layoutSecondaryFilters( QWidget * parent )
98 QWidget *vbox = new QWidget(parent);
101 QVBoxLayout *layout = new QVBoxLayout();
102 vbox->setLayout(layout);
104 layout->addSpacing( MARGIN );
106 // Translators: This is a combo box where the user can apply a secondary filter
107 // in addition to the primary filter by repository - one of
108 // "All packages", "RPM groups", "search", "summary"
110 // And yes, the colon really belongs there since this is one of the very
111 // few cases where a combo box label is left to the combo box rather than
113 _secondaryFilters = new QY2ComboTabWidget( _( "&Secondary Filter:" ));
114 layout->addWidget(_secondaryFilters);
116 Q_CHECK_PTR( _secondaryFilters );
118 // _secondaryFilters->setFrameStyle( Q3Frame::Plain );
119 // _secondaryFilters->setLineWidth( 0 );
120 // _secondaryFilters->setMidLineWidth( 0 );
121 // _secondaryFilters->setMargin( 0 );
128 _allPackages = new QWidget( this );
129 layout->addWidget(_allPackages);
130 Q_CHECK_PTR( _allPackages );
131 _secondaryFilters->addPage( _( "All Packages" ), _allPackages );
138 _rpmGroupTagsFilterView = new YQPkgRpmGroupTagsFilterView( this );
139 layout->addWidget(_rpmGroupTagsFilterView);
141 Q_CHECK_PTR( _rpmGroupTagsFilterView );
142 _secondaryFilters->addPage( _( "Package Groups" ), _rpmGroupTagsFilterView );
144 connect( _rpmGroupTagsFilterView, SIGNAL( filterStart() ),
145 _repoList, SLOT ( filter() ) );
149 // Package search view
152 _searchFilterView = new YQPkgSearchFilterView(this);
153 layout->addWidget(_searchFilterView);
154 Q_CHECK_PTR( _searchFilterView );
155 _secondaryFilters->addPage( _( "Search" ), _searchFilterView );
157 connect( _searchFilterView, SIGNAL( filterStart() ),
158 _repoList, SLOT ( filter() ) );
160 connect( _secondaryFilters, SIGNAL( currentChanged( QWidget * ) ),
161 this, SLOT ( filter() ) );
165 // Status change view
168 _statusFilterView = new YQPkgStatusFilterView( parent );
169 Q_CHECK_PTR( _statusFilterView );
170 _secondaryFilters->addPage( _( "Installation Summary" ), _statusFilterView );
172 connect( _statusFilterView, SIGNAL( filterStart() ),
173 _repoList, SLOT ( filter() ) );
176 return _secondaryFilters;
180 void YQPkgRepoFilterView::filter()
186 void YQPkgRepoFilterView::filterIfVisible()
188 _repoList->filterIfVisible();
192 void YQPkgRepoFilterView::primaryFilterMatch( ZyppSel selectable,
195 if ( secondaryFilterMatch( selectable, pkg ) )
196 emit filterMatch( selectable, pkg );
200 void YQPkgRepoFilterView::primaryFilterNearMatch( ZyppSel selectable,
203 if ( secondaryFilterMatch( selectable, pkg ) )
204 emit filterNearMatch( selectable, pkg );
209 YQPkgRepoFilterView::secondaryFilterMatch( ZyppSel selectable,
212 if ( _allPackages->isVisible() )
216 else if ( _rpmGroupTagsFilterView->isVisible() )
218 return _rpmGroupTagsFilterView->check( selectable, pkg );
220 else if ( _searchFilterView->isVisible() )
222 return _searchFilterView->check( selectable, pkg );
224 else if ( _statusFilterView->isVisible() )
226 return _statusFilterView->check( selectable, pkg );
239 #include "YQPkgRepoFilterView.moc"