diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2016-01-27 11:50:04 -0800 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2016-01-27 11:50:04 -0800 |
commit | ec0fc9d70b679b854fb50d685a5dcfe6f1bf7093 (patch) | |
tree | 101061bc11e7b413da02b4a4370f0ed8cba99bef /qt-models | |
parent | 6f953d51de0796bd584938d759b32eeffb849463 (diff) | |
download | subsurface-ec0fc9d70b679b854fb50d685a5dcfe6f1bf7093.tar.gz |
Change the api to update a single dive
Instead of searching for the dive in the list, just make sure we are given
the index.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-models')
-rw-r--r-- | qt-models/divelistmodel.cpp | 13 | ||||
-rw-r--r-- | qt-models/divelistmodel.h | 2 |
2 files changed, 5 insertions, 10 deletions
diff --git a/qt-models/divelistmodel.cpp b/qt-models/divelistmodel.cpp index 6e0804743..6706d9137 100644 --- a/qt-models/divelistmodel.cpp +++ b/qt-models/divelistmodel.cpp @@ -30,16 +30,11 @@ void DiveListModel::removeDive(int i) endRemoveRows(); } -void DiveListModel::updateDive(dive *d) +void DiveListModel::updateDive(int i, dive *d) { - for (int i = 0; i < m_dives.count(); i++) { - if (m_dives.at(i)->id() == d->id) { - DiveObjectHelper *newDive = new DiveObjectHelper(d); - removeDive(i); - insertDive(i, newDive); - break; - } - } + DiveObjectHelper *newDive = new DiveObjectHelper(d); + removeDive(i); + insertDive(i, newDive); } void DiveListModel::clear() diff --git a/qt-models/divelistmodel.h b/qt-models/divelistmodel.h index adc298515..8f52680a4 100644 --- a/qt-models/divelistmodel.h +++ b/qt-models/divelistmodel.h @@ -22,7 +22,7 @@ public: void addDive(dive *d); void insertDive(int i, DiveObjectHelper *newDive); void removeDive(int i); - void updateDive(dive *d); + void updateDive(int i, dive *d); void clear(); int rowCount(const QModelIndex &parent = QModelIndex()) const; QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; |