KDevelop API Documentation

propertymachinefactory.cpp

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2004 by Alexander Dymo                                  *
00003  *   cloudtemple@mskat.net                                                 *
00004  *                                                                         *
00005  *   This program is free software; you can redistribute it and/or modify  *
00006  *   it under the terms of the GNU Library General Public License as       *
00007  *   published by the Free Software Foundation; either version 2 of the    *
00008  *   License, or (at your option) any later version.                       *
00009  *                                                                         *
00010  *   This program is distributed in the hope that it will be useful,       *
00011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00013  *   GNU General Public License for more details.                          *
00014  *                                                                         *
00015  *   You should have received a copy of the GNU Library General Public     *
00016  *   License along with this program; if not, write to the                 *
00017  *   Free Software Foundation, Inc.,                                       *
00018  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
00019  ***************************************************************************/
00020 #include "propertymachinefactory.h"
00021 
00022 #ifndef PURE_QT
00023 #include <klocale.h>
00024 #else
00025 #include "compat_tools.h"
00026 #endif
00027 
00028 #include <qmap.h>
00029 
00030 #include "property.h"
00031 #include "childproperty.h"
00032 #include "multiproperty.h"
00033 #include "plineedit.h"
00034 #include "pspinbox.h"
00035 #include "pdoublenuminput.h"
00036 #include "pcheckbox.h"
00037 #include "pstringlistedit.h"
00038 #include "pcolorcombo.h"
00039 #include "pdummywidget.h"
00040 #include "pcombobox.h"
00041 #include "psymbolcombo.h"
00042 #include "pfontcombo.h"
00043 #include "psizeedit.h"
00044 #include "pdateedit.h"
00045 #include "pdatetimeedit.h"
00046 #include "purledit.h"
00047 #include "ppointedit.h"
00048 #include "prectedit.h"
00049 #include "psizepolicyedit.h"
00050 #include "pcolorbutton.h"
00051 #include "pyesnobutton.h"
00052 #include "pfontbutton.h"
00053 #include "ppixmapedit.h"
00054 #include "pcursoredit.h"
00055 
00056 namespace PropertyLib{
00057 
00058 PropertyMachineFactory *PropertyMachineFactory::m_factory = 0;
00059 
00060 PropertyMachineFactory::PropertyMachineFactory()
00061 {
00062 }
00063 
00064 PropertyMachineFactory::~PropertyMachineFactory()
00065 {
00066 }
00067 
00068 Machine *PropertyMachineFactory::machineForProperty(MultiProperty *property)
00069 {
00070     int type = property->type();
00071     QString propertyName = property->name();
00072     QMap<QString, QVariant> valueList = property->valueList();
00073     
00074     if (m_registeredForType.contains(type))
00075         return (*m_registeredForType[type])();
00076 
00077     switch (type)
00078     {
00079         case Property::String:
00080             return new Machine(new PLineEdit(property));
00081         case Property::Integer:
00082             return new Machine(new PSpinBox(property));
00083         case Property::Double:
00084             return new Machine(new PDoubleNumInput(property));
00085         case Property::Boolean:
00086             return new Machine(new PYesNoButton(property));
00087         case Property::Date:
00088             return new Machine(new PDateEdit(property));
00089         case Property::DateTime:
00090             return new Machine(new PDateTimeEdit(property));
00091         case Property::StringList:
00092             return new Machine(new PStringListEdit(property));
00093         case Property::Color:
00094             return new Machine(new PColorButton(property));
00095         case Property::Font:
00096             return new Machine(new PFontButton(property));
00097         case Property::Pixmap:
00098             return new Machine(new PPixmapEdit(property));
00099 
00100         case Property::ValueFromList:
00101             return new Machine(new PComboBox(property, valueList));
00102         case Property::Symbol:
00103             return new Machine(new PSymbolCombo(property));
00104         case Property::FontName:
00105             return new Machine(new PFontCombo(property));
00106         case Property::FileURL:
00107             return new Machine(new PUrlEdit(KFile::File, property));
00108         case Property::DirectoryURL:
00109             return new Machine(new PUrlEdit(KFile::Directory, property));
00110 
00111         case Property::Size:
00112         {
00113             Machine *mach = new Machine(new PSizeEdit(property));
00114             property->details.append(ChildProperty(property, Property::Integer, ChildProperty::Size_Width, i18n("Width"), i18n("Width")));
00115             property->details.append(ChildProperty(property, Property::Integer, ChildProperty::Size_Height, i18n("Height"), i18n("Height")));
00116             return mach;
00117         }
00118         case Property::Point:
00119         {
00120             Machine *mach = new Machine(new PPointEdit(property));
00121             property->details.append(ChildProperty(property, Property::Integer, ChildProperty::Point_X, i18n("x"), i18n("x")));
00122             property->details.append(ChildProperty(property, Property::Integer, ChildProperty::Point_Y, i18n("y"), i18n("y")));
00123             return mach;
00124         }
00125         case Property::Rect:
00126         {
00127             Machine *mach = new Machine(new PRectEdit(property));
00128             property->details.append(ChildProperty(property, Property::Integer, ChildProperty::Rect_X, i18n("x"), i18n("x")));
00129             property->details.append(ChildProperty(property, Property::Integer, ChildProperty::Rect_Y, i18n("y"), i18n("y")));
00130             property->details.append(ChildProperty(property, Property::Integer, ChildProperty::Rect_Width, i18n("Width"), i18n("Width")));
00131             property->details.append(ChildProperty(property, Property::Integer, ChildProperty::Rect_Height, i18n("Height"), i18n("Height")));
00132             return mach;
00133         }
00134         case Property::SizePolicy:
00135         {
00136             QMap<QString, QVariant> spValues;
00137             spValues[i18n("Fixed")] = QSizePolicy::Fixed;
00138             spValues[i18n("Minimum")] = QSizePolicy::Minimum;
00139             spValues[i18n("Maximum")] = QSizePolicy::Maximum;
00140             spValues[i18n("Preferred")] = QSizePolicy::Preferred;
00141             spValues[i18n("Expanding")] = QSizePolicy::Expanding;
00142             spValues[i18n("Minimum Expanding")] = QSizePolicy::MinimumExpanding;
00143             spValues[i18n("Ignored")] = QSizePolicy::Ignored;
00144         
00145             Machine *mach = new Machine(new PSizePolicyEdit(property, spValues));
00146             property->details.append(ChildProperty(property, i18n("hSizeType"), ChildProperty::SizePolicy_HorData, spValues, i18n("Horizontal Size Type")));
00147             property->details.append(ChildProperty(property, i18n("vSizeType"), ChildProperty::SizePolicy_VerData, spValues, i18n("Vertical Size Type")));
00148             property->details.append(ChildProperty(property, Property::Integer, ChildProperty::SizePolicy_HorStretch, i18n("hStretch"), i18n("Horizontal Stretch")));
00149             property->details.append(ChildProperty(property, Property::Integer, ChildProperty::SizePolicy_VerStretch, i18n("vStretch"), i18n("Vertical Stretch")));
00150             return mach;
00151         }
00152         case Property::Cursor:
00153         {
00154             QMap<QString, QVariant> spValues;
00155             spValues[i18n("Arrow")] = Qt::ArrowCursor;
00156             spValues[i18n("Up Arrow")] = Qt::UpArrowCursor;
00157             spValues[i18n("Cross")] = Qt::CrossCursor;
00158             spValues[i18n("Waiting")] = Qt::WaitCursor;
00159             spValues[i18n("iBeam")] = Qt::IbeamCursor;
00160             spValues[i18n("Size Vertical")] = Qt::SizeVerCursor;
00161             spValues[i18n("Size Horizontal")] = Qt::SizeHorCursor;
00162             spValues[i18n("Size Slash")] = Qt::SizeBDiagCursor;
00163             spValues[i18n("Size Backslash")] = Qt::SizeFDiagCursor;
00164             spValues[i18n("Size All")] = Qt::SizeAllCursor;
00165             spValues[i18n("Blank")] = Qt::BlankCursor;
00166             spValues[i18n("Split Vertical")] = Qt::SplitVCursor;
00167             spValues[i18n("Split Horizontal")] = Qt::SplitHCursor;
00168             spValues[i18n("Pointing Hand")] = Qt::PointingHandCursor;
00169             spValues[i18n("Forbidden")] = Qt::ForbiddenCursor;
00170             spValues[i18n("What's this")] = Qt::WhatsThisCursor;
00171             Machine *mach = new Machine(new PCursorEdit(property, spValues));
00172             return mach;
00173         }
00174 
00175         case Property::List:
00176         case Property::Map:
00177         default:
00178             return new Machine(new PDummyWidget(property));
00179     }
00180 }
00181 
00182 PropertyMachineFactory *PropertyMachineFactory::getInstance()
00183 {
00184     if (m_factory == 0)
00185         m_factory = new PropertyMachineFactory();
00186     return m_factory;
00187 }
00188 
00189 bool PropertyMachineFactory::hasDetailedEditors( int type )
00190 {
00191     if ( (type==Property::Size) || (type==Property::Point) ||
00192         (type==Property::Rect) || (type==Property::SizePolicy) )
00193         return true;
00194     return 0;
00195 }
00196 
00197 }
KDE Logo
This file is part of the documentation for KDevelop Version 3.1.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Tue Feb 22 09:22:37 2005 by doxygen 1.3.9.1 written by Dimitri van Heesch, © 1997-2003