[PATCH] Make Marble optional

Alberto albcoron at gmail.com
Fri Feb 28 22:15:12 PST 2014


From: Alberto Corona <albcoron at gmail.com>

Implemented some changes suggested by glance
Building could now be done without having to have Marble installed
Fixes #394

Signed-off-by: Alberto Corona <albcoron at gmail.com>
---
 qt-ui/globe.cpp          | 11 +++++++++++
 qt-ui/globe.h            | 21 +++++++++++++++++++++
 qt-ui/mainwindow.h       |  1 +
 subsurface-configure.pri | 10 +++++++---
 subsurface.pro           |  2 +-
 5 files changed, 41 insertions(+), 4 deletions(-)

diff --git a/qt-ui/globe.cpp b/qt-ui/globe.cpp
index 496afb4..7837ae7 100644
--- a/qt-ui/globe.cpp
+++ b/qt-ui/globe.cpp
@@ -1,4 +1,5 @@
 #include "globe.h"
+#ifndef NO_MARBLE
 #include "kmessagewidget.h"
 #include "mainwindow.h"
 #include "ui_mainwindow.h"
@@ -297,3 +298,13 @@ void GlobeGPS::resizeEvent(QResizeEvent *event)
 		messageWidget->setGeometry(5, 5, size - 10, 0);
 	messageWidget->setMaximumHeight(500);
 }
+
+#else
+
+GlobeGPS::GlobeGPS(QWidget *parent) {}
+void GlobeGPS::repopulateLabels() {}
+void GlobeGPS::centerOn(dive *dive) {}
+void GlobeGPS::prepareForGetDiveCoordinates() {}
+void GlobeGPS::reload() {}
+bool GlobeGPS::eventFilter(QObject *obj, QEvent *ev) {}
+#endif
diff --git a/qt-ui/globe.h b/qt-ui/globe.h
index 80d9613..e25f244 100644
--- a/qt-ui/globe.h
+++ b/qt-ui/globe.h
@@ -1,5 +1,6 @@
 #ifndef GLOBE_H
 #define GLOBE_H
+#ifndef NO_MARBLE
 
 #include <marble/MarbleWidget.h>
 #include <marble/GeoDataCoordinates.h>
@@ -41,4 +42,24 @@ slots:
 	void prepareForGetDiveCoordinates();
 };
 
+#else
+
+#include <QWidget>
+
+struct dive;
+
+class GlobeGPS : public QWidget {
+        Q_OBJECT
+public:
+        GlobeGPS(QWidget *parent);
+        void reload();
+        void repopulateLabels();
+        void centerOn(struct dive *dive);
+        bool eventFilter(QObject *, QEvent *);
+public
+slots:
+        void prepareForGetDiveCoordinates();
+};
+
+#endif
 #endif // GLOBE_H
diff --git a/qt-ui/mainwindow.h b/qt-ui/mainwindow.h
index 1db3d5a..65a532c 100644
--- a/qt-ui/mainwindow.h
+++ b/qt-ui/mainwindow.h
@@ -9,6 +9,7 @@
 
 #include <QMainWindow>
 #include <QAction>
+#include <QSettings>
 #include <QUrl>
 
 #include "ui_mainwindow.h"
diff --git a/subsurface-configure.pri b/subsurface-configure.pri
index 8e6aead..fb48185 100644
--- a/subsurface-configure.pri
+++ b/subsurface-configure.pri
@@ -116,7 +116,6 @@ isEmpty(XML2_CFLAGS)|isEmpty(XML2_LIBS): \
 isEmpty(XSLT_CFLAGS)|isEmpty(XSLT_LIBS): \
 	error("Could not find libxslt. Did you forget to install it?")
 
-
 QMAKE_CFLAGS *= $$XML2_CFLAGS $$XSLT_CFLAGS
 QMAKE_CXXFLAGS *= $$XML2_CFLAGS $$XSLT_CFLAGS
 LIBS *= $$XSLT_LIBS $$XML2_LIBS
@@ -131,14 +130,19 @@ link_pkgconfig: PKGCONFIG += libzip sqlite3
 # Add libiconv if needed
 link_pkgconfig: packagesExist(libiconv): PKGCONFIG += libiconv
 
+# Add Marble if present
+link_pkgconfig: packagesExist(libmarlbe): DEFINES += NO_MARBLE
+
 #
 # Find libmarble
 #
 # Before Marble 4.9, the GeoDataTreeModel.h header wasn't installed
 # Check if it's present by trying to compile
 # ### FIXME: implement that
-win32: CONFIG(debug, debug|release): LIBS += -lmarblewidgetd
-else: LIBS += -lmarblewidget
+!contains(DEFINES, NO_MARBLE) {
+        win32: CONFIG(debug, debug|release): LIBS += -lmarblewidgetd
+        else: LIBS += -lmarblewidget
+}
 
 #
 # Platform-specific changes
diff --git a/subsurface.pro b/subsurface.pro
index 81cb906..49865d7 100644
--- a/subsurface.pro
+++ b/subsurface.pro
@@ -4,7 +4,7 @@ QT = core gui network svg
 lessThan(QT_MAJOR_VERSION, 5) {
 	QT += webkit
 } else {
-	QT += webkitwidgets
+	!android: QT += webkitwidgets
 }
 INCLUDEPATH += qt-ui $$PWD
 DEPENDPATH += qt-ui
-- 
1.8.5.3



More information about the subsurface mailing list