summaryrefslogtreecommitdiffstats
path: root/qt-models
diff options
context:
space:
mode:
authorGravatar Stefan Fuchs <sfuchs@gmx.de>2017-10-11 21:27:06 +0200
committerGravatar Robert C. Helling <helling@atdotde.de>2017-10-16 17:14:17 +0200
commit73d2ab8099ce08ab20f119a126334463ffd41b1e (patch)
treeba80715002dcbfbe8bc0aa029e99b881d3fa73f4 /qt-models
parentdf6933326de3ff173b2bd3458d8b29dce8c0f88f (diff)
downloadsubsurface-73d2ab8099ce08ab20f119a126334463ffd41b1e.tar.gz
Update diveplannerpoints cylinderidx when deleting a cylinder
Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
Diffstat (limited to 'qt-models')
-rw-r--r--qt-models/cylindermodel.cpp7
-rw-r--r--qt-models/diveplannermodel.cpp7
-rw-r--r--qt-models/diveplannermodel.h1
3 files changed, 10 insertions, 5 deletions
diff --git a/qt-models/cylindermodel.cpp b/qt-models/cylindermodel.cpp
index 545341c78..6408342bc 100644
--- a/qt-models/cylindermodel.cpp
+++ b/qt-models/cylindermodel.cpp
@@ -576,11 +576,8 @@ void CylindersModel::remove(const QModelIndex &index)
}
changed = true;
endRemoveRows();
- struct divecomputer *dc = &displayed_dive.dc;
- while (dc) {
- dc_cylinder_renumber(&displayed_dive, dc, mapping);
- dc = dc->next;
- }
+ cylinder_renumber(&displayed_dive, mapping);
+ DivePlannerPointsModel::instance()->cylinderRenumber(mapping);
dataChanged(index, index);
}
diff --git a/qt-models/diveplannermodel.cpp b/qt-models/diveplannermodel.cpp
index 57866b9e8..5fc692a38 100644
--- a/qt-models/diveplannermodel.cpp
+++ b/qt-models/diveplannermodel.cpp
@@ -353,6 +353,13 @@ void DivePlannerPointsModel::gaschange(const QModelIndex &index, int newcylinder
emitDataChanged();
}
+void DivePlannerPointsModel::cylinderRenumber(int mapping[])
+{
+ for (int i = 0; i < rowCount(); i++)
+ divepoints[i].cylinderid = mapping[divepoints[i].cylinderid];
+ emitDataChanged();
+}
+
QVariant DivePlannerPointsModel::headerData(int section, Qt::Orientation orientation, int role) const
{
if (role == Qt::DisplayRole && orientation == Qt::Horizontal) {
diff --git a/qt-models/diveplannermodel.h b/qt-models/diveplannermodel.h
index 43a1186d4..8e853abf8 100644
--- a/qt-models/diveplannermodel.h
+++ b/qt-models/diveplannermodel.h
@@ -32,6 +32,7 @@ public:
virtual bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole);
virtual Qt::ItemFlags flags(const QModelIndex &index) const;
void gaschange(const QModelIndex &index, int newcylinderid);
+ void cylinderRenumber(int mapping[]);
void removeSelectedPoints(const QVector<int> &rows);
void setPlanMode(Mode mode);
bool isPlanner();