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

marble

  • sources
  • kde-4.14
  • kdeedu
  • marble
  • src
  • lib
  • marble
  • geodata
  • data
GeoDataObject.cpp
Go to the documentation of this file.
1 //
2 // This file is part of the Marble Virtual Globe.
3 //
4 // This program is free software licensed under the GNU LGPL. You can
5 // find a copy of this license in LICENSE.txt in the top directory of
6 // the source code.
7 //
8 // Copyright 2007 Murad Tagirov <tmurad@gmail.com>
9 // Copyright 2008 Jens-Michael Hoffmann <jensmh@gmx.de>
10 //
11 
12 #include "GeoDataObject.h"
13 
14 #include <QtGlobal>
15 #include <QDataStream>
16 #include <QFileInfo>
17 #include <QUrl>
18 
19 #include "GeoDataDocument.h"
20 
21 #include "GeoDataTypes.h"
22 
23 
24 namespace Marble
25 {
26 
27 class GeoDataObjectPrivate
28 {
29  public:
30  GeoDataObjectPrivate()
31  : m_id(),
32  m_targetId(),
33  m_parent(0)
34  {
35  }
36 
37  QString m_id;
38  QString m_targetId;
39  GeoDataObject *m_parent;
40 };
41 
42 GeoDataObject::GeoDataObject()
43  : GeoNode(), Serializable(),
44  d( new GeoDataObjectPrivate() )
45 {
46 }
47 
48 GeoDataObject::GeoDataObject( GeoDataObject const & other )
49  : GeoNode(), Serializable( other ),
50  d( new GeoDataObjectPrivate( *other.d ) )
51 {
52 }
53 
54 GeoDataObject & GeoDataObject::operator=( const GeoDataObject & rhs )
55 {
56  *d = *rhs.d;
57  return *this;
58 }
59 
60 GeoDataObject::~GeoDataObject()
61 {
62  delete d;
63 }
64 
65 GeoDataObject *GeoDataObject::parent() const
66 {
67  return d->m_parent;
68 }
69 
70 void GeoDataObject::setParent(GeoDataObject *parent)
71 {
72  d->m_parent = parent;
73 }
74 
75 QString GeoDataObject::id() const
76 {
77  return d->m_id;
78 }
79 
80 void GeoDataObject::setId( const QString& value )
81 {
82  d->m_id = value;
83 }
84 
85 QString GeoDataObject::targetId() const
86 {
87  return d->m_targetId;
88 }
89 
90 void GeoDataObject::setTargetId( const QString& value )
91 {
92  d->m_targetId = value;
93 }
94 
95 QString GeoDataObject::resolvePath( const QString &relativePath ) const
96 {
97  QUrl const url( relativePath );
98  QFileInfo const fileInfo( url.path() );
99  if ( url.isRelative() && fileInfo.isRelative() ) {
100  GeoDataDocument const * document = dynamic_cast<GeoDataDocument const*>( this );
101  if ( document ) {
102  QString const baseUri = document->baseUri();
103  QFileInfo const documentRoot = baseUri.isEmpty() ? document->fileName() : baseUri;
104  QFileInfo const absoluteImage( documentRoot.absolutePath() + '/' + url.path() );
105  return absoluteImage.absoluteFilePath();
106  } else if ( d->m_parent ) {
107  return d->m_parent->resolvePath( relativePath );
108  }
109  }
110 
111  return relativePath;
112 }
113 
114 void GeoDataObject::pack( QDataStream& stream ) const
115 {
116  stream << d->m_id;
117  stream << d->m_targetId;
118 }
119 
120 void GeoDataObject::unpack( QDataStream& stream )
121 {
122  stream >> d->m_id;
123  stream >> d->m_targetId;
124 }
125 
126 bool GeoDataObject::equals(const GeoDataObject &other) const
127 {
128  return d->m_id == other.d->m_id && d->m_targetId == other.d->m_targetId;
129 }
130 
131 }
GeoDataDocument.h
Marble::GeoDataObject::setTargetId
void setTargetId(const QString &value)
set a new targetId of this object
Definition: GeoDataObject.cpp:90
Marble::GeoDataDocument
A container for Features, Styles and in the future Schemas.
Definition: GeoDataDocument.h:65
QDataStream
Marble::GeoNode
A shared base class for all classes that are mapped to a specific tag (ie.
Definition: GeoDocument.h:60
Marble::GeoDataObject
A base class for all geodata objects.
Definition: GeoDataObject.h:48
Marble::GeoDataObject::equals
virtual bool equals(const GeoDataObject &other) const
Compares the value of id and targetId of the two objects.
Definition: GeoDataObject.cpp:126
Marble::GeoDataObject::parent
virtual GeoDataObject * parent() const
Provides the parent of the object in GeoDataContainers.
Definition: GeoDataObject.cpp:65
Marble::GeoDataObject::pack
virtual void pack(QDataStream &stream) const
Reimplemented from Serializable.
Definition: GeoDataObject.cpp:114
Marble::Serializable
Definition: Serializable.h:19
Marble::GeoDataObject::setParent
virtual void setParent(GeoDataObject *parent)
Sets the parent of the object.
Definition: GeoDataObject.cpp:70
Marble::GeoDataDocument::baseUri
QString baseUri() const
The URI relative paths should be resolved against.
Definition: GeoDataDocument.cpp:112
QFileInfo::absoluteFilePath
QString absoluteFilePath() const
QString::isEmpty
bool isEmpty() const
GeoDataObject.h
Marble::GeoDataObject::GeoDataObject
GeoDataObject()
Definition: GeoDataObject.cpp:42
Marble::GeoDataObject::~GeoDataObject
virtual ~GeoDataObject()
Definition: GeoDataObject.cpp:60
QUrl::path
QString path() const
QString
Marble::GeoDataObject::resolvePath
QString resolvePath(const QString &relativePath) const
Definition: GeoDataObject.cpp:95
Marble::GeoDataObject::targetId
QString targetId() const
Get the targetId of the object to be replaced.
Definition: GeoDataObject.cpp:85
QFileInfo
QUrl
Marble::GeoDataObject::id
QString id() const
Get the id of the object.
Definition: GeoDataObject.cpp:75
Marble::GeoDataObject::setId
void setId(const QString &value)
Set the id of the object.
Definition: GeoDataObject.cpp:80
Marble::GeoDataDocument::fileName
QString fileName() const
The filename of the document.
Definition: GeoDataDocument.cpp:101
QUrl::isRelative
bool isRelative() const
Marble::GeoDataObject::operator=
GeoDataObject & operator=(const GeoDataObject &)
Definition: GeoDataObject.cpp:54
Marble::GeoDataObject::unpack
virtual void unpack(QDataStream &steam)
Reimplemented from Serializable.
Definition: GeoDataObject.cpp:120
GeoDataTypes.h
QFileInfo::absolutePath
QString absolutePath() const
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:13:39 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
  • 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