Enum for undo commands.

--HG--
branch : feature
This commit is contained in:
dismine 2014-06-11 20:12:46 +03:00
parent 81c1c39be9
commit 77a160452a
10 changed files with 75 additions and 30 deletions

View File

@ -31,7 +31,9 @@
#include <QDomElement> #include <QDomElement>
#include <QGraphicsView> #include <QGraphicsView>
#include "../xml/vpattern.h" #include "../xml/vpattern.h"
#include "undocommands.h"
//---------------------------------------------------------------------------------------------------------------------
MoveSpline::MoveSpline(VPattern *doc, const VSpline *oldSpl, const VSpline &newSpl, const quint32 &id, MoveSpline::MoveSpline(VPattern *doc, const VSpline *oldSpl, const VSpline &newSpl, const quint32 &id,
QGraphicsScene *scene, QUndoCommand *parent) QGraphicsScene *scene, QUndoCommand *parent)
: QObject(), QUndoCommand(parent), doc(doc), oldSpline(*oldSpl), newSpline(newSpl), splineId(id), scene(scene) : 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); SCASSERT(scene != nullptr);
} }
//---------------------------------------------------------------------------------------------------------------------
MoveSpline::~MoveSpline() MoveSpline::~MoveSpline()
{} {}
//---------------------------------------------------------------------------------------------------------------------
void MoveSpline::undo() void MoveSpline::undo()
{ {
QDomElement domElement = doc->elementById(QString().setNum(splineId)); QDomElement domElement = doc->elementById(QString().setNum(splineId));
@ -66,6 +70,7 @@ void MoveSpline::undo()
} }
} }
//---------------------------------------------------------------------------------------------------------------------
void MoveSpline::redo() void MoveSpline::redo()
{ {
QDomElement domElement = doc->elementById(QString().setNum(splineId)); QDomElement domElement = doc->elementById(QString().setNum(splineId));
@ -88,6 +93,7 @@ void MoveSpline::redo()
} }
} }
//---------------------------------------------------------------------------------------------------------------------
bool MoveSpline::mergeWith(const QUndoCommand *command) bool MoveSpline::mergeWith(const QUndoCommand *command)
{ {
const MoveSpline *moveCommand = static_cast<const MoveSpline *>(command); const MoveSpline *moveCommand = static_cast<const MoveSpline *>(command);
@ -102,3 +108,9 @@ bool MoveSpline::mergeWith(const QUndoCommand *command)
newSpline = moveCommand->getNewSpline(); newSpline = moveCommand->getNewSpline();
return true; return true;
} }
//---------------------------------------------------------------------------------------------------------------------
int MoveSpline::id() const
{
return static_cast<int>(UndoCommand::MoveSpline);
}

View File

