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