diff options
author | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2020-04-10 09:50:57 +0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2020-04-10 10:53:03 -0700 |
commit | 1fd8ea9d499ccb7adacc5f728ad69ba5cb5c60f8 (patch) | |
tree | 734a6bde1451eb88342cf94c98cbdd6816f33467 /qt-models | |
parent | 3f3869ff650229e99262ee07b14e1d14ca973d10 (diff) | |
download | subsurface-1fd8ea9d499ccb7adacc5f728ad69ba5cb5c60f8.tar.gz |
cleanup: directly return from DivePictureModel::data()
Instead of assigning to a QVariant ret and returning at the end,
return directly in the various switch-cases. This makes the code
more readable, and is more idiomatic C++, as it avoids unnecessary
copies.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'qt-models')
-rw-r--r-- | qt-models/divepicturemodel.cpp | 28 |
1 files changed, 10 insertions, 18 deletions
diff --git a/qt-models/divepicturemodel.cpp b/qt-models/divepicturemodel.cpp index 1eb0767f6..ab54c2dc1 100644 --- a/qt-models/divepicturemodel.cpp +++ b/qt-models/divepicturemodel.cpp @@ -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 |