From a9703628c4c4d3b1226d4ea86b3079718940e14e Mon Sep 17 00:00:00 2001 From: "Robert C. Helling" Date: Mon, 27 Nov 2017 17:36:21 +0100 Subject: Actually compute variations in background This reenables the computation of plan variations but now in a separate thread. Once finieshed, a signal is sent to update the notes. Signed-off-by: Robert C. Helling --- desktop-widgets/mainwindow.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'desktop-widgets/mainwindow.cpp') diff --git a/desktop-widgets/mainwindow.cpp b/desktop-widgets/mainwindow.cpp index 6d4c36dc1..12592ece0 100644 --- a/desktop-widgets/mainwindow.cpp +++ b/desktop-widgets/mainwindow.cpp @@ -212,6 +212,7 @@ MainWindow::MainWindow() : QMainWindow(), connect(information(), SIGNAL(dateTimeChanged()), graphics(), SLOT(dateTimeChanged())); connect(DivePlannerPointsModel::instance(), SIGNAL(planCreated()), this, SLOT(planCreated())); connect(DivePlannerPointsModel::instance(), SIGNAL(planCanceled()), this, SLOT(planCanceled())); + connect(DivePlannerPointsModel::instance(), SIGNAL(variationsComputed(QString)), this, SLOT(updateVariations(QString))); connect(plannerDetails->printPlan(), SIGNAL(pressed()), divePlannerWidget(), SLOT(printDecoPlan())); connect(this, SIGNAL(startDiveSiteEdit()), this, SLOT(on_actionDiveSiteEdit_triggered())); connect(information(), SIGNAL(diveSiteChanged(struct dive_site *)), mapWidget, SLOT(centerOnDiveSite(struct dive_site *))); @@ -445,7 +446,6 @@ void MainWindow::enableDisableCloudActions() PlannerDetails *MainWindow::plannerDetails() const { return qobject_cast(applicationState["PlanDive"].bottomRight); } - PlannerSettingsWidget *MainWindow::divePlannerSettingsWidget() { return qobject_cast(applicationState["PlanDive"].bottomLeft); } @@ -899,6 +899,14 @@ void MainWindow::setPlanNotes() plannerDetails()->divePlanOutput()->setHtml(displayed_dive.notes); } +void MainWindow::updateVariations(QString variations) +{ + QString notes = QString(displayed_dive.notes); + free(displayed_dive.notes); + displayed_dive.notes = strdup(notes.replace("VARIATIONS", variations).toUtf8().data()); + plannerDetails()->divePlanOutput()->setHtml(displayed_dive.notes); +} + void MainWindow::printPlan() { #ifndef NO_PRINTING -- cgit v1.2.3-70-g09d2