Marble

AbstractFloatItem.h
1// SPDX-License-Identifier: LGPL-2.1-or-later
2//
3// SPDX-FileCopyrightText: 2008 Torsten Rahn <tackat@kde.org>
4// SPDX-FileCopyrightText: 2012 Illya Kovalevskyy <illya.kovalevskyy@gmail.com>
5//
6
7#ifndef MARBLE_ABSTRACTFLOATITEM_H
8#define MARBLE_ABSTRACTFLOATITEM_H
9
10#include <QPointF>
11#include <QSizeF>
12
13#include "FrameGraphicsItem.h"
14#include "RenderPlugin.h"
15#include "marble_export.h"
16
18class QHelpEvent;
19class QMenu;
20class QWidget;
21class QFont;
22class QPen;
23
24namespace Marble
25{
26
27class AbstractFloatItemPrivate;
28
29/**
30 * @brief The abstract class for float item plugins
31 *
32 * Float Item is a variant of Marble render plugins
33 * It keeps floating on top of the map at a given screen position
34 *
35 * Good examples are Overview Map, License
36 *
37 */
38
39class MARBLE_EXPORT AbstractFloatItem : public RenderPlugin, public FrameGraphicsItem
40{
42
43public:
44 explicit AbstractFloatItem(const MarbleModel *marbleModel, const QPointF &point = QPointF(10.0, 10.0), const QSizeF &size = QSizeF(150.0, 50.0));
45 ~AbstractFloatItem() override;
46
47 QHash<QString, QVariant> settings() const override;
48 void setSettings(const QHash<QString, QVariant> &settings) override;
49
50 RenderType renderType() const override;
51
52 /**
53 * @brief current pen for rendering
54 * @return pen
55 */
56 QPen pen() const;
57
58 /**
59 * @brief setting current pen for rendering
60 * @param pen
61 */
62 void setPen(const QPen &pen);
63
64 /**
65 * @brief current font for rendering
66 * @return font
67 */
68 QFont font() const;
69
70 /**
71 * @brief setting current font for rendering
72 * @param font
73 */
74 void setFont(const QFont &font);
75
76 /**
77 * @brief Paints the float item on the map.
78 * @deprecated Do not override this method since it won't be called any longer.
79 * Override one of FrameGraphicsItem's paint methods instead.
80 */
81 MARBLE_DEPRECATED bool
82 render(GeoPainter *painter, ViewportParams *viewport, const QString &renderPos = QLatin1String("FLOAT_ITEM"), GeoSceneLayer *layer = nullptr) override;
83
84 QString renderPolicy() const override;
85
86 /**
87 * @brief Returns the rendering position of this float item.
88 * @deprecated The return value of method is ignored. The float item's rendering position
89 * will always be "FLOAT_ITEM".
90 */
91 MARBLE_DEPRECATED QStringList renderPosition() const override;
92
93 /**
94 * @brief Set visibility of the float item
95 *
96 * Float items can be visible or invisible.
97 * It's possible to check visibility with @see visible
98 *
99 * @param visible visibility of the item
100 */
101 void setVisible(bool visible);
102
103 /**
104 * @brief Check visibility of the float item
105 *
106 * Float items can be visible or invisible.
107 * It's possible to set visibility with @see setVisible
108 *
109 * @return visible or not
110 */
111 bool visible() const;
112
113 /**
114 * @brief Check is position locked
115 *
116 * Float Item position can be locked. If it is,
117 * the item can't be moved with the cursor (in the UI)
118 *
119 * To set it use @see setPositionLocked
120 *
121 * @return position locked or not
122 */
123 bool positionLocked() const;
124
125public Q_SLOTS:
126 /**
127 * @brief Set is position locked
128 * @param lock is locked?
129 *
130 * Float Item position can be locked. If it is,
131 * item can't be moved with cursor (in UI)
132 *
133 * To check it use @see positionLocked
134 *
135 */
136 void setPositionLocked(bool lock);
137
138 /**
139 * @brief Show the item
140 *
141 * If the item was hidden this function will show it
142 *
143 */
144 void show();
145
146 /**
147 * @brief Hide the item
148 *
149 * If the item was shown this function will hide it
150 *
151 */
152 void hide();
153
154protected:
155 bool eventFilter(QObject *object, QEvent *e) override;
156 virtual void contextMenuEvent(QWidget *w, QContextMenuEvent *e);
157 virtual void toolTipEvent(QHelpEvent *e);
158 QMenu *contextMenu();
159
160private:
161 Q_DISABLE_COPY(AbstractFloatItem)
162 AbstractFloatItemPrivate *const d;
163};
164
165}
166
167#endif
bool visible() const
Check visibility of the float item.
bool positionLocked() const
Check is position locked.
QHash< QString, QVariant > settings() const override
Settings of the plugin.
void setPen(const QPen &pen)
setting current pen for rendering
void setSettings(const QHash< QString, QVariant > &settings) override
Set the settings of the plugin.
QFont font() const
current font for rendering
RenderType renderType() const override
Render type of the plugin.
void setPositionLocked(bool lock)
Set is position locked.
MARBLE_DEPRECATED bool render(GeoPainter *painter, ViewportParams *viewport, const QString &renderPos=QLatin1String("FLOAT_ITEM"), GeoSceneLayer *layer=nullptr) override
Paints the float item on the map.
QString renderPolicy() const override
Return how the plugin settings should be used.
MARBLE_DEPRECATED QStringList renderPosition() const override
Returns the rendering position of this float item.
QPen pen() const
current pen for rendering
void setVisible(bool visible)
Set visibility of the float item.
void setFont(const QFont &font)
setting current font for rendering
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
const MarbleModel * marbleModel() const
Access to the MarbleModel.
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.
QObject(QObject *parent)
Q_OBJECTQ_OBJECT
Q_SLOTSQ_SLOTS
This file is part of the KDE documentation.
Documentation copyright © 1996-2025 The KDE developers.
Generated on Fri Jan 24 2025 11:52:08 by doxygen 1.13.2 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.