]> icculus.org git repositories - duncan/yast2-qt4.git/blob - src/YQWidgetFactory.cc
clicking packages work! so the package selector is now
[duncan/yast2-qt4.git] / src / YQWidgetFactory.cc
1 /*---------------------------------------------------------------------\
2 |                                                                      |
3 |                      __   __    ____ _____ ____                      |
4 |                      \ \ / /_ _/ ___|_   _|___ \                     |
5 |                       \ V / _` \___ \ | |   __) |                    |
6 |                        | | (_| |___) || |  / __/                     |
7 |                        |_|\__,_|____/ |_| |_____|                    |
8 |                                                                      |
9 |                               core system                            |
10 |                                                        (C) SuSE GmbH |
11 \----------------------------------------------------------------------/
12
13   File:         YQWidgetFactory.cc
14
15   Author:       Stefan Hundhammer <sh@suse.de>
16
17 /-*/
18
19 #include <QColorGroup>
20 #define y2log_component "qt-ui"
21 #include <ycp/y2log.h>
22
23 #include "YQWidgetFactory.h"
24 #include "YQUI.h"
25 #include "YUIException.h"
26 #include "YQPackageSelectorPlugin.h"
27 #include "YQMainWinDock.h"
28
29 #include <string>
30
31 using std::string;
32
33 YQWidgetFactory::YQWidgetFactory()
34     : YWidgetFactory()
35 {
36     // NOP
37 }
38
39 YQWidgetFactory::~YQWidgetFactory()
40 {
41     // NOP
42 }
43
44
45
46
47 //
48 // Dialogs
49 //
50
51 YQDialog *
52 YQWidgetFactory::createDialog( YDialogType dialogType, YDialogColorMode colorMode )
53 {
54     YQDialog * dialog = new YQDialog( dialogType, colorMode );
55     YUI_CHECK_NEW( dialog );
56
57     return dialog;
58 }
59
60
61
62 //
63 // Layout Boxes
64 //
65
66 YQLayoutBox *
67 YQWidgetFactory::createLayoutBox( YWidget * parent, YUIDimension dim )
68 {
69     YQLayoutBox * layoutBox = new YQLayoutBox( parent, dim );
70     YUI_CHECK_NEW( layoutBox );
71
72     return layoutBox;
73 }
74
75
76
77 //
78 // Common Leaf Widgets
79 //
80
81 YQPushButton *
82 YQWidgetFactory::createPushButton( YWidget * parent, const string & label )
83 {
84     YQPushButton * pushButton = new YQPushButton( parent, label );
85     YUI_CHECK_NEW( pushButton );
86
87     return pushButton;
88 }
89
90
91
92 YQLabel *
93 YQWidgetFactory::createLabel( YWidget *         parent,
94                               const string &    text,
95                               bool              isHeading,
96                               bool              isOutputField )
97 {
98     YQLabel * label = new YQLabel( parent, text, isHeading, isOutputField );
99     YUI_CHECK_NEW( label );
100
101     return label;
102 }
103
104
105
106 YQInputField *
107 YQWidgetFactory::createInputField( YWidget * parent, const string & label, bool passwordMode )
108 {
109     YQInputField * inputField = new YQInputField( parent, label, passwordMode );
110     YUI_CHECK_NEW( inputField );
111
112     return inputField;
113 }
114
115
116
117 YQCheckBox *
118 YQWidgetFactory::createCheckBox( YWidget * parent, const string & label, bool isChecked )
119 {
120     YQCheckBox * checkBox = new YQCheckBox( parent, label, isChecked );
121     YUI_CHECK_NEW( checkBox );
122
123     return checkBox;
124 }
125
126
127
128 YQRadioButton *
129 YQWidgetFactory::createRadioButton( YWidget * parent, const string & label, bool isChecked )
130 {
131     YQRadioButton * radioButton = new YQRadioButton( parent, label, isChecked );
132     YUI_CHECK_NEW( radioButton );
133
134     // Register radio button with its button group.
135     // This has to be done after all constructors are done so virtual functions
136     // can be used.
137
138     if ( radioButton->buttonGroup() )
139         radioButton->buttonGroup()->addRadioButton( radioButton );
140
141     return radioButton;
142 }
143
144
145
146 YQComboBox *
147 YQWidgetFactory::createComboBox( YWidget * parent, const string & label, bool editable  )
148 {
149     YQComboBox * comboBox = new YQComboBox( parent, label, editable );
150     YUI_CHECK_NEW( comboBox );
151
152     return comboBox;
153 }
154
155
156
157 YQSelectionBox *
158 YQWidgetFactory::createSelectionBox( YWidget * parent, const string & label )
159 {
160     YQSelectionBox * selectionBox = new YQSelectionBox( parent, label );
161     YUI_CHECK_NEW( selectionBox );
162
163     return selectionBox;
164 }
165
166
167
168 YQTree *
169 YQWidgetFactory::createTree( YWidget * parent, const string & label )
170 {
171     YQTree * tree = new YQTree( parent, label );
172     YUI_CHECK_NEW( tree );
173
174     return tree;
175 }
176
177
178
179 YQTable *
180 YQWidgetFactory::createTable( YWidget * parent, YTableHeader * header )
181 {
182     YQTable * table = new YQTable( parent, header );
183     YUI_CHECK_NEW( table );
184
185     return table;
186 }
187
188
189
190 YQProgressBar *
191 YQWidgetFactory::createProgressBar( YWidget * parent, const string & label, int maxValue )
192 {
193     YQProgressBar * progressBar = new YQProgressBar( parent, label, maxValue );
194     YUI_CHECK_NEW( progressBar );
195
196     return progressBar;
197 }
198
199
200
201 YQRichText *
202 YQWidgetFactory::createRichText( YWidget * parent, const string & text, bool plainTextMode )
203 {
204     YQRichText * richText = new YQRichText( parent, text, plainTextMode );
205     YUI_CHECK_NEW( richText );
206
207     return richText;
208 }
209
210
211
212
213 //
214 // Less Common Leaf Widgets
215 //
216
217 YQIntField *
218 YQWidgetFactory::createIntField( YWidget * parent, const string & label, int minVal, int maxVal, int initialVal )
219 {
220     YQIntField * intField = new YQIntField( parent, label, minVal, maxVal, initialVal );
221     YUI_CHECK_NEW( intField );
222
223     return intField;
224 }
225
226
227
228 YQMenuButton *
229 YQWidgetFactory::createMenuButton( YWidget * parent, const string & label )
230 {
231     YQMenuButton * menuButton = new YQMenuButton( parent, label );
232     YUI_CHECK_NEW( menuButton );
233
234     return menuButton;
235 }
236
237
238
239 YQMultiLineEdit *
240 YQWidgetFactory::createMultiLineEdit( YWidget * parent, const string & label )
241 {
242     YQMultiLineEdit * multiLineEdit = new YQMultiLineEdit( parent, label );
243     YUI_CHECK_NEW( multiLineEdit );
244
245     return multiLineEdit;
246 }
247
248
249
250 YQImage *
251 YQWidgetFactory::createImage( YWidget * parent, const string & imageFileName, bool animated )
252 {
253     YQImage * image = new YQImage( parent, imageFileName, animated );
254     YUI_CHECK_NEW( image );
255
256     return image;
257 }
258
259
260 YQLogView *
261 YQWidgetFactory::createLogView( YWidget * parent, const string & label, int visibleLines, int storedLines )
262 {
263     YQLogView * logView = new YQLogView( parent, label, visibleLines, storedLines );
264     YUI_CHECK_NEW( logView );
265
266     return logView;
267 }
268
269
270
271 YQMultiSelectionBox *
272 YQWidgetFactory::createMultiSelectionBox( YWidget * parent, const string & label )
273 {
274     YQMultiSelectionBox * multiSelectionBox = new YQMultiSelectionBox( parent, label );
275     YUI_CHECK_NEW( multiSelectionBox );
276
277     return multiSelectionBox;
278 }
279
280
281
282 YQPackageSelector *
283 YQWidgetFactory::createPackageSelector( YWidget * parent, long modeFlags )
284 {
285     YQPackageSelectorPlugin * plugin = YQUI::ui()->packageSelectorPlugin();
286
287     if ( plugin )
288         return plugin->createPackageSelector( parent, modeFlags );
289     else
290         return 0;
291 }
292
293
294 YWidget *
295 YQWidgetFactory::createPkgSpecial( YWidget * , const string & )
296 {
297     YUI_THROW( YUIUnsupportedWidgetException( "YQPkgSpecial" ) ); // NCurses only
298     return 0;
299 }
300
301
302 //
303 // Layout Helpers
304 //
305
306 YQSpacing *
307 YQWidgetFactory::createSpacing( YWidget * parent, YUIDimension dim, bool stretchable, YLayoutSize_t size )
308 {
309     YQSpacing * spacing = new YQSpacing( parent, dim, stretchable, size );
310     YUI_CHECK_NEW( spacing );
311
312     return spacing;
313 }
314
315
316 YQEmpty *
317 YQWidgetFactory::createEmpty( YWidget * parent )
318 {
319     YQEmpty * empty = new YQEmpty( parent );
320     YUI_CHECK_NEW( empty );
321
322     return empty;
323 }
324
325
326
327 YQAlignment *
328 YQWidgetFactory::createAlignment( YWidget *      parent,
329                                   YAlignmentType horAlignment,
330                                   YAlignmentType vertAlignment )
331 {
332     YQAlignment * alignment = new YQAlignment( parent, horAlignment, vertAlignment );
333     YUI_CHECK_NEW( alignment );
334
335     return alignment;
336 }
337
338
339 YQSquash *
340 YQWidgetFactory::createSquash( YWidget * parent, bool horSquash, bool vertSquash )
341 {
342     YQSquash * squash = new YQSquash( parent, horSquash, vertSquash );
343     YUI_CHECK_NEW( squash );
344
345     return squash;
346 }
347
348
349
350 YQFrame *
351 YQWidgetFactory::createFrame( YWidget * parent, const string & label )
352 {
353     YQFrame * frame = new YQFrame( parent, label );
354     YUI_CHECK_NEW( frame );
355
356     return frame;
357 }
358
359
360
361 YQCheckBoxFrame *
362 YQWidgetFactory::createCheckBoxFrame( YWidget * parent, const string & label, bool checked )
363 {
364     YQCheckBoxFrame * checkBoxFrame = new YQCheckBoxFrame( parent, label, checked );
365     YUI_CHECK_NEW( checkBoxFrame );
366
367     return checkBoxFrame;
368 }
369
370
371
372 YQRadioButtonGroup *
373 YQWidgetFactory::createRadioButtonGroup( YWidget * parent )
374 {
375     YQRadioButtonGroup * radioButtonGroup = new YQRadioButtonGroup( parent );
376     YUI_CHECK_NEW( radioButtonGroup );
377
378     return radioButtonGroup;
379 }
380
381
382
383 YQReplacePoint *
384 YQWidgetFactory::createReplacePoint( YWidget * parent )
385 {
386     YQReplacePoint * replacePoint = new YQReplacePoint( parent );
387     YUI_CHECK_NEW( replacePoint );
388
389     return replacePoint;
390 }
391
392
393