summaryrefslogtreecommitdiffstats
path: root/qt-ui
diff options
context:
space:
mode:
authorGravatar Robert C. Helling <helling@atdotde.de>2014-11-04 12:15:27 +0100
committerGravatar Dirk Hohndel <dirk@hohndel.org>2014-11-04 07:21:34 -0800
commit20a9db779d3a7ba1591e8d336c6b99b80aef71de (patch)
tree9fa678ed3da32dc3b0e6006c11c78eb4a272adcf /qt-ui
parent06ddfc01222879ee0463affe796dba05de33b368 (diff)
downloadsubsurface-20a9db779d3a7ba1591e8d336c6b99b80aef71de.tar.gz
Offer to save to a copy in replan mode
When replannig a dive, offer another button that creates a new dive rather than overwriting the old. This should help in creating several versions of a planned dive (longer/shorter, deeper/shallower etc). Note that this makes dives that start at the same time not influcence each other's deco. Also, only the first of a row of simultaneous dives contributes to the tissue loadings of later dives. Signed-off-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui')
-rw-r--r--qt-ui/diveplanner.cpp30
-rw-r--r--qt-ui/diveplanner.h7
-rw-r--r--qt-ui/diveplanner.ui26
-rw-r--r--qt-ui/mainwindow.cpp2
4 files changed, 60 insertions, 5 deletions
diff --git a/qt-ui/diveplanner.cpp b/qt-ui/diveplanner.cpp
index 4a299ca98..839c9d080 100644
--- a/qt-ui/diveplanner.cpp
+++ b/qt-ui/diveplanner.cpp
@@ -300,7 +300,9 @@ DivePlannerWidget::DivePlannerWidget(QWidget *parent, Qt::WindowFlags f) : QWidg
connect(DivePlannerPointsModel::instance(), SIGNAL(startTimeChanged(QDateTime)), this, SLOT(setupStartTime(QDateTime)));
// Creating (and canceling) the plan
- connect(ui.buttonBox, SIGNAL(accepted()), plannerModel, SLOT(createPlan()));
+ replanButton = ui.buttonBox->addButton(tr("Save New"), QDialogButtonBox::ActionRole);
+ connect(replanButton, SIGNAL(clicked()), plannerModel, SLOT(saveDuplicatePlan()));
+ connect(ui.buttonBox, SIGNAL(accepted()), plannerModel, SLOT(savePlan()));
connect(ui.buttonBox, SIGNAL(rejected()), plannerModel, SLOT(cancelPlan()));
QShortcut *closeKey = new QShortcut(QKeySequence(Qt::Key_Escape), this);
connect(closeKey, SIGNAL(activated()), plannerModel, SLOT(cancelPlan()));
@@ -319,6 +321,11 @@ DivePlannerWidget::DivePlannerWidget(QWidget *parent, Qt::WindowFlags f) : QWidg
setMinimumHeight(0);
}
+void DivePlannerWidget::setReplanButton(bool replan)
+{
+ replanButton->setVisible(replan);
+}
+
void DivePlannerWidget::setupStartTime(QDateTime startTime)
{
ui.startTime->setTime(startTime.time());
@@ -1168,7 +1175,17 @@ void DivePlannerPointsModel::deleteTemporaryPlan()
free_dps(&diveplan);
}
-void DivePlannerPointsModel::createPlan()
+void DivePlannerPointsModel::savePlan()
+{
+ createPlan(false);
+}
+
+void DivePlannerPointsModel::saveDuplicatePlan()
+{
+ createPlan(true);
+}
+
+void DivePlannerPointsModel::createPlan(bool replanCopy)
{
// Ok, so, here the diveplan creates a dive
char *cache = NULL;
@@ -1188,6 +1205,15 @@ void DivePlannerPointsModel::createPlan()
displayed_dive.maxdepth.mm = 0;
displayed_dive.dc.maxdepth.mm = 0;
fixup_dive(&displayed_dive);
+ if (replanCopy) {
+ struct dive *copy = alloc_dive();
+ copy_dive(current_dive, copy);
+ copy->id = 0;
+ copy->divetrip = NULL;
+ if (current_dive->divetrip)
+ add_dive_to_trip(copy, current_dive->divetrip);
+ record_dive(copy);
+ }
copy_dive(&displayed_dive, current_dive);
}
mark_divelist_changed(true);
diff --git a/qt-ui/diveplanner.h b/qt-ui/diveplanner.h
index da2f6526b..c613ae210 100644
--- a/qt-ui/diveplanner.h
+++ b/qt-ui/diveplanner.h
@@ -3,6 +3,7 @@
#include <QGraphicsPathItem>
#include <QAbstractTableModel>
+#include <QAbstractButton>
#include <QDateTime>
#include "dive.h"
@@ -80,7 +81,8 @@ slots:
void setDisplayRuntime(bool value);
void setDisplayDuration(bool value);
void setDisplayTransitions(bool value);
- void createPlan();
+ void savePlan();
+ void saveDuplicatePlan();
void remove(const QModelIndex &index);
void cancelPlan();
void createTemporaryPlan();
@@ -97,6 +99,7 @@ signals:
private:
explicit DivePlannerPointsModel(QObject *parent = 0);
bool addGas(struct gasmix mix);
+ void createPlan(bool replanCopy);
struct diveplan diveplan;
Mode mode;
bool recalc;
@@ -136,6 +139,7 @@ class DivePlannerWidget : public QWidget {
Q_OBJECT
public:
explicit DivePlannerWidget(QWidget *parent = 0, Qt::WindowFlags f = 0);
+ void setReplanButton(bool replan);
public
slots:
void setupStartTime(QDateTime startTime);
@@ -146,6 +150,7 @@ slots:
private:
Ui::DivePlanner ui;
+ QAbstractButton *replanButton;
};
#include "ui_plannerSettings.h"
diff --git a/qt-ui/diveplanner.ui b/qt-ui/diveplanner.ui
index b640d88dc..54abcc35a 100644
--- a/qt-ui/diveplanner.ui
+++ b/qt-ui/diveplanner.ui
@@ -100,7 +100,10 @@
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="sizePolicy">
- <sizepolicy hsizetype="Expanding" vsizetype="Preferred"/>
+ <sizepolicy hsizetype="Expanding" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
</property>
<property name="text">
<string>Planned dive time</string>
@@ -109,6 +112,12 @@
</item>
<item row="1" column="1">
<widget class="QDialogButtonBox" name="buttonBox">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Save</set>
</property>
@@ -118,13 +127,26 @@
<layout class="QHBoxLayout" name="dateAndTime">
<item>
<widget class="QDateEdit" name="dateEdit">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
<property name="calendarPopup">
<bool>true</bool>
</property>
</widget>
</item>
<item>
- <widget class="QTimeEdit" name="startTime"/>
+ <widget class="QTimeEdit" name="startTime">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ </widget>
</item>
</layout>
</item>
diff --git a/qt-ui/mainwindow.cpp b/qt-ui/mainwindow.cpp
index cc2d9704e..8a72bc898 100644
--- a/qt-ui/mainwindow.cpp
+++ b/qt-ui/mainwindow.cpp
@@ -466,6 +466,7 @@ void MainWindow::on_actionReplanDive_triggered()
ui.newProfile->setPlanState();
ui.newProfile->clearHandlers();
ui.infoPane->setCurrentIndex(PLANNERWIDGET);
+ ui.divePlannerWidget->setReplanButton(true);
DivePlannerPointsModel::instance()->loadFromDive(current_dive);
reset_cylinders(&displayed_dive, true);
ui.diveListPane->setCurrentIndex(1); // switch to the plan output
@@ -491,6 +492,7 @@ void MainWindow::on_actionDivePlanner_triggered()
DivePlannerPointsModel::instance()->setupStartTime();
DivePlannerPointsModel::instance()->createSimpleDive();
DivePictureModel::instance()->updateDivePictures();
+ ui.divePlannerWidget->setReplanButton(false);
ui.diveListPane->setCurrentIndex(1); // switch to the plan output
ui.globePane->setCurrentIndex(1);