Commit 3336c395 authored by Thomas BOUTROUE's avatar Thomas BOUTROUE

Use new QML_SINGLETON_IMPL helper in Help class

parent 6e009c70
#include "Grapher.h"
#include <QtMath>
#include <QtGlobal>
Grapher::Grapher (QQuickItem * parent)
: QQuickItem (parent)
, m_samplingInterval (20)
......
......@@ -2784,19 +2784,6 @@ static ObjectHelp canOpenNmtState {
"This enum contains the CANopen NMT state values for local node."
};
Help & Help::instance (void) {
static Help ret;
return ret;
}
QObject * Help::qmlSingletonProvider (QQmlEngine * qmlEngine, QJSEngine * jsEngine) {
Q_UNUSED (jsEngine)
Q_UNUSED (qmlEngine)
QObject * ret = &Help::instance ();
QQmlEngine::setObjectOwnership (ret, QQmlEngine::CppOwnership);
return ret;
}
ObjectHelp * Help::getHelpForTypeByName (const QString & name) {
ObjectHelp * ret = m_objectsByName.value (name, Q_NULLPTR);
QQmlEngine::setObjectOwnership (ret, QQmlEngine::CppOwnership);
......
......@@ -10,6 +10,7 @@
#include "QQmlVarPropertyHelpers.h"
#include "QQmlPtrPropertyHelpers.h"
#include "QQmlConstRefPropertyHelpers.h"
#include "QQmlSingletonHelper.h"
#include "QQmlObjectListModel.h"
class EnumKeyHelp : public QObject {
......@@ -188,13 +189,10 @@ public:
class Help : public QObject {
Q_OBJECT
QML_SINGLETON_IMPL (Help)
QML_OBJMODEL_PROPERTY (HelpSection, sectionsList)
public:
static Help & instance (void);
static QObject * qmlSingletonProvider (QQmlEngine * qmlEngine, QJSEngine * jsEngine);
Q_INVOKABLE ObjectHelp * getHelpForTypeByName (const QString & name);
protected:
......
......@@ -73,8 +73,8 @@ void SharedObject::registerQmlTypes (QQmlEngine * qmlEngine) {
static const QString msg = "!!!";
qmlEngine->addImportPath (":/import");
// singletons
Help::registerQmlModule (uri, maj, min, "Help");
qmlRegisterSingletonType<SharedObject> (uri, maj, min, "Shared", &SharedObject::qmlSingletonProvider);
qmlRegisterSingletonType<Help> (uri, maj, min, "Help", &Help::qmlSingletonProvider);
// must not be instanciated in QML enum
qmlRegisterUncreatableType<Tabs> (uri, maj, min, "Tabs", msg);
qmlRegisterUncreatableType<Modes> (uri, maj, min, "Modes", msg);
......
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