• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdeedu API Reference
  • KDE Home
  • Contact Us
 

marble

  • sources
  • kde-4.12
  • kdeedu
  • marble
  • src
  • lib
  • marble
  • geodata
  • scene
GeoSceneGroup.cpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2008 Torsten Rahn <rahn@kde.org>
3 
4  This file is part of the KDE project
5 
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.
10 
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.
15 
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.
20 */
21 
22 #include "GeoSceneGroup.h"
23 
24 #include "MarbleDebug.h"
25 
26 #include "GeoSceneProperty.h"
27 
28 namespace Marble
29 {
30 
31 GeoSceneGroup::GeoSceneGroup( const QString& name )
32  : m_name( name )
33 {
34 }
35 
36 GeoSceneGroup::~GeoSceneGroup()
37 {
38  qDeleteAll( m_properties );
39 }
40 
41 bool GeoSceneGroup::propertyAvailable( const QString& name, bool& available ) const
42 {
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();
48  return true;
49  }
50  }
51 
52  available = false;
53 
54  return false;
55 }
56 
57 bool GeoSceneGroup::setPropertyValue( const QString& name, bool value )
58 {
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 );
65  return true;
66  }
67  }
68 
69  return false;
70 }
71 
72 bool GeoSceneGroup::propertyValue( const QString& name, bool& value ) const
73 {
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();
79  return true;
80  }
81  }
82 
83  value = false;
84 
85  return false;
86 }
87 
88 void GeoSceneGroup::addProperty( GeoSceneProperty* property )
89 {
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);
97  break;
98  }
99  else {
100  ++it;
101  }
102  }
103 
104  if ( property ) {
105  m_properties.append( property );
106 
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() );
111  }
112 }
113 
114 const GeoSceneProperty* GeoSceneGroup::property( const QString& name ) const
115 {
116  GeoSceneProperty* property = 0;
117 
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 ) {
122  property = *it;
123  break;
124  }
125  }
126 
127  return property;
128 }
129 
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 )
133 {
134  return const_cast<GeoSceneProperty*>
135  ( static_cast<GeoSceneGroup const *>( this )->property( name ));
136 }
137 
138 QVector<GeoSceneProperty*> GeoSceneGroup::properties()
139 {
140  return m_properties;
141 }
142 
143 QVector<const GeoSceneProperty*> GeoSceneGroup::properties() const
144 {
145  QVector<const GeoSceneProperty*> result;
146 
147  foreach ( const GeoSceneProperty *property, m_properties ) {
148  result << property;
149  }
150 
151  return result;
152 }
153 
154 QString GeoSceneGroup::name() const
155 {
156  return m_name;
157 }
158 
159 }
160 
161 #include "GeoSceneGroup.moc"
GeoSceneProperty.h
Marble::GeoSceneProperty
Settings property within a GeoScene document.
Definition: GeoSceneProperty.h:39
Marble::GeoSceneGroup::~GeoSceneGroup
~GeoSceneGroup()
Definition: GeoSceneGroup.cpp:36
Marble::GeoSceneGroup::valueChanged
void valueChanged(QString, bool)
GeoSceneGroup.h
Marble::GeoSceneGroup::properties
QVector< GeoSceneProperty * > properties()
Definition: GeoSceneGroup.cpp:138
Marble::GeoSceneGroup::setPropertyValue
bool setPropertyValue(const QString &name, bool value)
Set the value of a property in this group.
Definition: GeoSceneGroup.cpp:57
MarbleDebug.h
Marble::GeoSceneGroup::name
QString name() const
Definition: GeoSceneGroup.cpp:154
Marble::GeoSceneGroup
Group inside the settings of a GeoScene document.
Definition: GeoSceneGroup.h:40
Marble::GeoSceneGroup::propertyValue
bool propertyValue(const QString &name, bool &value) const
Get the value of a property in this group.
Definition: GeoSceneGroup.cpp:72
Marble::GeoSceneGroup::property
const GeoSceneProperty * property(const QString &name) const
Definition: GeoSceneGroup.cpp:114
Marble::GeoSceneGroup::GeoSceneGroup
GeoSceneGroup(const QString &name)
Definition: GeoSceneGroup.cpp:31
Marble::GeoSceneGroup::propertyAvailable
bool propertyAvailable(const QString &name, bool &available) const
Get the availability of a property in this group.
Definition: GeoSceneGroup.cpp:41
Marble::GeoSceneProperty::name
QString name() const
Definition: GeoSceneProperty.cpp:43
Marble::GeoSceneGroup::addProperty
void addProperty(GeoSceneProperty *)
Add a property to this setting group.
Definition: GeoSceneGroup.cpp:88
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:38:50 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

marble

Skip menu "marble"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdeedu API Reference

Skip menu "kdeedu API Reference"
  • Analitza
  •     lib
  • kalgebra
  • kalzium
  •   libscience
  • kanagram
  • kig
  •   lib
  • klettres
  • kstars
  • libkdeedu
  •   keduvocdocument
  • marble
  • parley
  • rocs
  •   App
  •   RocsCore
  •   VisualEditor
  •   stepcore

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal