Marble

GeoDataTimeSpan.cpp
1// SPDX-License-Identifier: LGPL-2.1-or-later
2//
3// SPDX-FileCopyrightText: 2010 Harshit Jain <hjain.itbhu@gmail.com>
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
20namespace Marble
21{
22
23GeoDataTimeSpan::GeoDataTimeSpan()
24 : GeoDataTimePrimitive()
25 , d(new GeoDataTimeSpanPrivate)
26{
27}
28
29GeoDataTimeSpan::GeoDataTimeSpan(const GeoDataTimeSpan &other)
30 : GeoDataTimePrimitive(other)
31 , d(new GeoDataTimeSpanPrivate(*other.d))
32{
33}
34
35GeoDataTimeSpan::~GeoDataTimeSpan()
36{
37 delete d;
38}
39
40const char *GeoDataTimeSpan::nodeType() const
41{
42 return GeoDataTypes::GeoDataTimePrimitiveType;
43}
44
45const GeoDataTimeStamp &GeoDataTimeSpan::end() const
46{
47 return d->m_end;
48}
49
50GeoDataTimeStamp &GeoDataTimeSpan::end()
51{
52 return d->m_end;
53}
54
55void GeoDataTimeSpan::setEnd(const GeoDataTimeStamp &end)
56{
57 d->m_end = end;
58}
59
60bool GeoDataTimeSpan::isValid() const
61{
62 if (d->m_begin.when().isValid() != d->m_end.when().isValid()) {
63 return true;
64 }
65
66 return d->m_begin.when().isValid() && d->m_end.when().isValid() && d->m_begin.when() <= d->m_end.when();
67}
68
69const GeoDataTimeStamp &GeoDataTimeSpan::begin() const
70{
71 return d->m_begin;
72}
73
74GeoDataTimeStamp &GeoDataTimeSpan::begin()
75{
76 return d->m_begin;
77}
78
79void GeoDataTimeSpan::setBegin(const GeoDataTimeStamp &begin)
80{
81 d->m_begin = begin;
82}
83
84GeoDataTimeSpan &GeoDataTimeSpan::operator=(const GeoDataTimeSpan &other)
85{
86 GeoDataTimePrimitive::operator=(other);
87 *d = *other.d;
88 return *this;
89}
90
91bool GeoDataTimeSpan::operator==(const GeoDataTimeSpan &other) const
92{
93 return equals(other) && d->m_begin == other.d->m_begin && d->m_end == other.d->m_end;
94}
95
96bool GeoDataTimeSpan::operator!=(const GeoDataTimeSpan &other) const
97{
98 return !this->operator==(other);
99}
100
101void GeoDataTimeSpan::pack(QDataStream &stream) const
102{
103 GeoDataTimePrimitive::pack(stream);
104 d->m_begin.pack(stream);
105 d->m_end.pack(stream);
106}
107
108void GeoDataTimeSpan::unpack(QDataStream &stream)
109{
110 GeoDataTimePrimitive::unpack(stream);
111 d->m_begin.unpack(stream);
112 d->m_end.unpack(stream);
113}
114
115}
KIOCORE_EXPORT bool operator==(const UDSEntry &entry, const UDSEntry &other)
const QList< QKeySequence > & begin()
const QList< QKeySequence > & end()
bool equals(const QVariant &lhs, const QVariant &rhs)
Binds a QML item to a specific geodetic location in screen coordinates.
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Dec 20 2024 11:52:13 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.