mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-28 05:00:20 +00:00
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>
This commit is contained in:
parent
53b216b228
commit
d2f828fbf3
1 changed files with 13 additions and 13 deletions
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue