From 9b9abd5f2a93b6155df6663b4b1577408e1acc56 Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Sun, 25 May 2014 15:56:39 -0300 Subject: Created a function to create a fake dive for Add and Plan states. This function should likely to move to C in the future, I'm only adding this here because I'm changing this file so much ( already 4 rewrites of the function ) Signed-off-by: Tomaz Canabrava Signed-off-by: Dirk Hohndel --- qt-ui/mainwindow.cpp | 32 ++++++++++++++++++++------------ qt-ui/mainwindow.h | 1 + 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/qt-ui/mainwindow.cpp b/qt-ui/mainwindow.cpp index 1062e43d8..827401a58 100644 --- a/qt-ui/mainwindow.cpp +++ b/qt-ui/mainwindow.cpp @@ -20,6 +20,7 @@ #include #include #include +#include #include "divelistview.h" #include "starwidget.h" @@ -365,6 +366,24 @@ bool MainWindow::plannerStateClean() return true; } +void MainWindow::createFakeDiveForAddAndPlan() +{ + // now cheat - create one dive that we use to store the info tab data in + //TODO: C-function create_temporary_dive ? + struct dive *dive = alloc_dive(); + dive->when = QDateTime::currentMSecsSinceEpoch() / 1000L + gettimezoneoffset(); + dive->dc.model = "manually added dive"; // don't translate! this is stored in the XML file + + dive->latitude.udeg = 0; + dive->longitude.udeg = 0; + record_dive(dive); + // this isn't in the UI yet, so let's call the C helper function - we'll fix this up when + // accepting the dive + select_dive(get_divenr(dive)); + ui.InfoWidget->updateDiveInfo(selected_dive); +} + + void MainWindow::on_actionDivePlanner_triggered() { if (!plannerStateClean()) @@ -396,20 +415,9 @@ void MainWindow::on_actionAddDive_triggered() dive_list()->unselectDives(); DivePlannerPointsModel::instance()->setPlanMode(DivePlannerPointsModel::ADD); - // now cheat - create one dive that we use to store the info tab data in - //TODO: C-function create_temporary_dive ? - struct dive *dive = alloc_dive(); - dive->when = QDateTime::currentMSecsSinceEpoch() / 1000L + gettimezoneoffset(); - dive->dc.model = "manually added dive"; // don't translate! this is stored in the XML file + createFakeDiveForAddAndPlan(); - dive->latitude.udeg = 0; - dive->longitude.udeg = 0; - record_dive(dive); - // this isn't in the UI yet, so let's call the C helper function - we'll fix this up when - // accepting the dive - select_dive(get_divenr(dive)); ui.InfoWidget->setCurrentIndex(0); - ui.InfoWidget->updateDiveInfo(selected_dive); ui.InfoWidget->addDiveStarted(); ui.infoPane->setCurrentIndex(MAINTAB); diff --git a/qt-ui/mainwindow.h b/qt-ui/mainwindow.h index 667e3810a..8bb62b933 100644 --- a/qt-ui/mainwindow.h +++ b/qt-ui/mainwindow.h @@ -174,6 +174,7 @@ private: UpdateManager *updateManager; bool plannerStateClean(); + void createFakeDiveForAddAndPlan(); }; #endif // MAINWINDOW_H -- cgit v1.2.3-70-g09d2