[libraries/kpublictransport] src/lib/backends: Work around unreasonably long display names for Amarillo ride shares
Volker Krause <[email protected]>
| Newsgroups | gmane.comp.kde.cvs |
|---|---|
| Message-ID | <[email protected]> |
Git commit 2d3c8b198d458447921aee53fc75b0c1e9dc398b by Volker Krause.
Committed on 26/07/2026 at 14:50.
Pushed by vkrause into branch 'master'.
Work around unreasonably long display names for Amarillo ride shares
Use the operator name instead in those cases, ie. we then show
"Fahrgemeinschaft.de" instead of "very detailed departure location ->
very detailed arrival location", which has no chance of fitting on the
screen, and entirely duplicates information we show elsewhere already
anyway.
M +13 -7 src/lib/backends/motis2parser.cpp
https://invent.kde.org/libraries/kpublictransport/-/commit/2d3c8b198d458447921aee53fc75b0c1e9dc398b
diff --git a/src/lib/backends/motis2parser.cpp b/src/lib/backends/motis2parser.cpp
index e50d1cc4..fb5cc1b2 100644
--- a/src/lib/backends/motis2parser.cpp
+++ b/src/lib/backends/motis2parser.cpp
@@ -241,15 +241,8 @@ Motis2Parser::MotisRoute Motis2Parser::parseRoute(const QJsonObject &obj) const
res.route.setDirection(obj.value("headsign"_L1).toString());
res.route.setDestination(parsePlace(obj.value("tripTo"_L1).toObject(), false).stopPoint());
- res.route.setLine(line);
res.bookingUrl = QUrl(obj.value("agencyFareUrl"_L1).toString());
-
- // Amarillo rideshare booking URLs
- if (res.route.line().mode() == Line::RideShare) {
- res.bookingUrl = QUrl(obj.value("routeUrl"_L1).toString());
- }
-
if (obj.contains("ticketUrls"_L1)) {
const auto urls = obj.value("ticketUrls"_L1).toObject();
// prefer web url even on android
@@ -262,6 +255,19 @@ Motis2Parser::MotisRoute Motis2Parser::parseRoute(const QJsonObject &obj) const
#endif
}
+ // Amarillo rideshare workarounds
+ if (line.mode() == Line::RideShare) {
+ // routeUrl has the booking URL
+ if (res.bookingUrl.isEmpty()) {
+ res.bookingUrl = QUrl(obj.value("routeUrl"_L1).toString());
+ }
+ // deal with the unreasonably long display names
+ if (line.name().size() > 20 && line.name().contains(" -> "_L1) && !line.operatorName().isEmpty() && line.operatorName().size() < line.name().size()) {
+ line.setName(line.operatorName());
+ }
+ }
+
+ res.route.setLine(line);
return res;
}