1 /*---------------------------------------------------------------------\
3 | __ __ ____ _____ ____ |
4 | \ \ / /_ _/ ___|_ _|___ \ |
5 | \ V / _` \___ \ | | __) | |
6 | | | (_| |___) || | / __/ |
7 | |_|\__,_|____/ |_| |_____| |
11 \----------------------------------------------------------------------/
13 File: YQSimplePatchSelector.cc
15 Author: Stefan Hundhammer <sh@suse.de>
17 Textdomain "packages-qt"
21 #include <QApplication>
23 #include <QHeaderView>
24 #include <QPushButton>
27 #define y2log_component "qt-pkg"
28 #include <ycp/y2log.h>
30 #include "QY2LayoutUtils.h"
32 #include "YQSimplePatchSelector.h"
33 #include "YQPkgConflictDialog.h"
34 #include "YQPkgDiskUsageList.h"
35 #include "YQPkgPatchFilterView.h"
36 #include "YQPkgPatchList.h"
49 #define SHOW_DISK_USAGE 0
56 YQSimplePatchSelector::YQSimplePatchSelector( YWidget * parent, long modeFlags )
57 : YQPackageSelectorBase( parent, modeFlags )
62 _wizard = findWizard();
68 _patchList->fillList();
69 _patchList->selectSomething();
73 _diskUsageList->updateDiskUsage();
79 YQSimplePatchSelector::findWizard() const
81 YQWizard * wizard = 0;
83 YQDialog * dialog = dynamic_cast<YQDialog *> ( YDialog::currentDialog() );
86 wizard = dialog->findWizard();
94 YQSimplePatchSelector::basicLayout()
96 QSplitter * splitter = new QSplitter( Qt::Vertical, this );
97 Q_CHECK_PTR( splitter );
103 QBoxLayout *layout = new QVBoxLayout;
104 layout->setMargin( MARGIN );
105 QWidget * upper_vbox = new QWidget( splitter );
106 Q_CHECK_PTR( upper_vbox );
107 upper_vbox->setLayout(layout);
108 splitter->addWidget(upper_vbox);
111 splitter->setStretchFactor( 0, 1 );
113 _patchFilterView = new YQPkgPatchFilterView( upper_vbox );
114 Q_CHECK_PTR( _patchFilterView );
115 layout->addWidget(_patchFilterView);
117 _patchList = _patchFilterView->patchList();
118 Q_CHECK_PTR( _patchList );
120 //addVSpacing( upper_vbox, MARGIN );
128 layout = new QVBoxLayout;
129 QWidget * lower_vbox = new QWidget( splitter );
130 lower_vbox->setLayout(layout);
132 Q_CHECK_PTR( lower_vbox );
133 //addVSpacing( lower_vbox, MARGIN );
135 _diskUsageList = new YQPkgDiskUsageList( lower_vbox );
136 Q_CHECK_PTR( _diskUsageList );
137 layout->addWidget(_diskUsageList);
139 splitter->setResizeMode( lower_vbox, QSplitter::FollowSizeHint );
147 if ( _wizard ) // No button box - add "Details..." button here
153 //addVSpacing( this, SPACING );
154 layout = new QHBoxLayout;
155 QWidget * hbox = new QWidget( this );
157 hbox->setLayout(layout);
158 QPushButton * details_button = new QPushButton( _( "&Details..." ), hbox );
159 layout->addWidget(details_button);
160 Q_CHECK_PTR( details_button );
162 connect( details_button, SIGNAL( clicked() ),
163 this, SLOT ( detailedPackageSelection() ) );
165 //addHStretch( hbox );
169 layoutButtons( this );
175 YQSimplePatchSelector::layoutButtons( QWidget * parent )
177 Q3HBox * button_box = new Q3HBox( parent );
178 Q_CHECK_PTR( button_box );
179 button_box->setMargin ( MARGIN );
180 button_box->setSpacing( SPACING );
183 QPushButton * details_button = new QPushButton( _( "&Details..." ), button_box );
184 Q_CHECK_PTR( details_button );
185 details_button->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ) ); // hor/vert
187 connect( details_button, SIGNAL( clicked() ),
188 this, SLOT ( detailedPackageSelection() ) );
191 addHStretch( button_box );
193 QPushButton * cancel_button = new QPushButton( _( "&Cancel" ), button_box );
194 Q_CHECK_PTR( cancel_button );
195 cancel_button->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ) ); // hor/vert
197 connect( cancel_button, SIGNAL( clicked() ),
198 this, SLOT ( reject() ) );
201 QPushButton * accept_button = new QPushButton( _( "&Accept" ), button_box );
202 Q_CHECK_PTR( accept_button );
203 accept_button->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ) ); // hor/vert
205 connect( accept_button, SIGNAL( clicked() ),
206 this, SLOT ( accept() ) );
208 button_box->setFixedHeight( button_box->sizeHint().height() );
214 YQSimplePatchSelector::makeConnections()
216 if ( _patchList && _diskUsageList )
218 connect( _patchList, SIGNAL( updatePackages() ),
219 _diskUsageList, SLOT ( updateDiskUsage() ) );
222 y2milestone( "Connection set up" );
226 connect( _wizard, SIGNAL( nextClicked() ),
227 this, SLOT ( accept() ) );
229 connect( _wizard, SIGNAL( backClicked() ),
230 this, SLOT ( reject() ) );
232 connect( _wizard, SIGNAL( abortClicked() ),
233 this, SLOT ( reject() ) );
239 YQSimplePatchSelector::detailedPackageSelection()
241 y2milestone( "\"Details..\" button clicked" );
242 YQUI::ui()->sendEvent( new YMenuEvent( YCPSymbol( "details" ) ) );
247 YQSimplePatchSelector::debugTrace()
249 y2warning( "debugTrace" );
254 #include "YQSimplePatchSelector.moc"