Marble

GeoDataHotSpot.cpp
1// SPDX-License-Identifier: LGPL-2.1-or-later
2//
3// SPDX-FileCopyrightText: 2007 Murad Tagirov <tmurad@gmail.com>
4// SPDX-FileCopyrightText: 2008 Inge Wallin <inge@lysator.liu.se>
5//
6
7#include "GeoDataHotSpot.h"
8
9#include <QDataStream>
10
11#include "GeoDataTypes.h"
12
13namespace Marble
14{
15
16class GeoDataHotSpotPrivate
17{
18public:
19 GeoDataHotSpotPrivate() = default;
20
21 GeoDataHotSpotPrivate(const QPointF &hotSpot, GeoDataHotSpot::Units xunits, GeoDataHotSpot::Units yunits)
22 : m_hotSpot(hotSpot)
23 , m_xunits(xunits)
24 , m_yunits(yunits)
25 {
26 }
27
28 QPointF m_hotSpot;
29 GeoDataHotSpot::Units m_xunits;
30 GeoDataHotSpot::Units m_yunits;
31};
32
33GeoDataHotSpot::GeoDataHotSpot(const QPointF &hotSpot, Units xunits, Units yunits)
34 : d(new GeoDataHotSpotPrivate(hotSpot, xunits, yunits))
35{
36}
37
38GeoDataHotSpot::GeoDataHotSpot(const GeoDataHotSpot &other)
39 : GeoDataObject(other)
40 , d(new GeoDataHotSpotPrivate(*other.d))
41{
42}
43
44GeoDataHotSpot::~GeoDataHotSpot()
45{
46 delete d;
47}
48
49GeoDataHotSpot &GeoDataHotSpot::operator=(const GeoDataHotSpot &other)
50{
51 GeoDataObject::operator=(other);
52
53 *d = *other.d;
54 return *this;
55}
56
57bool GeoDataHotSpot::operator==(const GeoDataHotSpot &other) const
58{
59 return equals(other) && d->m_hotSpot == other.d->m_hotSpot && d->m_xunits == other.d->m_xunits && d->m_yunits == other.d->m_yunits;
60}
61
62bool GeoDataHotSpot::operator!=(const GeoDataHotSpot &other) const
63{
64 return !this->operator==(other);
65}
66
67const QPointF &GeoDataHotSpot::hotSpot(Units &xunits, Units &yunits) const
68{
69 xunits = d->m_xunits;
70 yunits = d->m_yunits;
71
72 return d->m_hotSpot;
73}
74
75void GeoDataHotSpot::setHotSpot(const QPointF &hotSpot, Units xunits, Units yunits)
76{
77 d->m_hotSpot = hotSpot;
78 d->m_xunits = xunits;
79 d->m_yunits = yunits;
80}
81
82const char *GeoDataHotSpot::nodeType() const
83{
84 return GeoDataTypes::GeoDataHotspotType;
85}
86
87void GeoDataHotSpot::pack(QDataStream &stream) const
88{
89 GeoDataObject::pack(stream);
90
91 stream << d->m_xunits << d->m_yunits;
92 stream << d->m_hotSpot;
93}
94
95void GeoDataHotSpot::unpack(QDataStream &stream)
96{
97 GeoDataObject::unpack(stream);
98 int xu, yu;
99 stream >> xu >> yu;
100 d->m_xunits = static_cast<Units>(xu);
101 d->m_yunits = static_cast<Units>(yu);
102 stream >> d->m_hotSpot;
103}
104
105}
bool equals(const QVariant &lhs, const QVariant &rhs)
bool operator==(const StyleDelim &l, const StyleDelim &r)
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 Nov 8 2024 12:02:43 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.