1 /*---------------------------------------------------------------------\
3 | __ __ ____ _____ ____ |
4 | \ \ / /_ _/ ___|_ _|___ \ |
5 | \ V / _` \___ \ | | __) | |
6 | | | (_| |___) || | / __/ |
7 | |_|\__,_|____/ |_| |_____| |
11 \----------------------------------------------------------------------/
13 File: YQPatternSelector.cc
14 See also: YQPatternSelectorHelp.cc
16 Author: Stefan Hundhammer <sh@suse.de>
18 Textdomain "packages-qt"
24 #include <qapplication.h>
27 #include <qpushbutton.h>
28 #include <qsplitter.h>
30 #define y2log_component "qt-pkg"
31 #include <ycp/y2log.h>
33 #include "QY2LayoutUtils.h"
35 #include "YQPatternSelector.h"
36 #include "YQPkgConflictDialog.h"
37 #include "YQPkgSelDescriptionView.h"
38 #include "YQPkgDiskUsageList.h"
39 #include "YQPkgPatternList.h"
40 #include "YQPkgSelList.h"
49 #define ALWAYS_SOLVE_IMMEDIATELY 1
58 YQPatternSelector::YQPatternSelector( YWidget * parent, long modeFlags )
59 : YQPackageSelectorBase( parent, modeFlags )
64 _wizard = findWizard();
71 _patternList->fillList();
72 _patternList->selectSomething();
77 _selList->selectSomething();
80 if ( zyppPool().empty<zypp::Pattern >() &&
81 zyppPool().empty<zypp::Selection>() )
83 y2warning( "Neither patterns nor selections in ZyppPool" );
88 _diskUsageList->updateDiskUsage();
94 YQPatternSelector::findWizard() const
96 YQWizard * wizard = 0;
98 YQDialog * dialog = dynamic_cast<YQDialog *> ( YDialog::currentDialog() );
101 wizard = dialog->findWizard();
109 YQPatternSelector::basicLayout()
111 QSplitter * outer_splitter = new QSplitter( Qt::Horizontal, this );
112 Q_CHECK_PTR( outer_splitter );
114 QWidget * left_pane = layoutLeftPane ( outer_splitter );
115 QWidget * right_pane = layoutRightPane( outer_splitter );
117 int left_pane_width = (int) ( 0.3 * YQUI::ui()->defaultSize( YD_HORIZ ) );
118 left_pane->resize( QSize( left_pane_width, left_pane->height() ) );
120 outer_splitter->setResizeMode( left_pane, QSplitter::KeepSize );
121 outer_splitter->setResizeMode( right_pane, QSplitter::Stretch );
124 layoutButtons( this );
130 YQPatternSelector::layoutLeftPane( QWidget * parent )
132 Q3VBox * vbox = new Q3VBox( parent );
134 vbox->setMargin( MARGIN );
136 if ( ! zyppPool().empty<zypp::Pattern>() )
142 _patternList = new YQPkgPatternList( vbox,
143 false, // no autoFill - need to connect to details view first
144 false ); // no autoFilter - filterMatch() is not connected
145 Q_CHECK_PTR( _patternList );
146 //FIXME _patternList->header()->hide();
149 if ( ! _patternList )
152 // Fallback: selections list
156 * Create a selections list even if there are no selections, otherwise
157 * the layout will look very weird. An empty selections list still
158 * looks better than a lot of grey empty space.
161 y2warning( "No patterns in ZyppPool - using selections instead" );
162 _selList = new YQPkgSelList( vbox,
163 false, // no autoFill - need to connect to details view first
164 false ); // no autoFilter - filterMatch() is not connected
165 Q_CHECK_PTR( _selList );
166 //FIXME _selList->header()->hide();
169 if ( _wizard ) // No button box - add "Details..." button here
175 addVSpacing( vbox, SPACING );
177 Q3HBox * hbox = new Q3HBox( vbox );
180 QPushButton * details_button = new QPushButton( _( "&Details..." ), hbox );
181 Q_CHECK_PTR( details_button );
183 connect( details_button, SIGNAL( clicked() ),
184 this, SLOT ( detailedPackageSelection() ) );
195 YQPatternSelector::layoutRightPane( QWidget * parent )
197 QSplitter * splitter = new QSplitter( Qt::Vertical, parent );
198 Q_CHECK_PTR( splitter );
199 splitter->setMargin( MARGIN );
203 // Selection / Pattern description
206 Q3VBox * upper_vbox = new Q3VBox( splitter );
207 Q_CHECK_PTR( upper_vbox );
209 _descriptionView = new YQPkgSelDescriptionView( upper_vbox );
210 Q_CHECK_PTR( _descriptionView );
212 addVSpacing( upper_vbox, MARGIN );
219 Q3VBox * lower_vbox = new Q3VBox( splitter );
220 Q_CHECK_PTR( lower_vbox );
221 addVSpacing( lower_vbox, MARGIN );
223 _diskUsageList = new YQPkgDiskUsageList( lower_vbox );
224 Q_CHECK_PTR( _diskUsageList );
226 splitter->setResizeMode( upper_vbox, QSplitter::Stretch );
227 splitter->setResizeMode( lower_vbox, QSplitter::KeepSize );
235 YQPatternSelector::layoutButtons( QWidget * parent )
237 Q3HBox * button_box = new Q3HBox( parent );
238 Q_CHECK_PTR( button_box );
239 button_box->setMargin ( MARGIN );
240 button_box->setSpacing( SPACING );
243 QPushButton * details_button = new QPushButton( _( "&Details..." ), button_box );
244 Q_CHECK_PTR( details_button );
245 details_button->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ) ); // hor/vert
247 connect( details_button, SIGNAL( clicked() ),
248 this, SLOT ( detailedPackageSelection() ) );
251 addHStretch( button_box );
253 QPushButton * cancel_button = new QPushButton( _( "&Cancel" ), button_box );
254 Q_CHECK_PTR( cancel_button );
255 cancel_button->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ) ); // hor/vert
257 connect( cancel_button, SIGNAL( clicked() ),
258 this, SLOT ( reject() ) );
261 QPushButton * accept_button = new QPushButton( _( "&Accept" ), button_box );
262 Q_CHECK_PTR( accept_button );
263 accept_button->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ) ); // hor/vert
265 connect( accept_button, SIGNAL( clicked() ),
266 this, SLOT ( accept() ) );
268 button_box->setFixedHeight( button_box->sizeHint().height() );
274 YQPatternSelector::makeConnections()
278 #if ALWAYS_SOLVE_IMMEDIATELY
279 connect( _patternList, SIGNAL( statusChanged() ),
280 this, SLOT ( resolveDependencies() ) );
282 if ( _pkgConflictDialog )
284 connect( _pkgConflictDialog, SIGNAL( updatePackages() ),
285 _patternList, SLOT ( updateItemStates() ) );
289 if ( _descriptionView )
291 connect( _patternList, SIGNAL( currentItemChanged( ZyppSel ) ),
292 _descriptionView, SLOT ( showDetails ( ZyppSel ) ) );
295 if ( _diskUsageList )
297 connect( _patternList, SIGNAL( updatePackages() ),
298 _diskUsageList, SLOT ( updateDiskUsage() ) );
305 #if ALWAYS_SOLVE_IMMEDIATELY
306 connect( _selList, SIGNAL( statusChanged() ),
307 this, SLOT ( resolveDependencies() ) );
309 if ( _pkgConflictDialog )
311 connect( _pkgConflictDialog, SIGNAL( updatePackages() ),
312 _selList, SLOT ( updateItemStates() ) );
317 if ( _descriptionView )
319 connect( _selList, SIGNAL( currentItemChanged( ZyppSel ) ),
320 _descriptionView, SLOT ( showDetails ( ZyppSel ) ) );
323 if ( _diskUsageList )
325 connect( _selList, SIGNAL( updatePackages() ),
326 _diskUsageList, SLOT ( updateDiskUsage() ) );
330 y2milestone( "Connection set up" );
335 connect( _wizard, SIGNAL( nextClicked() ),
336 this, SLOT ( accept() ) );
338 connect( _wizard, SIGNAL( backClicked() ),
339 this, SLOT ( reject() ) );
341 connect( _wizard, SIGNAL( abortClicked() ),
342 this, SLOT ( reject() ) );
348 YQPatternSelector::detailedPackageSelection()
350 y2milestone( "\"Details..\" button clicked" );
351 YQUI::ui()->sendEvent( new YMenuEvent( YCPSymbol( "details" ) ) );
356 YQPatternSelector::debugTrace()
358 y2warning( "debugTrace" );
363 #include "YQPatternSelector.moc"