Marble

GeoSceneSection.cpp
1 /*
2  SPDX-FileCopyrightText: 2008 Torsten Rahn <[email protected]>
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 
14 namespace Marble
15 {
16 
17 GeoSceneSection::GeoSceneSection( const QString& name )
18  : m_name( name ),
19  m_checkable( false ),
20  m_spacing( 12 )
21 {
22 }
23 
24 GeoSceneSection::~GeoSceneSection()
25 {
26  qDeleteAll( m_items );
27 }
28 
29 const char* GeoSceneSection::nodeType() const
30 {
31  return GeoSceneTypes::GeoSceneSectionType;
32 }
33 
35 {
36  // Remove any item that has the same name
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 
55 GeoSceneItem* GeoSceneSection::item( const QString& name )
56 {
57  GeoSceneItem* item = nullptr;
58 
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 
76 QVector<GeoSceneItem*> GeoSceneSection::items() const
77 {
78  return m_items;
79 }
80 
81 QString GeoSceneSection::name() const
82 {
83  return m_name;
84 }
85 
86 QString GeoSceneSection::heading() const
87 {
88  return m_heading;
89 }
90 
91 void GeoSceneSection::setHeading( const QString& heading )
92 {
93  m_heading = heading;
94 }
95 
96 bool GeoSceneSection::checkable() const
97 {
98  return m_checkable;
99 }
100 
101 void GeoSceneSection::setCheckable( bool checkable )
102 {
103  m_checkable = checkable;
104 }
105 
106 QString GeoSceneSection::connectTo() const
107 {
108  return m_connectTo;
109 }
110 
111 void GeoSceneSection::setConnectTo( const QString& connectTo )
112 {
113  m_connectTo = connectTo;
114 }
115 
116 int GeoSceneSection::spacing() const
117 {
118  return m_spacing;
119 }
120 
121 void GeoSceneSection::setSpacing( int spacing )
122 {
123  m_spacing = spacing;
124 }
125 
126 QString GeoSceneSection::radio() const
127 {
128  return m_radio;
129 }
130 
131 void GeoSceneSection::setRadio( const QString& radio )
132 {
133  m_radio = radio;
134 }
135 
136 }
The section item in a legend of a GeoScene document.
Definition: GeoSceneItem.h:23
void append(const T &value)
QVector::iterator begin()
Binds a QML item to a specific geodetic location in screen coordinates.
void addItem(GeoSceneItem *)
Add an item to the legend section.
QVector::const_iterator constBegin() const const
const char * nodeType() const override
Provides type information for downcasting a GeoNode.
QVector::iterator end()
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Mon Jan 17 2022 23:11:26 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.