Enable undo for the Edit mode on Added Dives.

This enables undo for the edit mode on added dives, it uses the
premade backup to fill the old dive with data. :)

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
This commit is contained in:
Tomaz Canabrava 2013-11-01 14:06:03 -04:00
parent 23a193b0d1
commit 0e96c9f62e
4 changed files with 17 additions and 2 deletions

View file

@ -1197,6 +1197,16 @@ void DivePlannerPointsModel::createTemporaryPlan()
#endif #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() void DivePlannerPointsModel::deleteTemporaryPlan()
{ {
deleteTemporaryPlan(diveplan.dp); deleteTemporaryPlan(diveplan.dp);

View file

@ -55,7 +55,7 @@ public slots:
void createTemporaryPlan(); void createTemporaryPlan();
void deleteTemporaryPlan(); void deleteTemporaryPlan();
void loadFromDive(dive* d); void loadFromDive(dive* d);
void undoEdition();
signals: signals:
void planCreated(); void planCreated();
void planCanceled(); void planCanceled();

View file

@ -507,6 +507,9 @@ void MainTab::rejectChanges()
delete_single_dive(selected_dive); delete_single_dive(selected_dive);
DivePlannerPointsModel::instance()->cancelPlan(); DivePlannerPointsModel::instance()->cancelPlan();
} }
else if (editMode == MANUALLY_ADDED_DIVE ){
DivePlannerPointsModel::instance()->undoEdition();
}
struct dive *curr = current_dive; struct dive *curr = current_dive;
ui.notes->setText(notesBackup[curr].notes ); ui.notes->setText(notesBackup[curr].notes );
ui.location->setText(notesBackup[curr].location); ui.location->setText(notesBackup[curr].location);

View file

@ -46,7 +46,8 @@ class MainTab : public QTabWidget
{ {
Q_OBJECT Q_OBJECT
public: public:
enum EditMode { NONE, DIVE, TRIP, ADD, MANUALLY_ADDED_DIVE } editMode; enum EditMode { NONE, DIVE, TRIP, ADD, MANUALLY_ADDED_DIVE };
MainTab(QWidget *parent); MainTab(QWidget *parent);
void clearStats(); void clearStats();
void clearInfo(); void clearInfo();
@ -78,6 +79,7 @@ public slots:
void enableEdition(EditMode newEditMode = NONE); void enableEdition(EditMode newEditMode = NONE);
private: private:
EditMode editMode;
Ui::MainTab ui; Ui::MainTab ui;
WeightModel *weightModel; WeightModel *weightModel;
CylindersModel *cylindersModel; CylindersModel *cylindersModel;