QElectroTech 0.100.0-dev
Loading...
Searching...
No Matches
addelementtextcommand.h
Go to the documentation of this file.
1/*
2 Copyright 2006-2024 The QElectroTech Team
3 This file is part of QElectroTech.
4
5 QElectroTech is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 2 of the License, or
8 (at your option) any later version.
9
10 QElectroTech is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
17*/
18#ifndef ADDELEMENTTEXTCOMMAND_H
19#define ADDELEMENTTEXTCOMMAND_H
20
21#include <QUndoCommand>
22#include <QPointer>
23#include <QDomElement>
24#include <QHash>
25
26class Element;
29
34class AddElementTextCommand : public QUndoCommand
35{
36 public:
39 QUndoCommand *parent = nullptr);
40 ~AddElementTextCommand() override;
41
42 void undo() override;
43 void redo() override;
44
45 private:
46 Element *m_element = nullptr;
48};
49
54class AddTextsGroupCommand : public QUndoCommand
55{
56 public:
58 QString groupe_name,
59 QUndoCommand *parent = nullptr);
61 const QDomElement& dom_element,
62 QUndoCommand *parent = nullptr);
64 QString groupe_name,
65 QList<DynamicElementTextItem *> texts_list,
66 QUndoCommand *parent = nullptr);
67 ~AddTextsGroupCommand() override;
68
69 void undo() override;
70 void redo() override;
71
72 private:
73 QPointer<Element> m_element;
74 QPointer<ElementTextItemGroup> m_group;
75 QList <DynamicElementTextItem *> m_deti_list;
76 QDomElement m_dom_element;
77 QString m_name;
78 bool m_first_undo = true;
79};
80
85class RemoveTextsGroupCommand : public QUndoCommand
86{
87 public:
90 QUndoCommand *parent = nullptr);
91 ~RemoveTextsGroupCommand() override;
92
93 void undo() override;
94 void redo() override;
95
96 private:
97 QPointer<Element> m_element;
98 QPointer<ElementTextItemGroup> m_group;
99 QList<QPointer<DynamicElementTextItem>> m_text_list;
100};
101
105class AddTextToGroupCommand : public QUndoCommand
106{
107 public:
110 QUndoCommand *parent = nullptr);
111 ~AddTextToGroupCommand() override;
112
113 void undo() override;
114 void redo() override;
115
116 private:
117 QPointer<DynamicElementTextItem> m_text;
118 QPointer<ElementTextItemGroup> m_group;
119 QPointer<Element> m_element;
120};
121
125class RemoveTextFromGroupCommand : public QUndoCommand
126{
127 public:
130 QUndoCommand *parent = nullptr);
132
133 void undo() override;
134 void redo() override;
135
136 private:
137 QPointer<DynamicElementTextItem> m_text;
138 QPointer<ElementTextItemGroup> m_group;
139 QPointer<Element> m_element;
140};
141
145class AlignmentTextsGroupCommand : public QUndoCommand
146{
147 public:
149 Qt::Alignment new_alignment,
150 QUndoCommand *parent = nullptr);
152
153 int id() const override{return 6;}
154 bool mergeWith(const QUndoCommand *other) override;
155 void undo() override;
156 void redo() override;
157
158 private:
159 QPointer<ElementTextItemGroup> m_group;
160 Qt::Alignment m_previous_alignment,
162 QHash<DynamicElementTextItem *, QPointF> m_texts_pos;
163};
164
165#endif // ADDELEMENTTEXTCOMMAND_H
The AddElementTextCommand class Manage the adding of element text.
Definition addelementtextcommand.h:35
void redo() override
AddElementTextCommand::redo.
Definition addelementtextcommand.cpp:72
void undo() override
AddElementTextCommand::undo.
Definition addelementtextcommand.cpp:62
Element * m_element
Definition addelementtextcommand.h:46
~AddElementTextCommand() override
AddElementTextCommand::~AddElementTextCommand.
Definition addelementtextcommand.cpp:50
DynamicElementTextItem * m_text
Definition addelementtextcommand.h:47
The AddTextToGroupCommand class.
Definition addelementtextcommand.h:106
~AddTextToGroupCommand() override
AddTextToGroupCommand::~AddTextToGroupCommand Destructor.
Definition addelementtextcommand.cpp:290
QPointer< DynamicElementTextItem > m_text
Definition addelementtextcommand.h:117
QPointer< Element > m_element
Definition addelementtextcommand.h:119
void undo() override
AddTextToGroupCommand::undo.
Definition addelementtextcommand.cpp:303
void redo() override
AddTextToGroupCommand::redo.
Definition addelementtextcommand.cpp:312
QPointer< ElementTextItemGroup > m_group
Definition addelementtextcommand.h:118
The AddTextsGroupCommand class Manage the adding of a texts group.
Definition addelementtextcommand.h:55
QList< DynamicElementTextItem * > m_deti_list
Definition addelementtextcommand.h:75
void redo() override
AddTextsGroupCommand::redo.
Definition addelementtextcommand.cpp:165
QString m_name
Definition addelementtextcommand.h:77
QPointer< Element > m_element
Definition addelementtextcommand.h:73
QDomElement m_dom_element
Definition addelementtextcommand.h:76
~AddTextsGroupCommand() override
AddTextsGroupCommand::~AddTextsGroupCommand Destructor.
Definition addelementtextcommand.cpp:150
bool m_first_undo
Definition addelementtextcommand.h:78
QPointer< ElementTextItemGroup > m_group
Definition addelementtextcommand.h:74
void undo() override
AddTextsGroupCommand::undo.
Definition addelementtextcommand.cpp:156
The AlignmentTextsGroupCommand class.
Definition addelementtextcommand.h:146
void redo() override
AlignmentTextsGroupCommand::redo.
Definition addelementtextcommand.cpp:460
bool mergeWith(const QUndoCommand *other) override
AlignmentTextsGroupCommand::mergeWith Try to merge this command with other command.
Definition addelementtextcommand.cpp:422
int id() const override
Definition addelementtextcommand.h:153
void undo() override
AlignmentTextsGroupCommand::undo.
Definition addelementtextcommand.cpp:439
Qt::Alignment m_previous_alignment
Definition addelementtextcommand.h:160
QHash< DynamicElementTextItem *, QPointF > m_texts_pos
Definition addelementtextcommand.h:162
~AlignmentTextsGroupCommand() override
AlignmentTextsGroupCommand::~AlignmentTextsGroupCommand Destructor.
Definition addelementtextcommand.cpp:413
QPointer< ElementTextItemGroup > m_group
Definition addelementtextcommand.h:159
Qt::Alignment m_new_alignment
Definition addelementtextcommand.h:161
The DynamicElementTextItem class This class provide a simple text field of element who can be added o...
Definition dynamicelementtextitem.h:40
Definition element.h:43
The ElementTextItemGroup class This class represent a group of element text Texts in the group can be...
Definition elementtextitemgroup.h:36
The RemoveTextFromGroupCommand class.
Definition addelementtextcommand.h:126
void redo() override
RemoveTextFromGroupCommand::redo.
Definition addelementtextcommand.cpp:372
void undo() override
RemoveTextFromGroupCommand::undo.
Definition addelementtextcommand.cpp:363
QPointer< ElementTextItemGroup > m_group
Definition addelementtextcommand.h:138
QPointer< Element > m_element
Definition addelementtextcommand.h:139
~RemoveTextFromGroupCommand() override
RemoveTextFromGroupCommand::~RemoveTextFromGroupCommand Destructor.
Definition addelementtextcommand.cpp:350
QPointer< DynamicElementTextItem > m_text
Definition addelementtextcommand.h:137
The RemoveTextsGroupCommand class Manage the removinf of a texts group.
Definition addelementtextcommand.h:86
void redo() override
RemoveTextsGroupCommand::redo.
Definition addelementtextcommand.cpp:251
~RemoveTextsGroupCommand() override
RemoveTextsGroupCommand::~RemoveTextsGroupCommand.
Definition addelementtextcommand.cpp:228
QPointer< ElementTextItemGroup > m_group
Definition addelementtextcommand.h:98
QList< QPointer< DynamicElementTextItem > > m_text_list
Definition addelementtextcommand.h:99
void undo() override
RemoveTextsGroupCommand::undo.
Definition addelementtextcommand.cpp:234
QPointer< Element > m_element
Definition addelementtextcommand.h:97