aboutsummaryrefslogtreecommitdiffstats
path: root/desktop-widgets
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2021-01-28 14:24:38 +0100
committerGravatar Dirk Hohndel <dirk@hohndel.org>2021-04-02 13:53:23 -0700
commit2789bb05b133a7cf54081d58d4f5c51c8977e951 (patch)
tree48bb6337c24dcd87bd3d8fcf0ac545f544d11744 /desktop-widgets
parent36f0ba9abed595885edf52c8db848da71fa30b11 (diff)
downloadsubsurface-2789bb05b133a7cf54081d58d4f5c51c8977e951.tar.gz
profile: display arbitrary dive
So far the profile operated on the global displayed_dive. Instead, take the dive to be displayed as a parameter to the plotDive() functions. This is necessary if we want to have multiple concurrent profile objects. Think for example for printing or for mobile where multiple dive objects are active at the same time. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'desktop-widgets')
-rw-r--r--desktop-widgets/divelogexportdialog.cpp4
-rw-r--r--desktop-widgets/diveplanner.cpp4
-rw-r--r--desktop-widgets/mainwindow.cpp12
-rw-r--r--desktop-widgets/printer.cpp4
-rw-r--r--desktop-widgets/tab-widgets/maintab.cpp5
5 files changed, 12 insertions, 17 deletions
diff --git a/desktop-widgets/divelogexportdialog.cpp b/desktop-widgets/divelogexportdialog.cpp
index e9a4beb4e..30e389dde 100644
--- a/desktop-widgets/divelogexportdialog.cpp
+++ b/desktop-widgets/divelogexportdialog.cpp
@@ -229,7 +229,7 @@ void exportProfile(const struct dive *dive, const QString filename)
profile->setPrintMode(true);
double scale = profile->getFontPrintScale();
profile->setFontPrintScale(4 * scale);
- profile->plotDive(dive, true, false, true);
+ profile->plotDive(dive, 0, true, false, true);
QImage image = QImage(profile->size() * 4, QImage::Format_RGB32);
QPainter paint;
paint.begin(&image);
@@ -238,5 +238,5 @@ void exportProfile(const struct dive *dive, const QString filename)
profile->setToolTipVisibile(true);
profile->setFontPrintScale(scale);
profile->setPrintMode(false);
- profile->plotDive(dive, true);
+ profile->plotDive(dive, 0, true); // TODO: Shouldn't this plot the current dive?
}
diff --git a/desktop-widgets/diveplanner.cpp b/desktop-widgets/diveplanner.cpp
index 94912cab6..e237097c5 100644
--- a/desktop-widgets/diveplanner.cpp
+++ b/desktop-widgets/diveplanner.cpp
@@ -541,7 +541,7 @@ void PlannerWidgets::planDive()
{
DivePlannerPointsModel::instance()->setPlanMode(DivePlannerPointsModel::PLAN);
- MainWindow::instance()->graphics->setPlanState();
+ MainWindow::instance()->graphics->setPlanState(&displayed_dive, 0);
dc_number = 0;
// create a simple starting dive, using the first gas from the just copied cylinders
@@ -569,7 +569,7 @@ void PlannerWidgets::replanDive()
DivePlannerPointsModel::instance()->setPlanMode(DivePlannerPointsModel::PLAN);
DivePlannerPointsModel::instance()->loadFromDive(&displayed_dive);
- MainWindow::instance()->graphics->setPlanState();
+ MainWindow::instance()->graphics->setPlanState(&displayed_dive, 0);
plannerWidget.setReplanButton(true);
plannerWidget.setupStartTime(timestampToDateTime(displayed_dive.when));
diff --git a/desktop-widgets/mainwindow.cpp b/desktop-widgets/mainwindow.cpp
index 425aaa30f..b6cae1e96 100644
--- a/desktop-widgets/mainwindow.cpp
+++ b/desktop-widgets/mainwindow.cpp
@@ -434,7 +434,7 @@ void MainWindow::selectionChanged()
configureToolbar();
enableDisableOtherDCsActions();
}
- graphics->plotDive(current_dive, false);
+ graphics->plotDive(current_dive, dc_number, false);
MapWidget::instance()->selectionChanged();
}
@@ -685,7 +685,7 @@ void MainWindow::enableShortcuts()
void MainWindow::showProfile()
{
enableShortcuts();
- graphics->setProfileState();
+ graphics->setProfileState(current_dive, dc_number);
setApplicationState(ApplicationState::Default);
}
@@ -738,7 +738,7 @@ void MainWindow::refreshProfile()
{
showProfile();
configureToolbar();
- graphics->plotDive(current_dive, true);
+ graphics->plotDive(current_dive, dc_number, true);
}
void MainWindow::planCanceled()
@@ -919,7 +919,7 @@ void MainWindow::on_actionPreviousDC_triggered()
unsigned nrdc = number_of_computers(current_dive);
dc_number = (dc_number + nrdc - 1) % nrdc;
configureToolbar();
- graphics->plotDive(current_dive, false);
+ graphics->plotDive(current_dive, dc_number, false);
mainTab->updateDiveInfo();
}
@@ -928,7 +928,7 @@ void MainWindow::on_actionNextDC_triggered()
unsigned nrdc = number_of_computers(current_dive);
dc_number = (dc_number + 1) % nrdc;
configureToolbar();
- graphics->plotDive(current_dive, false);
+ graphics->plotDive(current_dive, dc_number, false);
mainTab->updateDiveInfo();
}
@@ -1516,7 +1516,7 @@ void MainWindow::editCurrentDive()
disableShortcuts();
copy_dive(current_dive, &displayed_dive); // Work on a copy of the dive
DivePlannerPointsModel::instance()->setPlanMode(DivePlannerPointsModel::ADD);
- graphics->setAddState();
+ graphics->setAddState(&displayed_dive, 0);
setApplicationState(ApplicationState::EditDive);
DivePlannerPointsModel::instance()->loadFromDive(&displayed_dive);
mainTab->enableEdition();
diff --git a/desktop-widgets/printer.cpp b/desktop-widgets/printer.cpp
index 49135d79c..022db1a07 100644
--- a/desktop-widgets/printer.cpp
+++ b/desktop-widgets/printer.cpp
@@ -38,7 +38,7 @@ void Printer::putProfileImage(const QRect &profilePlaceholder, const QRect &view
int y = profilePlaceholder.y() - viewPort.y();
// use the placeHolder and the viewPort position to calculate the relative position of the dive profile.
QRect pos(x, y, profilePlaceholder.width(), profilePlaceholder.height());
- profile->plotDive(dive, true, true);
+ profile->plotDive(dive, 0, true, true);
if (!printOptions.color_selected) {
QImage image(pos.width(), pos.height(), QImage::Format_ARGB32);
@@ -193,7 +193,7 @@ void Printer::render(int pages)
qPrefDisplay::set_animation_speed(animationOriginal);
//replot the dive after returning the settings
- profile->plotDive(current_dive, true, true);
+ profile->plotDive(current_dive, dc_number, true, true);
}
//value: ranges from 0 : 100 and shows the progress of the templating engine
diff --git a/desktop-widgets/tab-widgets/maintab.cpp b/desktop-widgets/tab-widgets/maintab.cpp
index 0170cdb40..78784de46 100644
--- a/desktop-widgets/tab-widgets/maintab.cpp
+++ b/desktop-widgets/tab-widgets/maintab.cpp
@@ -541,11 +541,6 @@ void MainTab::rejectChanges()
// no harm done to call cancelPlan even if we were not PLAN mode...
DivePlannerPointsModel::instance()->cancelPlan();
- // now make sure that the correct dive is displayed
- if (current_dive)
- copy_dive(current_dive, &displayed_dive);
- else
- clear_dive(&displayed_dive);
updateDiveInfo();
// show the profile and dive info