QElectroTech  0.8-dev
addelementtextcommand.h
Go to the documentation of this file.
1 /*
2  Copyright 2006-2020 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 
25 class Element;
28 
33 class AddElementTextCommand : public QUndoCommand
34 {
35  public:
38  QUndoCommand *parent = nullptr);
39  ~AddElementTextCommand() override;
40 
41  void undo() override;
42  void redo() override;
43 
44  private:
45  Element *m_element = nullptr;
47 };
48 
53 class AddTextsGroupCommand : public QUndoCommand
54 {
55  public:
57  QString groupe_name,
58  QUndoCommand *parent = nullptr);
60  const QDomElement& dom_element,
61  QUndoCommand *parent = nullptr);
63  QString groupe_name,
64  QList<DynamicElementTextItem *> texts_list,
65  QUndoCommand *parent = nullptr);
66  ~AddTextsGroupCommand() override;
67 
68  void undo() override;
69  void redo() override;
70 
71  private:
72  QPointer<Element> m_element;
73  QPointer<ElementTextItemGroup> m_group;
74  QList <DynamicElementTextItem *> m_deti_list;
75  QDomElement m_dom_element;
76  QString m_name;
77  bool m_first_undo = true;
78 };
79 
84 class RemoveTextsGroupCommand : public QUndoCommand
85 {
86  public:
88  ElementTextItemGroup *group,
89  QUndoCommand *parent = nullptr);
90  ~RemoveTextsGroupCommand() override;
91 
92  void undo() override;
93  void redo() override;
94 
95  private:
96  QPointer<Element> m_element;
97  QPointer<ElementTextItemGroup> m_group;
98  QList<QPointer<DynamicElementTextItem>> m_text_list;
99 };
100 
104 class AddTextToGroupCommand : public QUndoCommand
105 {
106  public:
108  ElementTextItemGroup *group,
109  QUndoCommand *parent = nullptr);
110  ~AddTextToGroupCommand() override;
111 
112  void undo() override;
113  void redo() override;
114 
115  private:
116  QPointer<DynamicElementTextItem> m_text;
117  QPointer<ElementTextItemGroup> m_group;
118  QPointer<Element> m_element;
119 };
120 
124 class RemoveTextFromGroupCommand : public QUndoCommand
125 {
126  public:
128  ElementTextItemGroup *group,
129  QUndoCommand *parent = nullptr);
130  ~RemoveTextFromGroupCommand() override;
131 
132  void undo() override;
133  void redo() override;
134 
135  private:
136  QPointer<DynamicElementTextItem> m_text;
137  QPointer<ElementTextItemGroup> m_group;
138  QPointer<Element> m_element;
139 };
140 
144 class AlignmentTextsGroupCommand : public QUndoCommand
145 {
146  public:
148  Qt::Alignment new_alignment,
149  QUndoCommand *parent = nullptr);
150  ~AlignmentTextsGroupCommand() override;
151 
152  int id() const override{return 6;}
153  bool mergeWith(const QUndoCommand *other) override;
154  void undo() override;
155  void redo() override;
156 
157  private:
158  QPointer<ElementTextItemGroup> m_group;
159  Qt::Alignment m_previous_alignment,
161  QHash<DynamicElementTextItem *, QPointF> m_texts_pos;
162 };
163 
164 #endif // ADDELEMENTTEXTCOMMAND_H
AlignmentTextsGroupCommand::m_new_alignment
Qt::Alignment m_new_alignment
Definition: addelementtextcommand.h:160
RemoveTextsGroupCommand::redo
void redo() override
RemoveTextsGroupCommand::redo.
Definition: addelementtextcommand.cpp:251
AddTextsGroupCommand::AddTextsGroupCommand
AddTextsGroupCommand(Element *element, QString groupe_name, QUndoCommand *parent=nullptr)
AddTextsGroupCommand::AddTextsGroupCommand.
Definition: addelementtextcommand.cpp:88
AddTextsGroupCommand::m_deti_list
QList< DynamicElementTextItem * > m_deti_list
Definition: addelementtextcommand.h:74
DynamicElementTextItem
The DynamicElementTextItem class This class provide a simple text field of element who can be added o...
Definition: dynamicelementtextitem.h:39
RemoveTextFromGroupCommand::redo
void redo() override
RemoveTextFromGroupCommand::redo.
Definition: addelementtextcommand.cpp:372
AddTextsGroupCommand::m_element
QPointer< Element > m_element
Definition: addelementtextcommand.h:72
AlignmentTextsGroupCommand::id
int id() const override
Definition: addelementtextcommand.h:152
RemoveTextFromGroupCommand::~RemoveTextFromGroupCommand
~RemoveTextFromGroupCommand() override
RemoveTextFromGroupCommand::~RemoveTextFromGroupCommand Destructor.
Definition: addelementtextcommand.cpp:350
RemoveTextsGroupCommand::m_text_list
QList< QPointer< DynamicElementTextItem > > m_text_list
Definition: addelementtextcommand.h:98
elementtextitemgroup.h
RemoveTextsGroupCommand::undo
void undo() override
RemoveTextsGroupCommand::undo.
Definition: addelementtextcommand.cpp:234
AlignmentTextsGroupCommand::AlignmentTextsGroupCommand
AlignmentTextsGroupCommand(ElementTextItemGroup *group, Qt::Alignment new_alignment, QUndoCommand *parent=nullptr)
AlignmentTextsGroupCommand::AlignmentTextsGroupCommand.
Definition: addelementtextcommand.cpp:388
AddTextToGroupCommand::AddTextToGroupCommand
AddTextToGroupCommand(DynamicElementTextItem *text, ElementTextItemGroup *group, QUndoCommand *parent=nullptr)
AddTextToGroupCommand::AddTextToGroupCommand.
Definition: addelementtextcommand.cpp:275
RemoveTextsGroupCommand::~RemoveTextsGroupCommand
~RemoveTextsGroupCommand() override
RemoveTextsGroupCommand::~RemoveTextsGroupCommand.
Definition: addelementtextcommand.cpp:228
AddTextsGroupCommand::m_group
QPointer< ElementTextItemGroup > m_group
Definition: addelementtextcommand.h:73
addelementtextcommand.h
AlignmentTextsGroupCommand::mergeWith
bool mergeWith(const QUndoCommand *other) override
AlignmentTextsGroupCommand::mergeWith Try to merge this command with other command.
Definition: addelementtextcommand.cpp:422
AlignmentTextsGroupCommand::m_group
QPointer< ElementTextItemGroup > m_group
Definition: addelementtextcommand.h:158
AddTextToGroupCommand::redo
void redo() override
AddTextToGroupCommand::redo.
Definition: addelementtextcommand.cpp:312
AddTextToGroupCommand::m_element
QPointer< Element > m_element
Definition: addelementtextcommand.h:118
AddElementTextCommand::redo
void redo() override
AddElementTextCommand::redo.
Definition: addelementtextcommand.cpp:72
AddTextsGroupCommand
The AddTextsGroupCommand class Manage the adding of a texts group.
Definition: addelementtextcommand.h:54
AddElementTextCommand::~AddElementTextCommand
~AddElementTextCommand() override
AddElementTextCommand::~AddElementTextCommand.
Definition: addelementtextcommand.cpp:50
AlignmentTextsGroupCommand::m_texts_pos
QHash< DynamicElementTextItem *, QPointF > m_texts_pos
Definition: addelementtextcommand.h:161
AddTextsGroupCommand::undo
void undo() override
AddTextsGroupCommand::undo.
Definition: addelementtextcommand.cpp:156
RemoveTextsGroupCommand::RemoveTextsGroupCommand
RemoveTextsGroupCommand(Element *element, ElementTextItemGroup *group, QUndoCommand *parent=nullptr)
RemoveTextsGroupCommand::RemoveTextsGroupCommand.
Definition: addelementtextcommand.cpp:212
RemoveTextFromGroupCommand::RemoveTextFromGroupCommand
RemoveTextFromGroupCommand(DynamicElementTextItem *text, ElementTextItemGroup *group, QUndoCommand *parent=nullptr)
RemoveTextFromGroupCommand::RemoveTextFromGroupCommand.
Definition: addelementtextcommand.cpp:334
ElementTextItemGroup::texts
QList< DynamicElementTextItem * > texts() const
ElementTextItemGroup::texts.
Definition: elementtextitemgroup.cpp:330
Element::removeDynamicTextItem
void removeDynamicTextItem(DynamicElementTextItem *deti)
Element::removeDynamicTextItem Remove deti, no matter if is a child of this element or a child of a g...
Definition: element.cpp:1287
AlignmentTextsGroupCommand::undo
void undo() override
AlignmentTextsGroupCommand::undo.
Definition: addelementtextcommand.cpp:439
element.h
Element::addDynamicTextItem
void addDynamicTextItem(DynamicElementTextItem *deti=nullptr)
Element::addDynamiqueTextItem Add deti as a dynamic text item of this element, deti is reparented to ...
Definition: element.cpp:1264
AlignmentTextsGroupCommand
The AlignmentTextsGroupCommand class.
Definition: addelementtextcommand.h:145
RemoveTextFromGroupCommand::undo
void undo() override
RemoveTextFromGroupCommand::undo.
Definition: addelementtextcommand.cpp:363
RemoveTextsGroupCommand::m_element
QPointer< Element > m_element
Definition: addelementtextcommand.h:96
RemoveTextsGroupCommand
The RemoveTextsGroupCommand class Manage the removinf of a texts group.
Definition: addelementtextcommand.h:85
Element
Definition: element.h:41
RemoveTextFromGroupCommand::m_element
QPointer< Element > m_element
Definition: addelementtextcommand.h:138
AddTextsGroupCommand::m_dom_element
QDomElement m_dom_element
Definition: addelementtextcommand.h:75
AddElementTextCommand::m_element
Element * m_element
Definition: addelementtextcommand.h:45
AddTextsGroupCommand::m_name
QString m_name
Definition: addelementtextcommand.h:76
RemoveTextsGroupCommand::m_group
QPointer< ElementTextItemGroup > m_group
Definition: addelementtextcommand.h:97
RemoveTextFromGroupCommand
The RemoveTextFromGroupCommand class.
Definition: addelementtextcommand.h:125
AddTextToGroupCommand::undo
void undo() override
AddTextToGroupCommand::undo.
Definition: addelementtextcommand.cpp:303
AddTextToGroupCommand::m_group
QPointer< ElementTextItemGroup > m_group
Definition: addelementtextcommand.h:117
AddTextsGroupCommand::redo
void redo() override
AddTextsGroupCommand::redo.
Definition: addelementtextcommand.cpp:165
ElementTextItemGroup
The ElementTextItemGroup class This class represent a group of element text Texts in the group can be...
Definition: elementtextitemgroup.h:36
AddElementTextCommand::AddElementTextCommand
AddElementTextCommand(Element *element, DynamicElementTextItem *deti, QUndoCommand *parent=nullptr)
AddElementTextCommand::AddElementTextCommand.
Definition: addelementtextcommand.cpp:37
RemoveTextFromGroupCommand::m_text
QPointer< DynamicElementTextItem > m_text
Definition: addelementtextcommand.h:136
AddElementTextCommand::undo
void undo() override
AddElementTextCommand::undo.
Definition: addelementtextcommand.cpp:62
RemoveTextFromGroupCommand::m_group
QPointer< ElementTextItemGroup > m_group
Definition: addelementtextcommand.h:137
AddTextToGroupCommand::~AddTextToGroupCommand
~AddTextToGroupCommand() override
AddTextToGroupCommand::~AddTextToGroupCommand Destructor.
Definition: addelementtextcommand.cpp:290
AlignmentTextsGroupCommand::~AlignmentTextsGroupCommand
~AlignmentTextsGroupCommand() override
AlignmentTextsGroupCommand::~AlignmentTextsGroupCommand Destructor.
Definition: addelementtextcommand.cpp:413
DynamicElementTextItem::parentGroup
ElementTextItemGroup * parentGroup() const
DynamicElementTextItem::parentGroup.
Definition: dynamicelementtextitem.cpp:236
dynamicelementtextitem.h
AddTextsGroupCommand::~AddTextsGroupCommand
~AddTextsGroupCommand() override
AddTextsGroupCommand::~AddTextsGroupCommand Destructor.
Definition: addelementtextcommand.cpp:150
AddElementTextCommand::m_text
DynamicElementTextItem * m_text
Definition: addelementtextcommand.h:46
AlignmentTextsGroupCommand::m_previous_alignment
Qt::Alignment m_previous_alignment
Definition: addelementtextcommand.h:159
AddTextsGroupCommand::m_first_undo
bool m_first_undo
Definition: addelementtextcommand.h:77
QET::Icons::tr
QIcon tr
Definition: qeticons.cpp:206
AddTextToGroupCommand
The AddTextToGroupCommand class.
Definition: addelementtextcommand.h:105
AlignmentTextsGroupCommand::redo
void redo() override
AlignmentTextsGroupCommand::redo.
Definition: addelementtextcommand.cpp:460
Element::dynamicTextItems
QList< DynamicElementTextItem * > dynamicTextItems() const
Element::dynamicTextItems.
Definition: element.cpp:1316
AddTextToGroupCommand::m_text
QPointer< DynamicElementTextItem > m_text
Definition: addelementtextcommand.h:116
AddElementTextCommand
The AddElementTextCommand class Manage the adding of element text.
Definition: addelementtextcommand.h:34