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 QWidget * button_box = new QWidget( parent );
178 QHBoxLayout *layout = new QHBoxLayout;
179 Q_CHECK_PTR( button_box );
180 button_box->setLayout(layout);
181 layout->setMargin ( MARGIN );
182 layout->setSpacing( SPACING );
185 QPushButton * details_button = new QPushButton( _( "&Details..." ), button_box );
186 Q_CHECK_PTR( details_button );
187 layout->addWidget(details_button);
188 details_button->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ) ); // hor/vert
190 connect( details_button, SIGNAL( clicked() ),
191 this, SLOT ( detailedPackageSelection() ) );
194 layout->addStretch();
196 QPushButton * cancel_button = new QPushButton( _( "&Cancel" ), button_box );
197 Q_CHECK_PTR( cancel_button );
198 layout->addWidget(cancel_button);
199 cancel_button->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ) ); // hor/vert
201 connect( cancel_button, SIGNAL( clicked() ),
202 this, SLOT ( reject() ) );
205 QPushButton * accept_button = new QPushButton( _( "&Accept" ), button_box );
206 Q_CHECK_PTR( accept_button );
207 layout->addWidget(accept_button);
208 accept_button->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ) ); // hor/vert
210 connect( accept_button, SIGNAL( clicked() ),
211 this, SLOT ( accept() ) );
213 button_box->setFixedHeight( button_box->sizeHint().height() );
219 YQSimplePatchSelector::makeConnections()
221 if ( _patchList && _diskUsageList )
223 connect( _patchList, SIGNAL( updatePackages() ),
224 _diskUsageList, SLOT ( updateDiskUsage() ) );
227 y2milestone( "Connection set up" );
231 connect( _wizard, SIGNAL( nextClicked() ),
232 this, SLOT ( accept() ) );
234 connect( _wizard, SIGNAL( backClicked() ),
235 this, SLOT ( reject() ) );
237 connect( _wizard, SIGNAL( abortClicked() ),
238 this, SLOT ( reject() ) );
244 YQSimplePatchSelector::detailedPackageSelection()
246 y2milestone( "\"Details..\" button clicked" );
247 YQUI::ui()->sendEvent( new YMenuEvent( YCPSymbol( "details" ) ) );
252 YQSimplePatchSelector::debugTrace()
254 y2warning( "debugTrace" );
259 #include "YQSimplePatchSelector.moc"