aboutsummaryrefslogtreecommitdiffstats
path: root/qt-models/divepicturemodel.h
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2020-05-04 09:47:55 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2020-05-06 13:58:09 -0700
commit4d407dc666ba471946541c835da3bb5805b514bc (patch)
tree3994e6ea0bc19352bccfd7185615ee33051273a4 /qt-models/divepicturemodel.h
parentc50e58d761c0c6e54219a3114a26bc033ddeee70 (diff)
downloadsubsurface-4d407dc666ba471946541c835da3bb5805b514bc.tar.gz
pictures: turn QString into std::string for filenames
For undo of picture manipulation, it will be crucial that the model and the core have the same order of pictures. The first sort criterion will be time, the second filename in the case that two pictures have, for whatever reason, the same timestamp. However in the core we us C-strings and thus sort byte-wise using strcmp. In the Qt-part we use QStrings, which sort according to unicode encoding. To enable consistent sorting, change the Qt-part to std::string, which uses a C-style 0-terminated string as its backing store. One might argue that in general filenames should use system-encoding and therefore use std::string instead of QString. However, a broader conversion to std::string turned out to be very painful, since Qt is (deliberately?) difficult to use with std::string. Notable all the file-manipulation functions don't take std::string by default. Thus, this commit only converts the internal data of DivePictureModel, but continues to use QString for the Qt-facing interface. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'qt-models/divepicturemodel.h')
-rw-r--r--qt-models/divepicturemodel.h6
1 files changed, 4 insertions, 2 deletions
diff --git a/qt-models/divepicturemodel.h b/qt-models/divepicturemodel.h
index 5bee26864..1ed5e8095 100644
--- a/qt-models/divepicturemodel.h
+++ b/qt-models/divepicturemodel.h
@@ -8,9 +8,11 @@
#include <QImage>
#include <QFuture>
+// We use std::string instead of QString to use the same character-encoding
+// as in the C core (UTF-8). This is crucial to guarantee the same sort-order.
struct PictureEntry {
int diveId;
- QString filename;
+ std::string filename;
QImage image;
int offsetSeconds;
duration_t length;
@@ -34,7 +36,7 @@ public slots:
private:
DivePictureModel();
QVector<PictureEntry> pictures;
- int findPictureId(const QString &filename); // Return -1 if not found
+ int findPictureId(const std::string &filename); // Return -1 if not found
double zoomLevel; // -1.0: minimum, 0.0: standard, 1.0: maximum
int size;
void updateThumbnails();