KPublicTransport

platformutils.cpp
1/*
2 SPDX-FileCopyrightText: 2019 Volker Krause <vkrause@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7#include "platformutils_p.h"
8
9#include <QString>
10
11using namespace KPublicTransport;
12
13static const char *platform_prefixes[] = {
14 "---",
15 "bahnsteig",
16 "bstg.",
17 "gleis",
18 "pl.",
19 "platform"
20};
21
22QString PlatformUtils::normalizePlatform(const QString &platform)
23{
24 for (const auto prefix : platform_prefixes) {
25 if (platform.startsWith(QLatin1String(prefix), Qt::CaseInsensitive)) {
26 return platform.mid(strlen(prefix)).trimmed();
27 }
28 }
29
30 return platform;
31}
32
33bool PlatformUtils::platformChanged(const QString &scheduledPlatform, const QString &expectedPlatform)
34{
35 return !scheduledPlatform.isEmpty() && !expectedPlatform.isEmpty() && scheduledPlatform != expectedPlatform;
36}
Query operations and data types for accessing realtime public transport information from online servi...
bool isEmpty() const const
QString mid(qsizetype position, qsizetype n) const const
bool startsWith(QChar c, Qt::CaseSensitivity cs) const const
QString trimmed() const const
CaseInsensitive
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 16:59:57 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.