summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2020-03-30 22:12:54 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2020-03-30 13:54:12 -0700
commitd2f828fbf3955f8072b8d2d02a73ccad4c1b9a67 (patch)
treee88c82ea77fd241df3eedc37443faf2aa7ce9118
parent53b216b228165db4a31d122f09e4d481d8ef321b (diff)
downloadsubsurface-d2f828fbf3955f8072b8d2d02a73ccad4c1b9a67.tar.gz
cleanup: replace REGISTER_TYPE macro by template
Arguably easier to read. By using the qWarning("...") instead of the qWarning() << "..." version, we can remove the <QDebug> include. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
-rw-r--r--subsurface-helper.cpp26
1 files changed, 13 insertions, 13 deletions
diff --git a/subsurface-helper.cpp b/subsurface-helper.cpp
index e87b30574..a23e63d6e 100644
--- a/subsurface-helper.cpp
+++ b/subsurface-helper.cpp
@@ -1,6 +1,5 @@
// SPDX-License-Identifier: GPL-2.0
#include <QQmlEngine>
-#include <QDebug>
#include <QQuickItem>
#include "map-widget/qmlmapwidgethelper.h"
@@ -184,27 +183,28 @@ static void register_meta_types()
}
#endif // not SUBSURFACE_TEST_DATA
-#define REGISTER_TYPE(useClass, useQML) \
- rc = qmlRegisterType<useClass>("org.subsurfacedivelog.mobile", 1, 0, useQML); \
- if (rc < 0) \
- qWarning() << "ERROR: Cannot register " << useQML << ", QML will not work!!";
+template <typename T>
+static void register_qml_type(const char *name)
+{
+ if(qmlRegisterType<T>("org.subsurfacedivelog.mobile", 1, 0, name) < 0)
+ qWarning("ERROR: Cannot register %s, QML will not work!!", name);
+}
-void register_qml_types(QQmlEngine *engine)
+static void register_qml_types(QQmlEngine *engine)
{
// register qPref*
qPref::registerQML(engine);
#ifndef SUBSURFACE_TEST_DATA
- int rc;
#ifdef SUBSURFACE_MOBILE
- REGISTER_TYPE(QMLManager, "QMLManager");
- REGISTER_TYPE(QMLProfile, "QMLProfile");
- REGISTER_TYPE(DiveImportedModel, "DCImportModel");
- REGISTER_TYPE(DiveSummaryModel, "DiveSummaryModel");
+ register_qml_type<QMLManager>("QMLManager");
+ register_qml_type<QMLProfile>("QMLProfile");
+ register_qml_type<DiveImportedModel>("DCImportModel");
+ register_qml_type<DiveSummaryModel>("DiveSummaryModel");
#endif // not SUBSURFACE_MOBILE
- REGISTER_TYPE(MapWidgetHelper, "MapWidgetHelper");
- REGISTER_TYPE(MapLocationModel, "MapLocationModel");
+ register_qml_type<MapWidgetHelper>("MapWidgetHelper");
+ register_qml_type<MapLocationModel>("MapLocationModel");
#endif // not SUBSURFACE_TEST_DATA
}