+class DateTimeExporter : public QObject
+{
+ Q_OBJECT
+
+public:
+ DateTimeExporter(const QDateTime &dt) : m_datetime(dt), m_offset(0), m_timespec("UTC")
+ {
+ switch (m_datetime.timeSpec()) {
+ case Qt::LocalTime:
+ {
+ QDateTime utc(m_datetime.toUTC());
+ utc.setTimeSpec(Qt::LocalTime);
+ m_offset = m_datetime.secsTo(utc) / 60;
+ m_timespec = "LocalTime";
+ }
+ break;
+ case Qt::OffsetFromUTC:
+ m_offset = m_datetime.utcOffset() / 60;
+ m_timespec = QString("%1%2:%3").arg(m_offset < 0 ? '-' : '+')
+ .arg(abs(m_offset) / 60)
+ .arg(abs(m_offset) % 60);
+ default:
+ break;
+ }
+ }
+
+ Q_INVOKABLE QDate getDate() const { return m_datetime.date(); }
+ Q_INVOKABLE QDateTime getDateTime() const { return m_datetime; }
+ Q_INVOKABLE int getDateTimeOffset() const { return m_offset; }
+ Q_INVOKABLE QString getTimeSpec() const { return m_timespec; }
+
+private:
+ QDateTime m_datetime;
+ int m_offset;
+ QString m_timespec;
+};
+
+class MyWorkerObject : public QObject
+{
+ Q_OBJECT
+
+public Q_SLOTS:
+ void doIt();
+
+Q_SIGNALS:
+ void done(const QString &result);
+};
+
+class MyUnregisteredEnumTypeObject : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(MyEnum enumProperty READ enumProperty WRITE setEnumProperty)
+
+public:
+ MyUnregisteredEnumTypeObject() : QObject(), m_ev(FirstValue) {}
+ ~MyUnregisteredEnumTypeObject() {}
+
+ enum MyEnum {
+ FirstValue = 1,
+ SecondValue = 2
+ };
+
+ MyEnum enumProperty() const { return m_ev; }
+ void setEnumProperty(MyEnum v) { m_ev = v; }
+
+private:
+ MyEnum m_ev;
+};
+
+class FallbackBindingsObject : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY (int test READ test NOTIFY testChanged)
+public:
+ FallbackBindingsObject(QObject* parent = 0)
+ : QObject(parent), m_test(100)
+ {
+ }
+
+ int test() const { return m_test; }
+
+Q_SIGNALS:
+ void testChanged();
+
+private:
+ int m_test;
+};
+
+class FallbackBindingsDerived : public FallbackBindingsObject
+{
+ Q_OBJECT
+ Q_PROPERTY (QString test READ test NOTIFY testChanged)
+public:
+ FallbackBindingsDerived(QObject* parent = 0)
+ : FallbackBindingsObject(parent), m_test("hello")
+ {
+ }
+
+ QString test() const { return m_test; }
+
+Q_SIGNALS:
+ void testChanged();
+
+private:
+ QString m_test;
+};
+
+class FallbackBindingsAttachedObject : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY (int test READ test NOTIFY testChanged)
+public:
+ FallbackBindingsAttachedObject(QObject *parent) : QObject(parent), m_test(100) {}
+
+ int test() const { return m_test; }
+
+Q_SIGNALS:
+ void testChanged();
+
+private:
+ int m_test;
+};
+
+class FallbackBindingsAttachedDerived : public FallbackBindingsAttachedObject
+{
+ Q_OBJECT
+ Q_PROPERTY (QString test READ test NOTIFY testChanged)
+public:
+ FallbackBindingsAttachedDerived(QObject* parent = 0)
+ : FallbackBindingsAttachedObject(parent), m_test("hello")
+ {
+ }
+
+ QString test() const { return m_test; }
+
+Q_SIGNALS:
+ void testChanged();
+
+private:
+ QString m_test;
+};
+
+class FallbackBindingsTypeObject : public QObject
+{
+ Q_OBJECT
+public:
+ FallbackBindingsTypeObject() : QObject() {}
+
+ static FallbackBindingsAttachedObject *qmlAttachedProperties(QObject *o) {
+ return new FallbackBindingsAttachedObject(o);
+ }
+};
+
+class FallbackBindingsTypeDerived : public QObject
+{
+ Q_OBJECT
+public:
+ FallbackBindingsTypeDerived() : QObject() {}
+
+ static FallbackBindingsAttachedObject *qmlAttachedProperties(QObject *o) {
+ return new FallbackBindingsAttachedDerived(o);
+ }
+};
+
+QML_DECLARE_TYPEINFO(FallbackBindingsTypeObject, QML_HAS_ATTACHED_PROPERTIES)
+QML_DECLARE_TYPEINFO(FallbackBindingsTypeDerived, QML_HAS_ATTACHED_PROPERTIES)
+