2
Copyright (C) 2008 Torsten Rahn <rahn@kde.org>
4
This file is part of the KDE project
6
This library is free software you can redistribute it and/or
7
modify it under the terms of the GNU Library General Public
8
License as published by the Free Software Foundation either
9
version 2 of the License, or (at your option) any later version.
11
This library is distributed in the hope that it will be useful,
12
but WITHOUT ANY WARRANTY without even the implied warranty of
13
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
Library General Public License for more details.
16
You should have received a copy of the GNU Library General Public License
17
aint with this library see the file COPYING.LIB. If not, write to
18
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19
Boston, MA 02110-1301, USA.
22
#include "GeoSceneGroup.h"
24
#include "MarbleDebug.h"
26
#include "GeoSceneProperty.h"
31
GeoSceneGroup::GeoSceneGroup( const QString& name )
36
GeoSceneGroup::~GeoSceneGroup()
38
qDeleteAll( m_properties );
41
bool GeoSceneGroup::propertyAvailable( const QString& name, bool& available ) const
43
QVector<GeoSceneProperty*>::const_iterator it = m_properties.constBegin();
44
QVector<GeoSceneProperty*>::const_iterator end = m_properties.constEnd();
45
for (; it != end; ++it) {
46
if ( (*it)->name() == name ) {
47
available = (*it)->available();
57
bool GeoSceneGroup::setPropertyValue( const QString& name, bool value )
59
QVector<GeoSceneProperty*>::const_iterator it = m_properties.constBegin();
60
QVector<GeoSceneProperty*>::const_iterator end = m_properties.constEnd();
61
for (; it != end; ++it) {
62
if ( (*it)->name() == name ) {
63
(*it)->setValue( value );
64
emit valueChanged( name, value );
72
bool GeoSceneGroup::propertyValue( const QString& name, bool& value ) const
74
QVector<GeoSceneProperty*>::const_iterator it = m_properties.constBegin();
75
QVector<GeoSceneProperty*>::const_iterator end = m_properties.constEnd();
76
for (; it != end; ++it) {
77
if ( (*it)->name() == name ) {
78
value = (*it)->value();
88
void GeoSceneGroup::addProperty( GeoSceneProperty* property )
90
// Remove any property that has the same name
91
QVector<GeoSceneProperty*>::iterator it = m_properties.begin();
92
while (it != m_properties.end()) {
93
GeoSceneProperty* currentProperty = *it;
94
if ( currentProperty->name() == property->name() ) {
95
delete currentProperty;
96
it = m_properties.erase(it);
105
m_properties.append( property );
107
// Establish connection to the outside, e.g. the LegendBrowser
108
connect ( property, SIGNAL( valueChanged( QString, bool ) ),
109
SIGNAL( valueChanged( QString, bool ) ) );
110
emit valueChanged( property->name(), property->value() );
114
const GeoSceneProperty* GeoSceneGroup::property( const QString& name ) const
116
GeoSceneProperty* property = 0;
118
QVector<GeoSceneProperty*>::const_iterator it = m_properties.constBegin();
119
QVector<GeoSceneProperty*>::const_iterator end = m_properties.constEnd();
120
for (; it != end; ++it) {
121
if ( (*it)->name() == name ) {
130
// implement non-const method by means of const method,
131
// for details, see "Effective C++" (third edition)
132
GeoSceneProperty* GeoSceneGroup::property( const QString& name )
134
return const_cast<GeoSceneProperty*>
135
( static_cast<GeoSceneGroup const *>( this )->property( name ));
138
QVector<GeoSceneProperty*> GeoSceneGroup::properties() const
143
QString GeoSceneGroup::name() const
150
#include "GeoSceneGroup.moc"