libyui-qt  2.43.5
/usr/src/RPM/BUILD/libyui-qt-2.43.5/src/YQOptionalWidgetFactory.cc
00001 /*
00002   Copyright (C) 2000-2012 Novell, Inc
00003   This library is free software; you can redistribute it and/or modify
00004   it under the terms of the GNU Lesser General Public License as
00005   published by the Free Software Foundation; either version 2.1 of the
00006   License, or (at your option) version 3.0 of the License. This library
00007   is distributed in the hope that it will be useful, but WITHOUT ANY
00008   WARRANTY; without even the implied warranty of MERCHANTABILITY or
00009   FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
00010   License for more details. You should have received a copy of the GNU
00011   Lesser General Public License along with this library; if not, write
00012   to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
00013   Floor, Boston, MA 02110-1301 USA
00014 */
00015 
00016 
00017 /*-/
00018 
00019   File:         YQOptionalWidgetFactory.cc
00020 
00021   Author:       Stefan Hundhammer <sh@suse.de>
00022 
00023 /-*/
00024 
00025 #include "YQOptionalWidgetFactory.h"
00026 #include "YQApplication.h"
00027 #include <yui/YUIException.h>
00028 #include "YQPackageSelectorPluginStub.h"
00029 #include "YQWizard.h"
00030 #include "YQTimezoneSelector.h"
00031 #include "YQGraphPluginStub.h"
00032 
00033 #define THROW_UNSUPPORTED( WIDGET_TYPE ) \
00034     YUI_THROW( YUIUnsupportedWidgetException( WIDGET_TYPE ) );  \
00035     return 0
00036 
00037 
00038 
00039 YQOptionalWidgetFactory::YQOptionalWidgetFactory()
00040     : YOptionalWidgetFactory()
00041 {
00042     // NOP
00043 }
00044 
00045 YQOptionalWidgetFactory::~YQOptionalWidgetFactory()
00046 {
00047     // NOP
00048 }
00049 
00050 
00051 
00052 bool YQOptionalWidgetFactory::hasWizard()
00053 {
00054     return true;
00055 }
00056 
00057 YWizard *
00058 YQOptionalWidgetFactory::createWizard( YWidget *        parent,
00059                                        const std::string &      backButtonLabel,
00060                                        const std::string &      abortButtonLabel,
00061                                        const std::string &      nextButtonLabel,
00062                                        YWizardMode      wizardMode )
00063 {
00064     YQWizard * wizard = new YQWizard( parent,
00065                                       backButtonLabel,
00066                                       abortButtonLabel,
00067                                       nextButtonLabel,
00068                                       wizardMode );
00069     YUI_CHECK_NEW( wizard );
00070 
00071     return wizard;
00072 }
00073 
00074 
00075 
00076 bool YQOptionalWidgetFactory::hasDumbTab()
00077 {
00078     return true;
00079 }
00080 
00081 YQDumbTab *
00082 YQOptionalWidgetFactory::createDumbTab( YWidget * parent )
00083 {
00084     YQDumbTab * dumbTab = new YQDumbTab( parent );
00085     YUI_CHECK_NEW( dumbTab );
00086 
00087     return dumbTab;
00088 }
00089 
00090 
00091 
00092 bool YQOptionalWidgetFactory::hasSlider()
00093 {
00094     return true;
00095 }
00096 
00097 YQSlider *
00098 YQOptionalWidgetFactory::createSlider( YWidget *        parent,
00099                                       const std::string &       label,
00100                                       int               minVal,
00101                                       int               maxVal,
00102                                       int               initialVal )
00103 {
00104     YQSlider * slider = new YQSlider( parent, label, minVal, maxVal, initialVal );
00105     YUI_CHECK_NEW( slider );
00106 
00107     return slider;
00108 }
00109 
00110 
00111 
00112 bool YQOptionalWidgetFactory::hasDateField()
00113 {
00114     return true;
00115 }
00116 
00117 YQDateField *
00118 YQOptionalWidgetFactory::createDateField( YWidget * parent, const std::string & label )
00119 {
00120     YQDateField * dateField = new YQDateField( parent, label );
00121     YUI_CHECK_NEW( dateField );
00122 
00123     return dateField;
00124 }
00125 
00126 
00127 
00128 bool YQOptionalWidgetFactory::hasTimeField()
00129 {
00130     return true;
00131 }
00132 
00133 YQTimeField *
00134 YQOptionalWidgetFactory::createTimeField( YWidget * parent, const std::string & label )
00135 {
00136     YQTimeField * timeField = new YQTimeField( parent, label );
00137     YUI_CHECK_NEW( timeField );
00138 
00139     return timeField;
00140 }
00141 
00142 
00143 
00144 bool YQOptionalWidgetFactory::hasBarGraph()
00145 {
00146     return true;
00147 }
00148 
00149 YQBarGraph *
00150 YQOptionalWidgetFactory::createBarGraph( YWidget * parent )
00151 {
00152     YQBarGraph * barGraph = new YQBarGraph( parent );
00153     YUI_CHECK_NEW( barGraph );
00154 
00155     return barGraph;
00156 }
00157 
00158 
00159 
00160 bool YQOptionalWidgetFactory::hasPatternSelector()
00161 {
00162     return true;
00163 }
00164 
00165 
00166 
00167 
00168 bool YQOptionalWidgetFactory::hasSimplePatchSelector()
00169 {
00170     return true;
00171 }
00172 
00173 
00174 bool YQOptionalWidgetFactory::hasMultiProgressMeter()
00175 {
00176     return true;
00177 }
00178 
00179 YQMultiProgressMeter *
00180 YQOptionalWidgetFactory::createMultiProgressMeter( YWidget * parent, YUIDimension dim, const vector<float> & maxValues )
00181 {
00182     YQMultiProgressMeter * multiProgressMeter = new YQMultiProgressMeter( parent, dim, maxValues );
00183     YUI_CHECK_NEW( multiProgressMeter );
00184 
00185     return multiProgressMeter;
00186 }
00187 
00188 
00189 
00190 bool YQOptionalWidgetFactory::hasPartitionSplitter()
00191 {
00192     return true;
00193 }
00194 
00195 YQPartitionSplitter *
00196 YQOptionalWidgetFactory::createPartitionSplitter( YWidget *             parent,
00197                                                   int                   usedSize,
00198                                                   int                   totalFreeSize,
00199                                                   int                   newPartSize,
00200                                                   int                   minNewPartSize,
00201                                                   int                   minFreeSize,
00202                                                   const std::string &   usedLabel,
00203                                                   const std::string &   freeLabel,
00204                                                   const std::string &   newPartLabel,
00205                                                   const std::string &   freeFieldLabel,
00206                                                   const std::string &   newPartFieldLabel )
00207 {
00208     YQPartitionSplitter * partitionSplitter = new YQPartitionSplitter(  parent,
00209                                                                         usedSize,
00210                                                                         totalFreeSize,
00211                                                                         newPartSize,
00212                                                                         minNewPartSize,
00213                                                                         minFreeSize,
00214                                                                         usedLabel,
00215                                                                         freeLabel,
00216                                                                         newPartLabel,
00217                                                                         freeFieldLabel,
00218                                                                         newPartFieldLabel );
00219     YUI_CHECK_NEW( partitionSplitter );
00220 
00221     return partitionSplitter;
00222 }
00223 
00224 
00225 
00226 bool YQOptionalWidgetFactory::hasDownloadProgress()
00227 {
00228     return true;
00229 }
00230 
00231 YQDownloadProgress *
00232 YQOptionalWidgetFactory::createDownloadProgress( YWidget *      parent,
00233                                                  const std::string &    label,
00234                                                  const std::string & filename,
00235                                                  YFileSize_t    expectedSize )
00236 {
00237     YQDownloadProgress * downloadProgress = new YQDownloadProgress( parent,
00238                                                                     label,
00239                                                                     filename,
00240                                                                     expectedSize );
00241     YUI_CHECK_NEW( downloadProgress );
00242 
00243     return downloadProgress;
00244 }
00245 
00246 bool YQOptionalWidgetFactory::hasTimezoneSelector()
00247 {
00248     return true;
00249 }
00250 
00251 
00252 YTimezoneSelector *
00253 YQOptionalWidgetFactory::createTimezoneSelector( YWidget * parent,
00254                                                  const std::string & pixmap,
00255                                                  const map<string,string> & timezones )
00256 {
00257     return new YQTimezoneSelector( parent, pixmap, timezones );
00258 }
00259 
00260 
00261 bool YQOptionalWidgetFactory::hasGraph()
00262 {
00263     YQGraphPluginStub * plugin = YQApplication::graphPlugin();
00264 
00265     return plugin != NULL && plugin->impl != NULL;
00266 }
00267 
00268 
00269 YGraph *
00270 YQOptionalWidgetFactory::createGraph( YWidget * parent, const std::string & filename,
00271                                       const std::string & layoutAlgorithm )
00272 {
00273     YQGraphPluginStub * plugin = YQApplication::graphPlugin();
00274 
00275     if ( plugin )
00276         return plugin->createGraph( parent, filename, layoutAlgorithm );
00277     else
00278         return 0;
00279 }
00280 
00281 
00282 YGraph *
00283 YQOptionalWidgetFactory::createGraph( YWidget * parent, /* graph_t */ void * graph )
00284 {
00285     YQGraphPluginStub * plugin = YQApplication::graphPlugin();
00286 
00287     if ( plugin )
00288         return plugin->createGraph( parent, graph );
00289     else
00290         return 0;
00291 }
00292 
00293 
00294 YWidget *
00295 YQOptionalWidgetFactory::createPatternSelector(YWidget* parent, long modeFlags)
00296 {
00297     YQPackageSelectorPluginStub * plugin = YQApplication::packageSelectorPlugin();
00298 
00299     if ( plugin )
00300         return plugin->createPatternSelector( parent, modeFlags );
00301     else
00302         return 0;
00303 }
00304 
00305 YWidget *
00306 YQOptionalWidgetFactory::createSimplePatchSelector(YWidget* parent, long modeFlags)
00307 {
00308     YQPackageSelectorPluginStub * plugin = YQApplication::packageSelectorPlugin();
00309 
00310     if ( plugin )
00311         return plugin->createSimplePatchSelector( parent, modeFlags );
00312     else
00313         return 0;
00314 }
00315 
00316 bool YQOptionalWidgetFactory::hasContextMenu()
00317 {
00318     return true;
00319 }
00320 
00321 
 All Classes Functions Variables