File indexing completed on 2025-01-05 03:59:31

0001 // SPDX-License-Identifier: LGPL-2.1-or-later
0002 //
0003 // SPDX-FileCopyrightText: 2012 Bernhard Beschow <bbeschow@cs.tu-berlin.de>
0004 //
0005 
0006 #ifndef MARBLE_RENDER_PLUGIN_MODEL_H
0007 #define MARBLE_RENDER_PLUGIN_MODEL_H
0008 
0009 #include <QStandardItemModel>
0010 #include <QList>
0011 
0012 #include "PluginInterface.h"
0013 
0014 #include "digikam_export.h"
0015 
0016 namespace Marble
0017 {
0018 
0019 class DialogConfigurationInterface;
0020 class PluginInterface;
0021 class RenderPlugin;
0022 
0023 /**
0024  * @brief Provides common access to various kinds of plugins without having to know about their details.
0025  */
0026 class DIGIKAM_EXPORT RenderPluginModel : public QStandardItemModel
0027 {
0028     Q_OBJECT
0029 
0030 public:
0031     /**
0032      * This enum contains the data roles for the QStandardItems.
0033      */
0034     enum ItemDataRole
0035     {
0036         Name = Qt::DisplayRole,          // QString
0037         Icon = Qt::DecorationRole,       // QIcon
0038         Description = Qt::ToolTipRole,   // QString
0039         NameId = Qt::UserRole + 2,       // QString
0040         ConfigurationDialogAvailable,    // bool
0041         BackendTypes,                    // QStringList
0042         Version,                         // QString
0043         AboutDataText,                   // QString
0044         CopyrightYears                   // QString
0045     };
0046 
0047     explicit RenderPluginModel(QObject* parent = nullptr);
0048 
0049     ~RenderPluginModel() override;
0050 
0051     /**
0052      * @brief Set the RenderPlugins the model should manage.
0053      *
0054      * The given plugins must not be deleted as long as the model has a hold on them,
0055      * i.e. until the model is deleted or a different set of plugins is assigned.
0056      *
0057      * @param renderPlugins the RenderPlugins to be managed
0058      */
0059     void setRenderPlugins(const QList<RenderPlugin*>& renderPlugins);
0060 
0061     QVector<PluginAuthor> pluginAuthors(const QModelIndex& index) const;
0062 
0063     DialogConfigurationInterface* pluginDialogConfigurationInterface(const QModelIndex& index);
0064     RenderPlugin* plugin(const QModelIndex& index);
0065     PluginInterface* pluginIface(const QModelIndex& index);
0066 
0067 public Q_SLOTS:
0068 
0069     /**
0070      * Retrieve the current plugin state for the user interface.
0071      */
0072     void retrievePluginState();
0073 
0074     /**
0075      * Apply the plugin state from the user interface.
0076      */
0077     void applyPluginState();
0078 
0079 private:
0080 
0081     class Private;
0082     Private *const d;
0083 
0084     friend class Private;
0085 };
0086 
0087 }
0088 
0089 #endif // MARBLE_RENDER_PLUGIN_MODEL_H