libyui-qt  2.49.2
YQOptionalWidgetFactory.cc
1 /*
2  Copyright (C) 2000-2012 Novell, Inc
3  This library is free software; you can redistribute it and/or modify
4  it under the terms of the GNU Lesser General Public License as
5  published by the Free Software Foundation; either version 2.1 of the
6  License, or (at your option) version 3.0 of the License. This library
7  is distributed in the hope that it will be useful, but WITHOUT ANY
8  WARRANTY; without even the implied warranty of MERCHANTABILITY or
9  FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
10  License for more details. You should have received a copy of the GNU
11  Lesser General Public License along with this library; if not, write
12  to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
13  Floor, Boston, MA 02110-1301 USA
14 */
15 
16 
17 /*-/
18 
19  File: YQOptionalWidgetFactory.cc
20 
21  Author: Stefan Hundhammer <sh@suse.de>
22 
23 /-*/
24 
25 #include "YQOptionalWidgetFactory.h"
26 #include "YQApplication.h"
27 #include <yui/YUIException.h>
28 #include "YQPackageSelectorPluginStub.h"
29 #include "YQWizard.h"
30 #include "YQTimezoneSelector.h"
31 #include "YQGraphPluginStub.h"
32 
33 #define THROW_UNSUPPORTED( WIDGET_TYPE ) \
34  YUI_THROW( YUIUnsupportedWidgetException( WIDGET_TYPE ) ); \
35  return 0
36 
37 
38 
40  : YOptionalWidgetFactory()
41 {
42  // NOP
43 }
44 
46 {
47  // NOP
48 }
49 
50 
51 
52 bool YQOptionalWidgetFactory::hasWizard()
53 {
54  return true;
55 }
56 
57 YWizard *
58 YQOptionalWidgetFactory::createWizard( YWidget * parent,
59  const std::string & backButtonLabel,
60  const std::string & abortButtonLabel,
61  const std::string & nextButtonLabel,
62  YWizardMode wizardMode )
63 {
64  YQWizard * wizard = new YQWizard( parent,
65  backButtonLabel,
66  abortButtonLabel,
67  nextButtonLabel,
68  wizardMode );
69  YUI_CHECK_NEW( wizard );
70 
71  return wizard;
72 }
73 
74 
75 
76 bool YQOptionalWidgetFactory::hasDumbTab()
77 {
78  return true;
79 }
80 
81 YQDumbTab *
82 YQOptionalWidgetFactory::createDumbTab( YWidget * parent )
83 {
84  YQDumbTab * dumbTab = new YQDumbTab( parent );
85  YUI_CHECK_NEW( dumbTab );
86 
87  return dumbTab;
88 }
89 
90 
91 
92 bool YQOptionalWidgetFactory::hasSlider()
93 {
94  return true;
95 }
96 
97 YQSlider *
98 YQOptionalWidgetFactory::createSlider( YWidget * parent,
99  const std::string & label,
100  int minVal,
101  int maxVal,
102  int initialVal )
103 {
104  YQSlider * slider = new YQSlider( parent, label, minVal, maxVal, initialVal );
105  YUI_CHECK_NEW( slider );
106 
107  return slider;
108 }
109 
110 
111 
112 bool YQOptionalWidgetFactory::hasDateField()
113 {
114  return true;
115 }
116 
117 YQDateField *
118 YQOptionalWidgetFactory::createDateField( YWidget * parent, const std::string & label )
119 {
120  YQDateField * dateField = new YQDateField( parent, label );
121  YUI_CHECK_NEW( dateField );
122 
123  return dateField;
124 }
125 
126 
127 
128 bool YQOptionalWidgetFactory::hasTimeField()
129 {
130  return true;
131 }
132 
133 YQTimeField *
134 YQOptionalWidgetFactory::createTimeField( YWidget * parent, const std::string & label )
135 {
136  YQTimeField * timeField = new YQTimeField( parent, label );
137  YUI_CHECK_NEW( timeField );
138 
139  return timeField;
140 }
141 
142 
143 
144 bool YQOptionalWidgetFactory::hasBarGraph()
145 {
146  return true;
147 }
148 
149 YQBarGraph *
150 YQOptionalWidgetFactory::createBarGraph( YWidget * parent )
151 {
152  YQBarGraph * barGraph = new YQBarGraph( parent );
153  YUI_CHECK_NEW( barGraph );
154 
155  return barGraph;
156 }
157 
158 
159 
160 bool YQOptionalWidgetFactory::hasPatternSelector()
161 {
162  return true;
163 }
164 
165 
166 
167 
168 bool YQOptionalWidgetFactory::hasSimplePatchSelector()
169 {
170  return true;
171 }
172 
173 
174 bool YQOptionalWidgetFactory::hasMultiProgressMeter()
175 {
176  return true;
177 }
178 
180 YQOptionalWidgetFactory::createMultiProgressMeter( YWidget * parent, YUIDimension dim, const vector<float> & maxValues )
181 {
182  YQMultiProgressMeter * multiProgressMeter = new YQMultiProgressMeter( parent, dim, maxValues );
183  YUI_CHECK_NEW( multiProgressMeter );
184 
185  return multiProgressMeter;
186 }
187 
188 
189 
190 bool YQOptionalWidgetFactory::hasPartitionSplitter()
191 {
192  return true;
193 }
194 
196 YQOptionalWidgetFactory::createPartitionSplitter( YWidget * parent,
197  int usedSize,
198  int totalFreeSize,
199  int newPartSize,
200  int minNewPartSize,
201  int minFreeSize,
202  const std::string & usedLabel,
203  const std::string & freeLabel,
204  const std::string & newPartLabel,
205  const std::string & freeFieldLabel,
206  const std::string & newPartFieldLabel )
207 {
208  YQPartitionSplitter * partitionSplitter = new YQPartitionSplitter( parent,
209  usedSize,
210  totalFreeSize,
211  newPartSize,
212  minNewPartSize,
213  minFreeSize,
214  usedLabel,
215  freeLabel,
216  newPartLabel,
217  freeFieldLabel,
218  newPartFieldLabel );
219  YUI_CHECK_NEW( partitionSplitter );
220 
221  return partitionSplitter;
222 }
223 
224 
225 
226 bool YQOptionalWidgetFactory::hasDownloadProgress()
227 {
228  return true;
229 }
230 
232 YQOptionalWidgetFactory::createDownloadProgress( YWidget * parent,
233  const std::string & label,
234  const std::string & filename,
235  YFileSize_t expectedSize )
236 {
237  YQDownloadProgress * downloadProgress = new YQDownloadProgress( parent,
238  label,
239  filename,
240  expectedSize );
241  YUI_CHECK_NEW( downloadProgress );
242 
243  return downloadProgress;
244 }
245 
246 bool YQOptionalWidgetFactory::hasTimezoneSelector()
247 {
248  return true;
249 }
250 
251 
252 YTimezoneSelector *
253 YQOptionalWidgetFactory::createTimezoneSelector( YWidget * parent,
254  const std::string & pixmap,
255  const map<string,string> & timezones )
256 {
257  return new YQTimezoneSelector( parent, pixmap, timezones );
258 }
259 
260 
261 bool YQOptionalWidgetFactory::hasGraph()
262 {
264 
265  return plugin != NULL && plugin->impl != NULL;
266 }
267 
268 
269 YGraph *
270 YQOptionalWidgetFactory::createGraph( YWidget * parent, const std::string & filename,
271  const std::string & layoutAlgorithm )
272 {
274 
275  if ( plugin )
276  return plugin->createGraph( parent, filename, layoutAlgorithm );
277  else
278  return 0;
279 }
280 
281 
282 YGraph *
283 YQOptionalWidgetFactory::createGraph( YWidget * parent, /* graph_t */ void * graph )
284 {
286 
287  if ( plugin )
288  return plugin->createGraph( parent, graph );
289  else
290  return 0;
291 }
292 
293 
294 YWidget *
295 YQOptionalWidgetFactory::createPatternSelector(YWidget* parent, long modeFlags)
296 {
298 
299  if ( plugin )
300  return plugin->createPatternSelector( parent, modeFlags );
301  else
302  return 0;
303 }
304 
305 YWidget *
306 YQOptionalWidgetFactory::createSimplePatchSelector(YWidget* parent, long modeFlags)
307 {
309 
310  if ( plugin )
311  return plugin->createSimplePatchSelector( parent, modeFlags );
312  else
313  return 0;
314 }
315 
316 bool YQOptionalWidgetFactory::hasContextMenu()
317 {
318  return true;
319 }
320 
321 
virtual YGraph * createGraph(YWidget *parent, const std::string &filename, const std::string &layoutAlgorithm)
Create a package selector.
virtual YWidget * createSimplePatchSelector(YWidget *parent, long modeFlags)
Create a simple patch selector (optional widget).
static YQGraphPluginStub * graphPlugin()
Return the package selector plugin singleton or creates it (including loading the plugin lib) if it d...
virtual YWidget * createPatternSelector(YWidget *parent, long modeFlags)
Create a pattern selector (optional widget).
static YQPackageSelectorPluginStub * packageSelectorPlugin()
Return the package selector plugin singleton or creates it (including loading the plugin lib) if it d...
virtual ~YQOptionalWidgetFactory()
Destructor.