Marble

FloatItemsLayer.cpp
1 // SPDX-License-Identifier: LGPL-2.1-or-later
2 //
3 // SPDX-FileCopyrightText: 2012-2016 Bernhard Beschow <[email protected]>
4 //
5 
6 #include "FloatItemsLayer.h"
7 
8 #include "AbstractFloatItem.h"
9 #include "GeoPainter.h"
10 #include "ViewportParams.h"
11 
12 namespace Marble
13 {
14 
15 FloatItemsLayer::FloatItemsLayer(QObject *parent) :
16  QObject(parent),
17  m_floatItems()
18 {
19 }
20 
21 QStringList FloatItemsLayer::renderPosition() const
22 {
23  return QStringList(QStringLiteral("FLOAT_ITEM"));
24 }
25 
26 bool 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 
52 void 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 
67 {
68  return m_floatItems;
69 }
70 
71 QString FloatItemsLayer::runtimeTrace() const
72 {
73  return QStringLiteral("Float Items: %1").arg(m_floatItems.size());
74 }
75 
76 void FloatItemsLayer::updateVisibility(bool visible, const QString &nameId)
77 {
78  emit visibilityChanged(nameId, visible);
79 }
80 
81 }
QList< AbstractFloatItem * > floatItems() const
Returns a list of all FloatItems of the layer.
QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
Binds a QML item to a specific geodetic location in screen coordinates.
QString arg(qlonglong a, int fieldWidth, int base, QChar fillChar) const const
void renderPluginInitialized(RenderPlugin *renderPlugin)
Signal that a render item has been initialized.
void repaintNeeded(const QRegion &dirtyRegion=QRegion())
This signal is emitted when the repaint of the view was requested by a plugin.
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Mon Oct 2 2023 03:52:07 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.