]> icculus.org git repositories - duncan/yast2-qt4.git/blob - src/pkg/YQPkgRepoFilterView.cc
picking up branches/tmp/sh/qt4-port/, merging it with trunk
[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     _secondaryFilters = new QY2ComboTabWidget( _( "&Secondary Filter:" ), vbox );
102     Q_CHECK_PTR( _secondaryFilters );
103
104     _secondaryFilters->setFrameStyle( Q3Frame::Plain );
105     _secondaryFilters->setLineWidth( 0 );
106     _secondaryFilters->setMidLineWidth( 0 );
107     _secondaryFilters->setMargin( 0 );
108
109
110     //
111     // All Packages
112     //
113
114     _allPackages = new QWidget( vbox );
115     Q_CHECK_PTR( _allPackages );
116     _secondaryFilters->addPage( _( "All Packages" ), _allPackages );
117
118
119     //
120     // RPM Groups
121     //
122
123     _rpmGroupTagsFilterView = new YQPkgRpmGroupTagsFilterView( vbox );
124     Q_CHECK_PTR( _rpmGroupTagsFilterView );
125     _secondaryFilters->addPage( _( "Package Groups" ), _rpmGroupTagsFilterView );
126
127     connect( _rpmGroupTagsFilterView,   SIGNAL( filterStart() ),
128              _repoList,         SLOT  ( filter()      ) );
129
130
131     //
132     // Package search view
133     //
134
135     _searchFilterView = new YQPkgSearchFilterView( vbox );
136     Q_CHECK_PTR( _searchFilterView );
137     _secondaryFilters->addPage( _( "Search" ), _searchFilterView );
138
139     connect( _searchFilterView, SIGNAL( filterStart() ),
140              _repoList, SLOT  ( filter()      ) );
141
142     connect( _secondaryFilters, SIGNAL( currentChanged( QWidget * ) ),
143              this,              SLOT  ( filter()                  ) );
144
145
146     //
147     // Status change view
148     //
149
150     _statusFilterView = new YQPkgStatusFilterView( parent );
151     Q_CHECK_PTR( _statusFilterView );
152     _secondaryFilters->addPage( _( "Installation Summary" ), _statusFilterView );
153
154     connect( _statusFilterView, SIGNAL( filterStart() ),
155              _repoList, SLOT  ( filter()      ) );
156
157
158     return _secondaryFilters;
159 }
160
161
162 void YQPkgRepoFilterView::filter()
163 {
164     _repoList->filter();
165 }
166
167
168 void YQPkgRepoFilterView::filterIfVisible()
169 {
170     _repoList->filterIfVisible();
171 }
172
173
174 void YQPkgRepoFilterView::primaryFilterMatch( ZyppSel   selectable,
175                                                  ZyppPkg        pkg )
176 {
177     if ( secondaryFilterMatch( selectable, pkg ) )
178         emit filterMatch( selectable, pkg );
179 }
180
181
182 void YQPkgRepoFilterView::primaryFilterNearMatch( ZyppSel       selectable,
183                                                      ZyppPkg    pkg )
184 {
185     if ( secondaryFilterMatch( selectable, pkg ) )
186         emit filterNearMatch( selectable, pkg );
187 }
188
189
190 bool
191 YQPkgRepoFilterView::secondaryFilterMatch( ZyppSel      selectable,
192                                               ZyppPkg   pkg )
193 {
194     if ( _allPackages->isVisible() )
195     {
196         return true;
197     }
198     else if ( _rpmGroupTagsFilterView->isVisible() )
199     {
200         return _rpmGroupTagsFilterView->check( selectable, pkg );
201     }
202     else if ( _searchFilterView->isVisible() )
203     {
204         return _searchFilterView->check( selectable, pkg );
205     }
206     else if ( _statusFilterView->isVisible() )
207     {
208         return _statusFilterView->check( selectable, pkg );
209     }
210     else
211     {
212         return true;
213     }
214 }
215
216
217
218
219
220
221 #include "YQPkgRepoFilterView.moc"