Commit c4ecfe23 authored by Volker Krause's avatar Volker Krause

Also enable navigation on Android if we only know the address

parent 9d21179b
......@@ -56,7 +56,7 @@ Item {
onClicked: _appController.showOnMap(place)
}
QQC2.ToolButton {
visible: place.geo.isValid
visible: _appController.canNavigateTo(place)
Kirigami.Icon {
anchors.centerIn: parent
width: Kirigami.Units.iconSizes.smallMedium
......
......@@ -103,6 +103,23 @@ void ApplicationController::showOnMap(const QVariant &place)
#endif
}
bool ApplicationController::canNavigateTo(const QVariant& place)
{
if (place.isNull()) {
return false;
}
if (JsonLdDocument::readProperty(place, "geo").value<GeoCoordinates>().isValid()) {
return true;
}
#ifdef Q_OS_ANDROID
return !JsonLdDocument::readProperty(place, "address").value<PostalAddress>().isEmpty();
#else
return false;
#endif
}
void ApplicationController::navigateTo(const QVariant& place)
{
if (place.isNull()) {
......
......@@ -31,6 +31,7 @@ public:
~ApplicationController();
Q_INVOKABLE void showOnMap(const QVariant &place);
Q_INVOKABLE bool canNavigateTo(const QVariant &place);
Q_INVOKABLE void navigateTo(const QVariant &place);
private:
......
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