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,
27 ViewportParams *viewport,
28 const QString &renderPos,
29 GeoSceneLayer *layer)
30{
31 Q_UNUSED(renderPos)
32 Q_UNUSED(layer)
33
34 for (AbstractFloatItem *item: m_floatItems) {
35 if (!item->enabled()) {
36 continue;
37 }
38
39 if (!item->isInitialized()) {
40 item->initialize();
41 emit renderPluginInitialized(item);
42 }
43
44 if (item->visible()) {
45 item->paintEvent(painter, viewport);
46 }
47 }
48
49 return true;
50}
51
52void FloatItemsLayer::addFloatItem(AbstractFloatItem *floatItem)
53{
54 Q_ASSERT(floatItem && "must not add a null float item to FloatItemsLayer");
55
56 connect(floatItem, SIGNAL(settingsChanged(QString)),
57 this, SIGNAL(pluginSettingsChanged()));
58 connect(floatItem, SIGNAL(repaintNeeded(QRegion)),
59 this, SIGNAL(repaintNeeded(QRegion)));
60 connect(floatItem, SIGNAL(visibilityChanged(bool,QString)),
61 this, SLOT(updateVisibility(bool,QString)));
62
63 m_floatItems.append( floatItem );
64}
65
66QList<AbstractFloatItem *> FloatItemsLayer::floatItems() const
67{
68 return m_floatItems;
69}
70
71QString FloatItemsLayer::runtimeTrace() const
72{
73 return QStringLiteral("Float Items: %1").arg(m_floatItems.size());
74}
75
76void FloatItemsLayer::updateVisibility(bool visible, const QString &nameId)
77{
78 emit visibilityChanged(nameId, visible);
79}
80
81}
82
83#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 Tue Mar 26 2024 11:18:17 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.