From 77a160452ae1cc7bee988d72730e4dcc3822136f Mon Sep 17 00:00:00 2001 From: dismine Date: Wed, 11 Jun 2014 20:12:46 +0300 Subject: [PATCH] Enum for undo commands. --HG-- branch : feature --- src/app/undocommands/movespline.cpp | 12 +++++++ src/app/undocommands/movespline.h | 7 ----- src/app/undocommands/movesplinepath.cpp | 7 +++++ src/app/undocommands/movesplinepath.h | 7 ----- src/app/undocommands/movespoint.cpp | 8 +++++ src/app/undocommands/movespoint.h | 7 ----- src/app/undocommands/savetooloptions.cpp | 7 ++++- src/app/undocommands/savetooloptions.h | 7 ----- src/app/undocommands/undocommands.h | 40 ++++++++++++++++++++++++ src/app/undocommands/undocommands.pri | 3 +- 10 files changed, 75 insertions(+), 30 deletions(-) create mode 100644 src/app/undocommands/undocommands.h diff --git a/src/app/undocommands/movespline.cpp b/src/app/undocommands/movespline.cpp index 0ce52e3ca..179bb7d08 100644 --- a/src/app/undocommands/movespline.cpp +++ b/src/app/undocommands/movespline.cpp @@ -31,7 +31,9 @@ #include #include #include "../xml/vpattern.h" +#include "undocommands.h" +//--------------------------------------------------------------------------------------------------------------------- MoveSpline::MoveSpline(VPattern *doc, const VSpline *oldSpl, const VSpline &newSpl, const quint32 &id, QGraphicsScene *scene, QUndoCommand *parent) : QObject(), QUndoCommand(parent), doc(doc), oldSpline(*oldSpl), newSpline(newSpl), splineId(id), scene(scene) @@ -41,9 +43,11 @@ MoveSpline::MoveSpline(VPattern *doc, const VSpline *oldSpl, const VSpline &newS SCASSERT(scene != nullptr); } +//--------------------------------------------------------------------------------------------------------------------- MoveSpline::~MoveSpline() {} +//--------------------------------------------------------------------------------------------------------------------- void MoveSpline::undo() { QDomElement domElement = doc->elementById(QString().setNum(splineId)); @@ -66,6 +70,7 @@ void MoveSpline::undo() } } +//--------------------------------------------------------------------------------------------------------------------- void MoveSpline::redo() { QDomElement domElement = doc->elementById(QString().setNum(splineId)); @@ -88,6 +93,7 @@ void MoveSpline::redo() } } +//--------------------------------------------------------------------------------------------------------------------- bool MoveSpline::mergeWith(const QUndoCommand *command) { const MoveSpline *moveCommand = static_cast(command); @@ -102,3 +108,9 @@ bool MoveSpline::mergeWith(const QUndoCommand *command) newSpline = moveCommand->getNewSpline(); return true; } + +//--------------------------------------------------------------------------------------------------------------------- +int MoveSpline::id() const +{ + return static_cast(UndoCommand::MoveSpline); +} diff --git a/src/app/undocommands/movespline.h b/src/app/undocommands/movespline.h index e01ec40a5..24045858b 100644 --- a/src/app/undocommands/movespline.h +++ b/src/app/undocommands/movespline.h @@ -52,7 +52,6 @@ signals: void NeedLiteParsing(); private: Q_DISABLE_COPY(MoveSpline) - enum { Id = 1 }; VPattern *doc; VSpline oldSpline; VSpline newSpline; @@ -60,12 +59,6 @@ private: QGraphicsScene *scene; }; -//--------------------------------------------------------------------------------------------------------------------- -inline int MoveSpline::id() const -{ - return Id; -} - //--------------------------------------------------------------------------------------------------------------------- inline quint32 MoveSpline::getSplineId() const { diff --git a/src/app/undocommands/movesplinepath.cpp b/src/app/undocommands/movesplinepath.cpp index bb9bd53fb..ba9b8a3cd 100644 --- a/src/app/undocommands/movesplinepath.cpp +++ b/src/app/undocommands/movesplinepath.cpp @@ -29,6 +29,7 @@ #include "movesplinepath.h" #include #include "../tools/drawTools/vtoolsplinepath.h" +#include "undocommands.h" //--------------------------------------------------------------------------------------------------------------------- MoveSplinePath::MoveSplinePath(VPattern *doc, const VSplinePath &oldSplPath, const VSplinePath &newSplPath, @@ -100,3 +101,9 @@ bool MoveSplinePath::mergeWith(const QUndoCommand *command) newSplinePath = moveCommand->getNewSplinePath(); return true; } + +//--------------------------------------------------------------------------------------------------------------------- +int MoveSplinePath::id() const +{ + return static_cast(UndoCommand::MoveSplinePath); +} diff --git a/src/app/undocommands/movesplinepath.h b/src/app/undocommands/movesplinepath.h index 0eb0a061c..aab71cc0b 100644 --- a/src/app/undocommands/movesplinepath.h +++ b/src/app/undocommands/movesplinepath.h @@ -52,7 +52,6 @@ signals: void NeedLiteParsing(); private: Q_DISABLE_COPY(MoveSplinePath) - enum { Id = 2 }; VPattern *doc; VSplinePath oldSplinePath; VSplinePath newSplinePath; @@ -60,12 +59,6 @@ private: QGraphicsScene *scene; }; -//--------------------------------------------------------------------------------------------------------------------- -inline int MoveSplinePath::id() const -{ - return Id; -} - //--------------------------------------------------------------------------------------------------------------------- inline quint32 MoveSplinePath::getSplinePathId() const { diff --git a/src/app/undocommands/movespoint.cpp b/src/app/undocommands/movespoint.cpp index 20a2796a6..940612c01 100644 --- a/src/app/undocommands/movespoint.cpp +++ b/src/app/undocommands/movespoint.cpp @@ -32,7 +32,9 @@ #include "../xml/vpattern.h" #include "../tools/vabstracttool.h" #include "../widgets/vapplication.h" +#include "undocommands.h" +//--------------------------------------------------------------------------------------------------------------------- MoveSPoint::MoveSPoint(VPattern *doc, const double &x, const double &y, const quint32 &id, QGraphicsScene *scene, QUndoCommand *parent) : QObject(), QUndoCommand(parent), doc(doc), oldX(10.0), oldY(10.0), newX(x), newY(y), sPointId(id), scene(scene) @@ -112,3 +114,9 @@ bool MoveSPoint::mergeWith(const QUndoCommand *command) newY = moveCommand->getNewY(); return true; } + +//--------------------------------------------------------------------------------------------------------------------- +int MoveSPoint::id() const +{ + return static_cast(UndoCommand::MoveSPoint); +} diff --git a/src/app/undocommands/movespoint.h b/src/app/undocommands/movespoint.h index 050df6482..17a5c869f 100644 --- a/src/app/undocommands/movespoint.h +++ b/src/app/undocommands/movespoint.h @@ -52,7 +52,6 @@ signals: void NeedLiteParsing(); private: Q_DISABLE_COPY(MoveSPoint) - enum { Id = 0 }; VPattern *doc; double oldX; double oldY; @@ -62,12 +61,6 @@ private: QGraphicsScene *scene; }; -//--------------------------------------------------------------------------------------------------------------------- -inline int MoveSPoint::id() const -{ - return Id; -} - //--------------------------------------------------------------------------------------------------------------------- inline quint32 MoveSPoint::getSPointId() const { diff --git a/src/app/undocommands/savetooloptions.cpp b/src/app/undocommands/savetooloptions.cpp index 52f45f1bf..29e1c77dd 100644 --- a/src/app/undocommands/savetooloptions.cpp +++ b/src/app/undocommands/savetooloptions.cpp @@ -29,6 +29,7 @@ #include "savetooloptions.h" #include "../options.h" #include "../xml/vpattern.h" +#include "undocommands.h" //--------------------------------------------------------------------------------------------------------------------- SaveToolOptions::SaveToolOptions(const QDomElement &oldXml, const QDomElement &newXml, VPattern *doc, const quint32 &id, @@ -90,4 +91,8 @@ bool SaveToolOptions::mergeWith(const QUndoCommand *command) return true; } - +//--------------------------------------------------------------------------------------------------------------------- +int SaveToolOptions::id() const +{ + return static_cast(UndoCommand::SaveToolOptions); +} diff --git a/src/app/undocommands/savetooloptions.h b/src/app/undocommands/savetooloptions.h index 78512977e..4112312d9 100644 --- a/src/app/undocommands/savetooloptions.h +++ b/src/app/undocommands/savetooloptions.h @@ -50,7 +50,6 @@ signals: void NeedLiteParsing(); private: Q_DISABLE_COPY(SaveToolOptions) - enum { Id = 3 }; const QDomElement oldXml; QDomElement newXml; VPattern *doc; @@ -63,12 +62,6 @@ inline QDomElement SaveToolOptions::getNewXml() const return newXml; } -//--------------------------------------------------------------------------------------------------------------------- -inline int SaveToolOptions::id() const -{ - return Id; -} - //--------------------------------------------------------------------------------------------------------------------- inline quint32 SaveToolOptions::getToolId() const { diff --git a/src/app/undocommands/undocommands.h b/src/app/undocommands/undocommands.h new file mode 100644 index 000000000..2a565a008 --- /dev/null +++ b/src/app/undocommands/undocommands.h @@ -0,0 +1,40 @@ +/************************************************************************ + ** + ** @file undocommands.h + ** @author Roman Telezhynskyi + ** @date 11 6, 2014 + ** + ** @brief + ** @copyright + ** This source code is part of the Valentine project, a pattern making + ** program, whose allow create and modeling patterns of clothing. + ** Copyright (C) 2014 Valentina project + ** All Rights Reserved. + ** + ** Valentina is free software: you can redistribute it and/or modify + ** it under the terms of the GNU General Public License as published by + ** the Free Software Foundation, either version 3 of the License, or + ** (at your option) any later version. + ** + ** Valentina is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + ** GNU General Public License for more details. + ** + ** You should have received a copy of the GNU General Public License + ** along with Valentina. If not, see . + ** + *************************************************************************/ + +#ifndef UNDOCOMMANDS_H +#define UNDOCOMMANDS_H + +enum class UndoCommand: char { AddPatternPiece, + AddToCalc, + MoveSpline, + MoveSplinePath, + MoveSPoint, + SaveToolOptions + }; + +#endif // UNDOCOMMANDS_H diff --git a/src/app/undocommands/undocommands.pri b/src/app/undocommands/undocommands.pri index 4e24e5814..0d425fcf7 100644 --- a/src/app/undocommands/undocommands.pri +++ b/src/app/undocommands/undocommands.pri @@ -4,7 +4,8 @@ HEADERS += \ undocommands/movespoint.h \ undocommands/movespline.h \ undocommands/movesplinepath.h \ - undocommands/savetooloptions.h + undocommands/savetooloptions.h \ + undocommands/undocommands.h SOURCES += \