diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 456a0594e..fd2754663 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -135,6 +135,7 @@ SET( brewtarget_SRCS ${SRCDIR}/RangedSlider.cpp ${SRCDIR}/recipe.cpp ${SRCDIR}/RecipeFormatter.cpp + ${SRCDIR}/RecipeUndoableUpdate.cpp ${SRCDIR}/RefractoDialog.cpp ${SRCDIR}/salt.cpp ${SRCDIR}/SaltTableModel.cpp diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp index edc8e1866..62b129557 100644 --- a/src/MainWindow.cpp +++ b/src/MainWindow.cpp @@ -71,6 +71,7 @@ #include "MiscTableModel.h" #include "style.h" #include "recipe.h" +#include "RecipeUndoableUpdate.h" #include "MainWindow.h" #include "AboutDialog.h" #include "database.h" @@ -1256,7 +1257,10 @@ void MainWindow::updateRecipeEfficiency() if( recipeObs == nullptr ) return; - recipeObs->setEfficiency_pct( lineEdit_efficiency->toSI() ); + this->doOrRedoUpdate(new RecipeUndoableUpdate(*this->recipeObs, + RecipeUndoableUpdate::Attribute::Efficiency, + lineEdit_efficiency->toSI())); + return; } void MainWindow::addFermentableToRecipe(Fermentable* ferm) @@ -1331,6 +1335,14 @@ void MainWindow::setUndoRedoEnable() return; } +void MainWindow::doOrRedoUpdate(QUndoCommand * update) +{ + Q_ASSERT(this->undoStack != 0); + this->undoStack->push(update); + this->setUndoRedoEnable(); + return; +} + // For undo/redo, we use Qt's Undo framework void MainWindow::editUndo() { diff --git a/src/MainWindow.h b/src/MainWindow.h index 1f19fec7d..3e633111b 100644 --- a/src/MainWindow.h +++ b/src/MainWindow.h @@ -297,6 +297,7 @@ private slots: //! \brief Set whether undo / redo commands are enabled void setUndoRedoEnable(); + void doOrRedoUpdate(QUndoCommand * update); private: Recipe* recipeObs;