summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Stefan Fuchs <sfuchs@gmx.de>2017-12-03 09:19:26 +0100
committerGravatar Dirk Hohndel <dirk@hohndel.org>2017-12-13 05:48:20 -0800
commit5b7e4c57f78c9ec2087726ecad89797132a32d08 (patch)
tree77f238222bf5a5056997eb26c76d168d780dec35
parenta11622623a43369368206e1e3b6a6b3173ad43fb (diff)
downloadsubsurface-5b7e4c57f78c9ec2087726ecad89797132a32d08.tar.gz
Dive pictures show pictures of all selected dives
In the dive picture tab show pictures of all selected dive. But at the same moment take care that in the profile only pictures from displayed_dive are displayed. Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
-rw-r--r--profile-widget/profilewidget2.cpp2
-rw-r--r--qt-models/divepicturemodel.cpp21
-rw-r--r--qt-models/divepicturemodel.h1
3 files changed, 17 insertions, 7 deletions
diff --git a/profile-widget/profilewidget2.cpp b/profile-widget/profilewidget2.cpp
index 6ca5334d4..d6a5f3343 100644
--- a/profile-widget/profilewidget2.cpp
+++ b/profile-widget/profilewidget2.cpp
@@ -2000,7 +2000,7 @@ void ProfileWidget2::plotPictures()
double x, y, lastX = -1.0, lastY = -1.0;
DivePictureModel *m = DivePictureModel::instance();
- for (int i = 0; i < m->rowCount(); i++) {
+ for (int i = m->rowDDStart; i <= m->rowDDEnd; i++) {
int offsetSeconds = m->index(i, 1).data(Qt::UserRole).value<int>();
// it's a correct picture, but doesn't have a timestamp: only show on the widget near the
// information area.
diff --git a/qt-models/divepicturemodel.cpp b/qt-models/divepicturemodel.cpp
index 41035aba2..894cd3db6 100644
--- a/qt-models/divepicturemodel.cpp
+++ b/qt-models/divepicturemodel.cpp
@@ -36,7 +36,7 @@ DivePictureModel *DivePictureModel::instance()
return self;
}
-DivePictureModel::DivePictureModel()
+DivePictureModel::DivePictureModel() : rowDDStart(0), rowDDEnd(0)
{
}
@@ -56,13 +56,22 @@ void DivePictureModel::updateDivePictures()
endRemoveRows();
}
- // if the dive_table is empty, ignore the displayed_dive
- if (dive_table.nr == 0 || dive_get_picture_count(&displayed_dive) == 0)
+ // if the dive_table is empty, quit
+ if (dive_table.nr == 0)
return;
- FOR_EACH_PICTURE_NON_PTR(displayed_dive)
- pictures.push_back({picture, picture->filename, QImage(), picture->offset.seconds});
-
+ int i;
+ struct dive *dive;
+ for_each_dive (i, dive) {
+ if (dive->selected) {
+ if (dive->id == displayed_dive.id)
+ rowDDStart = pictures.count();
+ FOR_EACH_PICTURE(dive)
+ pictures.push_back({picture, picture->filename, QImage(), picture->offset.seconds});
+ if (dive->id == displayed_dive.id)
+ rowDDEnd = pictures.count() - 1;
+ }
+ }
QtConcurrent::blockingMap(pictures, scaleImages);
beginInsertRows(QModelIndex(), 0, pictures.count() - 1);
diff --git a/qt-models/divepicturemodel.h b/qt-models/divepicturemodel.h
index 2ae3c3798..9602d84bc 100644
--- a/qt-models/divepicturemodel.h
+++ b/qt-models/divepicturemodel.h
@@ -26,6 +26,7 @@ public:
virtual void updateDivePictures();
void updateDivePicturesWhenDone(QList<QFuture<void>>);
void removePicture(const QString& fileUrl, bool last);
+ int rowDDStart, rowDDEnd;
protected:
DivePictureModel();