Warning, file /office/calligra/libs/rdf/KoRdfSemanticItemRegistry.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 Calligra project, made with-in the KDE community
0002 
0003    Copyright (C) 2010 KO GmbH <ben.martin@kogmbh.com>
0004    Copyright (C) 2013 Friedrich W. H. Kossebau <kossebau@kde.org>
0005 
0006    This library is free software; you can redistribute it and/or
0007    modify it under the terms of the GNU Library General Public
0008    License as published by the Free Software Foundation; either
0009    version 2.1 of the License, or (at your option) any later version.
0010 
0011    This library is distributed in the hope that it will be useful,
0012    but WITHOUT ANY WARRANTY; without even the implied warranty of
0013    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0014    Library General Public License for more details.
0015 
0016    You should have received a copy of the GNU Library General Public License
0017    along with this library; see the file COPYING.LIB.  If not, write to
0018    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
0019    Boston, MA 02110-1301, USA.
0020 */
0021 
0022 #ifndef KORDFSEMANTICITEMREGISTRY_H
0023 #define KORDFSEMANTICITEMREGISTRY_H
0024 
0025 #include "kordf_export.h"
0026 
0027 // Calligra
0028 #include "KoRdfSemanticItem.h"
0029 #include "KoRdfSemanticItemFactoryBase.h"
0030 #include <KoGenericRegistry.h>
0031 
0032 // Qt
0033 #include <QSharedPointer>
0034 
0035 class KoCanvasBase;
0036 
0037 /**
0038  * This singleton class keeps a register of all available semantic item factories.
0039  * @see KoRdfSemanticItemFactoryBase
0040  * @see KoRdfSemanticItem
0041  */
0042 class KORDF_EXPORT KoRdfSemanticItemRegistry : public KoGenericRegistry<KoRdfSemanticItemFactoryBase*>
0043 {
0044 public:
0045     ~KoRdfSemanticItemRegistry();
0046 
0047     /**
0048      * Return an instance of the KoRdfSemanticItemRegistry
0049      * Creates an instance if that has never happened before and returns the singleton instance.
0050      */
0051     static KoRdfSemanticItemRegistry *instance();
0052 
0053     /**
0054      * Gets a list of SemanticItem subclasses that can be created.
0055      * Any of the strings in the return value can be created using
0056      * createSemanticItem().
0057      *
0058      * @see createSemanticItem()
0059      */
0060     QStringList classNames() const;
0061 
0062     /**
0063      * Returns the display name of the class, or an empty string if none was found.
0064      */
0065     QString classDisplayName(const QString &className) const;
0066 
0067     /**
0068      * Create a SemanticItem subclass using its name from
0069      * classNames(). Useful for menus and other places that want to
0070      * allow the user to create new SemanticItem Objects.
0071      */
0072     hKoRdfBasicSemanticItem createSemanticItem(const QString &semanticClass, const KoDocumentRdf *docRdf, QObject *parent = 0) const;
0073 
0074     /**
0075      * Create a SemanticItem subclass from the passed mimeData.
0076      * TODO: support that mimedata could be used for different semantic item classes
0077      */
0078     hKoRdfBasicSemanticItem createSemanticItemFromMimeData(const QMimeData *mimeData, KoCanvasBase *host, const KoDocumentRdf *docRdf, QObject *parent = 0) const;
0079 
0080     /**
0081      * Returns if a semantic item could be principally created from the passed mimeData.
0082      * Creation could still fail if actually tried.
0083      */
0084     bool canCreateSemanticItemFromMimeData(const QMimeData *mimeData) const;
0085 
0086     void updateSemanticItems(
0087         QList<hKoRdfBasicSemanticItem> &semanticItems,
0088         const KoDocumentRdf *docRdf,
0089         const QString &className,
0090         QSharedPointer<Soprano::Model> m = QSharedPointer<Soprano::Model>(0)) const;
0091 
0092     bool isBasic(const QString &className);
0093 
0094 private:
0095     KoRdfSemanticItemRegistry();
0096     KoRdfSemanticItemRegistry(const KoRdfSemanticItemRegistry&);
0097     KoRdfSemanticItemRegistry operator=(const KoRdfSemanticItemRegistry&);
0098 
0099     class Private;
0100     Private * const d;
0101 };
0102 
0103 #endif