Marble

AbstractDataPlugin.h
1 // SPDX-License-Identifier: LGPL-2.1-or-later
2 //
3 // SPDX-FileCopyrightText: 2009 Bastian Holst <[email protected]>
4 //
5 
6 #ifndef MARBLE_ABSTRACTDATAPLUGIN_H
7 #define MARBLE_ABSTRACTDATAPLUGIN_H
8 
9 // Marble
10 #include "marble_export.h"
11 #include "RenderPlugin.h"
12 
13 namespace Marble
14 {
15 
16 class ViewportParams;
17 class GeoSceneLayer;
18 class AbstractDataPluginItem;
19 class AbstractDataPluginModel;
20 class AbstractDataPluginPrivate;
21 
22 /**
23  * @short An abstract class for plugins that show data that has a geo coordinate
24  *
25  * This is the abstract class for plugins that show data on Marble map.
26  * It takes care of painting all items it gets from the corresponding AbstractDataPluginModel
27  * that has to be set on initialisation.
28  *
29  * The user has to set the nameId as well as the number of items to fetch.
30  * Additionally it should be useful to set standard values via setEnabled (often true)
31  * and setVisible (often false) in the constructor of a subclass.
32  **/
33 class MARBLE_EXPORT AbstractDataPlugin : public RenderPlugin
34 {
35  Q_OBJECT
36 
37  Q_PROPERTY( bool favoriteItemsOnly READ isFavoriteItemsOnly WRITE setFavoriteItemsOnly NOTIFY favoriteItemsOnlyChanged )
38  /** @todo FIXME Qt Quick segfaults if using the real class here instead of QObject */
39  Q_PROPERTY( QObject* favoritesModel READ favoritesModel NOTIFY favoritesModelChanged )
40  Q_PROPERTY( int numberOfItems READ numberOfItems WRITE setNumberOfItems NOTIFY changedNumberOfItems )
41 
42  public:
43  explicit AbstractDataPlugin( const MarbleModel *marbleModel );
44 
45  ~AbstractDataPlugin() override;
46 
47  bool isInitialized() const override;
48 
49  /**
50  * @brief Returns the name(s) of the backend that the plugin can render
51  */
52  QStringList backendTypes() const override;
53 
54  /**
55  * @brief Return how the plugin settings should be used.
56  */
57  QString renderPolicy() const override;
58 
59  /**
60  * @brief Preferred level in the layer stack for the rendering
61  */
62  QStringList renderPosition() const override;
63 
64  /**
65  * @brief Renders the content provided by the plugin on the viewport.
66  * @return @c true Returns whether the rendering has been successful
67  */
68  bool render( GeoPainter *painter, ViewportParams *viewport,
69  const QString& renderPos = QLatin1String("NONE"), GeoSceneLayer * layer = nullptr ) override;
70 
71  /**
72  * @return The model associated with the plugin.
73  */
74  AbstractDataPluginModel *model();
75  const AbstractDataPluginModel *model() const;
76 
77  /**
78  * Set the model of the plugin.
79  */
80  void setModel( AbstractDataPluginModel* model );
81 
82  /**
83  * Set the number of items to be shown at the same time.
84  */
85  void setNumberOfItems( quint32 number );
86 
87  /**
88  * @return The number of items to be shown at the same time.
89  */
90  quint32 numberOfItems() const;
91 
92  /**
93  * This function returns all items at the position @p curpos. Depending on where they have
94  * been painted the last time.
95  *
96  * @return The items at the given position.
97  */
98  QList<AbstractDataPluginItem *> whichItemAt( const QPoint& curpos );
99 
100  /**
101  * Function for returning the type of plugin this is for.
102  * This affects where in the menu tree the action() is placed.
103  *
104  * @return: The type of render plugin this is.
105  */
106  RenderType renderType() const override;
107 
108  /** Convenience method to set the favorite item state on the current model */
109  void setFavoriteItemsOnly( bool favoriteOnly );
110 
111  bool isFavoriteItemsOnly() const;
112 
113  QObject* favoritesModel();
114 
115  private Q_SLOTS:
116  virtual void favoriteItemsChanged( const QStringList& favoriteItems );
117 
118  void delayedUpdate();
119 
120  Q_SIGNALS:
121  void changedNumberOfItems( quint32 number );
122 
123  void favoriteItemsOnlyChanged();
124 
125  void favoritesModelChanged();
126 
127  private:
128  AbstractDataPluginPrivate * const d;
129 };
130 
131 }
132 
133 #endif
The abstract class that creates a renderable item.
Definition: RenderPlugin.h:38
An abstract class for plugins that show data that has a geo coordinate.
Layer of a GeoScene document.
Definition: GeoSceneLayer.h:28
A public class that controls what is visible in the viewport of a Marble map.
Binds a QML item to a specific geodetic location in screen coordinates.
A painter that allows to draw geometric primitives on the map.
Definition: GeoPainter.h:88
RenderType
A Type of plugin.
Definition: RenderPlugin.h:54
The data model (not based on QAbstractModel) for a MarbleWidget.
Definition: MarbleModel.h:86
An abstract data model (not based on QAbstractModel) for a AbstractDataPlugin.
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Fri Sep 29 2023 03:52:20 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.