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
6
7#include <QtCore/QDebug>
8
10
11QT_DEFINE_QSDP_SPECIALIZATION_DTOR(QGeoTileSpecPrivate)
12
13QGeoTileSpec::QGeoTileSpec()
14 : d(new QGeoTileSpecPrivate())
15{
16}
17
18QGeoTileSpec::QGeoTileSpec(const QString &plugin, int mapId, int zoom, int x, int y, int version)
19 : d(new QGeoTileSpecPrivate(plugin, mapId, zoom, x, y, version))
20{
21}
22
23QGeoTileSpec::QGeoTileSpec(const QGeoTileSpec &other) noexcept = default;
24
25QGeoTileSpec::~QGeoTileSpec() = default;
26
27QGeoTileSpec &QGeoTileSpec::operator=(const QGeoTileSpec &other) noexcept
28{
29 if (this == &other)
30 return *this;
31
32 d = other.d;
33 return *this;
34}
35
36QString QGeoTileSpec::plugin() const
37{
38 return d->plugin_;
39}
40
41void QGeoTileSpec::setZoom(int zoom)
42{
43 d->zoom_ = zoom;
44}
45
46int QGeoTileSpec::zoom() const
47{
48 return d->zoom_;
49}
50
51void QGeoTileSpec::setX(int x)
52{
53 d->x_ = x;
54}
55
56int QGeoTileSpec::x() const
57{
58 return d->x_;
59}
60
61void QGeoTileSpec::setY(int y)
62{
63 d->y_ = y;
64}
65
66int QGeoTileSpec::y() const
67{
68 return d->y_;
69}
70
71void QGeoTileSpec::setMapId(int mapId)
72{
73 d->mapId_ = mapId;
74}
75
76int QGeoTileSpec::mapId() const
77{
78 return d->mapId_;
79}
80
81void QGeoTileSpec::setVersion(int version)
82{
83 d->version_ = version;
84}
85
86int QGeoTileSpec::version() const
87{
88 return d->version_;
89}
90
91bool QGeoTileSpec::isEqual(const QGeoTileSpec &rhs) const noexcept
92{
93 return (*(d.constData()) == *(rhs.d.constData()));
94}
95
96bool QGeoTileSpec::isLess(const QGeoTileSpec &rhs) const noexcept
97{
98 return (*(d.constData()) < *(rhs.d.constData()));
99}
100
101unsigned int qHash(const QGeoTileSpec &spec)
102{
103 unsigned int result = (qHash(spec.plugin()) * 13) % 31;
104 result += ((spec.mapId() * 17) % 31) << 5;
105 result += ((spec.zoom() * 19) % 31) << 10;
106 result += ((spec.x() * 23) % 31) << 15;
107 result += ((spec.y() * 29) % 31) << 20;
108 result += (spec.version() % 3) << 25;
109 return result;
110}
111
112QDebug operator<< (QDebug dbg, const QGeoTileSpec &spec)
113{
114 dbg << spec.plugin() << spec.mapId() << spec.zoom() << spec.x() << spec.y() << spec.version();
115 return dbg;
116}
117
118bool QGeoTileSpecPrivate::operator<(const QGeoTileSpecPrivate &rhs) const
119{
120 if (plugin_ < rhs.plugin_)
121 return true;
122 if (plugin_ > rhs.plugin_)
123 return false;
124
125 if (mapId_ < rhs.mapId_)
126 return true;
127 if (mapId_ > rhs.mapId_)
128 return false;
129
130 if (zoom_ < rhs.zoom_)
131 return true;
132 if (zoom_ > rhs.zoom_)
133 return false;
134
135 if (x_ < rhs.x_)
136 return true;
137 if (x_ > rhs.x_)
138 return false;
139
140 if (y_ < rhs.y_)
141 return true;
142 if (y_ > rhs.y_)
143 return false;
144
145 return (version_ < rhs.version_);
146}
147
148QT_END_NAMESPACE
Combined button and popup list for selecting options.
QDebug operator<<(QDebug dbg, const QFileInfo &fi)
size_t qHash(const QHashedString &string)