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>
This commit is contained in:
Stefan Fuchs 2017-12-03 09:19:26 +01:00 committed by Dirk Hohndel
parent a11622623a
commit 5b7e4c57f7
3 changed files with 17 additions and 7 deletions

View file

@ -2000,7 +2000,7 @@ void ProfileWidget2::plotPictures()
double x, y, lastX = -1.0, lastY = -1.0; double x, y, lastX = -1.0, lastY = -1.0;
DivePictureModel *m = DivePictureModel::instance(); 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>(); 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 // it's a correct picture, but doesn't have a timestamp: only show on the widget near the
// information area. // information area.

View file

@ -36,7 +36,7 @@ DivePictureModel *DivePictureModel::instance()
return self; return self;
} }
DivePictureModel::DivePictureModel() DivePictureModel::DivePictureModel() : rowDDStart(0), rowDDEnd(0)
{ {
} }
@ -56,13 +56,22 @@ void DivePictureModel::updateDivePictures()
endRemoveRows(); endRemoveRows();
} }
// if the dive_table is empty, ignore the displayed_dive // if the dive_table is empty, quit
if (dive_table.nr == 0 || dive_get_picture_count(&displayed_dive) == 0) if (dive_table.nr == 0)
return; return;
FOR_EACH_PICTURE_NON_PTR(displayed_dive) int i;
pictures.push_back({picture, picture->filename, QImage(), picture->offset.seconds}); 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); QtConcurrent::blockingMap(pictures, scaleImages);
beginInsertRows(QModelIndex(), 0, pictures.count() - 1); beginInsertRows(QModelIndex(), 0, pictures.count() - 1);

View file

@ -26,6 +26,7 @@ public:
virtual void updateDivePictures(); virtual void updateDivePictures();
void updateDivePicturesWhenDone(QList<QFuture<void>>); void updateDivePicturesWhenDone(QList<QFuture<void>>);
void removePicture(const QString& fileUrl, bool last); void removePicture(const QString& fileUrl, bool last);
int rowDDStart, rowDDEnd;
protected: protected:
DivePictureModel(); DivePictureModel();