]> icculus.org git repositories - duncan/yast2-qt4.git/blob - src/pkg/YQPkgRepoFilterView.cc
merge Huha's ydialog changes
[duncan/yast2-qt4.git] / src / pkg / YQPkgRepoFilterView.cc
1 /*---------------------------------------------------------------------\
2 |                                                                      |
3 |                      __   __    ____ _____ ____                      |
4 |                      \ \ / /_ _/ ___|_   _|___ \                     |
5 |                       \ V / _` \___ \ | |   __) |                    |
6 |                        | | (_| |___) || |  / __/                     |
7 |                        |_|\__,_|____/ |_| |_____|                    |
8 |                                                                      |
9 |                               core system                            |
10 |                                                        (C) SuSE GmbH |
11 \----------------------------------------------------------------------/
12
13   File:         YQPkgRepoFilterView.cc
14
15   Author:       Stefan Hundhammer <sh@suse.de>
16
17   Textdomain    "packages-qt"
18
19 /-*/
20
21
22 #define y2log_component "qt-pkg"
23 #include <ycp/y2log.h>
24
25 #include <qsplitter.h>
26
27 #include "QY2ComboTabWidget.h"
28 #include "QY2LayoutUtils.h"
29 //Added by qt3to4:
30 #include <q3frame.h>
31 #include "YQPkgRepoFilterView.h"
32 #include "YQPkgRepoList.h"
33 #include "YQPkgRpmGroupTagsFilterView.h"
34 #include "YQPkgSearchFilterView.h"
35 #include "YQPkgStatusFilterView.h"
36 #include "YQi18n.h"
37
38 #define MARGIN                  4
39
40
41 YQPkgRepoFilterView::YQPkgRepoFilterView( QWidget * parent )
42     : Q3VBox( parent )
43 {
44     QSplitter * splitter = new QSplitter( Qt::Vertical, this );
45     Q_CHECK_PTR( splitter );
46
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
51
52     addVSpacing( upper_vbox, MARGIN );
53
54
55     // Directly propagate signals filterStart() and filterFinished()
56     // from primary filter to the outside
57
58     connect( _repoList, SIGNAL( filterStart() ),
59              this,              SIGNAL( filterStart() ) );
60
61     connect( _repoList, SIGNAL( filterFinished() ),
62              this,              SIGNAL( filterFinished() ) );
63
64
65     // Redirect filterMatch() and filterNearMatch() signals to secondary filter
66
67     connect( _repoList, SIGNAL( filterMatch             ( ZyppSel, ZyppPkg ) ),
68              this,              SLOT  ( primaryFilterMatch      ( ZyppSel, ZyppPkg ) ) );
69
70     connect( _repoList, SIGNAL( filterNearMatch         ( ZyppSel, ZyppPkg ) ),
71              this,              SLOT  ( primaryFilterNearMatch  ( ZyppSel, ZyppPkg ) ) );
72
73 #if 0
74     QWidget * secondary_filters =
75 #endif
76     layoutSecondaryFilters( splitter );
77
78 #if 0
79     splitter->setResizeMode( _repoList, QSplitter::Stretch        );
80     splitter->setResizeMode( secondary_filters, QSplitter::FollowSizeHint );
81 #endif
82 }
83
84
85 YQPkgRepoFilterView::~YQPkgRepoFilterView()
86 {
87     // NOP
88 }
89
90
91 QWidget *
92 YQPkgRepoFilterView::layoutSecondaryFilters( QWidget * parent )
93 {
94     Q3VBox *vbox = new Q3VBox( parent );
95     Q_CHECK_PTR( vbox );
96     addVSpacing( vbox, MARGIN );
97
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     //
102     // And yes, the colon really belongs there since this is one of the very
103     // few cases where a combo box label is left to the combo box rather than
104     // above it.
105     _secondaryFilters = new QY2ComboTabWidget( _( "&Secondary Filter:" ), vbox );
106     Q_CHECK_PTR( _secondaryFilters );
107
108     _secondaryFilters->setFrameStyle( Q3Frame::Plain );
109     _secondaryFilters->setLineWidth( 0 );
110     _secondaryFilters->setMidLineWidth( 0 );
111     _secondaryFilters->setMargin( 0 );
112
113
114     //
115     // All Packages
116     //
117
118     _allPackages = new QWidget( vbox );
119     Q_CHECK_PTR( _allPackages );
120     _secondaryFilters->addPage( _( "All Packages" ), _allPackages );
121
122
123     //
124     // RPM Groups
125     //
126
127     _rpmGroupTagsFilterView = new YQPkgRpmGroupTagsFilterView( vbox );
128     Q_CHECK_PTR( _rpmGroupTagsFilterView );
129     _secondaryFilters->addPage( _( "Package Groups" ), _rpmGroupTagsFilterView );
130
131     connect( _rpmGroupTagsFilterView,   SIGNAL( filterStart() ),
132              _repoList,         SLOT  ( filter()      ) );
133
134
135     //
136     // Package search view
137     //
138
139     _searchFilterView = new YQPkgSearchFilterView( vbox );
140     Q_CHECK_PTR( _searchFilterView );
141     _secondaryFilters->addPage( _( "Search" ), _searchFilterView );
142
143     connect( _searchFilterView, SIGNAL( filterStart() ),
144              _repoList, SLOT  ( filter()      ) );
145
146     connect( _secondaryFilters, SIGNAL( currentChanged( QWidget * ) ),
147              this,              SLOT  ( filter()                  ) );
148
149
150     //
151     // Status change view
152     //
153
154     _statusFilterView = new YQPkgStatusFilterView( parent );
155     Q_CHECK_PTR( _statusFilterView );
156     _secondaryFilters->addPage( _( "Installation Summary" ), _statusFilterView );
157
158     connect( _statusFilterView, SIGNAL( filterStart() ),
159              _repoList, SLOT  ( filter()      ) );
160
161
162     return _secondaryFilters;
163 }
164
165
166 void YQPkgRepoFilterView::filter()
167 {
168     _repoList->filter();
169 }
170
171
172 void YQPkgRepoFilterView::filterIfVisible()
173 {
174     _repoList->filterIfVisible();
175 }
176
177
178 void YQPkgRepoFilterView::primaryFilterMatch( ZyppSel   selectable,
179                                                  ZyppPkg        pkg )
180 {
181     if ( secondaryFilterMatch( selectable, pkg ) )
182         emit filterMatch( selectable, pkg );
183 }
184
185
186 void YQPkgRepoFilterView::primaryFilterNearMatch( ZyppSel       selectable,
187                                                      ZyppPkg    pkg )
188 {
189     if ( secondaryFilterMatch( selectable, pkg ) )
190         emit filterNearMatch( selectable, pkg );
191 }
192
193
194 bool
195 YQPkgRepoFilterView::secondaryFilterMatch( ZyppSel      selectable,
196                                               ZyppPkg   pkg )
197 {
198     if ( _allPackages->isVisible() )
199     {
200         return true;
201     }
202     else if ( _rpmGroupTagsFilterView->isVisible() )
203     {
204         return _rpmGroupTagsFilterView->check( selectable, pkg );
205     }
206     else if ( _searchFilterView->isVisible() )
207     {
208         return _searchFilterView->check( selectable, pkg );
209     }
210     else if ( _statusFilterView->isVisible() )
211     {
212         return _statusFilterView->check( selectable, pkg );
213     }
214     else
215     {
216         return true;
217     }
218 }
219
220
221
222
223
224
225 #include "YQPkgRepoFilterView.moc"