diff options
Diffstat (limited to 'qt-models')
-rw-r--r-- | qt-models/divepicturemodel.cpp | 34 | ||||
-rw-r--r-- | qt-models/divepicturemodel.h | 1 | ||||
-rw-r--r-- | qt-models/divetripmodel.cpp | 1 |
3 files changed, 14 insertions, 22 deletions
diff --git a/qt-models/divepicturemodel.cpp b/qt-models/divepicturemodel.cpp index 8156693ef..705f23592 100644 --- a/qt-models/divepicturemodel.cpp +++ b/qt-models/divepicturemodel.cpp @@ -1,9 +1,9 @@ // SPDX-License-Identifier: GPL-2.0 #include "qt-models/divepicturemodel.h" -#include "core/dive.h" #include "core/metrics.h" -#include "core/divelist.h" +#include "core/divelist.h" // for mark_divelist_changed() #include "core/imagedownloader.h" +#include "core/picture.h" #include "core/qthelper.h" #include <QFileInfo> @@ -59,7 +59,7 @@ void DivePictureModel::updateDivePictures() if (dive->selected) { int first = pictures.count(); FOR_EACH_PICTURE(dive) - pictures.push_back({ dive->id, picture, picture->filename, {}, picture->offset.seconds, {.seconds = 0}}); + pictures.push_back({ dive->id, picture->filename, {}, picture->offset.seconds, {.seconds = 0}}); // Sort pictures of this dive by offset. // Thus, the list will be sorted by (diveId, offset). @@ -79,42 +79,34 @@ int DivePictureModel::columnCount(const QModelIndex&) const QVariant DivePictureModel::data(const QModelIndex &index, int role) const { - QVariant ret; if (!index.isValid()) - return ret; + return QVariant(); const PictureEntry &entry = pictures.at(index.row()); if (index.column() == 0) { switch (role) { case Qt::ToolTipRole: - ret = entry.filename; - break; + return entry.filename; case Qt::DecorationRole: - ret = entry.image.scaled(size, size, Qt::KeepAspectRatio); - break; + return entry.image.scaled(size, size, Qt::KeepAspectRatio); case Qt::DisplayRole: - ret = QFileInfo(entry.filename).fileName(); - break; + return QFileInfo(entry.filename).fileName(); case Qt::DisplayPropertyRole: - ret = QFileInfo(entry.filename).filePath(); - break; + return QFileInfo(entry.filename).filePath(); case Qt::UserRole: - ret = entry.diveId; - break; + return entry.diveId; case Qt::UserRole + 1: - ret = entry.offsetSeconds; - break; + return entry.offsetSeconds; case Qt::UserRole + 2: - ret = entry.length.seconds; + return entry.length.seconds; } } else if (index.column() == 1) { switch (role) { case Qt::DisplayRole: - ret = entry.filename; - break; + return entry.filename; } } - return ret; + return QVariant(); } // Return true if we actually removed a picture diff --git a/qt-models/divepicturemodel.h b/qt-models/divepicturemodel.h index 4e25db687..5bee26864 100644 --- a/qt-models/divepicturemodel.h +++ b/qt-models/divepicturemodel.h @@ -10,7 +10,6 @@ struct PictureEntry { int diveId; - struct picture *picture; QString filename; QImage image; int offsetSeconds; diff --git a/qt-models/divetripmodel.cpp b/qt-models/divetripmodel.cpp index 2e5359b89..0f381410a 100644 --- a/qt-models/divetripmodel.cpp +++ b/qt-models/divetripmodel.cpp @@ -10,6 +10,7 @@ #include "core/trip.h" #include "core/qthelper.h" #include "core/divesite.h" +#include "core/picture.h" #include "core/subsurface-string.h" #include "core/tag.h" #include "qt-models/divelocationmodel.h" // For the dive-site field ids |