mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
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>
This commit is contained in:
parent
58d5d5ca41
commit
9b9abd5f2a
2 changed files with 21 additions and 12 deletions
|
@ -20,6 +20,7 @@
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
#include <QShortcut>
|
#include <QShortcut>
|
||||||
|
#include <fcntl.h>
|
||||||
#include "divelistview.h"
|
#include "divelistview.h"
|
||||||
#include "starwidget.h"
|
#include "starwidget.h"
|
||||||
|
|
||||||
|
@ -365,6 +366,24 @@ bool MainWindow::plannerStateClean()
|
||||||
return true;
|
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()
|
void MainWindow::on_actionDivePlanner_triggered()
|
||||||
{
|
{
|
||||||
if (!plannerStateClean())
|
if (!plannerStateClean())
|
||||||
|
@ -396,20 +415,9 @@ void MainWindow::on_actionAddDive_triggered()
|
||||||
dive_list()->unselectDives();
|
dive_list()->unselectDives();
|
||||||
DivePlannerPointsModel::instance()->setPlanMode(DivePlannerPointsModel::ADD);
|
DivePlannerPointsModel::instance()->setPlanMode(DivePlannerPointsModel::ADD);
|
||||||
|
|
||||||
// now cheat - create one dive that we use to store the info tab data in
|
createFakeDiveForAddAndPlan();
|
||||||
//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->setCurrentIndex(0);
|
ui.InfoWidget->setCurrentIndex(0);
|
||||||
ui.InfoWidget->updateDiveInfo(selected_dive);
|
|
||||||
ui.InfoWidget->addDiveStarted();
|
ui.InfoWidget->addDiveStarted();
|
||||||
ui.infoPane->setCurrentIndex(MAINTAB);
|
ui.infoPane->setCurrentIndex(MAINTAB);
|
||||||
|
|
||||||
|
|
|
@ -174,6 +174,7 @@ private:
|
||||||
UpdateManager *updateManager;
|
UpdateManager *updateManager;
|
||||||
|
|
||||||
bool plannerStateClean();
|
bool plannerStateClean();
|
||||||
|
void createFakeDiveForAddAndPlan();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // MAINWINDOW_H
|
#endif // MAINWINDOW_H
|
||||||
|
|
Loading…
Add table
Reference in a new issue