]> icculus.org git repositories - duncan/yast2-qt4.git/blob - src/YQOptionalWidgetFactory.cc
ported everything n pkg selector needed to port the rest of the UI
[duncan/yast2-qt4.git] / src / YQOptionalWidgetFactory.cc
1 /*---------------------------------------------------------------------\
2 |                                                                      |
3 |                      __   __    ____ _____ ____                      |
4 |                      \ \ / /_ _/ ___|_   _|___ \                     |
5 |                       \ V / _` \___ \ | |   __) |                    |
6 |                        | | (_| |___) || |  / __/                     |
7 |                        |_|\__,_|____/ |_| |_____|                    |
8 |                                                                      |
9 |                               core system                            |
10 |                                                        (C) SuSE GmbH |
11 \----------------------------------------------------------------------/
12
13   File:         YQOptionalWidgetFactory.cc
14
15   Author:       Stefan Hundhammer <sh@suse.de>
16
17 /-*/
18
19 #include "YQOptionalWidgetFactory.h"
20 #include "YQUI.h"
21 #include "YUIException.h"
22 #include "YQPackageSelectorPlugin.h"
23 #include "YQWizard.h"
24
25 #define THROW_UNSUPPORTED( WIDGET_TYPE ) \
26     YUI_THROW( YUIUnsupportedWidgetException( WIDGET_TYPE ) );  \
27     return 0
28
29
30
31 YQOptionalWidgetFactory::YQOptionalWidgetFactory()
32     : YOptionalWidgetFactory()
33 {
34     // NOP
35 }
36
37 YQOptionalWidgetFactory::~YQOptionalWidgetFactory()
38 {
39     // NOP
40 }
41
42
43
44 bool YQOptionalWidgetFactory::hasWizard()
45 {
46     return true;
47 }
48
49 YWizard *
50 YQOptionalWidgetFactory::createWizard( YWidget *        parent,
51                                        const string &   backButtonLabel,
52                                        const string &   abortButtonLabel,
53                                        const string &   nextButtonLabel,
54                                        YWizardMode      wizardMode )
55 {
56     YQWizard * wizard = new YQWizard( parent,
57                                       backButtonLabel,
58                                       abortButtonLabel,
59                                       nextButtonLabel,
60                                       wizardMode );
61     YUI_CHECK_NEW( wizard );
62
63     return wizard;
64 }
65
66
67
68 bool YQOptionalWidgetFactory::hasDumbTab()
69 {
70     return true;
71 }
72
73 YQDumbTab *
74 YQOptionalWidgetFactory::createDumbTab( YWidget * parent )
75 {
76     YQDumbTab * dumbTab = new YQDumbTab( parent );
77     YUI_CHECK_NEW( dumbTab );
78
79     return dumbTab;
80 }
81
82
83
84 bool YQOptionalWidgetFactory::hasSlider()
85 {
86     return true;
87 }
88
89 YQSlider *
90 YQOptionalWidgetFactory::createSlider( YWidget *        parent,
91                                       const string &    label,
92                                       int               minVal,
93                                       int               maxVal,
94                                       int               initialVal )
95 {
96     YQSlider * slider = new YQSlider( parent, label, minVal, maxVal, initialVal );
97     YUI_CHECK_NEW( slider );
98
99     return slider;
100 }
101
102
103
104 bool YQOptionalWidgetFactory::hasDateField()
105 {
106     return true;
107 }
108
109 YQDateField *
110 YQOptionalWidgetFactory::createDateField( YWidget * parent, const string & label )
111 {
112     YQDateField * dateField = new YQDateField( parent, label );
113     YUI_CHECK_NEW( dateField );
114
115     return dateField;
116 }
117
118
119
120 bool YQOptionalWidgetFactory::hasTimeField()
121 {
122     return true;
123 }
124
125 YQTimeField *
126 YQOptionalWidgetFactory::createTimeField( YWidget * parent, const string & label )
127 {
128     YQTimeField * timeField = new YQTimeField( parent, label );
129     YUI_CHECK_NEW( timeField );
130
131     return timeField;
132 }
133
134
135
136 bool YQOptionalWidgetFactory::hasBarGraph()
137 {
138     return true;
139 }
140
141 YQBarGraph *
142 YQOptionalWidgetFactory::createBarGraph( YWidget * parent )
143 {
144     YQBarGraph * barGraph = new YQBarGraph( parent );
145     YUI_CHECK_NEW( barGraph );
146
147     return barGraph;
148 }
149
150
151
152 bool YQOptionalWidgetFactory::hasPatternSelector()
153 {
154     return true;
155 }
156
157 YQPatternSelector *
158 YQOptionalWidgetFactory::createPatternSelector( YWidget * parent, long modeFlags )
159 {
160     YQPackageSelectorPlugin * plugin = YQUI::ui()->packageSelectorPlugin();
161
162     if ( plugin )
163         return plugin->createPatternSelector( parent, modeFlags );
164     else
165         return 0;
166 }
167
168
169
170 bool YQOptionalWidgetFactory::hasSimplePatchSelector()
171 {
172     return true;
173 }
174
175 YQSimplePatchSelector *
176 YQOptionalWidgetFactory::createSimplePatchSelector( YWidget * parent, long modeFlags )
177 {
178     YQPackageSelectorPlugin * plugin = YQUI::ui()->packageSelectorPlugin();
179
180     if ( plugin )
181         return plugin->createSimplePatchSelector( parent, modeFlags );
182     else
183         return 0;
184 }
185
186
187
188 bool YQOptionalWidgetFactory::hasMultiProgressMeter()
189 {
190     return true;
191 }
192
193 YQMultiProgressMeter *
194 YQOptionalWidgetFactory::createMultiProgressMeter( YWidget * parent, YUIDimension dim, const vector<float> & maxValues )
195 {
196     YQMultiProgressMeter * multiProgressMeter = new YQMultiProgressMeter( parent, dim, maxValues );
197     YUI_CHECK_NEW( multiProgressMeter );
198
199     return multiProgressMeter;
200 }
201
202
203
204 bool YQOptionalWidgetFactory::hasPartitionSplitter()
205 {
206     return true;
207 }
208
209 YQPartitionSplitter *
210 YQOptionalWidgetFactory::createPartitionSplitter( YWidget *             parent,
211                                                   int                   usedSize,
212                                                   int                   totalFreeSize,
213                                                   int                   newPartSize,
214                                                   int                   minNewPartSize,
215                                                   int                   minFreeSize,
216                                                   const string &        usedLabel,
217                                                   const string &        freeLabel,
218                                                   const string &        newPartLabel,
219                                                   const string &        freeFieldLabel,
220                                                   const string &        newPartFieldLabel )
221 {
222     YQPartitionSplitter * partitionSplitter = new YQPartitionSplitter(  parent,
223                                                                         usedSize,
224                                                                         totalFreeSize,
225                                                                         newPartSize,
226                                                                         minNewPartSize,
227                                                                         minFreeSize,
228                                                                         usedLabel,
229                                                                         freeLabel,
230                                                                         newPartLabel,
231                                                                         freeFieldLabel,
232                                                                         newPartFieldLabel );
233     YUI_CHECK_NEW( partitionSplitter );
234
235     return partitionSplitter;
236 }
237
238
239
240 bool YQOptionalWidgetFactory::hasDownloadProgress()
241 {
242     return true;
243 }
244
245 YQDownloadProgress *
246 YQOptionalWidgetFactory::createDownloadProgress( YWidget *      parent,
247                                                  const string & label,
248                                                  const string & filename,
249                                                  YFileSize_t    expectedSize )
250 {
251     YQDownloadProgress * downloadProgress = new YQDownloadProgress( parent,
252                                                                     label,
253                                                                     filename,
254                                                                     expectedSize );
255     YUI_CHECK_NEW( downloadProgress );
256
257     return downloadProgress;
258 }
259