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>
This commit is contained in:
Grace Karanja 2015-02-28 07:42:37 +03:00 committed by Dirk Hohndel
parent 0995a800d9
commit 182fe790c9
3 changed files with 54 additions and 2 deletions

View file

@ -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)