diff options
author | Alexandru Croitor <alexandru.croitor@qt.io> | 2019-10-14 17:46:16 +0200 |
---|---|---|
committer | Alexandru Croitor <alexandru.croitor@qt.io> | 2019-10-14 17:46:34 +0200 |
commit | 440286655e0ca271506cf7cc02ad0dbf4baef9ca (patch) | |
tree | 896fa81adb8b14a69355a3a6cf64d06ec8173c9a /examples/widgets/tools/undo/commands.cpp | |
parent | 1e27ad1697187549151657ba187928e439300db7 (diff) | |
parent | e164d61ca8263fc4b46fdd916e1ea77c7dd2b735 (diff) |
Merge remote-tracking branch 'origin/dev' into wip/cmake
Change-Id: I4a78428a8ea273b6960792e3b8043f816fa37fcf
Diffstat (limited to 'examples/widgets/tools/undo/commands.cpp')
-rw-r--r-- | examples/widgets/tools/undo/commands.cpp | 36 |
1 files changed, 12 insertions, 24 deletions
diff --git a/examples/widgets/tools/undo/commands.cpp b/examples/widgets/tools/undo/commands.cpp index 81561d2421..97204f9d2f 100644 --- a/examples/widgets/tools/undo/commands.cpp +++ b/examples/widgets/tools/undo/commands.cpp @@ -50,18 +50,16 @@ #include "commands.h" -static const int setShapeRectCommandId = 1; -static const int setShapeColorCommandId = 2; +static constexpr int setShapeRectCommandId = 1; +static constexpr int setShapeColorCommandId = 2; /****************************************************************************** ** AddShapeCommand */ AddShapeCommand::AddShapeCommand(Document *doc, const Shape &shape, QUndoCommand *parent) - : QUndoCommand(parent) + : QUndoCommand(parent), m_doc(doc), m_shape(shape) { - m_doc = doc; - m_shape = shape; } void AddShapeCommand::undo() @@ -81,13 +79,11 @@ void AddShapeCommand::redo() */ RemoveShapeCommand::RemoveShapeCommand(Document *doc, const QString &shapeName, - QUndoCommand *parent) - : QUndoCommand(parent) + QUndoCommand *parent) + : QUndoCommand(parent), m_doc(doc), m_shape(doc->shape(shapeName)) + , m_shapeName(shapeName) { setText(QObject::tr("Remove %1").arg(shapeName)); - m_doc = doc; - m_shape = doc->shape(shapeName); - m_shapeName = shapeName; } void RemoveShapeCommand::undo() @@ -105,15 +101,11 @@ void RemoveShapeCommand::redo() */ SetShapeColorCommand::SetShapeColorCommand(Document *doc, const QString &shapeName, - const QColor &color, QUndoCommand *parent) - : QUndoCommand(parent) + const QColor &color, QUndoCommand *parent) + : QUndoCommand(parent), m_doc(doc), m_shapeName(shapeName) + , m_oldColor(doc->shape(shapeName).color()), m_newColor(color) { setText(QObject::tr("Set %1's color").arg(shapeName)); - - m_doc = doc; - m_shapeName = shapeName; - m_oldColor = doc->shape(shapeName).color(); - m_newColor = color; } void SetShapeColorCommand::undo() @@ -149,15 +141,11 @@ int SetShapeColorCommand::id() const */ SetShapeRectCommand::SetShapeRectCommand(Document *doc, const QString &shapeName, - const QRect &rect, QUndoCommand *parent) - : QUndoCommand(parent) + const QRect &rect, QUndoCommand *parent) + : QUndoCommand(parent), m_doc(doc), m_shapeName(shapeName) + , m_oldRect(doc->shape(shapeName).rect()), m_newRect(rect) { setText(QObject::tr("Change %1's geometry").arg(shapeName)); - - m_doc = doc; - m_shapeName = shapeName; - m_oldRect = doc->shape(shapeName).rect(); - m_newRect = rect; } void SetShapeRectCommand::undo() |