summaryrefslogtreecommitdiffstats
path: root/qt-models/divelistmodel.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'qt-models/divelistmodel.cpp')
-rw-r--r--qt-models/divelistmodel.cpp19
1 files changed, 17 insertions, 2 deletions
diff --git a/qt-models/divelistmodel.cpp b/qt-models/divelistmodel.cpp
index e6514064f..6e0804743 100644
--- a/qt-models/divelistmodel.cpp
+++ b/qt-models/divelistmodel.cpp
@@ -16,12 +16,27 @@ void DiveListModel::addDive(dive *d)
endInsertRows();
}
+void DiveListModel::insertDive(int i, DiveObjectHelper *newDive)
+{
+ beginInsertRows(QModelIndex(), i, i);
+ m_dives.insert(i, newDive);
+ endInsertRows();
+}
+
+void DiveListModel::removeDive(int i)
+{
+ beginRemoveRows(QModelIndex(), i, i);
+ m_dives.removeAt(i);
+ endRemoveRows();
+}
+
void DiveListModel::updateDive(dive *d)
{
for (int i = 0; i < m_dives.count(); i++) {
if (m_dives.at(i)->id() == d->id) {
DiveObjectHelper *newDive = new DiveObjectHelper(d);
- m_dives.replace(i, newDive);
+ removeDive(i);
+ insertDive(i, newDive);
break;
}
}
@@ -88,4 +103,4 @@ DiveListModel *DiveListModel::instance()
DiveObjectHelper* DiveListModel::at(int i){
return m_dives.at(i);
-} \ No newline at end of file
+}