From ec0fc9d70b679b854fb50d685a5dcfe6f1bf7093 Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Wed, 27 Jan 2016 11:50:04 -0800 Subject: 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 --- qt-models/divelistmodel.cpp | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) (limited to 'qt-models/divelistmodel.cpp') 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() -- cgit v1.2.3-70-g09d2