Commit d260dc32 authored by Volker Krause's avatar Volker Krause
Browse files

Detect which country we are in if that hasn't been specified explicitly

This helps with opening hours evaluation.
parent 0e3680ca
Pipeline #47903 passed with stage
in 21 seconds
......@@ -245,12 +245,11 @@ Kirigami.ApplicationWindow {
page.map.mapLoader.loadForCoordinate(locationSheet.coordinate.y, locationSheet.coordinate.x);
page.map.view.beginTime = new Date();
page.map.view.endTime = new Date(page.map.view.beginTime.getTime() + 3600000);
// TODO region, timezone
// TODO timezone
}
}
map.overlaySources: [ gateModel, platformModel, locationModel, equipmentModel ]
map.region: "DE"
map.timeZone: "Europe/Berlin"
header: RowLayout {
......
......@@ -137,7 +137,9 @@ void MapItem::loaderDone()
if (!m_loader->hasError()) {
auto data = m_loader->takeData();
if (data.regionCode().isEmpty()) {
data.setRegionCode(m_data.regionCode());
}
data.setTimeZone(m_data.timeZone());
m_data = std::move(data);
m_view->setSceneBoundingBox(m_data.boundingBox());
......
......@@ -161,6 +161,7 @@ void MapData::processElements()
const auto buildingLevelsUndergroundTag = d->m_dataSet.tagKey("building:levels:underground");
const auto maxLevelTag = d->m_dataSet.tagKey("max_level");
const auto minLevelTag = d->m_dataSet.tagKey("min_level");
const auto countryTag = d->m_dataSet.tagKey("addr:country");
MapCSSParser p;
auto filter = p.parse(QStringLiteral(":/org.kde.kosmindoormap/assets/css/input-filter.mapcss"));
......@@ -176,6 +177,14 @@ void MapData::processElements()
return;
}
// attempt to detect the country we are in
if (d->m_regionCode.isEmpty()) {
const auto countryCode = e.tagValue(countryTag);
if (countryCode.size() == 2 && std::isupper(countryCode[0]) && std::isupper(countryCode[1])) {
d->m_regionCode = QString::fromUtf8(countryCode);
}
}
// apply the input filter, anything that explicitly got opacity 0 will be discarded
bool isDependentElement = false;
MapCSSState filterState;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment