File indexing completed on 2024-04-21 04:41:50
0001 /* This file is part of the KDE project 0002 Copyright (C) 2010 by Adam Pigg (adam@piggz.co.uk) 0003 Copyright (C) 2015 Jarosław Staniek <staniek@kde.org> 0004 0005 This library is free software; you can redistribute it and/or 0006 modify it under the terms of the GNU Library General Public 0007 License as published by the Free Software Foundation; either 0008 version 2.1 of the License, or (at your option) any later version. 0009 0010 This library is distributed in the hope that it will be useful, 0011 but WITHOUT ANY WARRANTY; without even the implied warranty of 0012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0013 Library General Public License for more details. 0014 0015 You should have received a copy of the GNU Library General Public License 0016 along with this library; see the file COPYING.LIB. If not, write to 0017 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 0018 Boston, MA 02110-1301, USA. 0019 */ 0020 0021 #ifndef KREPORTPLUGINMANAGERP_H 0022 #define KREPORTPLUGINMANAGERP_H 0023 0024 #include <QMap> 0025 #include <QPluginLoader> 0026 0027 #if 0 // needed by lupdate to avoid "Qualifying with unknown namespace/class" 0028 class KReportPluginManager {}; 0029 #endif 0030 0031 class QJsonObject; 0032 class KReportPluginInterface; 0033 class KReportPluginManager; 0034 class KReportPluginMetaData; 0035 0036 //! @internal A single entry for a built-in or dynamic item plugin 0037 class KReportPluginEntry 0038 { 0039 public: 0040 //! Used for dynamic plugins. 0041 KReportPluginEntry(); 0042 0043 //! Used for static plugins. 0044 KReportPluginEntry(KReportPluginInterface *staticInterface); 0045 0046 ~KReportPluginEntry(); 0047 0048 KReportPluginInterface* plugin(); 0049 0050 void setBuiltIn(bool set); 0051 0052 void setStatic(bool set); 0053 0054 const KReportPluginMetaData *metaData() const; 0055 0056 void setMetaData(const QJsonObject &metaData); 0057 0058 void setMetaData(QPluginLoader *loader); 0059 0060 private: 0061 void setMetaData(KReportPluginMetaData *metaData); 0062 0063 QPluginLoader *m_loader; 0064 0065 KReportPluginInterface *m_interface; 0066 0067 //! Plugin info, owned. 0068 KReportPluginMetaData *m_metaData; 0069 }; 0070 0071 //! @internal 0072 class Q_DECL_HIDDEN KReportPluginManager::Private 0073 { 0074 public: 0075 explicit Private(KReportPluginManager *qq); 0076 ~Private(); 0077 0078 QMap<QString, KReportPluginEntry*> *plugins(); 0079 QMap<QString, KReportPluginEntry*> *pluginsByLegacyName(); 0080 0081 //! Add a built-in element plugins 0082 template<class PluginClass> 0083 void addBuiltInPlugin(const QJsonObject &json); 0084 0085 private: 0086 KReportPluginManager * const q; 0087 QObject *m_parent; 0088 bool m_findPlugins; 0089 void findPlugins(); 0090 void addEntry(KReportPluginEntry *entry); 0091 0092 //! A map of name -> plugin instances 0093 QMap<QString, KReportPluginEntry*> m_plugins; 0094 //! A map of legacy name -> plugin instances 0095 QMap<QString, KReportPluginEntry*> m_pluginsByLegacyName; 0096 }; 0097 0098 #endif