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"
22 #include <qapplication.h>
25 #include <qpushbutton.h>
26 #include <qsplitter.h>
28 #define y2log_component "qt-pkg"
29 #include <ycp/y2log.h>
31 #include "QY2LayoutUtils.h"
33 #include "YQPatternSelector.h"
34 #include "YQPkgConflictDialog.h"
35 #include "YQPkgSelDescriptionView.h"
36 #include "YQPkgDiskUsageList.h"
37 #include "YQPkgPatternList.h"
38 #include "YQPkgSelList.h"
47 #define ALWAYS_SOLVE_IMMEDIATELY 1
56 YQPatternSelector::YQPatternSelector( YWidget * parent, long modeFlags )
57 : YQPackageSelectorBase( parent, modeFlags )
62 _wizard = findWizard();
69 _patternList->fillList();
70 _patternList->selectSomething();
75 _selList->selectSomething();
78 if ( zyppPool().empty<zypp::Pattern >() &&
79 zyppPool().empty<zypp::Selection>() )
81 y2warning( "Neither patterns nor selections in ZyppPool" );
86 _diskUsageList->updateDiskUsage();
92 YQPatternSelector::findWizard() const
94 YQWizard * wizard = 0;
96 YQDialog * dialog = dynamic_cast<YQDialog *> ( YDialog::currentDialog() );
99 wizard = dialog->findWizard();
107 YQPatternSelector::basicLayout()
109 QSplitter * outer_splitter = new QSplitter( Qt::Horizontal, this );
110 Q_CHECK_PTR( outer_splitter );
112 QWidget * left_pane = layoutLeftPane ( outer_splitter );
113 QWidget * right_pane = layoutRightPane( outer_splitter );
115 int left_pane_width = (int) ( 0.3 * YQUI::ui()->defaultSize( YD_HORIZ ) );
116 left_pane->resize( QSize( left_pane_width, left_pane->height() ) );
118 outer_splitter->setResizeMode( left_pane, QSplitter::KeepSize );
119 outer_splitter->setResizeMode( right_pane, QSplitter::Stretch );
122 layoutButtons( this );
128 YQPatternSelector::layoutLeftPane( QWidget * parent )
130 Q3VBox * vbox = new Q3VBox( parent );
132 vbox->setMargin( MARGIN );
134 if ( ! zyppPool().empty<zypp::Pattern>() )
140 _patternList = new YQPkgPatternList( vbox,
141 false, // no autoFill - need to connect to details view first
142 false ); // no autoFilter - filterMatch() is not connected
143 Q_CHECK_PTR( _patternList );
144 //FIXME _patternList->header()->hide();
147 if ( ! _patternList )
150 // Fallback: selections list
154 * Create a selections list even if there are no selections, otherwise
155 * the layout will look very weird. An empty selections list still
156 * looks better than a lot of grey empty space.
159 y2warning( "No patterns in ZyppPool - using selections instead" );
160 _selList = new YQPkgSelList( vbox,
161 false, // no autoFill - need to connect to details view first
162 false ); // no autoFilter - filterMatch() is not connected
163 Q_CHECK_PTR( _selList );
164 //FIXME _selList->header()->hide();
167 if ( _wizard ) // No button box - add "Details..." button here
173 addVSpacing( vbox, SPACING );
175 Q3HBox * hbox = new Q3HBox( vbox );
178 QPushButton * details_button = new QPushButton( _( "&Details..." ), hbox );
179 Q_CHECK_PTR( details_button );
181 connect( details_button, SIGNAL( clicked() ),
182 this, SLOT ( detailedPackageSelection() ) );
193 YQPatternSelector::layoutRightPane( QWidget * parent )
195 QSplitter * splitter = new QSplitter( Qt::Vertical, parent );
196 Q_CHECK_PTR( splitter );
197 splitter->setMargin( MARGIN );
201 // Selection / Pattern description
204 Q3VBox * upper_vbox = new Q3VBox( splitter );
205 Q_CHECK_PTR( upper_vbox );
207 _descriptionView = new YQPkgSelDescriptionView( upper_vbox );
208 Q_CHECK_PTR( _descriptionView );
210 addVSpacing( upper_vbox, MARGIN );
217 Q3VBox * lower_vbox = new Q3VBox( splitter );
218 Q_CHECK_PTR( lower_vbox );
219 addVSpacing( lower_vbox, MARGIN );
221 _diskUsageList = new YQPkgDiskUsageList( lower_vbox );
222 Q_CHECK_PTR( _diskUsageList );
224 splitter->setResizeMode( upper_vbox, QSplitter::Stretch );
225 splitter->setResizeMode( lower_vbox, QSplitter::KeepSize );
233 YQPatternSelector::layoutButtons( QWidget * parent )
235 Q3HBox * button_box = new Q3HBox( parent );
236 Q_CHECK_PTR( button_box );
237 button_box->setMargin ( MARGIN );
238 button_box->setSpacing( SPACING );
241 QPushButton * details_button = new QPushButton( _( "&Details..." ), button_box );
242 Q_CHECK_PTR( details_button );
243 details_button->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ) ); // hor/vert
245 connect( details_button, SIGNAL( clicked() ),
246 this, SLOT ( detailedPackageSelection() ) );
249 addHStretch( button_box );
251 QPushButton * cancel_button = new QPushButton( _( "&Cancel" ), button_box );
252 Q_CHECK_PTR( cancel_button );
253 cancel_button->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ) ); // hor/vert
255 connect( cancel_button, SIGNAL( clicked() ),
256 this, SLOT ( reject() ) );
259 QPushButton * accept_button = new QPushButton( _( "&Accept" ), button_box );
260 Q_CHECK_PTR( accept_button );
261 accept_button->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ) ); // hor/vert
263 connect( accept_button, SIGNAL( clicked() ),
264 this, SLOT ( accept() ) );
266 button_box->setFixedHeight( button_box->sizeHint().height() );
272 YQPatternSelector::makeConnections()
276 #if ALWAYS_SOLVE_IMMEDIATELY
277 connect( _patternList, SIGNAL( statusChanged() ),
278 this, SLOT ( resolveDependencies() ) );
280 if ( _pkgConflictDialog )
282 connect( _pkgConflictDialog, SIGNAL( updatePackages() ),
283 _patternList, SLOT ( updateItemStates() ) );
287 if ( _descriptionView )
289 connect( _patternList, SIGNAL( selectionChanged( ZyppSel ) ),
290 _descriptionView, SLOT ( showDetails ( ZyppSel ) ) );
293 if ( _diskUsageList )
295 connect( _patternList, SIGNAL( updatePackages() ),
296 _diskUsageList, SLOT ( updateDiskUsage() ) );
303 #if ALWAYS_SOLVE_IMMEDIATELY
304 connect( _selList, SIGNAL( statusChanged() ),
305 this, SLOT ( resolveDependencies() ) );
307 if ( _pkgConflictDialog )
309 connect( _pkgConflictDialog, SIGNAL( updatePackages() ),
310 _selList, SLOT ( updateItemStates() ) );
315 if ( _descriptionView )
317 connect( _selList, SIGNAL( selectionChanged( ZyppSel ) ),
318 _descriptionView, SLOT ( showDetails ( ZyppSel ) ) );
321 if ( _diskUsageList )
323 connect( _selList, SIGNAL( updatePackages() ),
324 _diskUsageList, SLOT ( updateDiskUsage() ) );
328 y2milestone( "Connection set up" );
333 connect( _wizard, SIGNAL( nextClicked() ),
334 this, SLOT ( accept() ) );
336 connect( _wizard, SIGNAL( backClicked() ),
337 this, SLOT ( reject() ) );
339 connect( _wizard, SIGNAL( abortClicked() ),
340 this, SLOT ( reject() ) );
346 YQPatternSelector::detailedPackageSelection()
348 y2milestone( "\"Details..\" button clicked" );
349 YQUI::ui()->sendEvent( new YMenuEvent( YCPSymbol( "details" ) ) );
354 YQPatternSelector::debugTrace()
356 y2warning( "debugTrace" );
361 #include "YQPatternSelector.moc"