KPublicTransport

platformutils.cpp
1 /*
2  SPDX-FileCopyrightText: 2019 Volker Krause <[email protected]>
3 
4  SPDX-License-Identifier: LGPL-2.0-or-later
5 */
6 
7 #include "platformutils_p.h"
8 
9 #include <QString>
10 
11 using namespace KPublicTransport;
12 
13 static const char *platform_prefixes[] = {
14  "---",
15  "bahnsteig",
16  "bstg.",
17  "gleis",
18  "pl.",
19  "platform"
20 };
21 
22 QString 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 
33 bool 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...
Definition: attribution.cpp:16
CaseInsensitive
bool isEmpty() const const
QString trimmed() const const
bool startsWith(const QString &s, Qt::CaseSensitivity cs) const const
QString mid(int position, int n) const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Sat Oct 23 2021 23:05:21 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.