libs/flake

KoShapeFactory.cpp

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 Casper Boemann <cbr@boemann.dk>
00005  * Copyright (C) 2008 Thorsten Zachmann <zachmann@kde.org>
00006  *
00007  * This library is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU Library General Public
00009  * License as published by the Free Software Foundation; either
00010  * version 2 of the License, or (at your option) any later version.
00011  *
00012  * This library is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015  * Library General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU Library General Public License
00018  * along with this library; see the file COPYING.LIB.  If not, write to
00019  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00020  * Boston, MA 02110-1301, USA.
00021  */
00022 
00023 #include "KoShapeFactory.h"
00024 #include "KoShape.h"
00025 #include <KoProperties.h>
00026 
00027 #include <kdebug.h>
00028 
00029 class KoShapeFactory::Private
00030 {
00031 public:
00032     Private(const QString &i, const QString &n)
00033             : id(i)
00034             , name(n)
00035             , loadingPriority(0) {
00036     }
00037 
00038     ~Private() {
00039         foreach(const KoShapeTemplate & t, templates)
00040             delete t.properties;
00041         templates.clear();
00042     }
00043 
00044     QList<KoShapeTemplate> templates;
00045     QList<KoShapeConfigFactory*> configPanels;
00046     const QString id;
00047     const QString name;
00048     QString family;
00049     QString tooltip;
00050     QString iconName;
00051     quint32 loadingPriority;
00052     QString odfNameSpace;
00053     QStringList odfElementNames;
00054 };
00055 
00056 
00057 KoShapeFactory::KoShapeFactory(QObject *parent, const QString &id, const QString &name)
00058         : QObject(parent),
00059         d(new Private(id, name))
00060 {
00061 }
00062 
00063 KoShapeFactory::~KoShapeFactory()
00064 {
00065     delete d;
00066 }
00067 
00068 KoShape * KoShapeFactory::createDefaultShapeAndInit(const QMap<QString, KoDataCenter *> & dataCenterMap) const
00069 {
00070     KoShape * shape = createDefaultShape();
00071     Q_ASSERT(shape);
00072     shape->init(dataCenterMap);
00073     return shape;
00074 }
00075 
00076 KoShape * KoShapeFactory::createShapeAndInit(const KoProperties * params, const QMap<QString, KoDataCenter *> & dataCenterMap) const
00077 {
00078     KoShape * shape = createShape(params);
00079     Q_ASSERT(shape);
00080     shape->init(dataCenterMap);
00081     return shape;
00082 }
00083 
00084 QString KoShapeFactory::toolTip() const
00085 {
00086     return d->tooltip;
00087 }
00088 
00089 QString KoShapeFactory::icon() const
00090 {
00091     return d->iconName;
00092 }
00093 
00094 QString KoShapeFactory::name() const
00095 {
00096     return d->name;
00097 }
00098 
00099 QString KoShapeFactory::family() const
00100 {
00101     return d->family;
00102 }
00103 
00104 quint32 KoShapeFactory::loadingPriority() const
00105 {
00106     return d->loadingPriority;
00107 }
00108 
00109 QStringList KoShapeFactory::odfElementNames() const
00110 {
00111     return d->odfElementNames;
00112 }
00113 
00114 const QString & KoShapeFactory::odfNameSpace() const
00115 {
00116     return d->odfNameSpace;
00117 }
00118 
00119 bool KoShapeFactory::supports(const KoXmlElement & e) const
00120 {
00121     Q_UNUSED(e);
00122     // XXX: Remove this and replace with a pure virtual once
00123     // everything has implemented it.
00124     return false;
00125 }
00126 
00127 void KoShapeFactory::addTemplate(KoShapeTemplate &params)
00128 {
00129     params.id = d->id;
00130     d->templates.append(params);
00131 }
00132 
00133 void KoShapeFactory::setToolTip(const QString & tooltip)
00134 {
00135     d->tooltip = tooltip;
00136 }
00137 
00138 void KoShapeFactory::setIcon(const QString & iconName)
00139 {
00140     d->iconName = iconName;
00141 }
00142 
00143 void KoShapeFactory::setFamily(const QString & family)
00144 {
00145     d->family = family;
00146 }
00147 
00148 QString KoShapeFactory::id() const
00149 {
00150     return d->id;
00151 }
00152 
00153 void KoShapeFactory::setOptionPanels(QList<KoShapeConfigFactory*> &panelFactories)
00154 {
00155     d->configPanels = panelFactories;
00156 }
00157 
00158 const QList<KoShapeConfigFactory*> &KoShapeFactory::panelFactories()
00159 {
00160     return d->configPanels;
00161 }
00162 
00163 const QList<KoShapeTemplate> KoShapeFactory::templates() const
00164 {
00165     return d->templates;
00166 }
00167 
00168 void KoShapeFactory::setLoadingPriority(quint32 priority)
00169 {
00170     d->loadingPriority = priority;
00171 }
00172 
00173 void KoShapeFactory::setOdfElementNames(const QString & nameSpace, const QStringList & names)
00174 {
00175     d->odfNameSpace = nameSpace;
00176     d->odfElementNames = names;
00177 }
00178 
00179 bool KoShapeFactory::hidden() const
00180 {
00181     return false;
00182 }
00183 
00184 #include "KoShapeFactory.moc"