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"
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 Q3VBox * upper_vbox = new Q3VBox( splitter );
48 _repoList = new YQPkgRepoList( upper_vbox );
49 Q_CHECK_PTR( _repoList );
50 _repoList->setSizePolicy( QSizePolicy( QSizePolicy::Ignored, QSizePolicy::Expanding ) );// hor/vert
52 addVSpacing( upper_vbox, MARGIN );
55 // Directly propagate signals filterStart() and filterFinished()
56 // from primary filter to the outside
58 connect( _repoList, SIGNAL( filterStart() ),
59 this, SIGNAL( filterStart() ) );
61 connect( _repoList, SIGNAL( filterFinished() ),
62 this, SIGNAL( filterFinished() ) );
65 // Redirect filterMatch() and filterNearMatch() signals to secondary filter
67 connect( _repoList, SIGNAL( filterMatch ( ZyppSel, ZyppPkg ) ),
68 this, SLOT ( primaryFilterMatch ( ZyppSel, ZyppPkg ) ) );
70 connect( _repoList, SIGNAL( filterNearMatch ( ZyppSel, ZyppPkg ) ),
71 this, SLOT ( primaryFilterNearMatch ( ZyppSel, ZyppPkg ) ) );
74 QWidget * secondary_filters =
76 layoutSecondaryFilters( splitter );
79 splitter->setResizeMode( _repoList, QSplitter::Stretch );
80 splitter->setResizeMode( secondary_filters, QSplitter::FollowSizeHint );
85 YQPkgRepoFilterView::~YQPkgRepoFilterView()
92 YQPkgRepoFilterView::layoutSecondaryFilters( QWidget * parent )
94 Q3VBox *vbox = new Q3VBox( parent );
96 addVSpacing( vbox, MARGIN );
98 // Translators: This is a combo box where the user can apply a secondary filter
99 // in addition to the primary filter by repository - one of
100 // "all packages", "RPM groups", "search", "summary"
101 _secondaryFilters = new QY2ComboTabWidget( _( "&Secondary Filter:" ), vbox );
102 Q_CHECK_PTR( _secondaryFilters );
104 _secondaryFilters->setFrameStyle( Q3Frame::Plain );
105 _secondaryFilters->setLineWidth( 0 );
106 _secondaryFilters->setMidLineWidth( 0 );
107 _secondaryFilters->setMargin( 0 );
114 _allPackages = new QWidget( vbox );
115 Q_CHECK_PTR( _allPackages );
116 _secondaryFilters->addPage( _( "All Packages" ), _allPackages );
123 _rpmGroupTagsFilterView = new YQPkgRpmGroupTagsFilterView( vbox );
124 Q_CHECK_PTR( _rpmGroupTagsFilterView );
125 _secondaryFilters->addPage( _( "Package Groups" ), _rpmGroupTagsFilterView );
127 connect( _rpmGroupTagsFilterView, SIGNAL( filterStart() ),
128 _repoList, SLOT ( filter() ) );
132 // Package search view
135 _searchFilterView = new YQPkgSearchFilterView( vbox );
136 Q_CHECK_PTR( _searchFilterView );
137 _secondaryFilters->addPage( _( "Search" ), _searchFilterView );
139 connect( _searchFilterView, SIGNAL( filterStart() ),
140 _repoList, SLOT ( filter() ) );
142 connect( _secondaryFilters, SIGNAL( currentChanged( QWidget * ) ),
143 this, SLOT ( filter() ) );
147 // Status change view
150 _statusFilterView = new YQPkgStatusFilterView( parent );
151 Q_CHECK_PTR( _statusFilterView );
152 _secondaryFilters->addPage( _( "Installation Summary" ), _statusFilterView );
154 connect( _statusFilterView, SIGNAL( filterStart() ),
155 _repoList, SLOT ( filter() ) );
158 return _secondaryFilters;
162 void YQPkgRepoFilterView::filter()
168 void YQPkgRepoFilterView::filterIfVisible()
170 _repoList->filterIfVisible();
174 void YQPkgRepoFilterView::primaryFilterMatch( ZyppSel selectable,
177 if ( secondaryFilterMatch( selectable, pkg ) )
178 emit filterMatch( selectable, pkg );
182 void YQPkgRepoFilterView::primaryFilterNearMatch( ZyppSel selectable,
185 if ( secondaryFilterMatch( selectable, pkg ) )
186 emit filterNearMatch( selectable, pkg );
191 YQPkgRepoFilterView::secondaryFilterMatch( ZyppSel selectable,
194 if ( _allPackages->isVisible() )
198 else if ( _rpmGroupTagsFilterView->isVisible() )
200 return _rpmGroupTagsFilterView->check( selectable, pkg );
202 else if ( _searchFilterView->isVisible() )
204 return _searchFilterView->check( selectable, pkg );
206 else if ( _statusFilterView->isVisible() )
208 return _statusFilterView->check( selectable, pkg );
221 #include "YQPkgRepoFilterView.moc"