mirror of
https://github.com/subsurface/subsurface.git
synced 2025-01-19 14:25:27 +00:00
planner: split DivePlannerPointsModel::removePoints() in two
Split the function in one external version, that updates the dive profile and cylinders and one internal version, that does no recalculations. In the latter case, the caller is responsible for updating the dive. Thus, the recalculation flag-clearing can be removed from removeDeco(). Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
cbee716316
commit
601861ef5e
2 changed files with 11 additions and 5 deletions
|
@ -28,7 +28,7 @@ CylindersModel *DivePlannerPointsModel::cylindersModel()
|
||||||
return &cylinders;
|
return &cylinders;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DivePlannerPointsModel::removeSelectedPoints(const QVector<int> &rows)
|
void DivePlannerPointsModel::removePoints(const QVector<int> &rows)
|
||||||
{
|
{
|
||||||
if (!rows.count())
|
if (!rows.count())
|
||||||
return;
|
return;
|
||||||
|
@ -40,6 +40,12 @@ void DivePlannerPointsModel::removeSelectedPoints(const QVector<int> &rows)
|
||||||
divepoints.erase(divepoints.begin() + v2[i]);
|
divepoints.erase(divepoints.begin() + v2[i]);
|
||||||
endRemoveRows();
|
endRemoveRows();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void DivePlannerPointsModel::removeSelectedPoints(const QVector<int> &rows)
|
||||||
|
{
|
||||||
|
removePoints(rows);
|
||||||
|
|
||||||
updateDiveProfile();
|
updateDiveProfile();
|
||||||
emitDataChanged();
|
emitDataChanged();
|
||||||
cylinders.updateTrashIcon();
|
cylinders.updateTrashIcon();
|
||||||
|
@ -225,13 +231,12 @@ bool DivePlannerPointsModel::updateMaxDepth()
|
||||||
|
|
||||||
void DivePlannerPointsModel::removeDeco()
|
void DivePlannerPointsModel::removeDeco()
|
||||||
{
|
{
|
||||||
bool oldrec = std::exchange(recalc, false);
|
|
||||||
QVector<int> computedPoints;
|
QVector<int> computedPoints;
|
||||||
for (int i = 0; i < rowCount(); i++)
|
for (int i = 0; i < rowCount(); i++) {
|
||||||
if (!at(i).entered)
|
if (!at(i).entered)
|
||||||
computedPoints.push_back(i);
|
computedPoints.push_back(i);
|
||||||
removeSelectedPoints(computedPoints);
|
}
|
||||||
recalc = oldrec;
|
removePoints(computedPoints);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DivePlannerPointsModel::addCylinder_clicked()
|
void DivePlannerPointsModel::addCylinder_clicked()
|
||||||
|
|
|
@ -115,6 +115,7 @@ private:
|
||||||
explicit DivePlannerPointsModel(QObject *parent = 0);
|
explicit DivePlannerPointsModel(QObject *parent = 0);
|
||||||
void clear();
|
void clear();
|
||||||
int addStop(int millimeters, int seconds, int cylinderid_in, int ccpoint, bool entered, enum divemode_t);
|
int addStop(int millimeters, int seconds, int cylinderid_in, int ccpoint, bool entered, enum divemode_t);
|
||||||
|
void removePoints(const QVector<int> &rows);
|
||||||
void setupStartTime();
|
void setupStartTime();
|
||||||
void setupCylinders();
|
void setupCylinders();
|
||||||
int lastEnteredPoint() const;
|
int lastEnteredPoint() const;
|
||||||
|
|
Loading…
Add table
Reference in a new issue