From 882b2c146b2dfc164c1dd2fadf606e92c77addd8 Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Wed, 18 Sep 2013 21:33:53 -0500 Subject: Use Planner dialog to add dive Right now this is just calling the same code and setting a flag whether we are planning or adding a dive. Signed-off-by: Dirk Hohndel --- qt-ui/diveplanner.cpp | 10 ++++++++++ qt-ui/diveplanner.h | 14 +++++++++----- qt-ui/mainwindow.cpp | 14 +++++--------- 3 files changed, 24 insertions(+), 14 deletions(-) (limited to 'qt-ui') diff --git a/qt-ui/diveplanner.cpp b/qt-ui/diveplanner.cpp index ba578fed1..5356aa71f 100644 --- a/qt-ui/diveplanner.cpp +++ b/qt-ui/diveplanner.cpp @@ -894,6 +894,16 @@ void DivePlannerWidget::lastStopChanged(bool checked) plannerModel->setLastStop6m(checked); } +void DivePlannerPointsModel::setPlanMode(bool isPlan) +{ + mode = isPlan ? PLAN : ADD; +} + +bool DivePlannerPointsModel::isPlanner() +{ + return mode == PLAN; +} + int DivePlannerPointsModel::columnCount(const QModelIndex& parent) const { return COLUMNS; diff --git a/qt-ui/diveplanner.h b/qt-ui/diveplanner.h index 8dd8db3e3..2f7000a6d 100644 --- a/qt-ui/diveplanner.h +++ b/qt-ui/diveplanner.h @@ -29,9 +29,12 @@ public: virtual QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const; virtual int rowCount(const QModelIndex& parent = QModelIndex()) const; virtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const; - virtual bool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole); - virtual Qt::ItemFlags flags(const QModelIndex& index) const; + virtual bool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole); + virtual Qt::ItemFlags flags(const QModelIndex& index) const; void removeSelectedPoints(const QVector& rows); + enum Modes { PLAN, ADD }; + void setPlanMode(bool); + bool isPlanner(); /** * @return the row number. @@ -50,9 +53,9 @@ public slots: void setLastStop6m(bool value); void createPlan(); void remove(const QModelIndex& index); - void cancelPlan(); - void createTemporaryPlan(); - void deleteTemporaryPlan(); + void cancelPlan(); + void createTemporaryPlan(); + void deleteTemporaryPlan(); signals: void planCreated(); @@ -61,6 +64,7 @@ signals: private: explicit DivePlannerPointsModel(QObject* parent = 0); struct diveplan diveplan; + Modes mode; QVector divepoints; struct dive *tempDive; void deleteTemporaryPlan(struct divedatapoint *dp); diff --git a/qt-ui/mainwindow.cpp b/qt-ui/mainwindow.cpp index 8d6315d86..0b1f57ca9 100644 --- a/qt-ui/mainwindow.cpp +++ b/qt-ui/mainwindow.cpp @@ -209,6 +209,7 @@ void MainWindow::enableDcShortcuts() void MainWindow::on_actionDivePlanner_triggered() { disableDcShortcuts(); + DivePlannerPointsModel::instance()->setPlanMode(true); ui->stackedWidget->setCurrentIndex(1); ui->infoPane->setCurrentIndex(1); } @@ -254,15 +255,10 @@ void MainWindow::on_actionEditDeviceNames_triggered() void MainWindow::on_actionAddDive_triggered() { - struct dive *dive; - dive = alloc_dive(); - record_dive(dive); - process_dives(FALSE, FALSE); - - ui->InfoWidget->reload(); - ui->globe->reload(); - ui->ListWidget->reload(DiveTripModel::TREE); - ui->ListWidget->setFocus(); + disableDcShortcuts(); + DivePlannerPointsModel::instance()->setPlanMode(false); + ui->stackedWidget->setCurrentIndex(1); + ui->infoPane->setCurrentIndex(1); } void MainWindow::on_actionRenumber_triggered() -- cgit v1.2.3-70-g09d2 From 4141c68450bfceab8464aa1297d68a8258538ddd Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Wed, 18 Sep 2013 22:19:49 -0500 Subject: Rename createDecostops to drawProfile After all, that's what the function does. Signed-off-by: Dirk Hohndel --- qt-ui/diveplanner.cpp | 20 ++++++++++---------- qt-ui/diveplanner.h | 2 +- 2 files changed, 11 insertions(+), 11 deletions(-) (limited to 'qt-ui') diff --git a/qt-ui/diveplanner.cpp b/qt-ui/diveplanner.cpp index 5356aa71f..20dbabd68 100644 --- a/qt-ui/diveplanner.cpp +++ b/qt-ui/diveplanner.cpp @@ -164,7 +164,7 @@ DivePlannerGraphics::DivePlannerGraphics(QWidget* parent): QGraphicsView(parent) gasListView->hide(); connect(gasListView, SIGNAL(activated(QModelIndex)), this, SLOT(selectGas(QModelIndex))); - connect(plannerModel, SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(createDecoStops())); + connect(plannerModel, SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(drawProfile())); connect(plannerModel, SIGNAL(rowsInserted(const QModelIndex&,int,int)), this, SLOT(pointInserted(const QModelIndex&, int, int))); @@ -185,7 +185,7 @@ void DivePlannerGraphics::pointInserted(const QModelIndex& parent, int start , i connect(gasChooseBtn, SIGNAL(clicked()), this, SLOT(prepareSelectGas())); gases << gasChooseBtn; - createDecoStops(); + drawProfile(); } void DivePlannerGraphics::keyDownAction() @@ -219,7 +219,7 @@ void DivePlannerGraphics::keyUpAction() plannerModel->editStop(row, dp); } } - createDecoStops(); + drawProfile(); } void DivePlannerGraphics::keyLeftAction() @@ -303,7 +303,7 @@ void DivePlannerGraphics::pointsRemoved(const QModelIndex& , int start, int end) gases.pop_back(); } scene()->clearSelection(); - createDecoStops(); + drawProfile(); } bool intLessThan(int a, int b){ @@ -343,7 +343,7 @@ void DivePlannerGraphics::increaseDepth() return; depthLine->setMaximum( depthLine->maximum() + 10); depthLine->updateTicks(); - createDecoStops(); + drawProfile(); } void DivePlannerGraphics::increaseTime() @@ -351,7 +351,7 @@ void DivePlannerGraphics::increaseTime() minMinutes += 10; timeLine->setMaximum( minMinutes ); timeLine->updateTicks(); - createDecoStops(); + drawProfile(); } void DivePlannerGraphics::decreaseDepth() @@ -370,7 +370,7 @@ void DivePlannerGraphics::decreaseDepth() } depthLine->setMaximum(depthLine->maximum() - 10); depthLine->updateTicks(); - createDecoStops(); + drawProfile(); } void DivePlannerGraphics::decreaseTime() @@ -385,7 +385,7 @@ void DivePlannerGraphics::decreaseTime() minMinutes -= 10; timeLine->setMaximum(timeLine->maximum() -10); timeLine->updateTicks(); - createDecoStops(); + drawProfile(); } void DivePlannerGraphics::mouseDoubleClickEvent(QMouseEvent* event) @@ -415,7 +415,7 @@ void DivePlannerGraphics::selectGas(const QModelIndex& index) gasListView->hide(); } -void DivePlannerGraphics::createDecoStops() +void DivePlannerGraphics::drawProfile() { qDeleteAll(lines); lines.clear(); @@ -605,7 +605,7 @@ void DivePlannerGraphics::mouseReleaseEvent(QMouseEvent* event) activeDraggedHandler->setBrush(QBrush(Qt::white)); activeDraggedHandler->setPos(QPointF(xpos, ypos)); - createDecoStops(); + drawProfile(); activeDraggedHandler = 0; } } diff --git a/qt-ui/diveplanner.h b/qt-ui/diveplanner.h index 2f7000a6d..016fda332 100644 --- a/qt-ui/diveplanner.h +++ b/qt-ui/diveplanner.h @@ -147,7 +147,7 @@ private slots: void increaseDepth(); void decreaseTime(); void decreaseDepth();; - void createDecoStops(); + void drawProfile(); void prepareSelectGas(); void selectGas(const QModelIndex& index); void pointInserted(const QModelIndex&, int start, int end); -- cgit v1.2.3-70-g09d2 From 56535e4b3b9c2324f42674f385ee7bda2b9028eb Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Wed, 18 Sep 2013 22:40:34 -0500 Subject: Only calculate deco stops in planner mode In add dive mode simply bring the diver safely back to the surface (currently with a fixed ascent rate of 30ft/min (or 9m/min)). We should make that rate configurable (for the planner as well as the dive add function). Also, the dive add function should offer to automatically include a safety stop. Signed-off-by: Dirk Hohndel --- dive.h | 2 +- planner.c | 15 ++++++++++++++- planner.h | 2 +- qt-ui/diveplanner.cpp | 4 ++-- 4 files changed, 18 insertions(+), 5 deletions(-) (limited to 'qt-ui') diff --git a/dive.h b/dive.h index 53b2d0a98..ed0dd52fe 100644 --- a/dive.h +++ b/dive.h @@ -719,7 +719,7 @@ void free_dps(struct divedatapoint *dp); void get_gas_string(int o2, int he, char *buf, int len); struct divedatapoint *create_dp(int time_incr, int depth, int o2, int he, int po2); void dump_plan(struct diveplan *diveplan); -void plan(struct diveplan *diveplan, char **cached_datap, struct dive **divep, char **error_string_p); +void plan(struct diveplan *diveplan, char **cached_datap, struct dive **divep, bool add_deco, char **error_string_p); void delete_single_dive(int idx); struct event *get_next_event(struct event *event, char *name); diff --git a/planner.c b/planner.c index 7c77555ac..6ed7030c7 100644 --- a/planner.c +++ b/planner.c @@ -594,7 +594,7 @@ static void add_plan_to_notes(struct diveplan *diveplan, struct dive *dive) } #endif -void plan(struct diveplan *diveplan, char **cached_datap, struct dive **divep, char **error_string_p) +void plan(struct diveplan *diveplan, char **cached_datap, struct dive **divep, bool add_deco, char **error_string_p) { struct dive *dive; struct sample *sample; @@ -623,6 +623,19 @@ void plan(struct diveplan *diveplan, char **cached_datap, struct dive **divep, c get_gas_from_events(&dive->dc, sample->time.seconds, &o2, &he); po2 = dive->dc.sample[dive->dc.samples - 1].po2; depth = dive->dc.sample[dive->dc.samples - 1].depth.mm; + + /* if all we wanted was the dive just get us back to the surface */ + if (!add_deco) { + transitiontime = depth / 150; /* this still needs to be made configurable */ + plan_add_segment(diveplan, transitiontime, 0, o2, he, po2); + /* re-create the dive */ + delete_single_dive(dive_table.nr - 1); + *divep = dive = create_dive_from_plan(diveplan, error_string_p); + if (dive) + record_dive(dive); + return; + } + tissue_tolerance = tissue_at_end(dive, cached_datap, error_string_p); ceiling = deco_allowed_depth(tissue_tolerance, diveplan->surface_pressure / 1000.0, dive, 1); #if DEBUG_PLAN & 4 diff --git a/planner.h b/planner.h index d97a21fa7..fbff88ad8 100644 --- a/planner.h +++ b/planner.h @@ -6,7 +6,7 @@ extern "C" { #endif -extern void plan(struct diveplan *diveplan, char **cache_datap, struct dive **divep, char **error_string_p); +extern void plan(struct diveplan *diveplan, char **cache_datap, struct dive **divep, bool add_plan, char **error_string_p); extern int validate_gas(const char *text, int *o2_p, int *he_p); extern int validate_time(const char *text, int *sec_p, int *rel_p); extern int validate_depth(const char *text, int *mm_p); diff --git a/qt-ui/diveplanner.cpp b/qt-ui/diveplanner.cpp index 20dbabd68..d634aadf8 100644 --- a/qt-ui/diveplanner.cpp +++ b/qt-ui/diveplanner.cpp @@ -1148,7 +1148,7 @@ void DivePlannerPointsModel::createTemporaryPlan() char *cache = NULL; tempDive = NULL; char *errorString = NULL; - plan(&diveplan, &cache, &tempDive, &errorString); + plan(&diveplan, &cache, &tempDive, isPlanner(), &errorString); #if DEBUG_PLAN dump_plan(&diveplan); #endif @@ -1181,7 +1181,7 @@ void DivePlannerPointsModel::createPlan() char *errorString = NULL; createTemporaryPlan(); - plan(&diveplan, &cache, &tempDive, &errorString); + plan(&diveplan, &cache, &tempDive, isPlanner(), &errorString); mark_divelist_changed(TRUE); // Remove and clean the diveplan, so we don't delete -- cgit v1.2.3-70-g09d2 From 64b014aefb2c69f20d1a15e4e011481a5f98f9da Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Wed, 18 Sep 2013 23:02:53 -0500 Subject: Don't show the planner widget when adding a dive This looks like it might work, but since we keep recreating the dive, the info entered in the info pane is actually lost. But it's a step in the right direction. Signed-off-by: Dirk Hohndel --- qt-ui/diveplanner.cpp | 2 ++ qt-ui/mainwindow.cpp | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) (limited to 'qt-ui') diff --git a/qt-ui/diveplanner.cpp b/qt-ui/diveplanner.cpp index d634aadf8..9a1f0cb3d 100644 --- a/qt-ui/diveplanner.cpp +++ b/qt-ui/diveplanner.cpp @@ -4,6 +4,7 @@ #include "modeldelegates.h" #include "ui_diveplanner.h" #include "mainwindow.h" +#include "maintab.h" #include "tableview.h" #include "graphicsview-common.h" @@ -1149,6 +1150,7 @@ void DivePlannerPointsModel::createTemporaryPlan() tempDive = NULL; char *errorString = NULL; plan(&diveplan, &cache, &tempDive, isPlanner(), &errorString); + mainWindow()->information()->updateDiveInfo(get_divenr(tempDive)); #if DEBUG_PLAN dump_plan(&diveplan); #endif diff --git a/qt-ui/mainwindow.cpp b/qt-ui/mainwindow.cpp index 0b1f57ca9..593bbf166 100644 --- a/qt-ui/mainwindow.cpp +++ b/qt-ui/mainwindow.cpp @@ -258,7 +258,11 @@ void MainWindow::on_actionAddDive_triggered() disableDcShortcuts(); DivePlannerPointsModel::instance()->setPlanMode(false); ui->stackedWidget->setCurrentIndex(1); - ui->infoPane->setCurrentIndex(1); + ui->infoPane->setCurrentIndex(0); + ui->InfoWidget->clearStats(); + ui->InfoWidget->clearInfo(); + ui->InfoWidget->clearEquipment(); + ui->InfoWidget->updateDiveInfo(-1); } void MainWindow::on_actionRenumber_triggered() -- cgit v1.2.3-70-g09d2 From 5a96389cd3039ac822482232b3102106bbe70a5a Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Wed, 18 Sep 2013 23:08:39 -0500 Subject: Fix updateDiveInfo to clear coordinates when called with invalid dive Signed-off-by: Dirk Hohndel --- qt-ui/maintab.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'qt-ui') diff --git a/qt-ui/maintab.cpp b/qt-ui/maintab.cpp index 18702e7ce..a0fcdf744 100644 --- a/qt-ui/maintab.cpp +++ b/qt-ui/maintab.cpp @@ -306,6 +306,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(); -- cgit v1.2.3-70-g09d2 From 46b125782ee0e8af84c929deaa1ed34f53e7bcd0 Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Wed, 18 Sep 2013 23:33:39 -0500 Subject: Hook up adding a dive This gets things mostly right. It creates a dive and uses the planner widget to create samples which are copied into the dive. It fills in some reasonable defaults (DC model, timestamp), but doesn't allow editing the timestamp (or the temperatures and air pressure). On accept the planner gets reset and the dive appears correctly in the dive list. Cancel still needs to be handled. And I bet there are many subtle bugs lurking here and there. But it's a start. Signed-off-by: Dirk Hohndel --- dive.c | 13 +++++++++++++ dive.h | 1 + qt-ui/diveplanner.cpp | 5 +++-- qt-ui/maintab.cpp | 20 +++++++++++++++++--- qt-ui/maintab.h | 3 ++- qt-ui/mainwindow.cpp | 21 +++++++++++++++++---- 6 files changed, 53 insertions(+), 10 deletions(-) (limited to 'qt-ui') diff --git a/dive.c b/dive.c index f9f78d6bb..66d282d10 100644 --- a/dive.c +++ b/dive.c @@ -161,6 +161,19 @@ struct dive *alloc_dive(void) return dive; } +void copy_samples(struct dive* s, struct dive* d) +{ + /* instead of carefully copying them one by one and calling add_sample + * over and over again, let's just copy the whole blob */ + if (!s || !d) + return; + int nr = s->dc.samples; + d->dc.samples = nr; + d->dc.sample = malloc(nr * sizeof(struct sample)); + if (d->dc.sample) + memcpy(d->dc.sample, s->dc.sample, nr * sizeof(struct sample)); +} + struct sample *prepare_sample(struct divecomputer *dc) { if (dc) { diff --git a/dive.h b/dive.h index ed0dd52fe..fcfc20b34 100644 --- a/dive.h +++ b/dive.h @@ -622,6 +622,7 @@ extern unsigned int dc_airtemp(struct divecomputer *dc); extern struct dive *merge_dives(struct dive *a, struct dive *b, int offset, gboolean prefer_downloaded); extern struct dive *try_to_merge(struct dive *a, struct dive *b, gboolean prefer_downloaded); extern void renumber_dives(int nr); +extern void copy_samples(struct dive *s, struct dive *d); extern void add_gas_switch_event(struct dive *dive, struct divecomputer *dc, int time, int idx); extern void add_event(struct divecomputer *dc, int time, int type, int flags, int value, const char *name); diff --git a/qt-ui/diveplanner.cpp b/qt-ui/diveplanner.cpp index 9a1f0cb3d..fe1342112 100644 --- a/qt-ui/diveplanner.cpp +++ b/qt-ui/diveplanner.cpp @@ -1113,7 +1113,7 @@ struct diveplan DivePlannerPointsModel::getDiveplan() void DivePlannerPointsModel::cancelPlan() { - if(rowCount()){ + if(mode == PLAN && rowCount()){ if (QMessageBox::warning(mainWindow(), tr("Save the Plan?"), tr("You have a working plan, \n are you sure that you wanna cancel it?"), QMessageBox::Ok | QMessageBox::Cancel) != QMessageBox::Ok){ @@ -1150,7 +1150,8 @@ void DivePlannerPointsModel::createTemporaryPlan() tempDive = NULL; char *errorString = NULL; plan(&diveplan, &cache, &tempDive, isPlanner(), &errorString); - mainWindow()->information()->updateDiveInfo(get_divenr(tempDive)); + if (mode == ADD) + copy_samples(tempDive, current_dive); #if DEBUG_PLAN dump_plan(&diveplan); #endif diff --git a/qt-ui/maintab.cpp b/qt-ui/maintab.cpp index a0fcdf744..fcde96e0a 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 #include @@ -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); @@ -383,6 +390,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; @@ -500,7 +514,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){ struct dive* dive; int i = 0; for_each_dive(i, dive){ @@ -535,7 +549,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); diff --git a/qt-ui/maintab.h b/qt-ui/maintab.h index 25fe67743..041611b26 100644 --- a/qt-ui/maintab.h +++ b/qt-ui/maintab.h @@ -68,13 +68,14 @@ public slots: void on_visibility_valueChanged(int value); void editCylinderWidget(const QModelIndex& index); void editWeigthWidget(const QModelIndex& index); + void addDiveStarted(); private: Ui::MainTab *ui; WeightModel *weightModel; CylindersModel *cylindersModel; QMap notesBackup; - enum { NONE, DIVE, TRIP } editMode; + enum { NONE, DIVE, TRIP, ADD } editMode; Completers completers; void enableEdition(); }; diff --git a/qt-ui/mainwindow.cpp b/qt-ui/mainwindow.cpp index 593bbf166..c544dd812 100644 --- a/qt-ui/mainwindow.cpp +++ b/qt-ui/mainwindow.cpp @@ -36,6 +36,8 @@ #include "about.h" #include "printdialog.h" +#include "glib/gi18n.h" + static MainWindow* instance = 0; MainWindow* mainWindow() @@ -255,14 +257,25 @@ void MainWindow::on_actionEditDeviceNames_triggered() void MainWindow::on_actionAddDive_triggered() { + // clear the selection + for (int i = 0; i < dive_table.nr; i++) { + struct dive *d = get_dive(i); + if (d && d->selected) + deselect_dive(i); + } disableDcShortcuts(); DivePlannerPointsModel::instance()->setPlanMode(false); + // now cheat - create one dive that we use to store the info tab data in + struct dive *dive = alloc_dive(); + dive->when = QDateTime::currentMSecsSinceEpoch() / 1000L; + dive->dc.model = _("manually added dive"); + record_dive(dive); + select_dive(get_divenr(dive)); + ui->InfoWidget->updateDiveInfo(selected_dive); ui->stackedWidget->setCurrentIndex(1); ui->infoPane->setCurrentIndex(0); - ui->InfoWidget->clearStats(); - ui->InfoWidget->clearInfo(); - ui->InfoWidget->clearEquipment(); - ui->InfoWidget->updateDiveInfo(-1); + refreshDisplay(); + ui->InfoWidget->addDiveStarted(); } void MainWindow::on_actionRenumber_triggered() -- cgit v1.2.3-70-g09d2 From 6881f527390ed7e386fee60176c9b8bba9bfb316 Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Thu, 19 Sep 2013 22:58:53 -0500 Subject: Hook up cancelling out of adding a dive This was surprisingly easy - which of course has me worried that I'm missing something that I should do when cancelling out of this dialog. Signed-off-by: Dirk Hohndel --- qt-ui/maintab.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'qt-ui') diff --git a/qt-ui/maintab.cpp b/qt-ui/maintab.cpp index fcde96e0a..a42ce68dd 100644 --- a/qt-ui/maintab.cpp +++ b/qt-ui/maintab.cpp @@ -470,6 +470,14 @@ void MainTab::rejectChanges() ui->location->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 -- cgit v1.2.3-70-g09d2