Marble

GeoSceneSection.cpp
1/*
2 SPDX-FileCopyrightText: 2008 Torsten Rahn <rahn@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7#include "GeoSceneSection.h"
8
9#include "GeoSceneItem.h"
10#include "GeoSceneTypes.h"
11
12namespace Marble
13{
14
15GeoSceneSection::GeoSceneSection(const QString &name)
16 : m_name(name)
17 , m_checkable(false)
18 , m_spacing(12)
19{
20}
21
22GeoSceneSection::~GeoSceneSection()
23{
24 qDeleteAll(m_items);
25}
26
27const char *GeoSceneSection::nodeType() const
28{
29 return GeoSceneTypes::GeoSceneSectionType;
30}
31
32void GeoSceneSection::addItem(GeoSceneItem *item)
33{
34 // Remove any item that has the same name
35 QList<GeoSceneItem *>::iterator it = m_items.begin();
36 while (it != m_items.end()) {
37 GeoSceneItem *currentItem = *it;
38 if (currentItem->name() == item->name()) {
39 delete currentItem;
40 m_items.erase(it);
41 break;
42 } else {
43 ++it;
44 }
45 }
46
47 if (item) {
48 m_items.append(item);
49 }
50}
51
52GeoSceneItem *GeoSceneSection::item(const QString &name)
53{
54 GeoSceneItem *item = nullptr;
55
56 QList<GeoSceneItem *>::const_iterator it = m_items.constBegin();
57 QList<GeoSceneItem *>::const_iterator end = m_items.constEnd();
58 for (; it != end; ++it) {
59 if ((*it)->name() == name) {
60 item = *it;
61 break;
62 }
63 }
64
65 if (!item) {
66 item = new GeoSceneItem(name);
67 addItem(item);
68 }
69
70 return item;
71}
72
73QList<GeoSceneItem *> GeoSceneSection::items() const
74{
75 return m_items;
76}
77
78QString GeoSceneSection::name() const
79{
80 return m_name;
81}
82
83QString GeoSceneSection::heading() const
84{
85 return m_heading;
86}
87
88void GeoSceneSection::setHeading(const QString &heading)
89{
90 m_heading = heading;
91}
92
93bool GeoSceneSection::checkable() const
94{
95 return m_checkable;
96}
97
98void GeoSceneSection::setCheckable(bool checkable)
99{
100 m_checkable = checkable;
101}
102
103QString GeoSceneSection::connectTo() const
104{
105 return m_connectTo;
106}
107
108void GeoSceneSection::setConnectTo(const QString &connectTo)
109{
110 m_connectTo = connectTo;
111}
112
113int GeoSceneSection::spacing() const
114{
115 return m_spacing;
116}
117
118void GeoSceneSection::setSpacing(int spacing)
119{
120 m_spacing = spacing;
121}
122
123QString GeoSceneSection::radio() const
124{
125 return m_radio;
126}
127
128void GeoSceneSection::setRadio(const QString &radio)
129{
130 m_radio = radio;
131}
132
133}
The section item in a legend of a GeoScene document.
QString name(StandardAction id)
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 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.