diff options
author | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2018-05-01 12:35:18 +0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2018-05-13 13:52:35 -0700 |
commit | c71a5d74135d8ebf9dce6de6633499c1c41c07ff (patch) | |
tree | 2221f7e87767e80f2be0189cef82f8b03f9b511b /qt-models/divepicturemodel.cpp | |
parent | d33e3b22fc5d2e878ee6e03a25e99870484da217 (diff) | |
download | subsurface-c71a5d74135d8ebf9dce6de6633499c1c41c07ff.tar.gz |
Dive pictures: Don't update all pictures on drag & drop to profile
In the old code, we used to reload the whole picture list on drag & drop
to the profile. Instead, only update the drag&dropped picture and repaint
the profile-pictures.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'qt-models/divepicturemodel.cpp')
-rw-r--r-- | qt-models/divepicturemodel.cpp | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/qt-models/divepicturemodel.cpp b/qt-models/divepicturemodel.cpp index 89917761c..2fc7b8311 100644 --- a/qt-models/divepicturemodel.cpp +++ b/qt-models/divepicturemodel.cpp @@ -153,12 +153,28 @@ int DivePictureModel::rowCount(const QModelIndex &parent) const return pictures.count(); } +int DivePictureModel::findPictureId(const QString &filename) +{ + for (int i = 0; i < pictures.size(); ++i) + if (pictures[i].filename == filename) + return i; + return -1; +} + void DivePictureModel::updateThumbnail(QString filename, QImage thumbnail) { - for (int i = 0; i < pictures.size(); ++i) { - if (pictures[i].filename != filename) - continue; + int i = findPictureId(filename); + if (i >= 0) { pictures[i].image = thumbnail; emit dataChanged(createIndex(i, 0), createIndex(i, 1)); } } + +void DivePictureModel::updateDivePictureOffset(const QString &filename, int offsetSeconds) +{ + int i = findPictureId(filename); + if (i >= 0) { + pictures[i].offsetSeconds = offsetSeconds; + emit dataChanged(createIndex(i, 0), createIndex(i, 1)); + } +} |