diff options
-rw-r--r-- | qt-models/cylindermodel.cpp | 7 | ||||
-rw-r--r-- | qt-models/diveplannermodel.cpp | 7 | ||||
-rw-r--r-- | qt-models/diveplannermodel.h | 1 |
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(); |