File indexing completed on 2025-01-05 03:59:30
0001 // SPDX-License-Identifier: LGPL-2.1-or-later 0002 // 0003 // SPDX-FileCopyrightText: 2009 Bastian Holst <bastianholst@gmx.de> 0004 // 0005 0006 #ifndef MARBLE_ABSTRACTDATAPLUGIN_H 0007 #define MARBLE_ABSTRACTDATAPLUGIN_H 0008 0009 // Marble 0010 #include "digikam_export.h" 0011 #include "RenderPlugin.h" 0012 0013 namespace Marble 0014 { 0015 0016 class ViewportParams; 0017 class GeoSceneLayer; 0018 class AbstractDataPluginItem; 0019 class AbstractDataPluginModel; 0020 class AbstractDataPluginPrivate; 0021 0022 /** 0023 * @short An abstract class for plugins that show data that has a geo coordinate 0024 * 0025 * This is the abstract class for plugins that show data on Marble map. 0026 * It takes care of painting all items it gets from the corresponding AbstractDataPluginModel 0027 * that has to be set on initialisation. 0028 * 0029 * The user has to set the nameId as well as the number of items to fetch. 0030 * Additionally it should be useful to set standard values via setEnabled (often true) 0031 * and setVisible (often false) in the constructor of a subclass. 0032 **/ 0033 class DIGIKAM_EXPORT AbstractDataPlugin : public RenderPlugin 0034 { 0035 Q_OBJECT 0036 0037 Q_PROPERTY( bool favoriteItemsOnly READ isFavoriteItemsOnly WRITE setFavoriteItemsOnly NOTIFY favoriteItemsOnlyChanged ) 0038 /** @todo FIXME Qt Quick segfaults if using the real class here instead of QObject */ 0039 Q_PROPERTY( QObject* favoritesModel READ favoritesModel NOTIFY favoritesModelChanged ) 0040 Q_PROPERTY( int numberOfItems READ numberOfItems WRITE setNumberOfItems NOTIFY changedNumberOfItems ) 0041 0042 public: 0043 explicit AbstractDataPlugin( const MarbleModel *marbleModel ); 0044 0045 ~AbstractDataPlugin() override; 0046 0047 bool isInitialized() const override; 0048 0049 /** 0050 * @brief Returns the name(s) of the backend that the plugin can render 0051 */ 0052 QStringList backendTypes() const override; 0053 0054 /** 0055 * @brief Return how the plugin settings should be used. 0056 */ 0057 QString renderPolicy() const override; 0058 0059 /** 0060 * @brief Preferred level in the layer stack for the rendering 0061 */ 0062 QStringList renderPosition() const override; 0063 0064 /** 0065 * @brief Renders the content provided by the plugin on the viewport. 0066 * @return @c true Returns whether the rendering has been successful 0067 */ 0068 bool render( GeoPainter *painter, ViewportParams *viewport, 0069 const QString& renderPos = QLatin1String("NONE"), GeoSceneLayer * layer = nullptr ) override; 0070 0071 /** 0072 * @return The model associated with the plugin. 0073 */ 0074 AbstractDataPluginModel *model(); 0075 const AbstractDataPluginModel *model() const; 0076 0077 /** 0078 * Set the model of the plugin. 0079 */ 0080 void setModel( AbstractDataPluginModel* model ); 0081 0082 /** 0083 * Set the number of items to be shown at the same time. 0084 */ 0085 void setNumberOfItems( quint32 number ); 0086 0087 /** 0088 * @return The number of items to be shown at the same time. 0089 */ 0090 quint32 numberOfItems() const; 0091 0092 /** 0093 * This function returns all items at the position @p curpos. Depending on where they have 0094 * been painted the last time. 0095 * 0096 * @return The items at the given position. 0097 */ 0098 QList<AbstractDataPluginItem *> whichItemAt( const QPoint& curpos ); 0099 0100 /** 0101 * Function for returning the type of plugin this is for. 0102 * This affects where in the menu tree the action() is placed. 0103 * 0104 * @return: The type of render plugin this is. 0105 */ 0106 RenderType renderType() const override; 0107 0108 /** Convenience method to set the favorite item state on the current model */ 0109 void setFavoriteItemsOnly( bool favoriteOnly ); 0110 0111 bool isFavoriteItemsOnly() const; 0112 0113 QObject* favoritesModel(); 0114 0115 private Q_SLOTS: 0116 virtual void favoriteItemsChanged( const QStringList& favoriteItems ); 0117 0118 void delayedUpdate(); 0119 0120 Q_SIGNALS: 0121 void changedNumberOfItems( quint32 number ); 0122 0123 void favoriteItemsOnlyChanged(); 0124 0125 void favoritesModelChanged(); 0126 0127 private: 0128 AbstractDataPluginPrivate * const d; 0129 }; 0130 0131 } 0132 0133 #endif