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);
52 Q_CHECK_PTR( _repoList );
53 _repoList->setSizePolicy( QSizePolicy( QSizePolicy::Ignored, QSizePolicy::Expanding ) );// hor/vert
55 //addVSpacing( upper_vbox, MARGIN );
58 // Directly propagate signals filterStart() and filterFinished()
59 // from primary filter to the outside
61 connect( _repoList, SIGNAL( filterStart() ),
62 this, SIGNAL( filterStart() ) );
64 connect( _repoList, SIGNAL( filterFinished() ),
65 this, SIGNAL( filterFinished() ) );
68 // Redirect filterMatch() and filterNearMatch() signals to secondary filter
70 connect( _repoList, SIGNAL( filterMatch ( ZyppSel, ZyppPkg ) ),
71 this, SLOT ( primaryFilterMatch ( ZyppSel, ZyppPkg ) ) );
73 connect( _repoList, SIGNAL( filterNearMatch ( ZyppSel, ZyppPkg ) ),
74 this, SLOT ( primaryFilterNearMatch ( ZyppSel, ZyppPkg ) ) );
77 QWidget * secondary_filters =
79 layoutSecondaryFilters( splitter );
82 splitter->setResizeMode( _repoList, QSplitter::Stretch );
83 splitter->setResizeMode( secondary_filters, QSplitter::FollowSizeHint );
88 YQPkgRepoFilterView::~YQPkgRepoFilterView()
95 YQPkgRepoFilterView::layoutSecondaryFilters( QWidget * parent )
98 QVBoxLayout *vbox = new QVBoxLayout( parent );
100 //addVSpacing( vbox, MARGIN );
102 // Translators: This is a combo box where the user can apply a secondary filter
103 // in addition to the primary filter by repository - one of
104 // "All packages", "RPM groups", "search", "summary"
106 // And yes, the colon really belongs there since this is one of the very
107 // few cases where a combo box label is left to the combo box rather than
109 _secondaryFilters = new QY2ComboTabWidget( _( "&Secondary Filter:" ));
110 vbox->addWidget(_secondaryFilters);
112 Q_CHECK_PTR( _secondaryFilters );
114 // _secondaryFilters->setFrameStyle( Q3Frame::Plain );
115 // _secondaryFilters->setLineWidth( 0 );
116 // _secondaryFilters->setMidLineWidth( 0 );
117 // _secondaryFilters->setMargin( 0 );
124 _allPackages = new QWidget( this );
125 vbox->addWidget(_allPackages);
126 Q_CHECK_PTR( _allPackages );
127 _secondaryFilters->addPage( _( "All Packages" ), _allPackages );
134 _rpmGroupTagsFilterView = new YQPkgRpmGroupTagsFilterView( this );
135 vbox->addWidget(_rpmGroupTagsFilterView);
137 Q_CHECK_PTR( _rpmGroupTagsFilterView );
138 _secondaryFilters->addPage( _( "Package Groups" ), _rpmGroupTagsFilterView );
140 connect( _rpmGroupTagsFilterView, SIGNAL( filterStart() ),
141 _repoList, SLOT ( filter() ) );
145 // Package search view
148 _searchFilterView = new YQPkgSearchFilterView(this);
149 vbox->addWidget(_searchFilterView);
150 Q_CHECK_PTR( _searchFilterView );
151 _secondaryFilters->addPage( _( "Search" ), _searchFilterView );
153 connect( _searchFilterView, SIGNAL( filterStart() ),
154 _repoList, SLOT ( filter() ) );
156 connect( _secondaryFilters, SIGNAL( currentChanged( QWidget * ) ),
157 this, SLOT ( filter() ) );
161 // Status change view
164 _statusFilterView = new YQPkgStatusFilterView( parent );
165 Q_CHECK_PTR( _statusFilterView );
166 _secondaryFilters->addPage( _( "Installation Summary" ), _statusFilterView );
168 connect( _statusFilterView, SIGNAL( filterStart() ),
169 _repoList, SLOT ( filter() ) );
172 return _secondaryFilters;
176 void YQPkgRepoFilterView::filter()
182 void YQPkgRepoFilterView::filterIfVisible()
184 _repoList->filterIfVisible();
188 void YQPkgRepoFilterView::primaryFilterMatch( ZyppSel selectable,
191 if ( secondaryFilterMatch( selectable, pkg ) )
192 emit filterMatch( selectable, pkg );
196 void YQPkgRepoFilterView::primaryFilterNearMatch( ZyppSel selectable,
199 if ( secondaryFilterMatch( selectable, pkg ) )
200 emit filterNearMatch( selectable, pkg );
205 YQPkgRepoFilterView::secondaryFilterMatch( ZyppSel selectable,
208 if ( _allPackages->isVisible() )
212 else if ( _rpmGroupTagsFilterView->isVisible() )
214 return _rpmGroupTagsFilterView->check( selectable, pkg );
216 else if ( _searchFilterView->isVisible() )
218 return _searchFilterView->check( selectable, pkg );
220 else if ( _statusFilterView->isVisible() )
222 return _statusFilterView->check( selectable, pkg );
235 #include "YQPkgRepoFilterView.moc"