Skip to content

Commit

Permalink
Add qsyncableqmltypes.cpp for qml type registration
Browse files Browse the repository at this point in the history
  • Loading branch information
benlau committed Jul 10, 2016
1 parent e339d12 commit 5bf3d97
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 33 deletions.
10 changes: 0 additions & 10 deletions qsjsonlistmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,13 +190,3 @@ void QSJsonListModel::sync()
runner.patch(this, patches);
}
}

class QSJsonModelRegistionHelper {

public:
QSJsonModelRegistionHelper() {
qmlRegisterType<QSJsonListModel>("QSyncable", 1, 0, "JsonListModel");
}
};

static QSJsonModelRegistionHelper registerHelper;
22 changes: 0 additions & 22 deletions qsuuid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,25 +23,3 @@ QString QSUuid::create() const
{
return QUuid::createUuid().toString().replace(QRegExp("[{}]"), "");
}


static QObject *provider(QQmlEngine *engine, QJSEngine *scriptEngine) {
Q_UNUSED(engine);
Q_UNUSED(scriptEngine);

QSUuid* object = new QSUuid();

return object;
}


class QSUuidRegistionHelper {

public:
QSUuidRegistionHelper() {
qmlRegisterSingletonType<QSUuid>("QSyncable", 1, 0, "Uuid", provider);
}
};

static QSUuidRegistionHelper registerHelper;

3 changes: 2 additions & 1 deletion qsyncable.pri
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,5 @@ SOURCES += \
$$PWD/qsdiffrunneralgo.cpp \
$$PWD/qstree.cpp \
$$PWD/qstreenode.cpp \
$$PWD/qsjsonlistmodel.cpp
$$PWD/qsjsonlistmodel.cpp \
$$PWD/qsyncableqmltypes.cpp
19 changes: 19 additions & 0 deletions qsyncableqmltypes.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#include <QtQml>
#include "qsjsonlistmodel.h"
#include "qsuuid.h"

static QObject *provider(QQmlEngine *engine, QJSEngine *scriptEngine) {
Q_UNUSED(engine);
Q_UNUSED(scriptEngine);

QSUuid* object = new QSUuid();

return object;
}

static void registerTypes() {
qmlRegisterType<QSJsonListModel>("QSyncable", 1, 0, "JsonListModel");
qmlRegisterSingletonType<QSUuid>("QSyncable", 1, 0, "Uuid", provider);
}

Q_COREAPP_STARTUP_FUNCTION(registerTypes)

0 comments on commit 5bf3d97

Please sign in to comment.