summaryrefslogtreecommitdiffstats
path: root/core/pictureobj.cpp
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2020-04-17 16:49:15 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2020-05-06 13:58:09 -0700
commitfe82cb32b93e906b9bf53010538651b9c84df9db (patch)
tree91d944915294c37136221074e31e8077cefc52ad /core/pictureobj.cpp
parent6f8cc5aafecdbbd824be8872c6c4d837d725ef40 (diff)
downloadsubsurface-fe82cb32b93e906b9bf53010538651b9c84df9db.tar.gz
media: add small C++ helper describing a picture struct
By using a std::string instead of a C-string, memory management becomes so much simpler! This class will be used for keeping track of deleted/added pictures in the undo system. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'core/pictureobj.cpp')
-rw-r--r--core/pictureobj.cpp27
1 files changed, 27 insertions, 0 deletions
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;
+}