1 /************************************************************************
2  **
3  **  @file   vundocommand.h
4  **  @author Roman Telezhynskyi <dismine(at)gmail.com>
5  **  @date   16 7, 2014
6  **
7  **  @brief
8  **  @copyright
9  **  This source code is part of the Valentina project, a pattern making
10  **  program, whose allow create and modeling patterns of clothing.
11  **  Copyright (C) 2013-2015 Valentina project
12  **  <https://gitlab.com/smart-pattern/valentina> All Rights Reserved.
13  **
14  **  Valentina is free software: you can redistribute it and/or modify
15  **  it under the terms of the GNU General Public License as published by
16  **  the Free Software Foundation, either version 3 of the License, or
17  **  (at your option) any later version.
18  **
19  **  Valentina is distributed in the hope that it will be useful,
20  **  but WITHOUT ANY WARRANTY; without even the implied warranty of
21  **  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22  **  GNU General Public License for more details.
23  **
24  **  You should have received a copy of the GNU General Public License
25  **  along with Valentina.  If not, see <http://www.gnu.org/licenses/>.
26  **
27  *************************************************************************/
28 
29 #ifndef VUNDOCOMMAND_H
30 #define VUNDOCOMMAND_H
31 
32 #include <qcompilerdetection.h>
33 #include <QDomElement>
34 #include <QMetaObject>
35 #include <QObject>
36 #include <QString>
37 #include <QUndoCommand>
38 #include <QVector>
39 #include <QtGlobal>
40 
41 #include "../ifc/xml/vabstractpattern.h"
42 
43 Q_DECLARE_LOGGING_CATEGORY(vUndo)
44 
45 enum class UndoCommand: qint8
46 {
47     AddPatternPiece,
48     AddToCalc,
49     MoveSpline,
50     MoveSplinePath,
51     MoveSPoint,
52     SaveToolOptions,
53     SaveDetailOptions,
54     SavePieceOptions,
55     SavePiecePathOptions,
56     SavePlaceLabelOptions,
57     MovePiece,
58     DeleteTool,
59     DeletePatternPiece,
60     RenamePP,
61     MoveLabel,
62     MoveDoubleLabel,
63     RotationMoveLabel
64  };
65 
66 class VPattern;
67 
68 class VUndoCommand : public QObject, public QUndoCommand
69 {
70     Q_OBJECT
71 public:
72     VUndoCommand(const QDomElement &xml, VAbstractPattern *doc, QUndoCommand *parent = nullptr);
73     virtual ~VUndoCommand() =default;
74 signals:
75     void ClearScene();
76     void NeedFullParsing();
77     void NeedLiteParsing(const Document &parse);
78 protected:
79     QDomElement  xml;
80     VAbstractPattern *doc;
81     quint32      nodeId;
82     bool         redoFlag;
83     virtual void RedoFullParsing();
84     void         UndoDeleteAfterSibling(QDomNode &parentNode, quint32 siblingId,
85                                         const QString &tagName = QString()) const;
86 
87     void         IncrementReferences(const QVector<quint32> &nodes) const;
88     void         DecrementReferences(const QVector<quint32> &nodes) const;
89 
90     void         IncrementReferences(const QVector<CustomSARecord> &nodes) const;
91     void         DecrementReferences(const QVector<CustomSARecord> &nodes) const;
92 
93     void         IncrementReferences(const QVector<VPieceNode> &nodes) const;
94     void         DecrementReferences(const QVector<VPieceNode> &nodes) const;
95 
96     QDomElement  GetDestinationObject(quint32 idTool, quint32 idPoint) const;
97 private:
98     Q_DISABLE_COPY(VUndoCommand)
99 };
100 
101 #endif // VUNDOCOMMAND_H
102