Commit 801500bc authored by Volker Krause's avatar Volker Krause
Browse files

Make backend and coverage area objects accessbile from QML

parent a504d281
......@@ -40,7 +40,7 @@ public:
QString description() const;
bool isSecure() const;
CoverageArea coverageArea(CoverageArea::Type coverageType) const;
Q_INVOKABLE KPublicTransport::CoverageArea coverageArea(KPublicTransport::CoverageArea::Type coverageType) const;
};
}
......
......@@ -28,6 +28,7 @@ public:
Regular,
Any
};
Q_ENUM(Type)
KPUBLICTRANSPORT_PROPERTY(Type, type, setType)
/** ISO 3166-1/2 codes of covered regions.
......
......@@ -895,14 +895,22 @@ void Manager::setDisabledBackends(const QStringList &backendIds)
}
}
bool KPublicTransport::Manager::backendsEnabledByDefault() const
bool Manager::backendsEnabledByDefault() const
{
return d->m_backendsEnabledByDefault;
}
void KPublicTransport::Manager::setBackendsEnabledByDefault(bool byDefault)
void Manager::setBackendsEnabledByDefault(bool byDefault)
{
d->m_backendsEnabledByDefault = byDefault;
Q_EMIT configurationChanged();
}
QVariantList Manager::backendsVariant() const
{
QVariantList l;
l.reserve(d->m_backends.size());
std::transform(d->m_backends.begin(), d->m_backends.end(), std::back_inserter(l), [](const auto &b) { return QVariant::fromValue(b); });
return l;
}
......@@ -53,6 +53,9 @@ class KPUBLICTRANSPORT_EXPORT Manager : public QObject
/** @see backendsEnabledByDefault() */
Q_PROPERTY(bool backendsEnabledByDefault READ backendsEnabledByDefault WRITE setBackendsEnabledByDefault NOTIFY configurationChanged)
/** QML-compatible access to backends(). */
Q_PROPERTY(QVariantList backends READ backendsVariant CONSTANT)
public:
explicit Manager(QObject *parent = nullptr);
~Manager() override;
......@@ -134,6 +137,7 @@ Q_SIGNALS:
private:
Q_DECL_HIDDEN QVariantList attributionsVariant() const;
Q_DECL_HIDDEN QVariantList backendsVariant() const;
std::unique_ptr<ManagerPrivate> d;
};
......
......@@ -11,6 +11,7 @@
#include <QQmlContext>
#include <KPublicTransport/BackendModel>
#include <KPublicTransport/CoverageArea>
#include <KPublicTransport/Equipment>
#include <KPublicTransport/IndividualTransport>
#include <KPublicTransport/Journey>
......@@ -33,6 +34,8 @@
void KPublicTransportQmlPlugin::registerTypes(const char*)
{
qRegisterMetaType<KPublicTransport::CoverageArea>();
qRegisterMetaType<KPublicTransport::CoverageArea::Type>();
qRegisterMetaType<KPublicTransport::Equipment>();
qRegisterMetaType<KPublicTransport::Line>();
qRegisterMetaType<KPublicTransport::Line::Mode>();
......@@ -48,6 +51,7 @@ void KPublicTransportQmlPlugin::registerTypes(const char*)
qmlRegisterUncreatableMetaObject(KPublicTransport::Disruption::staticMetaObject, "org.kde.kpublictransport", 1, 0, "Disruption", {});
qmlRegisterUncreatableMetaObject(KPublicTransport::Load::staticMetaObject, "org.kde.kpublictransport", 1, 0, "Load", {});
qmlRegisterUncreatableType<KPublicTransport::CoverageArea>("org.kde.kpublictransport", 1, 0, "CoverageArea", {});
qmlRegisterUncreatableType<KPublicTransport::Line>("org.kde.kpublictransport", 1, 0, "Line", {});
qmlRegisterUncreatableType<KPublicTransport::Location>("org.kde.kpublictransport", 1, 0, "Location", {});
qmlRegisterUncreatableType<KPublicTransport::JourneySection>("org.kde.kpublictransport", 1, 0, "JourneySection", {});
......
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