summaryrefslogtreecommitdiffstats
path: root/qt-models
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2019-11-03 15:25:23 +0100
committerGravatar Dirk Hohndel <dirk@hohndel.org>2019-12-05 10:14:25 -0800
commit2cfb35b6d7b5bb7bb7275f078bf2aff959e6ecef (patch)
treee220c14fa1615a049b73e18681bab017b93438f4 /qt-models
parentb3f530bfb9d099414d833e7b0eb8c71cb3780eca (diff)
downloadsubsurface-2cfb35b6d7b5bb7bb7275f078bf2aff959e6ecef.tar.gz
Cleanup: return value type from WeightModel::weightSystemAt()
There is only one caller of WeightModel::weightSystemAt() and that certainly does not need a pointer into the weightsystem-table of the current dive. Return a value type instead of a pointer. This allows us to mark WeightModel::weightSystemAt() as const and use it from WeightModel::data(). Slightly cleaner code. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'qt-models')
-rw-r--r--qt-models/weightmodel.cpp6
-rw-r--r--qt-models/weightmodel.h2
2 files changed, 4 insertions, 4 deletions
diff --git a/qt-models/weightmodel.cpp b/qt-models/weightmodel.cpp
index ff0b5c87a..4a931a4bb 100644
--- a/qt-models/weightmodel.cpp
+++ b/qt-models/weightmodel.cpp
@@ -19,14 +19,14 @@ WeightModel::WeightModel(QObject *parent) : CleanerTableModel(parent),
connect(&diveListNotifier, &DiveListNotifier::weightRemoved, this, &WeightModel::weightRemoved);
}
-weightsystem_t *WeightModel::weightSystemAt(const QModelIndex &index)
+weightsystem_t WeightModel::weightSystemAt(const QModelIndex &index)
{
int row = index.row();
if (row < 0 || row >= d->weightsystems.nr) {
qWarning("WeightModel: Accessing invalid weightsystem %d (of %d)", row, d->weightsystems.nr);
- return nullptr;
+ return { { 0 }, nullptr };
}
- return &d->weightsystems.weightsystems[index.row()];
+ return d->weightsystems.weightsystems[index.row()];
}
void WeightModel::clear()
diff --git a/qt-models/weightmodel.h b/qt-models/weightmodel.h
index a61217379..2e5a190ba 100644
--- a/qt-models/weightmodel.h
+++ b/qt-models/weightmodel.h
@@ -25,7 +25,7 @@ public:
void passInData(const QModelIndex &index, const QVariant &value);
void clear();
void updateDive(dive *d);
- weightsystem_t *weightSystemAt(const QModelIndex &index);
+ weightsystem_t weightSystemAt(const QModelIndex &index);
bool changed;
public