summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--qt-ui/diveplanner.cpp5
-rw-r--r--qt-ui/diveplanner.h1
-rw-r--r--qt-ui/mainwindow.cpp9
-rw-r--r--qt-ui/models.cpp17
-rw-r--r--qt-ui/models.h1
5 files changed, 33 insertions, 0 deletions
diff --git a/qt-ui/diveplanner.cpp b/qt-ui/diveplanner.cpp
index cef6610ac..b45b4e07b 100644
--- a/qt-ui/diveplanner.cpp
+++ b/qt-ui/diveplanner.cpp
@@ -436,6 +436,11 @@ void DivePlannerPointsModel::copyCylinders(dive *d)
copy_cylinders(stagingDive, d);
}
+void DivePlannerPointsModel::copyCylindersFrom(dive *d)
+{
+ copy_cylinders(d, stagingDive);
+}
+
QStringList &DivePlannerPointsModel::getGasList()
{
struct dive *activeDive = isPlanner() ? stagingDive : current_dive;
diff --git a/qt-ui/diveplanner.h b/qt-ui/diveplanner.h
index 85b585537..506953275 100644
--- a/qt-ui/diveplanner.h
+++ b/qt-ui/diveplanner.h
@@ -48,6 +48,7 @@ public:
void rememberTanks();
bool tankInUse(int o2, int he);
void copyCylinders(struct dive *d);
+ void copyCylindersFrom(struct dive *d);
/**
* @return the row number.
*/
diff --git a/qt-ui/mainwindow.cpp b/qt-ui/mainwindow.cpp
index fb5e3af8e..769f486de 100644
--- a/qt-ui/mainwindow.cpp
+++ b/qt-ui/mainwindow.cpp
@@ -325,6 +325,8 @@ void MainWindow::enableDcShortcuts()
void MainWindow::on_actionDivePlanner_triggered()
{
+ int i;
+ struct dive *dive;
if (DivePlannerPointsModel::instance()->currentMode() != DivePlannerPointsModel::NOTHING ||
ui.InfoWidget->isEditing()) {
QMessageBox::warning(this, tr("Warning"), tr("Please save or cancel the current dive edit before trying to plan a dive."));
@@ -334,6 +336,13 @@ void MainWindow::on_actionDivePlanner_triggered()
DivePlannerPointsModel::instance()->setPlanMode(DivePlannerPointsModel::PLAN);
DivePlannerPointsModel::instance()->clear();
CylindersModel::instance()->clear();
+ for_each_dive(i,dive) {
+ if(dive->selected){
+ DivePlannerPointsModel::instance()->copyCylindersFrom(dive);
+ CylindersModel::instance()->copyFromDive(dive);
+ break;
+ }
+ }
ui.stackedWidget->setCurrentIndex(PLANNERPROFILE);
ui.infoPane->setCurrentIndex(PLANNERWIDGET);
}
diff --git a/qt-ui/models.cpp b/qt-ui/models.cpp
index 0564add12..43f08e106 100644
--- a/qt-ui/models.cpp
+++ b/qt-ui/models.cpp
@@ -332,6 +332,23 @@ void CylindersModel::setDive(dive *d)
}
}
+void CylindersModel::copyFromDive(dive *d)
+{
+ if (!d)
+ return;
+ rows = 0;
+ for (int i = 0; i < MAX_CYLINDERS; i++) {
+ if (!cylinder_none(&d->cylinder[i]) &&
+ (prefs.display_unused_tanks || d->cylinder[i].used)) {
+ rows = i + 1;
+ }
+ }
+ if (rows > 0) {
+ beginInsertRows(QModelIndex(), 0, rows - 1);
+ endInsertRows();
+ }
+}
+
Qt::ItemFlags CylindersModel::flags(const QModelIndex &index) const
{
if (index.column() == REMOVE)
diff --git a/qt-ui/models.h b/qt-ui/models.h
index 14969f8f4..d638e7de3 100644
--- a/qt-ui/models.h
+++ b/qt-ui/models.h
@@ -120,6 +120,7 @@ public:
void clear();
void update();
void setDive(struct dive *d);
+ void copyFromDive(struct dive *d);
cylinder_t *cylinderAt(const QModelIndex &index);
bool changed;