Seamly2D
Code documentation
vundocommand.h
Go to the documentation of this file.
1 /***************************************************************************
2  ** @file vundocommand.h
3  ** @author Douglas S Caskey
4  ** @date Dec 27, 2022
5  **
6  ** @copyright
7  ** Copyright (C) 2017 - 2022 Seamly, LLC
8  ** https://github.com/fashionfreedom/seamly2d
9  **
10  ** @brief
11  ** Seamly2D is free software: you can redistribute it and/or modify
12  ** it under the terms of the GNU General Public License as published by
13  ** the Free Software Foundation, either version 3 of the License, or
14  ** (at your option) any later version.
15  **
16  ** Seamly2D is distributed in the hope that it will be useful,
17  ** but WITHOUT ANY WARRANTY; without even the implied warranty of
18  ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  ** GNU General Public License for more details.
20  **
21  ** You should have received a copy of the GNU General Public License
22  ** along with Seamly2D. If not, see <http://www.gnu.org/licenses/>.
23  **************************************************************************/
24 
25  /************************************************************************
26  **
27  ** @file vundocommand.h
28  ** @author Roman Telezhynskyi <dismine(at)gmail.com>
29  ** @date 16 7, 2014
30  **
31  ** @brief
32  ** @copyright
33  ** This source code is part of the Valentina project, a pattern making
34  ** program, whose allow create and modeling patterns of clothing.
35  ** Copyright (C) 2013-2015 Valentina project
36  ** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
37  **
38  ** Valentina is free software: you can redistribute it and/or modify
39  ** it under the terms of the GNU General Public License as published by
40  ** the Free Software Foundation, either version 3 of the License, or
41  ** (at your option) any later version.
42  **
43  ** Valentina is distributed in the hope that it will be useful,
44  ** but WITHOUT ANY WARRANTY; without even the implied warranty of
45  ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
46  ** GNU General Public License for more details.
47  **
48  ** You should have received a copy of the GNU General Public License
49  ** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
50  **
51  *************************************************************************/
52 
53 #ifndef VUNDOCOMMAND_H
54 #define VUNDOCOMMAND_H
55 
56 #include <qcompilerdetection.h>
57 #include <QDomElement>
58 #include <QMetaObject>
59 #include <QObject>
60 #include <QString>
61 #include <QUndoCommand>
62 #include <QVector>
63 #include <QtGlobal>
64 
65 #include "../ifc/xml/vabstractpattern.h"
66 #include "../vmisc/logging.h"
67 
68 Q_DECLARE_LOGGING_CATEGORY(vUndo)
69 
70 enum class UndoCommand: char { AddDraftBlock,
71  AddToCalc,
72  MoveSpline,
74  MoveSPoint,
78  MovePiece,
79  deleteTool,
82  MoveLabel,
88  };
89 
90 class VPattern;
91 
92 class VUndoCommand : public QObject, public QUndoCommand
93 {
94  Q_OBJECT
95 public:
96  VUndoCommand(const QDomElement &xml, VAbstractPattern *doc, QUndoCommand *parent = nullptr);
97  virtual ~VUndoCommand() =default;
98 
99 signals:
100  void ClearScene();
102  void NeedLiteParsing(const Document &parse);
103 
104 protected:
105  QDomElement xml;
107  quint32 nodeId;
108  bool redoFlag;
109  virtual void RedoFullParsing();
110  void UndoDeleteAfterSibling(QDomNode &parentNode, const quint32 &siblingId) const;
111 
112  void IncrementReferences(const QVector<quint32> &nodes) const;
113  void DecrementReferences(const QVector<quint32> &nodes) const;
114 
115  void IncrementReferences(const QVector<CustomSARecord> &nodes) const;
116  void DecrementReferences(const QVector<CustomSARecord> &nodes) const;
117 
118  void IncrementReferences(const QVector<VPieceNode> &nodes) const;
119  void DecrementReferences(const QVector<VPieceNode> &nodes) const;
120 
121  QDomElement getDestinationObject(quint32 idTool, quint32 idPoint) const;
122 
123 private:
124  Q_DISABLE_COPY(VUndoCommand)
125 };
126 
127 #endif // VUNDOCOMMAND_H
The VPattern class working with pattern file.
Definition: vpattern.h:68
void NeedFullParsing()
virtual void RedoFullParsing()
void DecrementReferences(const QVector< quint32 > &nodes) const
void ClearScene()
QDomElement xml
Definition: vundocommand.h:105
VAbstractPattern * doc
Definition: vundocommand.h:106
virtual ~VUndoCommand()=default
void NeedLiteParsing(const Document &parse)
void IncrementReferences(const QVector< quint32 > &nodes) const
VUndoCommand(const QDomElement &xml, VAbstractPattern *doc, QUndoCommand *parent=nullptr)
void UndoDeleteAfterSibling(QDomNode &parentNode, const quint32 &siblingId) const
QDomElement getDestinationObject(quint32 idTool, quint32 idPoint) const
quint32 nodeId
Definition: vundocommand.h:107
Document
UndoCommand
Definition: vundocommand.h:70