Warning, file /office/calligra/libs/rdf/KoRdfSemanticItemRegistry.cpp 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 #include "KoRdfSemanticItemRegistry.h" 0023 0024 #include <KoPluginLoader.h> 0025 0026 #include <KDebug> 0027 #include <KGlobal> 0028 0029 class Q_DECL_HIDDEN KoRdfSemanticItemRegistry::Private 0030 { 0031 public: 0032 ~Private(); 0033 void init(); 0034 }; 0035 0036 KoRdfSemanticItemRegistry::Private::~Private() 0037 { 0038 } 0039 0040 void KoRdfSemanticItemRegistry::Private::init() 0041 { 0042 KoPluginLoader::PluginsConfig config; 0043 config.whiteList = "SemanticItemPlugins"; 0044 config.blacklist = "SemanticItemPluginsDisabled"; 0045 config.group = "calligra"; 0046 KoPluginLoader::load(QStringLiteral("calligra/semanticitems"), config); 0047 } 0048 0049 KoRdfSemanticItemRegistry* KoRdfSemanticItemRegistry::instance() 0050 { 0051 K_GLOBAL_STATIC(KoRdfSemanticItemRegistry, s_instance) 0052 if (!s_instance.exists()) { 0053 s_instance->d->init(); 0054 } 0055 return s_instance; 0056 } 0057 0058 QStringList KoRdfSemanticItemRegistry::classNames() const 0059 { 0060 return keys(); 0061 } 0062 0063 QString KoRdfSemanticItemRegistry::classDisplayName(const QString& className) const 0064 { 0065 const KoRdfSemanticItemFactoryBase *factory = value(className); 0066 return factory ? factory->classDisplayName() : QString(); 0067 } 0068 0069 0070 hKoRdfBasicSemanticItem KoRdfSemanticItemRegistry::createSemanticItem(const QString &semanticClass, const KoDocumentRdf *docRdf, QObject *parent) const 0071 { 0072 KoRdfSemanticItemFactoryBase *factory = value(semanticClass); 0073 if (factory) { 0074 return factory->createSemanticItem(docRdf, parent); 0075 } 0076 return hKoRdfBasicSemanticItem(0); 0077 } 0078 0079 hKoRdfBasicSemanticItem KoRdfSemanticItemRegistry::createSemanticItemFromMimeData(const QMimeData *mimeData, KoCanvasBase *host, const KoDocumentRdf *docRdf, QObject *parent) const 0080 { 0081 foreach (const QString &key, keys()) { 0082 KoRdfSemanticItemFactoryBase *factory = value(key); 0083 if (factory->canCreateSemanticItemFromMimeData(mimeData)) { 0084 return factory->createSemanticItemFromMimeData(mimeData, host, docRdf, parent); 0085 } 0086 } 0087 return hKoRdfBasicSemanticItem(0); 0088 } 0089 0090 bool KoRdfSemanticItemRegistry::canCreateSemanticItemFromMimeData(const QMimeData *mimeData) const 0091 { 0092 foreach (const QString &key, keys()) { 0093 KoRdfSemanticItemFactoryBase *factory = value(key); 0094 if (factory->canCreateSemanticItemFromMimeData(mimeData)) { 0095 return true; 0096 } 0097 } 0098 return false; 0099 } 0100 0101 void KoRdfSemanticItemRegistry::updateSemanticItems(QList<hKoRdfBasicSemanticItem> &semanticItems, const KoDocumentRdf *docRdf, const QString &className, QSharedPointer<Soprano::Model> m) const 0102 { 0103 KoRdfSemanticItemFactoryBase *factory = value(className); 0104 if (factory) { 0105 factory->updateSemanticItems(semanticItems, docRdf, m); 0106 } 0107 } 0108 0109 KoRdfSemanticItemRegistry::~KoRdfSemanticItemRegistry() 0110 { 0111 delete d; 0112 } 0113 0114 KoRdfSemanticItemRegistry::KoRdfSemanticItemRegistry() 0115 : d(new Private()) 0116 { 0117 } 0118 0119 bool KoRdfSemanticItemRegistry::isBasic(const QString &className) 0120 { 0121 return value(className)->isBasic(); 0122 }