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 "YQPkgRepoFilterView.h"
30 #include "YQPkgRepoList.h"
31 #include "YQPkgRpmGroupTagsFilterView.h"
32 #include "YQPkgSearchFilterView.h"
33 #include "YQPkgStatusFilterView.h"
39 YQPkgRepoFilterView::YQPkgRepoFilterView( QWidget * parent )
42 QSplitter * splitter = new QSplitter( QSplitter::Vertical, this );
43 CHECK_PTR( splitter );
45 QVBox * upper_vbox = new QVBox( splitter );
46 _repoList = new YQPkgRepoList( upper_vbox );
47 CHECK_PTR( _repoList );
48 _repoList->setSizePolicy( QSizePolicy( QSizePolicy::Ignored, QSizePolicy::Expanding ) );// hor/vert
50 addVSpacing( upper_vbox, MARGIN );
53 // Directly propagate signals filterStart() and filterFinished()
54 // from primary filter to the outside
56 connect( _repoList, SIGNAL( filterStart() ),
57 this, SIGNAL( filterStart() ) );
59 connect( _repoList, SIGNAL( filterFinished() ),
60 this, SIGNAL( filterFinished() ) );
63 // Redirect filterMatch() and filterNearMatch() signals to secondary filter
65 connect( _repoList, SIGNAL( filterMatch ( ZyppSel, ZyppPkg ) ),
66 this, SLOT ( primaryFilterMatch ( ZyppSel, ZyppPkg ) ) );
68 connect( _repoList, SIGNAL( filterNearMatch ( ZyppSel, ZyppPkg ) ),
69 this, SLOT ( primaryFilterNearMatch ( ZyppSel, ZyppPkg ) ) );
72 QWidget * secondary_filters =
74 layoutSecondaryFilters( splitter );
77 splitter->setResizeMode( _repoList, QSplitter::Stretch );
78 splitter->setResizeMode( secondary_filters, QSplitter::FollowSizeHint );
83 YQPkgRepoFilterView::~YQPkgRepoFilterView()
90 YQPkgRepoFilterView::layoutSecondaryFilters( QWidget * parent )
92 QVBox *vbox = new QVBox( parent );
94 addVSpacing( vbox, MARGIN );
96 // Translators: This is a combo box where the user can apply a secondary filter
97 // in addition to the primary filter by repository - one of
98 // "all packages", "RPM groups", "search", "summary"
99 _secondaryFilters = new QY2ComboTabWidget( _( "&Secondary Filter:" ), vbox );
100 CHECK_PTR( _secondaryFilters );
102 _secondaryFilters->setFrameStyle( QFrame::Plain );
103 _secondaryFilters->setLineWidth( 0 );
104 _secondaryFilters->setMidLineWidth( 0 );
105 _secondaryFilters->setMargin( 0 );
112 _allPackages = new QWidget( vbox );
113 CHECK_PTR( _allPackages );
114 _secondaryFilters->addPage( _( "All Packages" ), _allPackages );
121 _rpmGroupTagsFilterView = new YQPkgRpmGroupTagsFilterView( vbox );
122 CHECK_PTR( _rpmGroupTagsFilterView );
123 _secondaryFilters->addPage( _( "Package Groups" ), _rpmGroupTagsFilterView );
125 connect( _rpmGroupTagsFilterView, SIGNAL( filterStart() ),
126 _repoList, SLOT ( filter() ) );
130 // Package search view
133 _searchFilterView = new YQPkgSearchFilterView( vbox );
134 CHECK_PTR( _searchFilterView );
135 _secondaryFilters->addPage( _( "Search" ), _searchFilterView );
137 connect( _searchFilterView, SIGNAL( filterStart() ),
138 _repoList, SLOT ( filter() ) );
140 connect( _secondaryFilters, SIGNAL( currentChanged( QWidget * ) ),
141 this, SLOT ( filter() ) );
145 // Status change view
148 _statusFilterView = new YQPkgStatusFilterView( parent );
149 CHECK_PTR( _statusFilterView );
150 _secondaryFilters->addPage( _( "Installation Summary" ), _statusFilterView );
152 connect( _statusFilterView, SIGNAL( filterStart() ),
153 _repoList, SLOT ( filter() ) );
156 return _secondaryFilters;
160 void YQPkgRepoFilterView::filter()
166 void YQPkgRepoFilterView::filterIfVisible()
168 _repoList->filterIfVisible();
172 void YQPkgRepoFilterView::primaryFilterMatch( ZyppSel selectable,
175 if ( secondaryFilterMatch( selectable, pkg ) )
176 emit filterMatch( selectable, pkg );
180 void YQPkgRepoFilterView::primaryFilterNearMatch( ZyppSel selectable,
183 if ( secondaryFilterMatch( selectable, pkg ) )
184 emit filterNearMatch( selectable, pkg );
189 YQPkgRepoFilterView::secondaryFilterMatch( ZyppSel selectable,
192 if ( _allPackages->isVisible() )
196 else if ( _rpmGroupTagsFilterView->isVisible() )
198 return _rpmGroupTagsFilterView->check( selectable, pkg );
200 else if ( _searchFilterView->isVisible() )
202 return _searchFilterView->check( selectable, pkg );
204 else if ( _statusFilterView->isVisible() )
206 return _statusFilterView->check( selectable, pkg );
219 #include "YQPkgRepoFilterView.moc"