Marble

GeoDataTimeSpan.cpp
1 // SPDX-License-Identifier: LGPL-2.1-or-later
2 //
3 // SPDX-FileCopyrightText: 2010 Harshit Jain <[email protected]>
4 //
5 
6 // Own
7 #include "GeoDataTimeSpan.h"
8 
9 // Private
10 #include "GeoDataTimeSpan_p.h"
11 
12 // Qt
13 #include <QDataStream>
14 #include <QDateTime>
15 
16 // GeoData
17 #include "GeoDataTypes.h"
18 #include "MarbleDebug.h"
19 
20 namespace Marble
21 {
22 
23 GeoDataTimeSpan::GeoDataTimeSpan()
24  : GeoDataTimePrimitive(), d( new GeoDataTimeSpanPrivate )
25 {
26 }
27 
28 GeoDataTimeSpan::GeoDataTimeSpan( const GeoDataTimeSpan& other )
29  : GeoDataTimePrimitive( other ), d( new GeoDataTimeSpanPrivate( *other.d ) )
30 {
31 }
32 
33 GeoDataTimeSpan::~GeoDataTimeSpan()
34 {
35  delete d;
36 }
37 
38 const char* GeoDataTimeSpan::nodeType() const
39 {
40  return GeoDataTypes::GeoDataTimePrimitiveType;
41 }
42 
43 const GeoDataTimeStamp & GeoDataTimeSpan::end() const
44 {
45  return d->m_end;
46 }
47 
48 GeoDataTimeStamp &GeoDataTimeSpan::end()
49 {
50  return d->m_end;
51 }
52 
53 void GeoDataTimeSpan::setEnd( const GeoDataTimeStamp& end )
54 {
55  d->m_end = end;
56 }
57 
58 bool GeoDataTimeSpan::isValid() const
59 {
60  if (d->m_begin.when().isValid() != d->m_end.when().isValid()) {
61  return true;
62  }
63 
64  return d->m_begin.when().isValid() && d->m_end.when().isValid() && d->m_begin.when() <= d->m_end.when();
65 }
66 
67 const GeoDataTimeStamp & GeoDataTimeSpan::begin() const
68 {
69  return d->m_begin;
70 }
71 
72 GeoDataTimeStamp &GeoDataTimeSpan::begin()
73 {
74  return d->m_begin;
75 }
76 
77 void GeoDataTimeSpan::setBegin( const GeoDataTimeStamp& begin )
78 {
79  d->m_begin = begin;
80 }
81 
82 GeoDataTimeSpan& GeoDataTimeSpan::operator=( const GeoDataTimeSpan& other )
83 {
84  GeoDataTimePrimitive::operator=( other );
85  *d = *other.d;
86  return *this;
87 }
88 
89 bool GeoDataTimeSpan::operator==( const GeoDataTimeSpan& other ) const
90 {
91  return equals(other) &&
92  d->m_begin == other.d->m_begin &&
93  d->m_end == other.d->m_end;
94 }
95 
96 bool GeoDataTimeSpan::operator!=( const GeoDataTimeSpan& other ) const
97 {
98  return !this->operator==( other );
99 }
100 
101 void GeoDataTimeSpan::pack( QDataStream& stream ) const
102 {
103  GeoDataTimePrimitive::pack( stream );
104  d->m_begin.pack( stream );
105  d->m_end.pack( stream );
106 }
107 
108 void GeoDataTimeSpan::unpack( QDataStream& stream )
109 {
111  d->m_begin.unpack( stream );
112  d->m_end.unpack( stream );
113 }
114 
115 }
const QList< QKeySequence > & begin()
bool operator==(const Qt3DRender::QGraphicsApiFilter &reference, const Qt3DRender::QGraphicsApiFilter &sample)
void pack(QDataStream &stream) const override
Serialize the styleselector to a stream.
Binds a QML item to a specific geodetic location in screen coordinates.
void unpack(QDataStream &stream) override
Unserialize the styleselector from a stream.
const QList< QKeySequence > & end()
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Mon Oct 2 2023 03:52:08 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.