Marble

FloatItemsLayer.cpp
1// SPDX-License-Identifier: LGPL-2.1-or-later
2//
3// SPDX-FileCopyrightText: 2012-2016 Bernhard Beschow <bbeschow@cs.tu-berlin.de>
4//
5
6#include "FloatItemsLayer.h"
7
8#include "AbstractFloatItem.h"
9#include "GeoPainter.h"
10#include "ViewportParams.h"
11
12namespace Marble
13{
14
15FloatItemsLayer::FloatItemsLayer(QObject *parent)
16 : QObject(parent)
17 , m_floatItems()
18{
19}
20
21QStringList FloatItemsLayer::renderPosition() const
22{
23 return QStringList(QStringLiteral("FLOAT_ITEM"));
24}
25
26bool FloatItemsLayer::render(GeoPainter *painter, ViewportParams *viewport, const QString &renderPos, GeoSceneLayer *layer)
27{
28 Q_UNUSED(renderPos)
29 Q_UNUSED(layer)
30
31 for (AbstractFloatItem *item : std::as_const(m_floatItems)) {
32 if (!item->enabled()) {
33 continue;
34 }
35
36 if (!item->isInitialized()) {
37 item->initialize();
38 Q_EMIT renderPluginInitialized(item);
39 }
40
41 if (item->visible()) {
42 item->paintEvent(painter, viewport);
43 }
44 }
45
46 return true;
47}
48
49void FloatItemsLayer::addFloatItem(AbstractFloatItem *floatItem)
50{
51 Q_ASSERT(floatItem && "must not add a null float item to FloatItemsLayer");
52
53 connect(floatItem, SIGNAL(settingsChanged(QString)), this, SIGNAL(pluginSettingsChanged()));
54 connect(floatItem, SIGNAL(repaintNeeded(QRegion)), this, SIGNAL(repaintNeeded(QRegion)));
55 connect(floatItem, SIGNAL(visibilityChanged(bool, QString)), this, SLOT(updateVisibility(bool, QString)));
56
57 m_floatItems.append(floatItem);
58}
59
60QList<AbstractFloatItem *> FloatItemsLayer::floatItems() const
61{
62 return m_floatItems;
63}
64
65QString FloatItemsLayer::runtimeTrace() const
66{
67 return QStringLiteral("Float Items: %1").arg(m_floatItems.size());
68}
69
70void FloatItemsLayer::updateVisibility(bool visible, const QString &nameId)
71{
72 Q_EMIT visibilityChanged(nameId, visible);
73}
74
75}
76
77#include "moc_FloatItemsLayer.cpp"
This file contains the headers for ViewportParams.
Binds a QML item to a specific geodetic location in screen coordinates.
QString arg(Args &&... args) const const
QFuture< ArgsType< Signal > > connect(Sender *sender, Signal signal)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 17:04:14 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.