summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--core/CMakeLists.txt2
-rw-r--r--core/pictureobj.cpp27
-rw-r--r--core/pictureobj.h25
-rw-r--r--packaging/ios/Subsurface-mobile.pro2
4 files changed, 56 insertions, 0 deletions
diff --git a/core/CMakeLists.txt b/core/CMakeLists.txt
index 7699877bc..4a498cde8 100644
--- a/core/CMakeLists.txt
+++ b/core/CMakeLists.txt
@@ -127,6 +127,8 @@ set(SUBSURFACE_CORE_LIB_SRCS
parse.h
picture.c
picture.h
+ pictureobj.cpp
+ pictureobj.h
planner.c
planner.h
plannernotes.c
diff --git a/core/pictureobj.cpp b/core/pictureobj.cpp
new file mode 100644
index 000000000..cb6b32675
--- /dev/null
+++ b/core/pictureobj.cpp
@@ -0,0 +1,27 @@
+// SPDX-License-Identifier: GPL-2.0
+#include "pictureobj.h"
+#include "qthelper.h"
+
+PictureObj::PictureObj() : offset({ 0 }), location({ 0 })
+{
+}
+
+PictureObj::PictureObj(const picture &pic) : filename(pic.filename), offset(pic.offset), location(pic.location)
+{
+}
+
+picture PictureObj::toCore() const
+{
+ return picture {
+ strdup(filename.c_str()),
+ offset,
+ location
+ };
+}
+
+bool PictureObj::operator<(const PictureObj &p2) const
+{
+ if (offset.seconds != p2.offset.seconds)
+ return offset.seconds < p2.offset.seconds;
+ return strcmp(filename.c_str(), p2.filename.c_str()) < 0;
+}
diff --git a/core/pictureobj.h b/core/pictureobj.h
new file mode 100644
index 000000000..6ea20259b
--- /dev/null
+++ b/core/pictureobj.h
@@ -0,0 +1,25 @@
+// SPDX-License-Identifier: GPL-2.0
+
+#ifndef PICTUREOBJ_H
+#define PICTUREOBJ_H
+
+// A tiny helper class that represents a struct picture of the core
+// It does, however, keep the filename as a std::string so that C++ code
+// doesn't have do its own memory-management.
+
+#include "core/units.h"
+#include "core/picture.h"
+#include <string>
+
+struct PictureObj {
+ std::string filename;
+ offset_t offset;
+ location_t location;
+
+ PictureObj(); // Initialize to empty picture.
+ PictureObj(const picture &pic); // Create from core struct picture.
+ picture toCore() const; // Turn into core structure. Caller responsible for freeing.
+ bool operator<(const PictureObj &p2) const;
+};
+
+#endif // PICTUREOBJ_H
diff --git a/packaging/ios/Subsurface-mobile.pro b/packaging/ios/Subsurface-mobile.pro
index a036ccae8..36da3e3af 100644
--- a/packaging/ios/Subsurface-mobile.pro
+++ b/packaging/ios/Subsurface-mobile.pro
@@ -64,6 +64,7 @@ SOURCES += ../../subsurface-mobile-main.cpp \
../../core/parse-xml.c \
../../core/parse.c \
../../core/picture.c \
+ ../../core/pictureobj.cpp \
../../core/import-suunto.c \
../../core/import-shearwater.c \
../../core/import-cobalt.c \
@@ -205,6 +206,7 @@ HEADERS += \
../../core/units.h \
../../core/version.h \
../../core/picture.h \
+ ../../core/pictureobj.h \
../../core/planner.h \
../../core/divesite.h \
../../core/checkcloudconnection.h \