diff options
-rw-r--r-- | qt-ui/diveplanner.cpp | 10 | ||||
-rw-r--r-- | qt-ui/diveplanner.h | 2 | ||||
-rw-r--r-- | qt-ui/maintab.cpp | 3 | ||||
-rw-r--r-- | qt-ui/maintab.h | 4 |
4 files changed, 17 insertions, 2 deletions
diff --git a/qt-ui/diveplanner.cpp b/qt-ui/diveplanner.cpp index d94e96570..169158987 100644 --- a/qt-ui/diveplanner.cpp +++ b/qt-ui/diveplanner.cpp @@ -1197,6 +1197,16 @@ void DivePlannerPointsModel::createTemporaryPlan() #endif } +void DivePlannerPointsModel::undoEdition() +{ + beginRemoveRows(QModelIndex(), 0, rowCount()-1); + divepoints.clear(); + endRemoveRows(); + Q_FOREACH(const sample &s, backupSamples){ + plannerModel->addStop(s.depth.mm, s.time.seconds, tr("Air"), 0); + } +} + void DivePlannerPointsModel::deleteTemporaryPlan() { deleteTemporaryPlan(diveplan.dp); diff --git a/qt-ui/diveplanner.h b/qt-ui/diveplanner.h index 6812b26ef..6883f62eb 100644 --- a/qt-ui/diveplanner.h +++ b/qt-ui/diveplanner.h @@ -55,7 +55,7 @@ public slots: void createTemporaryPlan(); void deleteTemporaryPlan(); void loadFromDive(dive* d); - + void undoEdition(); signals: void planCreated(); void planCanceled(); diff --git a/qt-ui/maintab.cpp b/qt-ui/maintab.cpp index f88d7c6d0..ddcdc6c63 100644 --- a/qt-ui/maintab.cpp +++ b/qt-ui/maintab.cpp @@ -507,6 +507,9 @@ void MainTab::rejectChanges() delete_single_dive(selected_dive); DivePlannerPointsModel::instance()->cancelPlan(); } + else if (editMode == MANUALLY_ADDED_DIVE ){ + DivePlannerPointsModel::instance()->undoEdition(); + } struct dive *curr = current_dive; ui.notes->setText(notesBackup[curr].notes ); ui.location->setText(notesBackup[curr].location); diff --git a/qt-ui/maintab.h b/qt-ui/maintab.h index 1f586e70a..afc30a079 100644 --- a/qt-ui/maintab.h +++ b/qt-ui/maintab.h @@ -46,7 +46,8 @@ class MainTab : public QTabWidget { Q_OBJECT public: - enum EditMode { NONE, DIVE, TRIP, ADD, MANUALLY_ADDED_DIVE } editMode; + enum EditMode { NONE, DIVE, TRIP, ADD, MANUALLY_ADDED_DIVE }; + MainTab(QWidget *parent); void clearStats(); void clearInfo(); @@ -78,6 +79,7 @@ public slots: void enableEdition(EditMode newEditMode = NONE); private: + EditMode editMode; Ui::MainTab ui; WeightModel *weightModel; CylindersModel *cylindersModel; |