File indexing completed on 2024-05-12 04:42:45

0001 /*
0002     SPDX-FileCopyrightText: 2019 Volker Krause <vkrause@kde.org>
0003 
0004     SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #include "platformutils_p.h"
0008 
0009 #include <QString>
0010 
0011 using namespace KPublicTransport;
0012 
0013 static const char *platform_prefixes[] = {
0014     "---",
0015     "bahnsteig",
0016     "bstg.",
0017     "gleis",
0018     "pl.",
0019     "platform"
0020 };
0021 
0022 QString PlatformUtils::normalizePlatform(const QString &platform)
0023 {
0024     for (const auto prefix : platform_prefixes) {
0025         if (platform.startsWith(QLatin1String(prefix), Qt::CaseInsensitive)) {
0026             return platform.mid(strlen(prefix)).trimmed();
0027         }
0028     }
0029 
0030     return platform;
0031 }
0032 
0033 bool PlatformUtils::platformChanged(const QString &scheduledPlatform, const QString &expectedPlatform)
0034 {
0035     return !scheduledPlatform.isEmpty() && !expectedPlatform.isEmpty() && scheduledPlatform != expectedPlatform;
0036 }