mirror of
				https://github.com/subsurface/subsurface.git
				synced 2025-02-19 22:16:15 +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
 | 
					// SPDX-License-Identifier: GPL-2.0
 | 
				
			||||||
#include <QQmlEngine>
 | 
					#include <QQmlEngine>
 | 
				
			||||||
#include <QDebug>
 | 
					 | 
				
			||||||
#include <QQuickItem>
 | 
					#include <QQuickItem>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "map-widget/qmlmapwidgethelper.h"
 | 
					#include "map-widget/qmlmapwidgethelper.h"
 | 
				
			||||||
| 
						 | 
					@ -184,27 +183,28 @@ static void register_meta_types()
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
#endif // not SUBSURFACE_TEST_DATA
 | 
					#endif // not SUBSURFACE_TEST_DATA
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define REGISTER_TYPE(useClass, useQML) \
 | 
					template <typename T>
 | 
				
			||||||
	rc = qmlRegisterType<useClass>("org.subsurfacedivelog.mobile", 1, 0, useQML); \
 | 
					static void register_qml_type(const char *name)
 | 
				
			||||||
	if (rc < 0) \
 | 
					{
 | 
				
			||||||
		qWarning() << "ERROR: Cannot register " << useQML << ", QML will not work!!";
 | 
						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*
 | 
						// register qPref*
 | 
				
			||||||
	qPref::registerQML(engine);
 | 
						qPref::registerQML(engine);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifndef SUBSURFACE_TEST_DATA
 | 
					#ifndef SUBSURFACE_TEST_DATA
 | 
				
			||||||
	int rc;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifdef SUBSURFACE_MOBILE
 | 
					#ifdef SUBSURFACE_MOBILE
 | 
				
			||||||
	REGISTER_TYPE(QMLManager, "QMLManager");
 | 
						register_qml_type<QMLManager>("QMLManager");
 | 
				
			||||||
	REGISTER_TYPE(QMLProfile, "QMLProfile");
 | 
						register_qml_type<QMLProfile>("QMLProfile");
 | 
				
			||||||
	REGISTER_TYPE(DiveImportedModel, "DCImportModel");
 | 
						register_qml_type<DiveImportedModel>("DCImportModel");
 | 
				
			||||||
	REGISTER_TYPE(DiveSummaryModel, "DiveSummaryModel");
 | 
						register_qml_type<DiveSummaryModel>("DiveSummaryModel");
 | 
				
			||||||
#endif // not SUBSURFACE_MOBILE
 | 
					#endif // not SUBSURFACE_MOBILE
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	REGISTER_TYPE(MapWidgetHelper, "MapWidgetHelper");
 | 
						register_qml_type<MapWidgetHelper>("MapWidgetHelper");
 | 
				
			||||||
	REGISTER_TYPE(MapLocationModel, "MapLocationModel");
 | 
						register_qml_type<MapLocationModel>("MapLocationModel");
 | 
				
			||||||
#endif // not SUBSURFACE_TEST_DATA
 | 
					#endif // not SUBSURFACE_TEST_DATA
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue