Warning, file /office/calligra/libs/flake/KoShapeConfigFactoryBase.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 /* This file is part of the KDE project
0002  * Copyright (C) 2006 Thomas Zander <zander@kde.org>
0003  *
0004  * This library is free software; you can redistribute it and/or
0005  * modify it under the terms of the GNU Library General Public
0006  * License as published by the Free Software Foundation; either
0007  * version 2 of the License, or (at your option) any later version.
0008  *
0009  * This library is distributed in the hope that it will be useful,
0010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0012  * Library General Public License for more details.
0013  *
0014  * You should have received a copy of the GNU Library General Public License
0015  * along with this library; see the file COPYING.LIB.  If not, write to
0016  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
0017  * Boston, MA 02110-1301, USA.
0018  */
0019 
0020 #ifndef _KO_SHAPE_CONFIG_FACTORY_
0021 #define _KO_SHAPE_CONFIG_FACTORY_
0022 
0023 #include "flake_export.h"
0024 
0025 #include <QString>
0026 
0027 class KoShape;
0028 class KoShapeConfigWidgetBase;
0029 
0030 /**
0031  * A factory that creates config panels (widgets) for just a created shape.
0032  * The KoCreateShapesTool is able to show a number of configuration panels after
0033  * it created a shape via user interaction.  Each shape configuration panel type
0034  * has its own factory, which will inherit from this class.
0035  * @see KoShapeFactoryBase::panelFactories()
0036  * @see KoShapeConfigWidgetBase
0037  */
0038 class FLAKE_EXPORT KoShapeConfigFactoryBase
0039 {
0040 public:
0041     /// default constructor
0042     KoShapeConfigFactoryBase();
0043     virtual ~KoShapeConfigFactoryBase();
0044 
0045     /**
0046      * create a new config widget, initialized with the param shape
0047      * @param shape the shape that will be configured in the config widget.
0048      * @see KoShapeConfigWidgetBase::open()
0049      */
0050     virtual KoShapeConfigWidgetBase *createConfigWidget(KoShape *shape) = 0;
0051     /// return the (translated) name of this configuration
0052     virtual QString name() const = 0;
0053 
0054     /**
0055      * Return a sorting ordering to specify where in the list of config widgets this
0056      * one will be shown.
0057      * Higher sorting numbers will be shown first. The default is 1.
0058      */
0059     virtual int sortingOrder() const {
0060         return 1;
0061     }
0062 
0063     /**
0064      * Return true if the createConfigWidget() should be called at all for a shape of
0065      * the specified type.
0066      * @param id an ID like the KoShapeFactoryBase::shapeId()
0067      */
0068     virtual bool showForShapeId(const QString &id) const {
0069         Q_UNUSED(id); return true;
0070     }
0071 
0072 
0073     /// \internal a compare for sorting.
0074     static bool compare(KoShapeConfigFactoryBase *f1, KoShapeConfigFactoryBase *f2) {
0075         return f1->sortingOrder() - f2->sortingOrder() > 0;
0076     }
0077 };
0078 
0079 #endif