aboutsummaryrefslogtreecommitdiffstats
path: root/qt-ui/mainwindow.cpp
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2014-07-03 14:45:01 -0700
committerGravatar Dirk Hohndel <dirk@hohndel.org>2014-07-03 14:45:01 -0700
commit611bae344111845bfa8bd676c0fad49d1c051c10 (patch)
tree6500f730170eb455fcceeacdc900316a44682f24 /qt-ui/mainwindow.cpp
parentd8c31135848d765a3d241d295e5d6afc311f7820 (diff)
downloadsubsurface-611bae344111845bfa8bd676c0fad49d1c051c10.tar.gz
UI restructure: use displayed_dive for add dive and plan dive
This gets rid of the stagingDive and stops the constant adding and removing of dives from the divelist (that was an INSANE design, seriously). When adding or planning a dive all work is now done in the dedicated displayed_dive. Add dive mostly works - when the user clicks save the dive is added to the dive list and selected. Plan dive is mostly untested. It passed trivial "start planner, save" testing so it's not entirely broken, but I'm sure there's more work to be done there. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui/mainwindow.cpp')
-rw-r--r--qt-ui/mainwindow.cpp47
1 files changed, 23 insertions, 24 deletions
diff --git a/qt-ui/mainwindow.cpp b/qt-ui/mainwindow.cpp
index 04f94671b..0eb753203 100644
--- a/qt-ui/mainwindow.cpp
+++ b/qt-ui/mainwindow.cpp
@@ -63,7 +63,6 @@ MainWindow::MainWindow() : QMainWindow(),
yearlyStatsModel(0),
state(VIEWALL),
updateManager(0),
- fakeDiveId(0),
survey(0)
{
Q_ASSERT_X(m_Instance == NULL, "MainWindow", "MainWindow recreated!");
@@ -392,48 +391,38 @@ bool MainWindow::plannerStateClean()
return true;
}
+// setup displayed_dive so we can start planning with it
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();
- fakeDiveId = dive->id;
- dive->when = QDateTime::currentMSecsSinceEpoch() / 1000L + gettimezoneoffset();
- dive->dc.model = "manually added dive"; // don't translate! this is stored in the XML file
+ clear_dive(&displayed_dive);
+ displayed_dive.when = QDateTime::currentMSecsSinceEpoch() / 1000L + gettimezoneoffset() + 3600;
+ displayed_dive.dc.model = "manually added dive"; // don't translate! this is stored in the XML file
+ // now show the mostly empty main tab
+ ui.InfoWidget->updateDiveInfo();
- dive->latitude.udeg = 0;
- dive->longitude.udeg = 0;
- record_dive(dive);
+#if 0 // don't want to do any of this, I think
// select this new dive (but remember the old selection
ui.ListWidget->rememberSelection();
ui.ListWidget->unselectDives();
ui.ListWidget->reload(DiveTripModel::CURRENT);
ui.ListWidget->selectDives(QList<int>() << dive_table.nr - 1);
ui.InfoWidget->updateDiveInfo();
-}
-
-void MainWindow::removeFakeDiveForAddAndPlan()
-{
- int idx;
-
- if (!fakeDiveId ||
- (idx = get_idx_by_uniq_id(fakeDiveId)) == dive_table.nr)
- return;
- delete_single_dive(idx);
+ showProfile();
+#endif
}
void MainWindow::planCanceled()
{
- removeFakeDiveForAddAndPlan();
showProfile();
+#if 0 // shouldn't need this
ui.ListWidget->reload(DiveTripModel::CURRENT);
ui.ListWidget->restoreSelection();
+#endif
refreshDisplay();
}
void MainWindow::planCreated()
{
- removeFakeDiveForAddAndPlan();
showProfile();
refreshDisplay();
}
@@ -501,16 +490,26 @@ void MainWindow::on_actionAddDive_triggered()
ui.ListWidget->endSearch();
DivePlannerPointsModel::instance()->setPlanMode(DivePlannerPointsModel::ADD);
- createFakeDiveForAddAndPlan();
+ clear_dive(&displayed_dive);
+ displayed_dive.when = QDateTime::currentMSecsSinceEpoch() / 1000L + gettimezoneoffset() + 3600;
+ displayed_dive.dc.model = "manually added dive"; // don't translate! this is stored in the XML file
+
+ // setup the dive cylinders
+ DivePlannerPointsModel::instance()->setupCylinders();
+
+ // now show the mostly empty main tab
+ ui.InfoWidget->updateDiveInfo();
+ // show main tab
ui.InfoWidget->setCurrentIndex(0);
+
ui.InfoWidget->addDiveStarted();
ui.infoPane->setCurrentIndex(MAINTAB);
ui.newProfile->setAddState();
DivePlannerPointsModel::instance()->clear();
DivePlannerPointsModel::instance()->createSimpleDive();
- ui.ListWidget->reload(DiveTripModel::CURRENT);
+ ui.newProfile->plotDive();
}
void MainWindow::on_actionRenumber_triggered()