summaryrefslogtreecommitdiffstats
path: root/qt-ui/maintab.cpp
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2013-09-19 23:02:50 -0500
committerGravatar Dirk Hohndel <dirk@hohndel.org>2013-09-19 23:05:17 -0500
commit46c23c53a12485e3e59e8d52bf9ba6943bdfc200 (patch)
tree4292ce1dcf5ad7f908572dd20138db558a465dba /qt-ui/maintab.cpp
parent169d9e9c015efa779ec67abdfb27ca6c462c3d63 (diff)
parent6881f527390ed7e386fee60176c9b8bba9bfb316 (diff)
downloadsubsurface-46c23c53a12485e3e59e8d52bf9ba6943bdfc200.tar.gz
Merge branch 'addDive'
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui/maintab.cpp')
-rw-r--r--qt-ui/maintab.cpp29
1 files changed, 26 insertions, 3 deletions
diff --git a/qt-ui/maintab.cpp b/qt-ui/maintab.cpp
index 7c933931d..d35fefcf9 100644
--- a/qt-ui/maintab.cpp
+++ b/qt-ui/maintab.cpp
@@ -14,6 +14,7 @@
#include "modeldelegates.h"
#include "globe.h"
#include "completionmodels.h"
+#include "diveplanner.h"
#include <QLabel>
#include <QCompleter>
@@ -90,9 +91,15 @@ MainTab::MainTab(QWidget *parent) : QTabWidget(parent),
ui->suit->setCompleter(completers.suit);
}
+void MainTab::addDiveStarted()
+{
+ enableEdition();
+ editMode = ADD;
+}
+
void MainTab::enableEdition()
{
- if (!selected_dive)
+ if (selected_dive < 0 || editMode != NONE)
return;
mainWindow()->dive_list()->setEnabled(false);
@@ -306,6 +313,7 @@ void MainTab::updateDiveInfo(int dive)
} else {
/* clear the fields */
ui->rating->setCurrentStars(0);
+ ui->coordinates->clear();
ui->sacText->clear();
ui->otuText->clear();
ui->oxygenHeliumText->clear();
@@ -387,6 +395,13 @@ void MainTab::acceptChanges()
mainWindow()->globe()->centerOn(current_dive);
}
}
+ if (editMode == ADD) {
+ // clean up the dive data (get duration, depth information from samples)
+ fixup_dive(current_dive);
+ DivePlannerPointsModel::instance()->cancelPlan();
+ mainWindow()->showProfile();
+ mainWindow()->refreshDisplay();
+ }
editMode = NONE;
QPalette p;
@@ -462,6 +477,14 @@ void MainTab::rejectChanges()
ui->coordinates->setPalette(p);
ui->divemaster->setPalette(p);
ui->suit->setPalette(p);
+ if (editMode == ADD) {
+ // clean up
+ delete_single_dive(selected_dive);
+ selected_dive = -1;
+ DivePlannerPointsModel::instance()->cancelPlan();
+ mainWindow()->showProfile();
+ mainWindow()->refreshDisplay();
+ }
editMode = NONE;
}
#undef EDIT_TEXT2
@@ -507,7 +530,7 @@ void MainTab::on_location_textChanged(const QString& text)
// we are editing a trip
dive_trip_t *currentTrip = *mainWindow()->dive_list()->selectedTrips.begin();
EDIT_TEXT(currentTrip->location, text);
- } else if (editMode == DIVE){
+ } else if (editMode == DIVE || editMode == ADD){
if (!ui->coordinates->isModified() ||
ui->coordinates->text().trimmed().isEmpty()) {
struct dive* dive;
@@ -547,7 +570,7 @@ void MainTab::on_notes_textChanged()
// we are editing a trip
dive_trip_t *currentTrip = *mainWindow()->dive_list()->selectedTrips.begin();
EDIT_TEXT(currentTrip->notes, ui->notes->toPlainText());
- } else if (editMode == DIVE) {
+ } else if (editMode == DIVE || editMode == ADD) {
EDIT_SELECTED_DIVES( EDIT_TEXT(mydive->notes, ui->notes->toPlainText()) );
}
markChangedWidget(ui->notes);