summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar jan Iversen <jani@apache.org>2018-07-12 18:22:56 +0200
committerGravatar jan Iversen <jani@apache.org>2018-07-12 18:34:49 +0200
commitf354592050948700f702516d8e3de20977b634fa (patch)
treec9e1b2ee4aaa4ffe3a487d9b3b815edf49b35f8a
parent35eecaa82af4f78337ab18a5e43cc04b8459029a (diff)
downloadsubsurface-f354592050948700f702516d8e3de20977b634fa.tar.gz
ssrf: prepare subsurface_helper.cpp to be used by testqml
add test for SUBSURFACE_TEST_DATA to exclude functions not used when testing Signed-off-by: Jan Iversen <jani@apache.org>
-rw-r--r--subsurface-helper.cpp92
1 files changed, 48 insertions, 44 deletions
diff --git a/subsurface-helper.cpp b/subsurface-helper.cpp
index b58f8b4aa..50f975611 100644
--- a/subsurface-helper.cpp
+++ b/subsurface-helper.cpp
@@ -28,6 +28,7 @@
#include "core/pluginmanager.h"
#endif
+#ifndef SUBSURFACE_TEST_DATA
QObject *qqWindowObject = NULL;
void init_ui()
@@ -38,14 +39,14 @@ void init_ui()
MainWindow *window = new MainWindow();
window->setTitle();
-#endif
+#endif // SUBSURFACE_MOBILE
}
void exit_ui()
{
#ifndef SUBSURFACE_MOBILE
delete MainWindow::instance();
-#endif
+#endif // SUBSURFACE_MOBILE
delete qApp;
free((void *)existing_filename);
}
@@ -56,45 +57,6 @@ double get_screen_dpi()
return mydesk->physicalDpiX();
}
-void register_qml_types()
-{
- int rc;
- rc = qmlRegisterType<qPref>("org.subsurfacedivelog.mobile", 1, 0, "SsrfPrefs");
- if (rc < 0)
- qDebug() << "ERROR: Cannot register Prefs (class qPref), QML will not work!!";
- rc = qmlRegisterType<qPrefDisplay>("org.subsurfacedivelog.mobile", 1, 0, "SsrfDisplayPrefs");
- if (rc < 0)
- qDebug() << "ERROR: Cannot register DisplayPrefs (class qPrefDisplay), QML will not work!!";
-
-#ifdef SUBSURFACE_MOBILE
- rc = qmlRegisterType<QMLManager>("org.subsurfacedivelog.mobile", 1, 0, "QMLManager");
- if (rc < 0)
- qDebug() << "ERROR: Cannot register QMLManager, QML will not work!!";
- rc = qmlRegisterType<QMLPrefs>("org.subsurfacedivelog.mobile", 1, 0, "QMLPrefs");
- if (rc < 0)
- qDebug() << "ERROR: Cannot register QMLPrefs, QML will not work!!";
- rc = qmlRegisterType<QMLProfile>("org.subsurfacedivelog.mobile", 1, 0, "QMLProfile");
- if (rc < 0)
- qDebug() << "ERROR: Cannot register QMLProfile, QML will not work!!";
- rc = qmlRegisterType<DownloadThread>("org.subsurfacedivelog.mobile", 1, 0, "DCDownloadThread");
- if (rc < 0)
- qDebug() << "ERROR: Cannot register DCDownloadThread, QML will not work!!";
- rc = qmlRegisterType<DiveImportedModel>("org.subsurfacedivelog.mobile", 1, 0, "DCImportModel");
- if (rc < 0)
- qDebug() << "ERROR: Cannot register DCImportModel, QML will not work!!";
-#endif
-
- rc = qmlRegisterType<MapWidgetHelper>("org.subsurfacedivelog.mobile", 1, 0, "MapWidgetHelper");
- if (rc < 0)
- qDebug() << "ERROR: Cannot register MapWidgetHelper, QML will not work!!";
- rc = qmlRegisterType<MapLocationModel>("org.subsurfacedivelog.mobile", 1, 0, "MapLocationModel");
- if (rc < 0)
- qDebug() << "ERROR: Cannot register MapLocationModel, QML will not work!!";
- rc = qmlRegisterType<MapLocation>("org.subsurfacedivelog.mobile", 1, 0, "MapLocation");
- if (rc < 0)
- qDebug() << "ERROR: Cannot register MapLocation, QML will not work!!";
-}
-
void run_ui()
{
register_qml_types();
@@ -115,7 +77,7 @@ void run_ui()
engine.addImportPath(importPath.replace("MacOS", "Frameworks"));
}
qDebug() << "QML import path" << engine.importPathList();
-#endif
+#endif // __APPLE__ not Q_OS_IOS
engine.addImportPath("qrc://imports");
DiveListModel diveListModel;
LOG_STP("run_ui diveListModel started");
@@ -167,11 +129,53 @@ void run_ui()
#if !defined(Q_OS_ANDROID) && !defined(Q_OS_IOS)
qml_window->setHeight(1200);
qml_window->setWidth(800);
-#endif
+#endif // not Q_OS_ANDROID and not Q_OS_IOS
qml_window->show();
LOG_STP("run_ui running exec");
#else
MainWindow::instance()->show();
-#endif
+#endif // SUBSURFACE_MOBILE
qApp->exec();
}
+#endif // not SUBSURFACE_TEST_DATA
+
+void register_qml_types()
+{
+ int rc;
+ rc = qmlRegisterType<qPref>("org.subsurfacedivelog.mobile", 1, 0, "SsrfPrefs");
+ if (rc < 0)
+ qDebug() << "ERROR: Cannot register Prefs (class qPref), QML will not work!!";
+ rc = qmlRegisterType<qPrefDisplay>("org.subsurfacedivelog.mobile", 1, 0, "SsrfDisplayPrefs");
+ if (rc < 0)
+ qDebug() << "ERROR: Cannot register DisplayPrefs (class qPrefDisplay), QML will not work!!";
+
+#ifndef SUBSURFACE_TEST_DATA
+#ifdef SUBSURFACE_MOBILE
+ rc = qmlRegisterType<QMLManager>("org.subsurfacedivelog.mobile", 1, 0, "QMLManager");
+ if (rc < 0)
+ qDebug() << "ERROR: Cannot register QMLManager, QML will not work!!";
+ rc = qmlRegisterType<QMLPrefs>("org.subsurfacedivelog.mobile", 1, 0, "QMLPrefs");
+ if (rc < 0)
+ qDebug() << "ERROR: Cannot register QMLPrefs, QML will not work!!";
+ rc = qmlRegisterType<QMLProfile>("org.subsurfacedivelog.mobile", 1, 0, "QMLProfile");
+ if (rc < 0)
+ qDebug() << "ERROR: Cannot register QMLProfile, QML will not work!!";
+ rc = qmlRegisterType<DownloadThread>("org.subsurfacedivelog.mobile", 1, 0, "DCDownloadThread");
+ if (rc < 0)
+ qDebug() << "ERROR: Cannot register DCDownloadThread, QML will not work!!";
+ rc = qmlRegisterType<DiveImportedModel>("org.subsurfacedivelog.mobile", 1, 0, "DCImportModel");
+ if (rc < 0)
+ qDebug() << "ERROR: Cannot register DCImportModel, QML will not work!!";
+#endif // not SUBSURFACE_MOBILE
+
+ rc = qmlRegisterType<MapWidgetHelper>("org.subsurfacedivelog.mobile", 1, 0, "MapWidgetHelper");
+ if (rc < 0)
+ qDebug() << "ERROR: Cannot register MapWidgetHelper, QML will not work!!";
+ rc = qmlRegisterType<MapLocationModel>("org.subsurfacedivelog.mobile", 1, 0, "MapLocationModel");
+ if (rc < 0)
+ qDebug() << "ERROR: Cannot register MapLocationModel, QML will not work!!";
+ rc = qmlRegisterType<MapLocation>("org.subsurfacedivelog.mobile", 1, 0, "MapLocation");
+ if (rc < 0)
+ qDebug() << "ERROR: Cannot register MapLocation, QML will not work!!";
+#endif // not SUBSURFACE_TEST_DATA
+}