summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--profile-widget/profilewidget2.cpp8
-rw-r--r--qt-models/divepicturemodel.cpp22
-rw-r--r--qt-models/divepicturemodel.h2
3 files changed, 25 insertions, 7 deletions
diff --git a/profile-widget/profilewidget2.cpp b/profile-widget/profilewidget2.cpp
index 1e7e64daf..c033e2c34 100644
--- a/profile-widget/profilewidget2.cpp
+++ b/profile-widget/profilewidget2.cpp
@@ -2060,14 +2060,14 @@ void ProfileWidget2::dropEvent(QDropEvent *event)
if (QString(picture->filename) == filename) {
picture->offset.seconds = lrint(timeAxis->valueAt(mappedPos));
mark_divelist_changed(true);
+#ifndef SUBSURFACE_MOBILE
+ DivePictureModel::instance()->updateDivePictureOffset(filename, picture->offset.seconds);
+ plotPictures();
+#endif
break;
}
}
copy_dive(current_dive, &displayed_dive);
-#ifndef SUBSURFACE_MOBILE
- DivePictureModel::instance()->updateDivePictures();
-#endif
-
if (event->source() == this) {
event->setDropAction(Qt::MoveAction);
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));
+ }
+}
diff --git a/qt-models/divepicturemodel.h b/qt-models/divepicturemodel.h
index e68c00570..7f2cde6d0 100644
--- a/qt-models/divepicturemodel.h
+++ b/qt-models/divepicturemodel.h
@@ -24,12 +24,14 @@ public:
void updateDivePicturesWhenDone(QList<QFuture<void>>);
void removePicture(const QString& fileUrl, bool last);
int rowDDStart, rowDDEnd;
+ void updateDivePictureOffset(const QString &filename, int offsetSeconds);
public slots:
void setZoomLevel(int level);
void updateThumbnail(QString filename, QImage thumbnail);
private:
DivePictureModel();
QList<PictureEntry> pictures;
+ int findPictureId(const QString &filename); // Return -1 if not found
double zoomLevel; // -1.0: minimum, 0.0: standard, 1.0: maximum
int size;
int defaultSize;