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

Forward region and timezone properties needed for opening hours

This should complete the API needed to integrate opening hours into map
styling.
parent 328ae84e
Pipeline #42395 passed with stage
in 22 seconds
......@@ -27,6 +27,10 @@ Item {
property alias mapData: map.mapData
/** Access to overlay sources. */
property alias overlaySources: map.overlaySources
/** ISO 3166-1/2 country or region code for opening hours interpretation. */
property alias region: map.region
/** IANA timezone id for opening hours interpretation. */
property alias timeZone: map.timeZone
/** Emitted when a map element has been picked by clicking/tapping on it. */
signal elementPicked(var element);
......
......@@ -16,6 +16,7 @@
#include <QPalette>
#include <QQuickWindow>
#include <QStandardPaths>
#include <QTimeZone>
using namespace KOSMIndoorMap;
......@@ -135,7 +136,10 @@ void MapItem::loaderDone()
m_sg.clear();
if (!m_loader->hasError()) {
m_data = m_loader->takeData();
auto data = m_loader->takeData();
data.setRegionCode(m_data.regionCode());
data.setTimeZone(m_data.timeZone());
m_data = std::move(data);
m_view->setSceneBoundingBox(m_data.boundingBox());
m_controller.setMapData(m_data);
m_style.compile(m_data.dataSet());
......@@ -232,3 +236,34 @@ void MapItem::addOverlaySource(std::vector<OverlaySource> &overlaySources, const
qWarning() << "unsupported overlay source:" << source << obj;
}
}
QString MapItem::region() const
{
return m_data.regionCode();
}
void MapItem::setRegion(const QString &region)
{
if (m_data.regionCode() == region) {
return;
}
m_data.setRegionCode(region);
emit regionChanged();
}
QString MapItem::timeZoneId() const
{
return QString::fromUtf8(m_data.timeZone().id());
}
void MapItem::setTimeZoneId(const QString &tz)
{
const auto tzId = tz.toUtf8();
if (m_data.timeZone().id() == tzId) {
return;
}
m_data.setTimeZone(QTimeZone(tzId));
emit timeZoneChanged();
}
......@@ -44,6 +44,17 @@ class MapItem : public QQuickPaintedItem
/** Sources for overlays that should be rendered on top of the map. */
Q_PROPERTY(QVariant overlaySources READ overlaySources WRITE setOverlaySources NOTIFY overlaySourcesChanged)
/** ISO 3166-1/2 country or region code this map area is in.
* Used for interpreting opening hours expressions.
*/
Q_PROPERTY(QString region READ region WRITE setRegion NOTIFY regionChanged)
/** IANA timezone id of the timezone this map area is in.
* Used for interpreting opening hours expressions.
*/
Q_PROPERTY(QString timeZone READ timeZoneId WRITE setTimeZoneId NOTIFY timeZoneChanged)
public:
explicit MapItem(QQuickItem *parent = nullptr);
~MapItem();
......@@ -63,12 +74,19 @@ public:
bool hasError() const;
QString errorMessage() const;
QString region() const;
void setRegion(const QString &region);
QString timeZoneId() const;
void setTimeZoneId(const QString &tz);
Q_SIGNALS:
void mapDataChanged();
void styleSheetChanged();
void currentFloorLevelChanged();
void errorChanged();
void overlaySourcesChanged();
void regionChanged();
void timeZoneChanged();
protected:
void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) override;
......
......@@ -212,6 +212,8 @@ Kirigami.ApplicationWindow {
}
map.overlaySources: [ gateModel, platformModel, locationModel ]
map.region: "DE"
map.timeZone: "Europe/Berlin"
header: RowLayout {
QQC2.Label { text: "Floor Level:" }
......
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