diff options
author | Grace Karanja <gracie.karanja89@gmail.com> | 2015-02-28 07:42:37 +0300 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2015-02-28 12:44:14 +0100 |
commit | 182fe790c9e88898ec3d8bd4be68614a560415bb (patch) | |
tree | e05d4e9ca250adfbeaec8aac9a44d34f03f8c2bf /qt-ui/simplewidgets.cpp | |
parent | 0995a800d915c606ca78ea210ccc1fba290d1eea (diff) | |
download | subsurface-182fe790c9e88898ec3d8bd4be68614a560415bb.tar.gz |
Add ability to undo renumbering of dives
Expand the undo feature by storing a list of renumbered dives' ids
and numbers so that the original numbers can be restored if needed.
Signed-off-by: Grace Karanja <gracie.karanja89@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui/simplewidgets.cpp')
-rw-r--r-- | qt-ui/simplewidgets.cpp | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/qt-ui/simplewidgets.cpp b/qt-ui/simplewidgets.cpp index f7944c90c..003fc053d 100644 --- a/qt-ui/simplewidgets.cpp +++ b/qt-ui/simplewidgets.cpp @@ -142,8 +142,17 @@ void RenumberDialog::renumberOnlySelected(bool selected) void RenumberDialog::buttonClicked(QAbstractButton *button) { - if (ui.buttonBox->buttonRole(button) == QDialogButtonBox::AcceptRole) - renumber_dives(ui.spinBox->value(), selectedOnly); + if (ui.buttonBox->buttonRole(button) == QDialogButtonBox::AcceptRole) { + QMap<int,int> renumberedDives; + int i; + struct dive *dive = NULL; + for_each_dive (i, dive) { + if (!selectedOnly || dive->selected) + renumberedDives.insert(dive->id, dive->number); + } + UndoRenumberDives *undoCommand = new UndoRenumberDives(renumberedDives, ui.spinBox->value()); + MainWindow::instance()->undoStack->push(undoCommand); + } } RenumberDialog::RenumberDialog(QWidget *parent) : QDialog(parent), selectedOnly(false) |