KPublicTransport

lineutil.cpp
1/*
2 SPDX-FileCopyrightText: 2018 Volker Krause <vkrause@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7#include "lineutil_p.h"
8#include "linecompare_p.h"
9
10#include <knowledgedb/linemetadata.h>
11
12#include <KPublicTransport/Location>
13
14#include <QColor>
15#include <QDebug>
16#include <QString>
17#include <QUrl>
18
19using namespace KPublicTransport;
20
21bool LineUtil::isSameLineNameStrict(const QString &lhs, const QString &rhs)
22{
23 return Internal::isSameLineName(lhs, rhs, Internal::StrictCompare);
24}
25
26bool LineUtil::isSameLineNameFuzzy(const QString &lhs, const QString &rhs)
27{
28 return Internal::isSameLineName(lhs, rhs, Internal::FuzzyCompare);
29}
30
31bool LineUtil::isHighlyIdentifyingName(QStringView s)
32{
33 return s.size() >= 2
34 && std::any_of(s.begin(), s.end(), [](QChar c) { return c.isDigit(); })
35 && std::any_of(s.begin(), s.end(), [](QChar c) { return c.isLetter(); });
36}
37
38bool LineUtil::isCompatibleMode(Line::Mode lhs, Line::Mode rhs)
39{
40 if (lhs == rhs || lhs == Line::Unknown || rhs == Line::Unknown) {
41 return true;
42 }
43
44 if (lhs == Line::Train) {
45 return rhs == Line::LocalTrain || rhs == Line::LongDistanceTrain || rhs == Line::RapidTransit;
46 }
47 if (rhs == Line::Train) {
48 return lhs == Line::LocalTrain || lhs == Line::LongDistanceTrain || lhs == Line::RapidTransit;
49 }
50
51 return false;
52}
53
54bool LineUtil::isCompatibleBaseMode(Line::Mode lhs, Line::Mode rhs)
55{
56 if ((lhs == Line::RapidTransit || lhs == Line::Metro || lhs == Line::Tramway)
57 && (rhs == Line::RapidTransit || rhs == Line::Metro || rhs == Line::Tramway)) {
58 return true;
59 }
60
61 return isCompatibleMode(lhs, rhs);
62}
Mode
Mode of transportation.
Definition line.h:27
Query operations and data types for accessing realtime public transport information from online servi...
const_iterator begin() const const
const_iterator end() const const
qsizetype size() const const
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.