mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
planner: remove DivePlannerPointsModel::startTimeChanged signal
The way the starting time of a new plan was set was bonkers: 1) PlannerWidgets::planDive() invokes DivePlannerPointsModel:: createSimpleDive(). 2) createSimpleDive() calls DivePlannerPointsModel:: setupStartTime() 3) setupStartTime() emits a signal startTimeChanged() 4) startTimeChanged is caught by PlannerWidget and sets the UI field 5) change of the UI field emits a timeChanged() signal which is connected to DivePlannerPointsModel::setStartTime() 6) setStartTime() sets the time of the plan and displayed_dive and emits dataChanged() 7) dataChanged() replots the dive() 8) Back in DivePlannerPointsModel::createSimpleDive() the diveplan start time is overwritten with displayed_dive (the value are equal owing to 6) Wow! But it gets worse: 9) The initial dive plan is set up in createSimpleDive(). Since the profile is drawn in 7) after clearing the displayed_dive and before constructing the initial plan, the profile is shown on a dive without samples. It therefore generates a dummy profile. To make this somewhat less insane, remove the startTimeChanged() signal in 3), explicitly set the start time of plan and dive to the one calculated by setupStartTime() and explicitly set the UI filed in the plannerWidget. This still indirectly draws the profile via signals in a convoluted way, but at it straightens out things somewhat. Most importantly, the profile doesn't have to generate a fake DC. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
de220c2da0
commit
764aa6c512
3 changed files with 5 additions and 6 deletions
|
@ -72,7 +72,6 @@ DivePlannerWidget::DivePlannerWidget(QWidget *parent) : QWidget(parent, QFlag(0)
|
|||
connect(ui.atmHeight, QOverload<int>::of(&QSpinBox::valueChanged), this, &DivePlannerWidget::heightChanged);
|
||||
connect(ui.waterType, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &DivePlannerWidget::waterTypeChanged);
|
||||
connect(ui.customSalinity, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this, &DivePlannerWidget::customSalinityChanged);
|
||||
connect(plannerModel, &DivePlannerPointsModel::startTimeChanged, this, &DivePlannerWidget::setupStartTime);
|
||||
|
||||
// Creating (and canceling) the plan
|
||||
replanButton = ui.buttonBox->addButton(tr("Save new"), QDialogButtonBox::ActionRole);
|
||||
|
@ -564,6 +563,8 @@ void PlannerWidgets::planDive()
|
|||
plannerWidget.setSalinity(SEAWATER_SALINITY);
|
||||
}
|
||||
plannerWidget.setReplanButton(false);
|
||||
|
||||
plannerWidget.setupStartTime(timestampToDateTime(displayed_dive.when)); // This will reload the profile!
|
||||
}
|
||||
|
||||
void PlannerWidgets::replanDive()
|
||||
|
|
|
@ -58,13 +58,14 @@ void DivePlannerPointsModel::createSimpleDive()
|
|||
setupStartTime();
|
||||
|
||||
// initialize the start time in the plan
|
||||
diveplan.when = displayed_dive.when;
|
||||
diveplan.when = dateTimeToTimestamp(startTime);
|
||||
displayed_dive.when = diveplan.when;
|
||||
|
||||
// Use gas from the first cylinder
|
||||
int cylinderid = 0;
|
||||
|
||||
// If we're in drop_stone_mode, don't add a first point.
|
||||
// It will be added implicit.
|
||||
// It will be added implicitly.
|
||||
if (!prefs.drop_stone_mode)
|
||||
addStop(M_OR_FT(15, 45), 1 * 60, cylinderid, 0, true, UNDEF_COMP_TYPE);
|
||||
|
||||
|
@ -91,7 +92,6 @@ void DivePlannerPointsModel::setupStartTime()
|
|||
startTime = startTime.addSecs(diff + 3600);
|
||||
}
|
||||
}
|
||||
emit startTimeChanged(startTime);
|
||||
}
|
||||
|
||||
void DivePlannerPointsModel::loadFromDive(dive *d)
|
||||
|
@ -737,7 +737,6 @@ void DivePlannerPointsModel::setStartTime(const QTime &t)
|
|||
emitDataChanged();
|
||||
}
|
||||
|
||||
|
||||
bool divePointsLessThan(const divedatapoint &p1, const divedatapoint &p2)
|
||||
{
|
||||
return p1.time < p2.time;
|
||||
|
|
|
@ -116,7 +116,6 @@ signals:
|
|||
void planCreated();
|
||||
void planCanceled();
|
||||
void cylinderModelEdited();
|
||||
void startTimeChanged(QDateTime);
|
||||
void recreationChanged(bool);
|
||||
void calculatedPlanNotes(QString);
|
||||
void variationsComputed(QString);
|
||||
|
|
Loading…
Add table
Reference in a new issue