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 QVBoxLayout *vbox = new QVBoxLayout( this );
113 QSplitter * outer_splitter = new QSplitter( Qt::Horizontal, this );
114 Q_CHECK_PTR( outer_splitter );
116 vbox->addWidget( outer_splitter );
118 QWidget * left_pane = layoutLeftPane ( outer_splitter );
119 QWidget * right_pane = layoutRightPane( outer_splitter );
121 int left_pane_width = (int) ( 0.3 * YQUI::ui()->defaultSize( YD_HORIZ ) );
122 left_pane->resize( QSize( left_pane_width, left_pane->height() ) );
124 outer_splitter->setResizeMode( left_pane, QSplitter::KeepSize );
125 outer_splitter->setResizeMode( right_pane, QSplitter::Stretch );
128 layoutButtons( this );
134 YQPatternSelector::layoutLeftPane( QWidget * parent )
136 Q3VBox * vbox = new Q3VBox( parent );
138 vbox->setMargin( MARGIN );
140 if ( ! zyppPool().empty<zypp::Pattern>() )
146 _patternList = new YQPkgPatternList( vbox,
147 false, // no autoFill - need to connect to details view first
148 false ); // no autoFilter - filterMatch() is not connected
149 Q_CHECK_PTR( _patternList );
150 //FIXME _patternList->header()->hide();
153 if ( ! _patternList )
156 // Fallback: selections list
160 * Create a selections list even if there are no selections, otherwise
161 * the layout will look very weird. An empty selections list still
162 * looks better than a lot of grey empty space.
165 y2warning( "No patterns in ZyppPool - using selections instead" );
166 _selList = new YQPkgSelList( vbox,
167 false, // no autoFill - need to connect to details view first
168 false ); // no autoFilter - filterMatch() is not connected
169 Q_CHECK_PTR( _selList );
170 //FIXME _selList->header()->hide();
173 if ( _wizard ) // No button box - add "Details..." button here
179 addVSpacing( vbox, SPACING );
181 Q3HBox * hbox = new Q3HBox( vbox );
184 QPushButton * details_button = new QPushButton( _( "&Details..." ), hbox );
185 Q_CHECK_PTR( details_button );
187 connect( details_button, SIGNAL( clicked() ),
188 this, SLOT ( detailedPackageSelection() ) );
199 YQPatternSelector::layoutRightPane( QWidget * parent )
201 QSplitter * splitter = new QSplitter( Qt::Vertical, parent );
202 Q_CHECK_PTR( splitter );
203 splitter->setMargin( MARGIN );
207 // Selection / Pattern description
210 Q3VBox * upper_vbox = new Q3VBox( splitter );
211 Q_CHECK_PTR( upper_vbox );
213 _descriptionView = new YQPkgSelDescriptionView( upper_vbox );
214 Q_CHECK_PTR( _descriptionView );
216 addVSpacing( upper_vbox, MARGIN );
223 Q3VBox * lower_vbox = new Q3VBox( splitter );
224 Q_CHECK_PTR( lower_vbox );
225 addVSpacing( lower_vbox, MARGIN );
227 _diskUsageList = new YQPkgDiskUsageList( lower_vbox );
228 Q_CHECK_PTR( _diskUsageList );
230 splitter->setStretchFactor( 0, 0 );
231 splitter->setStretchFactor( 0, 1 );
239 YQPatternSelector::layoutButtons( QWidget * parent )
241 Q3HBox * button_box = new Q3HBox( parent );
242 Q_CHECK_PTR( button_box );
243 button_box->setMargin ( MARGIN );
244 button_box->setSpacing( SPACING );
246 parent->layout()->addWidget( button_box );
248 QPushButton * details_button = new QPushButton( _( "&Details..." ), button_box );
249 Q_CHECK_PTR( details_button );
250 details_button->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ) ); // hor/vert
252 connect( details_button, SIGNAL( clicked() ),
253 this, SLOT ( detailedPackageSelection() ) );
256 addHStretch( button_box );
258 QPushButton * cancel_button = new QPushButton( _( "&Cancel" ), button_box );
259 Q_CHECK_PTR( cancel_button );
260 cancel_button->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ) ); // hor/vert
262 connect( cancel_button, SIGNAL( clicked() ),
263 this, SLOT ( reject() ) );
266 QPushButton * accept_button = new QPushButton( _( "&Accept" ), button_box );
267 Q_CHECK_PTR( accept_button );
268 accept_button->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ) ); // hor/vert
270 connect( accept_button, SIGNAL( clicked() ),
271 this, SLOT ( accept() ) );
273 button_box->setFixedHeight( button_box->sizeHint().height() );
279 YQPatternSelector::makeConnections()
283 #if ALWAYS_SOLVE_IMMEDIATELY
284 connect( _patternList, SIGNAL( statusChanged() ),
285 this, SLOT ( resolveDependencies() ) );
287 if ( _pkgConflictDialog )
289 connect( _pkgConflictDialog, SIGNAL( updatePackages() ),
290 _patternList, SLOT ( updateItemStates() ) );
294 if ( _descriptionView )
296 connect( _patternList, SIGNAL( currentItemChanged( ZyppSel ) ),
297 _descriptionView, SLOT ( showDetails ( ZyppSel ) ) );
300 if ( _diskUsageList )
302 connect( _patternList, SIGNAL( updatePackages() ),
303 _diskUsageList, SLOT ( updateDiskUsage() ) );
310 #if ALWAYS_SOLVE_IMMEDIATELY
311 connect( _selList, SIGNAL( statusChanged() ),
312 this, SLOT ( resolveDependencies() ) );
314 if ( _pkgConflictDialog )
316 connect( _pkgConflictDialog, SIGNAL( updatePackages() ),
317 _selList, SLOT ( updateItemStates() ) );
322 if ( _descriptionView )
324 connect( _selList, SIGNAL( currentItemChanged( ZyppSel ) ),
325 _descriptionView, SLOT ( showDetails ( ZyppSel ) ) );
328 if ( _diskUsageList )
330 connect( _selList, SIGNAL( updatePackages() ),
331 _diskUsageList, SLOT ( updateDiskUsage() ) );
335 y2milestone( "Connection set up" );
340 connect( _wizard, SIGNAL( nextClicked() ),
341 this, SLOT ( accept() ) );
343 connect( _wizard, SIGNAL( backClicked() ),
344 this, SLOT ( reject() ) );
346 connect( _wizard, SIGNAL( abortClicked() ),
347 this, SLOT ( reject() ) );
353 YQPatternSelector::detailedPackageSelection()
355 y2milestone( "\"Details..\" button clicked" );
356 YQUI::ui()->sendEvent( new YMenuEvent( YCPSymbol( "details" ) ) );
361 YQPatternSelector::debugTrace()
363 y2warning( "debugTrace" );
368 #include "YQPatternSelector.moc"