Enum for undo commands.
--HG-- branch : feature
This commit is contained in:
parent
81c1c39be9
commit
77a160452a
|
@ -31,7 +31,9 @@
|
|||
#include <QDomElement>
|
||||
#include <QGraphicsView>
|
||||
#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<const MoveSpline *>(command);
|
||||
|
@ -102,3 +108,9 @@ bool MoveSpline::mergeWith(const QUndoCommand *command)
|
|||
newSpline = moveCommand->getNewSpline();
|
||||
return true;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
int MoveSpline::id() const
|
||||
{
|
||||
return static_cast<int>(UndoCommand::MoveSpline);
|
||||
}
|
||||
|
|
|
@ -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
|
||||
{
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
#include "movesplinepath.h"
|
||||
#include <QDomElement>
|
||||
#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<int>(UndoCommand::MoveSplinePath);
|
||||
}
|
||||
|
|
|
@ -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
|
||||
{
|
||||
|
|
|
@ -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<int>(UndoCommand::MoveSPoint);
|
||||
}
|
||||
|
|
|
@ -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
|
||||
{
|
||||
|
|
|
@ -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<int>(UndoCommand::SaveToolOptions);
|
||||
}
|
||||
|
|
|
@ -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
|
||||
{
|
||||
|
|
40
src/app/undocommands/undocommands.h
Normal file
40
src/app/undocommands/undocommands.h
Normal 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
|
|
@ -4,7 +4,8 @@ HEADERS += \
|
|||
undocommands/movespoint.h \
|
||||
undocommands/movespline.h \
|
||||
undocommands/movesplinepath.h \
|
||||
undocommands/savetooloptions.h
|
||||
undocommands/savetooloptions.h \
|
||||
undocommands/undocommands.h
|
||||
|
||||
|
||||
SOURCES += \
|
||||
|
|
Loading…
Reference in New Issue
Block a user