Skip to content
Snippets Groups Projects

rm unfinished undo/redo engine (#757)

Merged Wuttke, Joachim requested to merge j.757 into main
3 files
+ 1
101
Compare changes
  • Side-by-side
  • Inline
Files
3
// ************************************************************************************************
//
// BornAgain: simulate and fit reflection and scattering
//
//! @file GUI/View/SampleDesigner/SampleEditorCommands.cpp
//! @brief Implements command classes for LayerOrientedSampleEditor
//!
//! @homepage http://www.bornagainproject.org
//! @license GNU General Public License v3 or higher (see COPYING)
//! @copyright Forschungszentrum Jülich GmbH 2021
//! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS)
//
// ************************************************************************************************
#include "GUI/View/SampleDesigner/SampleEditorCommands.h"
#include "GUI/Model/Sample/LayerItem.h"
#include "GUI/Model/Sample/SampleItem.h"
#include "GUI/Support/XML/Backup.h"
#include "GUI/View/SampleDesigner/SampleEditorController.h"
#include "GUI/View/SampleDesigner/SampleForm.h"
#include <utility>
namespace {
constexpr int COMMAND_ID_CHANGE_VALUE = 11;
} // namespace
CommandChangeValue::CommandChangeValue(const QString& label, SampleEditorController* ec,
double oldValue, double newValue, const QString& path,
QUndoCommand* parent /*= nullptr*/)
: QUndoCommand(parent)
, m_ec(ec)
, m_oldValue(oldValue)
, m_newValue(newValue)
, m_path(path)
{
setText("change " + label + "\n");
}
int CommandChangeValue::id() const
{
return COMMAND_ID_CHANGE_VALUE;
}
void CommandChangeValue::redo()
{
if (m_isFirst)
m_isFirst = false;
else
m_ec->setDoubleFromUndo(m_newValue, m_path);
}
void CommandChangeValue::undo()
{
m_ec->setDoubleFromUndo(m_oldValue, m_path);
}
Loading