43 #include <QApplication>
44 #include <QHeaderView>
45 #include <QPushButton>
48 #define YUILogComponent "qt-pkg"
51 #include "QY2LayoutUtils.h"
53 #include "YQPatternSelector.h"
54 #include "YQPkgConflictDialog.h"
55 #include "YQPkgSelDescriptionView.h"
56 #include "YQPkgDiskUsageList.h"
57 #include "YQPkgPatternList.h"
66 #define ALWAYS_SOLVE_IMMEDIATELY 1
76 YQPatternSelector::YQPatternSelector( YWidget * parent,
long modeFlags )
81 _wizard = findWizard();
88 _patternList->fillList();
89 _patternList->selectSomething();
92 if ( zyppPool().empty<zypp::Pattern >() )
94 yuiWarning() <<
"Neither patterns nor selections in ZyppPool" << endl;
99 _diskUsageList->updateDiskUsage();
107 YQWizard * wizard = 0;
109 YQDialog * dialog =
dynamic_cast<YQDialog *
> ( YDialog::currentDialog() );
112 wizard = dialog->findWizard();
120 YQPatternSelector::basicLayout()
122 QVBoxLayout *vbox =
new QVBoxLayout();
125 QSplitter * outer_splitter =
new QSplitter( Qt::Horizontal,
this );
126 Q_CHECK_PTR( outer_splitter );
128 vbox->addWidget( outer_splitter );
130 QWidget * left_pane = layoutLeftPane ( outer_splitter );
131 QWidget * right_pane = layoutRightPane( outer_splitter );
133 int left_pane_width = (int) ( 0.3 * YQUI::ui()->defaultSize( YD_HORIZ ) );
134 left_pane->resize( QSize( left_pane_width, left_pane->height() ) );
136 outer_splitter->setStretchFactor(outer_splitter->indexOf(left_pane), 0);
137 outer_splitter->setStretchFactor(outer_splitter->indexOf(right_pane), 1);
140 layoutButtons(
this );
146 YQPatternSelector::layoutLeftPane( QWidget * parent )
148 QWidget *vbox =
new QWidget(parent);
149 QVBoxLayout * layout =
new QVBoxLayout( vbox );
151 layout->setMargin( MARGIN );
152 vbox->setLayout(layout);
154 if ( ! zyppPool().empty<zypp::Pattern>() )
163 Q_CHECK_PTR( _patternList );
164 layout->addWidget(_patternList);
174 layout->addSpacing( SPACING );
176 QHBoxLayout * hbox =
new QHBoxLayout();
178 layout->addLayout(hbox);
180 QPushButton * details_button =
new QPushButton( _(
"&Details..." ), vbox );
181 Q_CHECK_PTR( details_button );
182 hbox->addWidget(details_button);
184 connect( details_button, SIGNAL( clicked() ),
196 YQPatternSelector::layoutRightPane( QWidget * parent )
198 QSplitter * splitter =
new QSplitter( Qt::Vertical, parent );
199 Q_CHECK_PTR( splitter );
206 QWidget *upper_vbox =
new QWidget(splitter);
207 QVBoxLayout * layout =
new QVBoxLayout(upper_vbox);
209 Q_CHECK_PTR( upper_vbox );
212 Q_CHECK_PTR( _descriptionView );
213 layout->addWidget(_descriptionView);
219 QWidget *lower_vbox =
new QWidget(splitter);
220 layout =
new QVBoxLayout( lower_vbox);
222 Q_CHECK_PTR( lower_vbox );
225 Q_CHECK_PTR( _diskUsageList );
226 layout->addWidget(_diskUsageList);
228 splitter->setStretchFactor( 0, 3 );
229 splitter->setStretchFactor( 0, 1 );
237 YQPatternSelector::layoutButtons( QWidget * parent )
239 QWidget *button_box =
new QWidget(parent);
240 Q_CHECK_PTR( button_box );
242 parent->layout()->addWidget( button_box );
243 QHBoxLayout *layout =
new QHBoxLayout(button_box);
245 layout->setMargin ( MARGIN );
246 layout->setSpacing( SPACING );
248 QPushButton * details_button =
new QPushButton( _(
"&Details..." ), button_box );
249 layout->addWidget(details_button);
250 Q_CHECK_PTR( details_button );
251 details_button->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ) );
253 connect( details_button, SIGNAL( clicked() ),
257 layout->addStretch();
259 QPushButton * cancel_button =
new QPushButton( _(
"&Cancel" ), button_box );
260 Q_CHECK_PTR( cancel_button );
261 layout->addWidget(cancel_button);
262 cancel_button->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ) );
264 connect( cancel_button, SIGNAL( clicked() ),
265 this, SLOT (
reject() ) );
268 QPushButton * accept_button =
new QPushButton( _(
"&Accept" ), button_box );
269 Q_CHECK_PTR( accept_button );
270 layout->addWidget(accept_button);
271 accept_button->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ) );
273 connect( accept_button, SIGNAL( clicked() ),
274 this, SLOT (
accept() ) );
276 button_box->setFixedHeight( button_box->sizeHint().height() );
286 #if ALWAYS_SOLVE_IMMEDIATELY
287 connect( _patternList, SIGNAL( statusChanged() ),
290 if ( _pkgConflictDialog )
292 connect( _pkgConflictDialog, SIGNAL( updatePackages() ),
293 _patternList, SLOT ( updateItemStates() ) );
297 if ( _descriptionView )
299 connect( _patternList, SIGNAL( currentItemChanged( ZyppSel ) ),
300 _descriptionView, SLOT ( showDetails ( ZyppSel ) ) );
303 if ( _diskUsageList )
305 connect( _patternList, SIGNAL( updatePackages() ),
306 _diskUsageList, SLOT ( updateDiskUsage() ) );
311 yuiMilestone() <<
"Connection set up" << endl;
316 connect( _wizard, SIGNAL( nextClicked() ),
317 this, SLOT (
accept() ) );
319 connect( _wizard, SIGNAL( backClicked() ),
320 this, SLOT (
reject() ) );
322 connect( _wizard, SIGNAL( abortClicked() ),
323 this, SLOT (
reject() ) );
331 yuiMilestone() <<
"\"Details..\" button clicked" << endl;
332 YQUI::ui()->sendEvent(
new YMenuEvent(
"details" ) );
339 yuiWarning() <<
"debugTrace" << endl;
344 #include "YQPatternSelector.moc"
YQWizard * findWizard() const
Display a list of zypp::Pattern objects.
void detailedPackageSelection()
Display the description of a zypp::ResObject derived object along with its name and summary...
int resolveDependencies()
List of disk usage of all attached partitions.