mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
planner: move clearing of model into loadFromDive() function
Both loadFromDive() callers were clearing the model before calling loadFromDive(). Move the clearing into that function since it makes no sense to load into a non-cleared model. Apparently this changes the way that no-cylinder dives are treated and the code in ProfileWidget2::repositionDiveHandlers() must now explicitly check for that condition. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
02ef58a48b
commit
e419ebf55a
5 changed files with 8 additions and 6 deletions
|
@ -563,7 +563,6 @@ void PlannerWidgets::planDive()
|
||||||
|
|
||||||
void PlannerWidgets::replanDive()
|
void PlannerWidgets::replanDive()
|
||||||
{
|
{
|
||||||
DivePlannerPointsModel::instance()->clear();
|
|
||||||
DivePlannerPointsModel::instance()->setPlanMode(DivePlannerPointsModel::PLAN);
|
DivePlannerPointsModel::instance()->setPlanMode(DivePlannerPointsModel::PLAN);
|
||||||
|
|
||||||
MainWindow::instance()->graphics->setPlanState();
|
MainWindow::instance()->graphics->setPlanState();
|
||||||
|
|
|
@ -1514,7 +1514,6 @@ void MainWindow::editCurrentDive()
|
||||||
return;
|
return;
|
||||||
|
|
||||||
disableShortcuts();
|
disableShortcuts();
|
||||||
DivePlannerPointsModel::instance()->clear();
|
|
||||||
DivePlannerPointsModel::instance()->setPlanMode(DivePlannerPointsModel::ADD);
|
DivePlannerPointsModel::instance()->setPlanMode(DivePlannerPointsModel::ADD);
|
||||||
graphics->setAddState();
|
graphics->setAddState();
|
||||||
setApplicationState(ApplicationState::EditDive);
|
setApplicationState(ApplicationState::EditDive);
|
||||||
|
|
|
@ -1792,7 +1792,10 @@ void ProfileWidget2::repositionDiveHandlers()
|
||||||
QLineF line(p1, p2);
|
QLineF line(p1, p2);
|
||||||
QPointF pos = line.pointAt(0.5);
|
QPointF pos = line.pointAt(0.5);
|
||||||
gases[i]->setPos(pos);
|
gases[i]->setPos(pos);
|
||||||
|
if (datapoint.cylinderid >= 0 && datapoint.cylinderid < displayed_dive.cylinders.nr)
|
||||||
gases[i]->setText(get_gas_string(get_cylinder(&displayed_dive, datapoint.cylinderid)->gasmix));
|
gases[i]->setText(get_gas_string(get_cylinder(&displayed_dive, datapoint.cylinderid)->gasmix));
|
||||||
|
else
|
||||||
|
gases[i]->setText(QString());
|
||||||
gases[i]->setVisible(datapoint.entered &&
|
gases[i]->setVisible(datapoint.entered &&
|
||||||
(i == 0 || gases[i]->text() != gases[i-1]->text()));
|
(i == 0 || gases[i]->text() != gases[i-1]->text()));
|
||||||
}
|
}
|
||||||
|
|
|
@ -106,9 +106,10 @@ void DivePlannerPointsModel::loadFromDive(dive *d)
|
||||||
duration_t lasttime = { 0 };
|
duration_t lasttime = { 0 };
|
||||||
duration_t lastrecordedtime = {};
|
duration_t lastrecordedtime = {};
|
||||||
duration_t newtime = {};
|
duration_t newtime = {};
|
||||||
free_dps(&diveplan);
|
|
||||||
if (mode != PLAN)
|
|
||||||
clear();
|
clear();
|
||||||
|
free_dps(&diveplan);
|
||||||
|
|
||||||
diveplan.when = d->when;
|
diveplan.when = d->when;
|
||||||
// is this a "new" dive where we marked manually entered samples?
|
// is this a "new" dive where we marked manually entered samples?
|
||||||
// if yes then the first sample should be marked
|
// if yes then the first sample should be marked
|
||||||
|
|
|
@ -40,7 +40,6 @@ public:
|
||||||
void setPlanMode(Mode mode);
|
void setPlanMode(Mode mode);
|
||||||
bool isPlanner() const;
|
bool isPlanner() const;
|
||||||
void createSimpleDive();
|
void createSimpleDive();
|
||||||
void clear();
|
|
||||||
Mode currentMode() const;
|
Mode currentMode() const;
|
||||||
bool setRecalc(bool recalc);
|
bool setRecalc(bool recalc);
|
||||||
bool recalcQ() const;
|
bool recalcQ() const;
|
||||||
|
@ -119,6 +118,7 @@ signals:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
explicit DivePlannerPointsModel(QObject *parent = 0);
|
explicit DivePlannerPointsModel(QObject *parent = 0);
|
||||||
|
void clear();
|
||||||
void setupStartTime();
|
void setupStartTime();
|
||||||
void setupCylinders();
|
void setupCylinders();
|
||||||
int lastEnteredPoint() const;
|
int lastEnteredPoint() const;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue