Marble

AbstractDataPlugin.h
1// SPDX-License-Identifier: LGPL-2.1-or-later
2//
3// SPDX-FileCopyrightText: 2009 Bastian Holst <bastianholst@gmx.de>
4//
5
6#ifndef MARBLE_ABSTRACTDATAPLUGIN_H
7#define MARBLE_ABSTRACTDATAPLUGIN_H
8
9// Marble
10#include "RenderPlugin.h"
11#include "marble_export.h"
12
13namespace Marble
14{
15
16class ViewportParams;
17class GeoSceneLayer;
18class AbstractDataPluginItem;
19class AbstractDataPluginModel;
20class 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 **/
33class 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
42public:
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, const QString &renderPos = QLatin1String("NONE"), GeoSceneLayer *layer = nullptr) override;
69
70 /**
71 * @return The model associated with the plugin.
72 */
74 const AbstractDataPluginModel *model() const;
75
76 /**
77 * Set the model of the plugin.
78 */
79 void setModel(AbstractDataPluginModel *model);
80
81 /**
82 * Set the number of items to be shown at the same time.
83 */
84 void setNumberOfItems(quint32 number);
85
86 /**
87 * @return The number of items to be shown at the same time.
88 */
89 quint32 numberOfItems() const;
90
91 /**
92 * This function returns all items at the position @p curpos. Depending on where they have
93 * been painted the last time.
94 *
95 * @return The items at the given position.
96 */
97 QList<AbstractDataPluginItem *> whichItemAt(const QPoint &curpos);
98
99 /**
100 * Function for returning the type of plugin this is for.
101 * This affects where in the menu tree the action() is placed.
102 *
103 * @return: The type of render plugin this is.
104 */
105 RenderType renderType() const override;
106
107 /** Convenience method to set the favorite item state on the current model */
108 void setFavoriteItemsOnly(bool favoriteOnly);
109
110 bool isFavoriteItemsOnly() const;
111
112 QObject *favoritesModel();
113
114private Q_SLOTS:
115 virtual void favoriteItemsChanged(const QStringList &favoriteItems);
116
117 void delayedUpdate();
118
119Q_SIGNALS:
120 void changedNumberOfItems(quint32 number);
121
122 void favoriteItemsOnlyChanged();
123
124 void favoritesModelChanged();
125
126private:
127 AbstractDataPluginPrivate *const d;
128};
129
130}
131
132#endif
An abstract data model (not based on QAbstractModel) for a AbstractDataPlugin.
An abstract class for plugins that show data that has a geo coordinate.
A painter that allows to draw geometric primitives on the map.
Definition GeoPainter.h:86
Layer of a GeoScene document.
The data model (not based on QAbstractModel) for a MarbleWidget.
Definition MarbleModel.h:84
The abstract class that creates a renderable item.
RenderType
A Type of plugin.
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.
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Nov 8 2024 12:02:42 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.