qml 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +46 -0
- data/.rspec +2 -0
- data/.travis.yml +15 -0
- data/.yardopts +4 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +351 -0
- data/Rakefile +6 -0
- data/examples/assets/fonts/fontawesome-webfont.ttf +0 -0
- data/examples/fizzbuzz/fizzbuzz.rb +43 -0
- data/examples/fizzbuzz/main.qml +38 -0
- data/examples/imageprovider/imageprovider.rb +57 -0
- data/examples/imageprovider/main.qml +51 -0
- data/examples/todo/main.qml +70 -0
- data/examples/todo/todo.rb +36 -0
- data/examples/twitter/main.qml +36 -0
- data/examples/twitter/twitter.rb +55 -0
- data/ext/qml/accessclass.cpp +71 -0
- data/ext/qml/accessclass.h +19 -0
- data/ext/qml/accessobject.cpp +30 -0
- data/ext/qml/accessobject.h +22 -0
- data/ext/qml/application.cpp +54 -0
- data/ext/qml/application.h +17 -0
- data/ext/qml/common.h +18 -0
- data/ext/qml/ext_accesssupport.cpp +77 -0
- data/ext/qml/ext_accesssupport.h +42 -0
- data/ext/qml/ext_gcmarker.cpp +39 -0
- data/ext/qml/ext_gcmarker.h +27 -0
- data/ext/qml/ext_kernel.cpp +62 -0
- data/ext/qml/ext_kernel.h +11 -0
- data/ext/qml/ext_metaobject.cpp +410 -0
- data/ext/qml/ext_metaobject.h +62 -0
- data/ext/qml/ext_pluginloader.cpp +55 -0
- data/ext/qml/ext_pluginloader.h +32 -0
- data/ext/qml/ext_pointer.cpp +134 -0
- data/ext/qml/ext_pointer.h +43 -0
- data/ext/qml/ext_testutil.cpp +42 -0
- data/ext/qml/ext_testutil.h +11 -0
- data/ext/qml/extconf.rb +84 -0
- data/ext/qml/foreignclass.cpp +72 -0
- data/ext/qml/foreignclass.h +88 -0
- data/ext/qml/foreignmetaobject.cpp +345 -0
- data/ext/qml/foreignmetaobject.h +46 -0
- data/ext/qml/foreignobject.cpp +22 -0
- data/ext/qml/foreignobject.h +21 -0
- data/ext/qml/functioninfo.h +16 -0
- data/ext/qml/init.cpp +69 -0
- data/ext/qml/listmodel.cpp +112 -0
- data/ext/qml/listmodel.h +43 -0
- data/ext/qml/markable.h +12 -0
- data/ext/qml/objectdata.cpp +26 -0
- data/ext/qml/objectdata.h +20 -0
- data/ext/qml/objectgc.cpp +69 -0
- data/ext/qml/objectgc.h +28 -0
- data/ext/qml/plugins/core/applicationextension.cpp +34 -0
- data/ext/qml/plugins/core/applicationextension.h +28 -0
- data/ext/qml/plugins/core/componentextension.cpp +41 -0
- data/ext/qml/plugins/core/componentextension.h +28 -0
- data/ext/qml/plugins/core/contextextension.cpp +39 -0
- data/ext/qml/plugins/core/contextextension.h +29 -0
- data/ext/qml/plugins/core/core.pro +29 -0
- data/ext/qml/plugins/core/coreplugin.cpp +87 -0
- data/ext/qml/plugins/core/coreplugin.h +49 -0
- data/ext/qml/plugins/core/engineextension.cpp +27 -0
- data/ext/qml/plugins/core/engineextension.h +28 -0
- data/ext/qml/plugins/core/imageprovider.cpp +38 -0
- data/ext/qml/plugins/core/imageprovider.h +18 -0
- data/ext/qml/plugins/core/imagerequestpromise.cpp +19 -0
- data/ext/qml/plugins/core/imagerequestpromise.h +21 -0
- data/ext/qml/plugins/core/qmlexception.cpp +11 -0
- data/ext/qml/plugins/core/qmlexception.h +17 -0
- data/ext/qml/plugins/testutil/objectlifechecker.cpp +17 -0
- data/ext/qml/plugins/testutil/objectlifechecker.h +24 -0
- data/ext/qml/plugins/testutil/ownershiptest.cpp +26 -0
- data/ext/qml/plugins/testutil/ownershiptest.h +30 -0
- data/ext/qml/plugins/testutil/testobject.cpp +6 -0
- data/ext/qml/plugins/testutil/testobject.h +108 -0
- data/ext/qml/plugins/testutil/testobjectsubclass.cpp +10 -0
- data/ext/qml/plugins/testutil/testobjectsubclass.h +19 -0
- data/ext/qml/plugins/testutil/testutil.pro +20 -0
- data/ext/qml/plugins/testutil/testutilplugin.cpp +47 -0
- data/ext/qml/plugins/testutil/testutilplugin.h +32 -0
- data/ext/qml/qmltyperegisterer.cpp +74 -0
- data/ext/qml/qmltyperegisterer.h +30 -0
- data/ext/qml/rubyclass.cpp +94 -0
- data/ext/qml/rubyclass.h +234 -0
- data/ext/qml/rubyvalue.cpp +690 -0
- data/ext/qml/rubyvalue.h +256 -0
- data/ext/qml/signalforwarder.cpp +66 -0
- data/ext/qml/signalforwarder.h +29 -0
- data/ext/qml/util.cpp +120 -0
- data/ext/qml/util.h +101 -0
- data/ext/qml/valuereference.cpp +50 -0
- data/ext/qml/valuereference.h +22 -0
- data/ext/qml/weakvaluereference.cpp +27 -0
- data/ext/qml/weakvaluereference.h +19 -0
- data/lib/qml.rb +41 -0
- data/lib/qml/access.rb +137 -0
- data/lib/qml/application.rb +139 -0
- data/lib/qml/class_builder.rb +126 -0
- data/lib/qml/component.rb +53 -0
- data/lib/qml/context.rb +71 -0
- data/lib/qml/data.rb +2 -0
- data/lib/qml/data/array_model.rb +103 -0
- data/lib/qml/data/error.rb +5 -0
- data/lib/qml/data/list_model.rb +146 -0
- data/lib/qml/dispatchable.rb +34 -0
- data/lib/qml/dispatcher.rb +61 -0
- data/lib/qml/engine.rb +54 -0
- data/lib/qml/error_converter.rb +15 -0
- data/lib/qml/errors.rb +26 -0
- data/lib/qml/geometry.rb +3 -0
- data/lib/qml/geometry/point.rb +5 -0
- data/lib/qml/geometry/rectangle.rb +5 -0
- data/lib/qml/geometry/size.rb +5 -0
- data/lib/qml/image_provider.rb +87 -0
- data/lib/qml/meta_object.rb +20 -0
- data/lib/qml/models.rb +1 -0
- data/lib/qml/name_helper.rb +12 -0
- data/lib/qml/platform.rb +15 -0
- data/lib/qml/plugin_loader.rb +46 -0
- data/lib/qml/plugins.rb +26 -0
- data/lib/qml/qml.rb +1 -0
- data/lib/qml/qt.rb +6 -0
- data/lib/qml/qt_classes.rb +9 -0
- data/lib/qml/qt_object_base.rb +108 -0
- data/lib/qml/reactive.rb +8 -0
- data/lib/qml/reactive/bindable.rb +79 -0
- data/lib/qml/reactive/chained_signal.rb +25 -0
- data/lib/qml/reactive/error.rb +5 -0
- data/lib/qml/reactive/object.rb +278 -0
- data/lib/qml/reactive/property.rb +19 -0
- data/lib/qml/reactive/signal.rb +116 -0
- data/lib/qml/reactive/signal_spy.rb +27 -0
- data/lib/qml/reactive/signals/map_signal.rb +21 -0
- data/lib/qml/reactive/signals/merge_signal.rb +21 -0
- data/lib/qml/reactive/signals/select_signal.rb +21 -0
- data/lib/qml/reactive/simple_property.rb +17 -0
- data/lib/qml/reactive/unbound_property.rb +42 -0
- data/lib/qml/reactive/unbound_signal.rb +51 -0
- data/lib/qml/root_path.rb +3 -0
- data/lib/qml/test_util.rb +1 -0
- data/lib/qml/test_util/object_life_checker.rb +17 -0
- data/lib/qml/version.rb +3 -0
- data/lib/qml/wrappable.rb +9 -0
- data/qml.gemspec +28 -0
- data/spec/assets/testobj.qml +5 -0
- data/spec/qml/.access_spec.rb.swp +0 -0
- data/spec/qml/access_spec.rb +162 -0
- data/spec/qml/application_spec.rb +43 -0
- data/spec/qml/component_spec.rb +44 -0
- data/spec/qml/context_spec.rb +43 -0
- data/spec/qml/conversion_spec.rb +59 -0
- data/spec/qml/data/array_model_spec.rb +215 -0
- data/spec/qml/dispatchable_spec.rb +26 -0
- data/spec/qml/dispatcher_spec.rb +48 -0
- data/spec/qml/geometry/point_spec.rb +4 -0
- data/spec/qml/geometry/rectangle_spec.rb +4 -0
- data/spec/qml/geometry/size_spec.rb +4 -0
- data/spec/qml/plugin_loader_spec.rb +33 -0
- data/spec/qml/qt_object_base_spec.rb +119 -0
- data/spec/qml/reactive/object_spec.rb +273 -0
- data/spec/qml/reactive/property_spec.rb +70 -0
- data/spec/qml/reactive/signal_spec.rb +191 -0
- data/spec/qml/reactive/signal_spy_spec.rb +26 -0
- data/spec/qml/test_object_spec.rb +186 -0
- data/spec/qml_spec.rb +7 -0
- data/spec/spec_helper.rb +5 -0
- metadata +321 -0
@@ -0,0 +1,38 @@
|
|
1
|
+
#include "imageprovider.h"
|
2
|
+
#include "imagerequestpromise.h"
|
3
|
+
#include <QDebug>
|
4
|
+
#include <QApplication>
|
5
|
+
|
6
|
+
namespace RubyQml {
|
7
|
+
|
8
|
+
ImageProvider::ImageProvider(QObject *rubyCallback) :
|
9
|
+
QQuickImageProvider(QQuickImageProvider::Image, QQuickImageProvider::ForceAsynchronousImageLoading),
|
10
|
+
mRubyCallback(rubyCallback)
|
11
|
+
{
|
12
|
+
rubyCallback->setParent(this);
|
13
|
+
}
|
14
|
+
|
15
|
+
QImage ImageProvider::requestImage(const QString &id, QSize *size, const QSize &requestedSize)
|
16
|
+
{
|
17
|
+
std::promise<QImage> promise;
|
18
|
+
auto future = promise.get_future();
|
19
|
+
auto promiseObj = new ImageRequestPromise(std::move(promise));
|
20
|
+
promiseObj->moveToThread(qApp->thread());
|
21
|
+
|
22
|
+
mRubyCallback->metaObject()->invokeMethod(
|
23
|
+
mRubyCallback,
|
24
|
+
"request",
|
25
|
+
Qt::QueuedConnection,
|
26
|
+
Q_ARG(QVariant, id),
|
27
|
+
Q_ARG(QVariant, QVariant::fromValue(promiseObj)));
|
28
|
+
|
29
|
+
auto image = future.get();
|
30
|
+
if (requestedSize.isValid() && image.size() != requestedSize) {
|
31
|
+
image = image.scaled(requestedSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
|
32
|
+
}
|
33
|
+
|
34
|
+
*size = image.size();
|
35
|
+
return image;
|
36
|
+
}
|
37
|
+
|
38
|
+
} // namespace RubyQml
|
@@ -0,0 +1,18 @@
|
|
1
|
+
#pragma once
|
2
|
+
#include <QObject>
|
3
|
+
#include <QQuickImageProvider>
|
4
|
+
|
5
|
+
namespace RubyQml {
|
6
|
+
|
7
|
+
class ImageProvider : public QObject, public QQuickImageProvider
|
8
|
+
{
|
9
|
+
Q_OBJECT
|
10
|
+
public:
|
11
|
+
explicit ImageProvider(QObject *rubyImageProvider);
|
12
|
+
QImage requestImage(const QString &id, QSize *size, const QSize &requestedSize) override;
|
13
|
+
|
14
|
+
private:
|
15
|
+
QObject *mRubyCallback = nullptr;
|
16
|
+
};
|
17
|
+
|
18
|
+
} // namespace RubyQml
|
@@ -0,0 +1,19 @@
|
|
1
|
+
#include "imagerequestpromise.h"
|
2
|
+
#include <QImage>
|
3
|
+
#include <QDebug>
|
4
|
+
|
5
|
+
namespace RubyQml {
|
6
|
+
|
7
|
+
ImageRequestPromise::ImageRequestPromise(std::promise<QImage> &&promise, QObject *parent) :
|
8
|
+
QObject(parent),
|
9
|
+
mPromise(std::move(promise))
|
10
|
+
{
|
11
|
+
}
|
12
|
+
|
13
|
+
void ImageRequestPromise::setData(const QByteArray &data)
|
14
|
+
{
|
15
|
+
auto image = QImage::fromData(data);
|
16
|
+
mPromise.set_value(image);
|
17
|
+
}
|
18
|
+
|
19
|
+
} // namespace RubyQml
|
@@ -0,0 +1,21 @@
|
|
1
|
+
#pragma once
|
2
|
+
#include <QObject>
|
3
|
+
#include <QImage>
|
4
|
+
#include <future>
|
5
|
+
|
6
|
+
namespace RubyQml {
|
7
|
+
|
8
|
+
class ImageRequestPromise : public QObject
|
9
|
+
{
|
10
|
+
Q_OBJECT
|
11
|
+
public:
|
12
|
+
explicit ImageRequestPromise(std::promise<QImage> &&promise, QObject *parent = 0);
|
13
|
+
|
14
|
+
public slots:
|
15
|
+
void setData(const QByteArray &data);
|
16
|
+
|
17
|
+
private:
|
18
|
+
std::promise<QImage> mPromise;
|
19
|
+
};
|
20
|
+
|
21
|
+
} // namespace RubyQml
|
@@ -0,0 +1,17 @@
|
|
1
|
+
#ifndef RUBYQML_QMLERROR_H
|
2
|
+
#define RUBYQML_QMLERROR_H
|
3
|
+
|
4
|
+
#include <stdexcept>
|
5
|
+
class QString;
|
6
|
+
|
7
|
+
namespace RubyQml {
|
8
|
+
|
9
|
+
class QmlException : public std::runtime_error
|
10
|
+
{
|
11
|
+
public:
|
12
|
+
QmlException(const QString &error);
|
13
|
+
};
|
14
|
+
|
15
|
+
} // namespace RubyQml
|
16
|
+
|
17
|
+
#endif // RUBYQML_QMLERROR_H
|
@@ -0,0 +1,17 @@
|
|
1
|
+
#include "objectlifechecker.h"
|
2
|
+
#include <QQmlEngine>
|
3
|
+
|
4
|
+
namespace RubyQml {
|
5
|
+
|
6
|
+
ObjectLifeChecker::ObjectLifeChecker(QObject *target) :
|
7
|
+
mTarget(target)
|
8
|
+
{
|
9
|
+
}
|
10
|
+
|
11
|
+
bool ObjectLifeChecker::isOwnedByQml() const
|
12
|
+
{
|
13
|
+
if (!mTarget) return false;
|
14
|
+
return QQmlEngine::objectOwnership(mTarget) == QQmlEngine::JavaScriptOwnership;
|
15
|
+
}
|
16
|
+
|
17
|
+
} // namespace RubyQml
|
@@ -0,0 +1,24 @@
|
|
1
|
+
#pragma once
|
2
|
+
#include <QObject>
|
3
|
+
#include <QPointer>
|
4
|
+
|
5
|
+
namespace RubyQml {
|
6
|
+
|
7
|
+
class ObjectLifeChecker : public QObject
|
8
|
+
{
|
9
|
+
Q_OBJECT
|
10
|
+
Q_PROPERTY(QObject* target READ target)
|
11
|
+
public:
|
12
|
+
explicit ObjectLifeChecker(QObject *target);
|
13
|
+
QObject *target() { return mTarget; }
|
14
|
+
signals:
|
15
|
+
|
16
|
+
public slots:
|
17
|
+
bool isAlive() const { return mTarget; }
|
18
|
+
bool isOwnedByQml() const;
|
19
|
+
|
20
|
+
private:
|
21
|
+
QPointer<QObject> mTarget;
|
22
|
+
};
|
23
|
+
|
24
|
+
} // namespace RubyQml
|
@@ -0,0 +1,26 @@
|
|
1
|
+
#include "ownershiptest.h"
|
2
|
+
|
3
|
+
namespace RubyQml {
|
4
|
+
|
5
|
+
OwnershipTest::OwnershipTest(QObject *parent) :
|
6
|
+
QObject(parent)
|
7
|
+
{
|
8
|
+
mSubObject = new QObject(this);
|
9
|
+
connect(mSubObject, &QObject::destroyed, this, &OwnershipTest::subObjectDeleted);
|
10
|
+
mPropertyObject = new QObject();
|
11
|
+
connect(mPropertyObject, &QObject::destroyed, this, &OwnershipTest::subObjectDeleted);
|
12
|
+
}
|
13
|
+
|
14
|
+
OwnershipTest::~OwnershipTest()
|
15
|
+
{
|
16
|
+
delete mPropertyObject;
|
17
|
+
}
|
18
|
+
|
19
|
+
QObject *OwnershipTest::createObject()
|
20
|
+
{
|
21
|
+
auto obj = new QObject();
|
22
|
+
connect(obj, &QObject::destroyed, this, &OwnershipTest::createdObjectDeleted);
|
23
|
+
return obj;
|
24
|
+
}
|
25
|
+
|
26
|
+
} // namespace RubyQml
|
@@ -0,0 +1,30 @@
|
|
1
|
+
#pragma once
|
2
|
+
#include <QObject>
|
3
|
+
|
4
|
+
namespace RubyQml {
|
5
|
+
|
6
|
+
class OwnershipTest : public QObject
|
7
|
+
{
|
8
|
+
Q_OBJECT
|
9
|
+
Q_PROPERTY(QObject* propertyObject READ propertyObject)
|
10
|
+
public:
|
11
|
+
explicit OwnershipTest(QObject *parent = 0);
|
12
|
+
~OwnershipTest();
|
13
|
+
|
14
|
+
QObject *propertyObject() { return mPropertyObject; }
|
15
|
+
|
16
|
+
signals:
|
17
|
+
void subObjectDeleted();
|
18
|
+
void propertyObjectDeleted();
|
19
|
+
void createdObjectDeleted();
|
20
|
+
|
21
|
+
public slots:
|
22
|
+
QObject *subObject() { return mSubObject; }
|
23
|
+
QObject *createObject();
|
24
|
+
|
25
|
+
private:
|
26
|
+
QObject *mSubObject;
|
27
|
+
QObject *mPropertyObject;
|
28
|
+
};
|
29
|
+
|
30
|
+
} // namespace RubyQml
|
@@ -0,0 +1,108 @@
|
|
1
|
+
#pragma once
|
2
|
+
|
3
|
+
#include <QObject>
|
4
|
+
#include <QVariant>
|
5
|
+
#include <QDebug>
|
6
|
+
#include <QtPlugin>
|
7
|
+
#include <stdexcept>
|
8
|
+
|
9
|
+
namespace RubyQml {
|
10
|
+
|
11
|
+
class TestObject : public QObject
|
12
|
+
{
|
13
|
+
Q_OBJECT
|
14
|
+
Q_PROPERTY(QString name MEMBER mName NOTIFY nameChanged)
|
15
|
+
Q_PROPERTY(double someValue MEMBER mSomeValue NOTIFY someValueChanged)
|
16
|
+
Q_PROPERTY(RubyQml::TestObject::Enums enumValue MEMBER mEnumValue NOTIFY enumValueChanged)
|
17
|
+
|
18
|
+
public:
|
19
|
+
explicit TestObject(QObject *parent = 0) : QObject(parent)
|
20
|
+
{
|
21
|
+
}
|
22
|
+
|
23
|
+
enum Enums
|
24
|
+
{
|
25
|
+
Foo = 0,
|
26
|
+
Bar = 1,
|
27
|
+
FooBar = 2,
|
28
|
+
};
|
29
|
+
|
30
|
+
public slots:
|
31
|
+
|
32
|
+
int normalMethod(int x, const QString &y)
|
33
|
+
{
|
34
|
+
return x + y.toInt();
|
35
|
+
}
|
36
|
+
|
37
|
+
QVariant variantMethod(const QVariant &x, const QVariant &y)
|
38
|
+
{
|
39
|
+
int sum = x.toInt();
|
40
|
+
auto list = y.toList();
|
41
|
+
for (const auto &variant : list) {
|
42
|
+
sum += variant.toInt();
|
43
|
+
}
|
44
|
+
return sum;
|
45
|
+
}
|
46
|
+
|
47
|
+
QString overloadedMethod(int x)
|
48
|
+
{
|
49
|
+
Q_UNUSED(x);
|
50
|
+
return "first";
|
51
|
+
}
|
52
|
+
|
53
|
+
QString overloadedMethod(const QString &x)
|
54
|
+
{
|
55
|
+
Q_UNUSED(x);
|
56
|
+
return "last";
|
57
|
+
}
|
58
|
+
|
59
|
+
QString overloadedMethod(const QString &x, int y)
|
60
|
+
{
|
61
|
+
Q_UNUSED(x)
|
62
|
+
Q_UNUSED(y)
|
63
|
+
return "2 params";
|
64
|
+
}
|
65
|
+
|
66
|
+
void emitSomeSignal(const QString &arg)
|
67
|
+
{
|
68
|
+
emit someSignal(arg);
|
69
|
+
}
|
70
|
+
|
71
|
+
QString getName() const
|
72
|
+
{
|
73
|
+
return mName;
|
74
|
+
}
|
75
|
+
|
76
|
+
void throwingMethod() const
|
77
|
+
{
|
78
|
+
throw std::runtime_error("test error");
|
79
|
+
}
|
80
|
+
|
81
|
+
const QMetaObject *metaObjectMethod() const
|
82
|
+
{
|
83
|
+
return &TestObject::staticMetaObject;
|
84
|
+
}
|
85
|
+
|
86
|
+
QObject *selfReturningMethod()
|
87
|
+
{
|
88
|
+
return this;
|
89
|
+
}
|
90
|
+
|
91
|
+
signals:
|
92
|
+
|
93
|
+
void someSignal(const QString &arg);
|
94
|
+
void nameChanged(const QString &name);
|
95
|
+
void someValueChanged(double value);
|
96
|
+
void enumValueChanged(RubyQml::TestObject::Enums value);
|
97
|
+
|
98
|
+
private:
|
99
|
+
|
100
|
+
Q_ENUMS(Enums)
|
101
|
+
QString mName;
|
102
|
+
double mSomeValue = 0;
|
103
|
+
Enums mEnumValue = Foo;
|
104
|
+
};
|
105
|
+
|
106
|
+
} // RubyQml
|
107
|
+
|
108
|
+
Q_DECLARE_METATYPE(RubyQml::TestObject::Enums)
|
@@ -0,0 +1,19 @@
|
|
1
|
+
#pragma once
|
2
|
+
|
3
|
+
#include "testobject.h"
|
4
|
+
|
5
|
+
namespace RubyQml {
|
6
|
+
|
7
|
+
class TestObjectSubclass : public TestObject
|
8
|
+
{
|
9
|
+
Q_OBJECT
|
10
|
+
public:
|
11
|
+
explicit TestObjectSubclass(QObject *parent = 0);
|
12
|
+
|
13
|
+
signals:
|
14
|
+
|
15
|
+
public slots:
|
16
|
+
|
17
|
+
};
|
18
|
+
|
19
|
+
} // namespace RubyQml
|
@@ -0,0 +1,20 @@
|
|
1
|
+
TEMPLATE = lib
|
2
|
+
CONFIG += plugin c++11
|
3
|
+
QT += qml
|
4
|
+
|
5
|
+
TARGET = rubyqml-testutil
|
6
|
+
INCLUDEPATH += .
|
7
|
+
|
8
|
+
# Input
|
9
|
+
SOURCES += testobject.cpp \
|
10
|
+
testobjectsubclass.cpp \
|
11
|
+
ownershiptest.cpp \
|
12
|
+
testutilplugin.cpp \
|
13
|
+
objectlifechecker.cpp
|
14
|
+
|
15
|
+
HEADERS += \
|
16
|
+
testobject.h \
|
17
|
+
testobjectsubclass.h \
|
18
|
+
ownershiptest.h \
|
19
|
+
testutilplugin.h \
|
20
|
+
objectlifechecker.h
|
@@ -0,0 +1,47 @@
|
|
1
|
+
#include "testutilplugin.h"
|
2
|
+
#include "testobject.h"
|
3
|
+
#include "testobjectsubclass.h"
|
4
|
+
#include "ownershiptest.h"
|
5
|
+
#include "objectlifechecker.h"
|
6
|
+
#include <QtQml>
|
7
|
+
|
8
|
+
Q_DECLARE_METATYPE(const QMetaObject*)
|
9
|
+
|
10
|
+
namespace RubyQml {
|
11
|
+
|
12
|
+
TestUtilPlugin::TestUtilPlugin(QObject *parent) :
|
13
|
+
QObject(parent)
|
14
|
+
{
|
15
|
+
qRegisterMetaType<TestObject *>();
|
16
|
+
qRegisterMetaType<TestObject::Enums>();
|
17
|
+
qRegisterMetaType<TestObjectSubclass *>();
|
18
|
+
qRegisterMetaType<OwnershipTest *>();
|
19
|
+
qRegisterMetaType<ObjectLifeChecker *>();
|
20
|
+
|
21
|
+
auto metaObjects = { &TestObject::staticMetaObject, &ObjectLifeChecker::staticMetaObject};
|
22
|
+
for (auto metaobj : metaObjects) {
|
23
|
+
mMetaObjects[metaobj->className()] = QVariant::fromValue(metaobj);
|
24
|
+
}
|
25
|
+
}
|
26
|
+
|
27
|
+
TestObject *TestUtilPlugin::createTestObject()
|
28
|
+
{
|
29
|
+
return new TestObject();
|
30
|
+
}
|
31
|
+
|
32
|
+
TestObjectSubclass *TestUtilPlugin::createTestObjectSubclass()
|
33
|
+
{
|
34
|
+
return new TestObjectSubclass();
|
35
|
+
}
|
36
|
+
|
37
|
+
OwnershipTest *TestUtilPlugin::createOwnershipTest()
|
38
|
+
{
|
39
|
+
return new OwnershipTest();
|
40
|
+
}
|
41
|
+
|
42
|
+
ObjectLifeChecker *TestUtilPlugin::createObjectLifeChecker(QObject *target)
|
43
|
+
{
|
44
|
+
return new ObjectLifeChecker(target);
|
45
|
+
}
|
46
|
+
|
47
|
+
} // namespace RubyQml
|