Commit db77eada authored by Volker Krause's avatar Volker Krause

This does not need to be a QObject, Q_GADGET is enough

parent 93c61f50
......@@ -21,6 +21,7 @@
#include <KItinerary/Place>
#include <KContacts/Address>
#include <KFormat>
#include <QDateTime>
#include <QLocale>
......@@ -28,13 +29,6 @@
using namespace KItinerary;
Localizer::Localizer(QObject *parent)
: QObject(parent)
{
}
Localizer::~Localizer() = default;
QString Localizer::countryName(const QString& isoCode) const
{
return KContacts::Address::ISOtoCountry(isoCode);
......
......@@ -26,13 +26,10 @@ class QVariant;
* Works around JS losing timezone information, ie. we need
* to do this without passing the date/time values through JS.
*/
class Localizer : public QObject
class Localizer
{
Q_OBJECT
Q_GADGET
public:
explicit Localizer(QObject *parent = nullptr);
~Localizer();
Q_INVOKABLE QString countryName(const QString &isoCode) const;
Q_INVOKABLE QString formatAddress(const QVariant &obj) const;
Q_INVOKABLE QString formatTime(const QVariant &obj, const QString &propertyName) const;
......
......@@ -194,8 +194,8 @@ int main(int argc, char **argv)
qmlRegisterUncreatableType<CountryInformation>("org.kde.itinerary", 1, 0, "CountryInformation", {});
qmlRegisterType<CountryModel>("org.kde.itinerary", 1, 0, "CountryModel");
qmlRegisterSingletonType<Localizer>("org.kde.itinerary", 1, 0, "Localizer", [](QQmlEngine*, QJSEngine*) -> QObject*{
return new Localizer;
qmlRegisterSingletonType("org.kde.itinerary", 1, 0, "Localizer", [](QQmlEngine*, QJSEngine *engine) -> QJSValue {
return engine->toScriptValue(Localizer());
});
qmlRegisterType<TicketTokenModel>("org.kde.itinerary", 1, 0, "TicketTokenModel");
qmlRegisterUncreatableType<TimelineModel>("org.kde.itinerary", 1, 0, "TimelineModel", {});
......
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