summaryrefslogtreecommitdiffstats
path: root/qt-ui/models.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'qt-ui/models.cpp')
-rw-r--r--qt-ui/models.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/qt-ui/models.cpp b/qt-ui/models.cpp
index 14c3cb5ea..dd69e45c2 100644
--- a/qt-ui/models.cpp
+++ b/qt-ui/models.cpp
@@ -1198,6 +1198,23 @@ QVariant DiveComputerModel::data(const QModelIndex& index, int role) const
return ret;
}
+void DiveTripModel::deleteSelectedDives()
+{
+ // after a dive is deleted the ones following it move forward in the dive_table
+ // so instead of using the for_each_dive macro I'm using an explicit for loop
+ // to make this easier to understand
+ beginRemoveRows(index(0,0), 0, rowCount()-1);
+ for (int i = 0; i < dive_table.nr; i++) {
+ struct dive *d = get_dive(i);
+ if (!d->selected)
+ continue;
+ delete_single_dive(i);
+ i--; // so the next dive isn't skipped... it's now #i
+ }
+ endRemoveRows();
+ setupModelData();
+}
+
int DiveComputerModel::rowCount(const QModelIndex& parent) const
{
return numRows;