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