Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qgeotilespec.cpp
Go to the documentation of this file.
1// Copyright (C) 2022 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3// Qt-Security score:significant reason:default
4
7
8#include <QtCore/QDebug>
9
11
12QT_DEFINE_QSDP_SPECIALIZATION_DTOR(QGeoTileSpecPrivate)
13
14QGeoTileSpec::QGeoTileSpec()
15 : d(new QGeoTileSpecPrivate())
16{
17}
18
19QGeoTileSpec::QGeoTileSpec(const QString &plugin, int mapId, int zoom, int x, int y, int version)
20 : d(new QGeoTileSpecPrivate(plugin, mapId, zoom, x, y, version))
21{
22}
23
24QGeoTileSpec::QGeoTileSpec(const QGeoTileSpec &other) noexcept = default;
25
26QGeoTileSpec::~QGeoTileSpec() = default;
27
28QGeoTileSpec &QGeoTileSpec::operator=(const QGeoTileSpec &other) noexcept
29{
30 if (this == &other)
31 return *this;
32
33 d = other.d;
34 return *this;
35}
36
37QString QGeoTileSpec::plugin() const
38{
39 return d->plugin_;
40}
41
42void QGeoTileSpec::setZoom(int zoom)
43{
44 d->zoom_ = zoom;
45}
46
47int QGeoTileSpec::zoom() const
48{
49 return d->zoom_;
50}
51
52void QGeoTileSpec::setX(int x)
53{
54 d->x_ = x;
55}
56
57int QGeoTileSpec::x() const
58{
59 return d->x_;
60}
61
62void QGeoTileSpec::setY(int y)
63{
64 d->y_ = y;
65}
66
67int QGeoTileSpec::y() const
68{
69 return d->y_;
70}
71
72void QGeoTileSpec::setMapId(int mapId)
73{
74 d->mapId_ = mapId;
75}
76
77int QGeoTileSpec::mapId() const
78{
79 return d->mapId_;
80}
81
82void QGeoTileSpec::setVersion(int version)
83{
84 d->version_ = version;
85}
86
87int QGeoTileSpec::version() const
88{
89 return d->version_;
90}
91
92bool QGeoTileSpec::isEqual(const QGeoTileSpec &rhs) const noexcept
93{
94 return (*(d.constData()) == *(rhs.d.constData()));
95}
96
97bool QGeoTileSpec::isLess(const QGeoTileSpec &rhs) const noexcept
98{
99 return (*(d.constData()) < *(rhs.d.constData()));
100}
101
102unsigned int qHash(const QGeoTileSpec &spec)
103{
104 unsigned int result = (qHash(spec.plugin()) * 13) % 31;
105 result += ((spec.mapId() * 17) % 31) << 5;
106 result += ((spec.zoom() * 19) % 31) << 10;
107 result += ((spec.x() * 23) % 31) << 15;
108 result += ((spec.y() * 29) % 31) << 20;
109 result += (spec.version() % 3) << 25;
110 return result;
111}
112
113QDebug operator<< (QDebug dbg, const QGeoTileSpec &spec)
114{
115 dbg << spec.plugin() << spec.mapId() << spec.zoom() << spec.x() << spec.y() << spec.version();
116 return dbg;
117}
118
119bool QGeoTileSpecPrivate::operator<(const QGeoTileSpecPrivate &rhs) const
120{
121 if (plugin_ < rhs.plugin_)
122 return true;
123 if (plugin_ > rhs.plugin_)
124 return false;
125
126 if (mapId_ < rhs.mapId_)
127 return true;
128 if (mapId_ > rhs.mapId_)
129 return false;
130
131 if (zoom_ < rhs.zoom_)
132 return true;
133 if (zoom_ > rhs.zoom_)
134 return false;
135
136 if (x_ < rhs.x_)
137 return true;
138 if (x_ > rhs.x_)
139 return false;
140
141 if (y_ < rhs.y_)
142 return true;
143 if (y_ > rhs.y_)
144 return false;
145
146 return (version_ < rhs.version_);
147}
148
149QT_END_NAMESPACE
Combined button and popup list for selecting options.
QDebug operator<<(QDebug dbg, const QFileInfo &fi)
size_t qHash(const QHashedString &string)