summaryrefslogtreecommitdiffstats
path: root/qt-ui
diff options
context:
space:
mode:
authorGravatar Tomaz Canabrava <tomaz.canabrava@intel.com>2014-05-25 15:56:39 -0300
committerGravatar Dirk Hohndel <dirk@hohndel.org>2014-05-26 13:18:37 -0700
commit9b9abd5f2a93b6155df6663b4b1577408e1acc56 (patch)
tree35a209453f3a22aa4e34af10c37489aa70b44f2c /qt-ui
parent58d5d5ca412287a4be65e27e2a774ba7731b7098 (diff)
downloadsubsurface-9b9abd5f2a93b6155df6663b4b1577408e1acc56.tar.gz
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 <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui')
-rw-r--r--qt-ui/mainwindow.cpp32
-rw-r--r--qt-ui/mainwindow.h1
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 <QStringList>
#include <QSettings>
#include <QShortcut>
+#include <fcntl.h>
#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