1 /*---------------------------------------------------------------------\
3 | __ __ ____ _____ ____ |
4 | \ \ / /_ _/ ___|_ _|___ \ |
5 | \ V / _` \___ \ | | __) | |
6 | | | (_| |___) || | / __/ |
7 | |_|\__,_|____/ |_| |_____| |
11 \----------------------------------------------------------------------/
13 File: YQWidgetFactory.cc
15 Author: Stefan Hundhammer <sh@suse.de>
19 #include <QColorGroup>
20 #define y2log_component "qt-ui"
21 #include <ycp/y2log.h>
23 #include "YQWidgetFactory.h"
25 #include "YUIException.h"
26 #include "YQPackageSelectorPlugin.h"
27 #include "YQMainWinDock.h"
33 YQWidgetFactory::YQWidgetFactory()
39 YQWidgetFactory::~YQWidgetFactory()
52 YQWidgetFactory::createDialog( YDialogType dialogType, YDialogColorMode colorMode )
54 YQDialog * dialog = new YQDialog( dialogType, colorMode );
55 YUI_CHECK_NEW( dialog );
67 YQWidgetFactory::createLayoutBox( YWidget * parent, YUIDimension dim )
69 YQLayoutBox * layoutBox = new YQLayoutBox( parent, dim );
70 YUI_CHECK_NEW( layoutBox );
78 // Common Leaf Widgets
82 YQWidgetFactory::createPushButton( YWidget * parent, const string & label )
84 YQPushButton * pushButton = new YQPushButton( parent, label );
85 YUI_CHECK_NEW( pushButton );
93 YQWidgetFactory::createLabel( YWidget * parent,
98 YQLabel * label = new YQLabel( parent, text, isHeading, isOutputField );
99 YUI_CHECK_NEW( label );
107 YQWidgetFactory::createInputField( YWidget * parent, const string & label, bool passwordMode )
109 YQInputField * inputField = new YQInputField( parent, label, passwordMode );
110 YUI_CHECK_NEW( inputField );
118 YQWidgetFactory::createCheckBox( YWidget * parent, const string & label, bool isChecked )
120 YQCheckBox * checkBox = new YQCheckBox( parent, label, isChecked );
121 YUI_CHECK_NEW( checkBox );
129 YQWidgetFactory::createRadioButton( YWidget * parent, const string & label, bool isChecked )
131 YQRadioButton * radioButton = new YQRadioButton( parent, label, isChecked );
132 YUI_CHECK_NEW( radioButton );
134 // Register radio button with its button group.
135 // This has to be done after all constructors are done so virtual functions
138 if ( radioButton->buttonGroup() )
139 radioButton->buttonGroup()->addRadioButton( radioButton );
147 YQWidgetFactory::createComboBox( YWidget * parent, const string & label, bool editable )
149 YQComboBox * comboBox = new YQComboBox( parent, label, editable );
150 YUI_CHECK_NEW( comboBox );
158 YQWidgetFactory::createSelectionBox( YWidget * parent, const string & label )
160 YQSelectionBox * selectionBox = new YQSelectionBox( parent, label );
161 YUI_CHECK_NEW( selectionBox );
169 YQWidgetFactory::createTree( YWidget * parent, const string & label )
171 YQTree * tree = new YQTree( parent, label );
172 YUI_CHECK_NEW( tree );
180 YQWidgetFactory::createTable( YWidget * parent, YTableHeader * header )
182 YQTable * table = new YQTable( parent, header );
183 YUI_CHECK_NEW( table );
191 YQWidgetFactory::createProgressBar( YWidget * parent, const string & label, int maxValue )
193 YQProgressBar * progressBar = new YQProgressBar( parent, label, maxValue );
194 YUI_CHECK_NEW( progressBar );
202 YQWidgetFactory::createRichText( YWidget * parent, const string & text, bool plainTextMode )
204 YQRichText * richText = new YQRichText( parent, text, plainTextMode );
205 YUI_CHECK_NEW( richText );
214 // Less Common Leaf Widgets
218 YQWidgetFactory::createIntField( YWidget * parent, const string & label, int minVal, int maxVal, int initialVal )
220 YQIntField * intField = new YQIntField( parent, label, minVal, maxVal, initialVal );
221 YUI_CHECK_NEW( intField );
229 YQWidgetFactory::createMenuButton( YWidget * parent, const string & label )
231 YQMenuButton * menuButton = new YQMenuButton( parent, label );
232 YUI_CHECK_NEW( menuButton );
240 YQWidgetFactory::createMultiLineEdit( YWidget * parent, const string & label )
242 YQMultiLineEdit * multiLineEdit = new YQMultiLineEdit( parent, label );
243 YUI_CHECK_NEW( multiLineEdit );
245 return multiLineEdit;
251 YQWidgetFactory::createImage( YWidget * parent, const string & imageFileName, bool animated )
253 YQImage * image = new YQImage( parent, imageFileName, animated );
254 YUI_CHECK_NEW( image );
261 YQWidgetFactory::createLogView( YWidget * parent, const string & label, int visibleLines, int storedLines )
263 YQLogView * logView = new YQLogView( parent, label, visibleLines, storedLines );
264 YUI_CHECK_NEW( logView );
271 YQMultiSelectionBox *
272 YQWidgetFactory::createMultiSelectionBox( YWidget * parent, const string & label )
274 YQMultiSelectionBox * multiSelectionBox = new YQMultiSelectionBox( parent, label );
275 YUI_CHECK_NEW( multiSelectionBox );
277 return multiSelectionBox;
283 YQWidgetFactory::createPackageSelector( YWidget * parent, long modeFlags )
285 YQPackageSelectorPlugin * plugin = YQUI::ui()->packageSelectorPlugin();
288 return plugin->createPackageSelector( parent, modeFlags );
295 YQWidgetFactory::createPkgSpecial( YWidget * , const string & )
297 YUI_THROW( YUIUnsupportedWidgetException( "YQPkgSpecial" ) ); // NCurses only
307 YQWidgetFactory::createSpacing( YWidget * parent, YUIDimension dim, bool stretchable, YLayoutSize_t size )
309 YQSpacing * spacing = new YQSpacing( parent, dim, stretchable, size );
310 YUI_CHECK_NEW( spacing );
317 YQWidgetFactory::createEmpty( YWidget * parent )
319 YQEmpty * empty = new YQEmpty( parent );
320 YUI_CHECK_NEW( empty );
328 YQWidgetFactory::createAlignment( YWidget * parent,
329 YAlignmentType horAlignment,
330 YAlignmentType vertAlignment )
332 YQAlignment * alignment = new YQAlignment( parent, horAlignment, vertAlignment );
333 YUI_CHECK_NEW( alignment );
340 YQWidgetFactory::createSquash( YWidget * parent, bool horSquash, bool vertSquash )
342 YQSquash * squash = new YQSquash( parent, horSquash, vertSquash );
343 YUI_CHECK_NEW( squash );
351 YQWidgetFactory::createFrame( YWidget * parent, const string & label )
353 YQFrame * frame = new YQFrame( parent, label );
354 YUI_CHECK_NEW( frame );
362 YQWidgetFactory::createCheckBoxFrame( YWidget * parent, const string & label, bool checked )
364 YQCheckBoxFrame * checkBoxFrame = new YQCheckBoxFrame( parent, label, checked );
365 YUI_CHECK_NEW( checkBoxFrame );
367 return checkBoxFrame;
373 YQWidgetFactory::createRadioButtonGroup( YWidget * parent )
375 YQRadioButtonGroup * radioButtonGroup = new YQRadioButtonGroup( parent );
376 YUI_CHECK_NEW( radioButtonGroup );
378 return radioButtonGroup;
384 YQWidgetFactory::createReplacePoint( YWidget * parent )
386 YQReplacePoint * replacePoint = new YQReplacePoint( parent );
387 YUI_CHECK_NEW( replacePoint );