@ -52,7 +52,6 @@ signals:
void NeedLiteParsing(); void NeedLiteParsing();
private: private:
Q_DISABLE_COPY(MoveSpline) Q_DISABLE_COPY(MoveSpline)
enum { Id = 1 };
VPattern *doc; VPattern *doc;
VSpline oldSpline; VSpline oldSpline;
VSpline newSpline; VSpline newSpline;
@ -60,12 +59,6 @@ private:
QGraphicsScene *scene; QGraphicsScene *scene;
}; };
//---------------------------------------------------------------------------------------------------------------------
inline int MoveSpline::id() const
{
return Id;
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
inline quint32 MoveSpline::getSplineId() const inline quint32 MoveSpline::getSplineId() const
{ {

View File

@ -29,6 +29,7 @@
#include "movesplinepath.h" #include "movesplinepath.h"
#include <QDomElement> #include <QDomElement>
#include "../tools/drawTools/vtoolsplinepath.h" #include "../tools/drawTools/vtoolsplinepath.h"
#include "undocommands.h"
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
MoveSplinePath::MoveSplinePath(VPattern *doc, const VSplinePath &oldSplPath, const VSplinePath &newSplPath, MoveSplinePath::MoveSplinePath(VPattern *doc, const VSplinePath &oldSplPath, const VSplinePath &newSplPath,
@ -100,3 +101,9 @@ bool MoveSplinePath::mergeWith(const QUndoCommand *command)
newSplinePath = moveCommand->getNewSplinePath(); newSplinePath = moveCommand->getNewSplinePath();
return true; return true;
} }
//---------------------------------------------------------------------------------------------------------------------
int MoveSplinePath::id() const
{
return static_cast<int>(UndoCommand::MoveSplinePath);
}

View File

@ -52,7 +52,6 @@ signals:
void NeedLiteParsing(); void NeedLiteParsing();
private: private:
Q_DISABLE_COPY(MoveSplinePath) Q_DISABLE_COPY(MoveSplinePath)
enum { Id = 2 };
VPattern *doc; VPattern *doc;
VSplinePath oldSplinePath; VSplinePath oldSplinePath;
VSplinePath newSplinePath; VSplinePath newSplinePath;
@ -60,12 +59,6 @@ private:
QGraphicsScene *scene; QGraphicsScene *scene;
}; };
//---------------------------------------------------------------------------------------------------------------------
inline int MoveSplinePath::id() const
{
return Id;
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
inline quint32 MoveSplinePath::getSplinePathId() const inline quint32 MoveSplinePath::getSplinePathId() const
{ {

View File

@ -32,7 +32,9 @@
#include "../xml/vpattern.h" #include "../xml/vpattern.h"
#include "../tools/vabstracttool.h" #include "../tools/vabstracttool.h"
#include "../widgets/vapplication.h" #include "../widgets/vapplication.h"
#include "undocommands.h"
//---------------------------------------------------------------------------------------------------------------------
MoveSPoint::MoveSPoint(VPattern *doc, const double &x, const double &y, const quint32 &id, QGraphicsScene *scene, MoveSPoint::MoveSPoint(VPattern *doc, const double &x, const double &y, const quint32 &id, QGraphicsScene *scene,
QUndoCommand *parent) QUndoCommand *parent)
: QObject(), QUndoCommand(parent), doc(doc), oldX(10.0), oldY(10.0), newX(x), newY(y), sPointId(id), scene(scene) : 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(); newY = moveCommand->getNewY();
return true; return true;
} }
//---------------------------------------------------------------------------------------------------------------------
int MoveSPoint::id() const
{
return static_cast<int>(UndoCommand::MoveSPoint);
}

View File

@ -52,7 +52,6 @@ signals:
void NeedLiteParsing(); void NeedLiteParsing();
private: private:
Q_DISABLE_COPY(MoveSPoint) Q_DISABLE_COPY(MoveSPoint)
enum { Id = 0 };
VPattern *doc; VPattern *doc;
double oldX; double oldX;
double oldY; double oldY;
@ -62,12 +61,6 @@ private:
QGraphicsScene *scene; QGraphicsScene *scene;
}; };
//---------------------------------------------------------------------------------------------------------------------
inline int MoveSPoint::id() const
{
return Id;
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
inline quint32 MoveSPoint::getSPointId() const inline quint32 MoveSPoint::getSPointId() const
{ {

View File

@ -29,6 +29,7 @@
#include "savetooloptions.h" #include "savetooloptions.h"
#include "../options.h" #include "../options.h"
#include "../xml/vpattern.h" #include "../xml/vpattern.h"
#include "undocommands.h"
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
SaveToolOptions::SaveToolOptions(const QDomElement &oldXml, const QDomElement &newXml, VPattern *doc, const quint32 &id, 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; return true;
} }
//---------------------------------------------------------------------------------------------------------------------
int SaveToolOptions::id() const
{
return static_cast<int>(UndoCommand::SaveToolOptions);
}

View File

@ -50,7 +50,6 @@ signals:
void NeedLiteParsing(); void NeedLiteParsing();
private: private:
Q_DISABLE_COPY(SaveToolOptions) Q_DISABLE_COPY(SaveToolOptions)
enum { Id = 3 };
const QDomElement oldXml; const QDomElement oldXml;
QDomElement newXml; QDomElement newXml;
VPattern *doc; VPattern *doc;
@ -63,12 +62,6 @@ inline QDomElement SaveToolOptions::getNewXml() const
return newXml; return newXml;
} }
//---------------------------------------------------------------------------------------------------------------------
inline int SaveToolOptions::id() const
{
return Id;
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
inline quint32 SaveToolOptions::getToolId() const inline quint32 SaveToolOptions::getToolId() const
{ {

View File

@ -0,0 +1,40 @@
/************************************************************************
**
** @file undocommands.h
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @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
** <https://bitbucket.org/dismine/valentina> 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 <http://www.gnu.org/licenses/>.
**
*************************************************************************/
#ifndef UNDOCOMMANDS_H
#define UNDOCOMMANDS_H
enum class UndoCommand: char { AddPatternPiece,
AddToCalc,
MoveSpline,
MoveSplinePath,
MoveSPoint,
SaveToolOptions
};
#endif // UNDOCOMMANDS_H

View File

@ -4,7 +4,8 @@ HEADERS += \
undocommands/movespoint.h \ undocommands/movespoint.h \
undocommands/movespline.h \ undocommands/movespline.h \
undocommands/movesplinepath.h \ undocommands/movesplinepath.h \
undocommands/savetooloptions.h undocommands/savetooloptions.h \
undocommands/undocommands.h
SOURCES += \ SOURCES += \