libs/flake
KoShapeFactory.h
Go to the documentation of this file.00001 /* This file is part of the KDE project 00002 * Copyright (c) 2006 Boudewijn Rempt (boud@valdyas.org) 00003 * Copyright (C) 2006-2007 Thomas Zander <zander@kde.org> 00004 * Copyright (C) 2008 Thorsten Zachmann <zachmann@kde.org> 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 _KO_SHAPE_FACTORY_ 00023 #define _KO_SHAPE_FACTORY_ 00024 00025 #include <QStringList> 00026 #include <QString> 00027 #include <QWidget> 00028 #include <QList> 00029 #include <QMap> 00030 00031 #include "flake_export.h" 00032 00033 #include <KoXmlReader.h> 00034 00035 class KoShape; 00036 class KoProperties; 00037 class KoShapeConfigFactory; 00038 class KoShapeConfigWidgetBase; 00039 class KoDataCenter; 00040 00041 #define SHAPETEMPLATE_MIMETYPE "application/x-flake-shapetemplate" 00042 #define SHAPEID_MIMETYPE "application/x-flake-shapeId" 00043 00049 struct FLAKE_EXPORT KoShapeTemplate { 00050 KoShapeTemplate() { 00051 properties = 0; 00052 } 00053 QString id; 00054 QString templateId; 00055 QString name; 00056 QString family; 00057 QString toolTip; 00058 QString icon; 00059 00063 KoProperties *properties; 00064 }; 00065 00088 class FLAKE_EXPORT KoShapeFactory : public QObject 00089 { 00090 Q_OBJECT 00091 public: 00092 00100 KoShapeFactory(QObject *parent, const QString &id, const QString &name); 00101 virtual ~KoShapeFactory(); 00102 00121 KoShape * createDefaultShapeAndInit(const QMap<QString, KoDataCenter *> & dataCenterMap) const; 00122 00143 KoShape * createShapeAndInit(const KoProperties * params, const QMap<QString, KoDataCenter *> & dataCenterMap) const; 00144 00153 virtual QList<KoShapeConfigWidgetBase*> createShapeOptionPanels() { 00154 return QList<KoShapeConfigWidgetBase*>(); 00155 } 00156 00172 void setOptionPanels(QList<KoShapeConfigFactory*> &panelFactories); 00173 00178 const QList<KoShapeConfigFactory*> &panelFactories(); 00179 00185 virtual void populateDataCenterMap(QMap<QString, KoDataCenter *> & dataCenterMap) { 00186 Q_UNUSED(dataCenterMap) 00187 } 00192 QString id() const; 00197 const QList<KoShapeTemplate> templates() const; 00202 QString toolTip() const; 00207 QString icon() const; 00212 QString name() const; 00217 QString family() const; 00219 quint32 loadingPriority() const; 00220 00223 const QString & odfNameSpace() const; 00224 00227 QStringList odfElementNames() const; 00228 00231 virtual bool supports(const KoXmlElement & e) const; 00232 00238 virtual bool hidden() const; 00239 00240 protected: 00241 00250 virtual KoShape * createDefaultShape() const = 0; 00251 00259 virtual KoShape * createShape(const KoProperties * params) const = 0; 00260 00266 void addTemplate(KoShapeTemplate ¶ms); 00267 00272 void setToolTip(const QString & tooltip); 00273 00279 void setIcon(const QString & iconName); 00280 00286 void setFamily(const QString &family); 00287 00293 void setLoadingPriority(quint32 priority); 00294 00306 void setOdfElementNames(const QString & nameSpace, const QStringList & elementNames); 00307 00308 private: 00309 class Private; 00310 Private * const d; 00311 }; 00312 00313 #endif // _KO_SHAPE_FACTORY_
