Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
Loading...
Searching...
No Matches
qgeouriprovider.cpp
Go to the documentation of this file.
1
// Copyright (C) 2015 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
#
include
"qgeouriprovider.h"
4
5
#
include
<
QMap
>
6
#
include
<
QVariant
>
7
#
include
<
QRandomGenerator
>
8
#
include
<
QSet
>
9
#
include
<
QString
>
10
11
QT_BEGIN_NAMESPACE
12
13
QGeoUriProvider
::
QGeoUriProvider
(
14
QObject
*
parent
,
15
const
QVariantMap
&
parameters
,
16
const
QString
&
hostParameterName
,
17
const
QString
&
internationalHost
,
18
const
QString
&
localizedHost
)
19
:
QObject
(
parent
)
20
, m_internationalHost(parameters.value(hostParameterName, internationalHost).toString())
21
, m_localizedHost(localizedHost)
22
, m_firstSubdomain(QChar::Null)
23
, m_maxSubdomains(0)
24
{
25
setCurrentHost(isInternationalNetwork() || m_localizedHost.isEmpty() ? m_internationalHost : m_localizedHost);
26
}
27
28
QString
QGeoUriProvider
::
getCurrentHost
()
const
29
{
30
if
(m_maxSubdomains) {
31
auto
result = QString(
"%1"
).arg(
static_cast
<
char
>(m_firstSubdomain.toLatin1() + QRandomGenerator::global()->bounded(m_maxSubdomains)));
32
result +=
'.'
+ m_currentHost;
33
return
result;
34
}
35
return
m_currentHost;
36
}
37
38
void
QGeoUriProvider
::setCurrentHost(
const
QString &host)
39
{
40
if
(host.length() > 4 && host.at(1) == QChar(
'-'
) && host.at(3) == QChar(
'.'
)) {
41
QString realHost = host.right(host.length() - 4);
42
m_firstSubdomain = host.at(0);
43
m_maxSubdomains = host.at(2).toLatin1() - host.at(0).toLatin1() + 1;
44
m_currentHost = realHost;
45
}
else
{
46
m_currentHost = host;
47
m_firstSubdomain = QChar::Null;
48
m_maxSubdomains = 0;
49
}
50
}
51
52
void
QGeoUriProvider
::mobileCountryCodeChanged(
int
interfaceId,
const
QString& mcc)
53
{
54
Q_UNUSED(interfaceId);
55
Q_UNUSED(mcc);
56
57
setCurrentHost(isInternationalNetwork() || m_localizedHost.isEmpty() ? m_internationalHost : m_localizedHost);
58
}
59
60
bool
QGeoUriProvider
::isInternationalNetwork()
const
61
{
62
return
true
;
63
}
64
65
QT_END_NAMESPACE
QGeoUriProvider
Definition
qgeouriprovider.h:14
QGeoUriProvider::getCurrentHost
QString getCurrentHost() const
Definition
qgeouriprovider.cpp:28
QObjectData::parent
QObject * parent
Definition
qobject.h:74
QObject
\inmodule QtCore
Definition
qobject.h:106
QT_BEGIN_NAMESPACE
Combined button and popup list for selecting options.
Definition
qsequentialanimationgroup.cpp:47
qtlocation
src
plugins
geoservices
nokia
qgeouriprovider.cpp
Generated on
for Qt by
1.18.0