aboutsummaryrefslogtreecommitdiffstats
path: root/qt-models/divelistmodel.cpp
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2016-01-29 06:25:13 -0800
committerGravatar Dirk Hohndel <dirk@hohndel.org>2016-01-29 07:50:38 -0800
commit9f7ecbb53eabe4028f44ac420cd176bf8c76421e (patch)
tree38b16136a1515175309940282261203908af4668 /qt-models/divelistmodel.cpp
parent957f03f2a437bf735379405540102db5bdb548f4 (diff)
downloadsubsurface-9f7ecbb53eabe4028f44ac420cd176bf8c76421e.tar.gz
Add helper to remove dive from model
I tried various things to do this from QML but it just doesn't seem to work at all. So I gave up and instead added a trivial helper function. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-models/divelistmodel.cpp')
-rw-r--r--qt-models/divelistmodel.cpp13
1 files changed, 12 insertions, 1 deletions
diff --git a/qt-models/divelistmodel.cpp b/qt-models/divelistmodel.cpp
index 114745fe7..9ddf05dbc 100644
--- a/qt-models/divelistmodel.cpp
+++ b/qt-models/divelistmodel.cpp
@@ -52,6 +52,16 @@ void DiveListModel::removeDive(int i)
endRemoveRows();
}
+void DiveListModel::removeDiveById(int id)
+{
+ for (int i = 0; i < rowCount(); i++) {
+ if (m_dives.at(i)->id() == id) {
+ removeDive(i);
+ return;
+ }
+ }
+}
+
void DiveListModel::updateDive(int i, dive *d)
{
DiveObjectHelper *newDive = new DiveObjectHelper(d);
@@ -125,6 +135,7 @@ DiveListModel *DiveListModel::instance()
return m_instance;
}
-DiveObjectHelper* DiveListModel::at(int i){
+DiveObjectHelper* DiveListModel::at(int i)
+{
return m_dives.at(i);
}