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
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
4
5#include <QMap>
6#include <QVariant>
7#include <QRandomGenerator>
8#include <QSet>
9#include <QString>
10
12
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
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
38void 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
52void 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
60bool QGeoUriProvider::isInternationalNetwork() const
61{
62 return true;
63}
64
65QT_END_NAMESPACE
QString getCurrentHost() const
QObject * parent
Definition qobject.h:73
\inmodule QtCore
Definition qobject.h:103
Combined button and popup list for selecting options.