lib

factory.h

00001 /* This file is part of the KDE project
00002    Copyright (C) 2004 Cedric Pasteur <cedric.pasteur@free.fr>
00003    Copyright (C) 2004 Alexander Dymo <cloudtemple@mskat.net>
00004    Copyright (C) 2005 Jaroslaw Staniek <js@iidea.pl>
00005 
00006    This library is free software; you can redistribute it and/or
00007    modify it under the terms of the GNU Library General Public
00008    License as published by the Free Software Foundation; either
00009    version 2 of the License, or (at your option) any later version.
00010 
00011    This library is distributed in the hope that it will be useful,
00012    but WITHOUT ANY WARRANTY; without even the implied warranty of
00013    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014    Library General Public License for more details.
00015 
00016    You should have received a copy of the GNU Library General Public License
00017    along with this library; see the file COPYING.LIB.  If not, write to
00018    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00019  * Boston, MA 02110-1301, USA.
00020 */
00021 
00022 #ifndef KPROPERTY_FACTORY_H
00023 #define KPROPERTY_FACTORY_H
00024 
00025 #include "koproperty_global.h"
00026 #include <kstaticdeleter.h> 
00027 #include <qobject.h> 
00028 
00029 template<class U> class QValueList;
00030 
00031 namespace KoProperty {
00032 
00033 class Widget;
00034 class CustomProperty;
00035 class Property;
00036 class FactoryManagerPrivate;
00037 
00039 //typedef Widget *(*createWidget) (Property*);
00040 //typedef CustomProperty *(*createCustomProperty) (Property*);
00041 
00043 class KOPROPERTY_EXPORT CustomPropertyFactory : public QObject
00044 {
00045     public:
00046         CustomPropertyFactory(QObject *parent);
00047         virtual ~CustomPropertyFactory();
00048 
00052         virtual CustomProperty* createCustomProperty(Property *parent) = 0;
00053 
00057         virtual Widget* createCustomWidget(Property *property) = 0;
00058 };
00059 
00061 
00097 class KOPROPERTY_EXPORT FactoryManager : public QObject
00098 {
00099     public:
00108         void registerFactoryForEditor(int editorType, CustomPropertyFactory *factory);
00109 
00112         void registerFactoryForEditors(const QValueList<int> &editorTypes, CustomPropertyFactory *factory);
00113 
00117         CustomPropertyFactory *factoryForEditorType(int type);
00118 
00123         Widget* createWidgetForProperty(Property *property);
00124 
00127         void registerFactoryForProperty(int propertyType, CustomPropertyFactory *factory);
00128 
00131         void registerFactoryForProperties(const QValueList<int> &propertyTypes, 
00132             CustomPropertyFactory *factory);
00133 
00137         CustomProperty* createCustomProperty(Property *parent);
00138 
00140         static FactoryManager* self();
00141 
00142     private:
00143         FactoryManager();
00144         ~FactoryManager();
00145 
00146         FactoryManagerPrivate *d;
00147         friend class KStaticDeleter<KoProperty::FactoryManager>;
00148 };
00149 
00150 }
00151 
00152 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys