Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit e23b39e3 authored by Volker Krause's avatar Volker Krause

Add action to show hotel locations on OpenStreetMap

parent 9a16c031
......@@ -35,9 +35,11 @@
#include <QDate>
#include <QDBusInterface>
#include <QDesktopServices>
#include <QIcon>
#include <QMenu>
#include <QMetaProperty>
#include <QUrlQuery>
#include <memory>
......@@ -72,11 +74,34 @@ bool SemanticUrlHandler::handleContextMenuRequest(MimeTreeParser::Interface::Bod
showCalendar(date);
});
}
action = menu.addAction(QIcon::fromTheme(QStringLiteral("appointment-new")), i18n("Add To Calendar"));
QObject::connect(action, &QAction::triggered, this, [this, m](){
addToCalendar(m);
});
for (const auto &r : m->data()) {
if (r.userType() == qMetaTypeId<LodgingReservation>()) {
const auto hotel = JsonLdDocument::readProperty(r, "reservationFor");
const auto addr = JsonLdDocument::readProperty(hotel, "address");
action = menu.addAction(QIcon::fromTheme(QStringLiteral("map-globe")), i18n("Show %1 On Map", JsonLdDocument::readProperty(hotel, "name").toString()));
QObject::connect(action, &QAction::triggered, this, [addr]() {
QUrl url;
url.setScheme(QStringLiteral("https"));
url.setHost(QStringLiteral("www.openstreetmap.org"));
url.setPath(QStringLiteral("/search"));
const QString queryString = JsonLdDocument::readProperty(addr, "streetAddress").toString() + QLatin1String(", ")
+ JsonLdDocument::readProperty(addr, "postalCode").toString() + QLatin1Char(' ')
+ JsonLdDocument::readProperty(addr, "addressLocality").toString() + QLatin1String(", ")
+ JsonLdDocument::readProperty(addr, "addressCountry").toString();
QUrlQuery query;
query.addQueryItem(QStringLiteral("query"), queryString);
url.setQuery(query);
QDesktopServices::openUrl(url);
});
}
}
menu.exec(p);
return true;
}
......
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