From d2f828fbf3955f8072b8d2d02a73ccad4c1b9a67 Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Mon, 30 Mar 2020 22:12:54 +0200 Subject: cleanup: replace REGISTER_TYPE macro by template Arguably easier to read. By using the qWarning("...") instead of the qWarning() << "..." version, we can remove the include. Signed-off-by: Berthold Stoeger --- subsurface-helper.cpp | 26 +++++++++++++------------- 1 file 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 -#include #include #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("org.subsurfacedivelog.mobile", 1, 0, useQML); \ - if (rc < 0) \ - qWarning() << "ERROR: Cannot register " << useQML << ", QML will not work!!"; +template +static void register_qml_type(const char *name) +{ + if(qmlRegisterType("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"); + register_qml_type("QMLProfile"); + register_qml_type("DCImportModel"); + register_qml_type("DiveSummaryModel"); #endif // not SUBSURFACE_MOBILE - REGISTER_TYPE(MapWidgetHelper, "MapWidgetHelper"); - REGISTER_TYPE(MapLocationModel, "MapLocationModel"); + register_qml_type("MapWidgetHelper"); + register_qml_type("MapLocationModel"); #endif // not SUBSURFACE_TEST_DATA } -- cgit v1.2.3-70-g09d2