mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-17 12:40:35 +01:00
Wrap code for better readability
This commit is contained in:
@@ -28,7 +28,9 @@
|
||||
* AddElementTextCommand*
|
||||
* **********************/
|
||||
|
||||
AddElementTextCommand::AddElementTextCommand(Element *element, DynamicElementTextItem *deti, QUndoCommand *parent):
|
||||
AddElementTextCommand::AddElementTextCommand(Element *element,
|
||||
DynamicElementTextItem *deti,
|
||||
QUndoCommand *parent):
|
||||
QUndoCommand(parent),
|
||||
m_element(element),
|
||||
m_text(deti)
|
||||
@@ -68,7 +70,9 @@ void AddElementTextCommand::redo()
|
||||
* @param groupe_name : the name of the group
|
||||
* @param parent : parent undo
|
||||
*/
|
||||
AddTextsGroupCommand::AddTextsGroupCommand(Element *element, QString groupe_name, QUndoCommand *parent) :
|
||||
AddTextsGroupCommand::AddTextsGroupCommand(Element *element,
|
||||
QString groupe_name,
|
||||
QUndoCommand *parent) :
|
||||
QUndoCommand(parent),
|
||||
m_element(element),
|
||||
m_name(std::move(groupe_name))
|
||||
@@ -82,7 +86,9 @@ AddTextsGroupCommand::AddTextsGroupCommand(Element *element, QString groupe_name
|
||||
* @param dom_element : the first time the group is created, we call the function fromXml of the group, and give @dom_element has argument.
|
||||
* @param parent : parent undo
|
||||
*/
|
||||
AddTextsGroupCommand::AddTextsGroupCommand(Element *element, const QDomElement& dom_element, QUndoCommand *parent) :
|
||||
AddTextsGroupCommand::AddTextsGroupCommand(Element *element,
|
||||
const QDomElement& dom_element,
|
||||
QUndoCommand *parent) :
|
||||
QUndoCommand(parent),
|
||||
m_element(element),
|
||||
m_dom_element(dom_element)
|
||||
@@ -96,7 +102,11 @@ AddTextsGroupCommand::AddTextsGroupCommand(Element *element, const QDomElement&
|
||||
* @param texts_list : a list of texts to add to the created group (texts must be child of element)
|
||||
* @param parent : parent undo
|
||||
*/
|
||||
AddTextsGroupCommand::AddTextsGroupCommand(Element *element, QString groupe_name, QList<DynamicElementTextItem *> texts_list, QUndoCommand *parent) :
|
||||
AddTextsGroupCommand::AddTextsGroupCommand(
|
||||
Element *element,
|
||||
QString groupe_name,
|
||||
QList<DynamicElementTextItem *> texts_list,
|
||||
QUndoCommand *parent) :
|
||||
QUndoCommand(parent),
|
||||
m_element(element),
|
||||
m_name(std::move(groupe_name))
|
||||
@@ -129,33 +139,38 @@ void AddTextsGroupCommand::undo()
|
||||
|
||||
void AddTextsGroupCommand::redo()
|
||||
{
|
||||
if(m_element)
|
||||
if(!m_element)
|
||||
return;
|
||||
if(m_first_undo)
|
||||
{
|
||||
if(m_first_undo)
|
||||
m_group = m_element.data()->addTextGroup(m_name);
|
||||
if(!m_dom_element.isNull())
|
||||
{
|
||||
m_group = m_element.data()->addTextGroup(m_name);
|
||||
if(!m_dom_element.isNull())
|
||||
{
|
||||
m_group.data()->fromXml(m_dom_element);
|
||||
//We get the list of texts (if any) because when undo is called, all child text will be removed
|
||||
//from the group, and reparented to m_elemeny.
|
||||
//Then the next time redo is called, the texts will be added to the group
|
||||
m_deti_list = m_group.data()->texts();
|
||||
m_group.data()->updateAlignment();
|
||||
}
|
||||
else
|
||||
{
|
||||
for(DynamicElementTextItem *deti : m_deti_list)
|
||||
m_element.data()->addTextToGroup(deti, m_group.data());
|
||||
}
|
||||
m_first_undo = false;
|
||||
m_group.data()->fromXml(m_dom_element);
|
||||
/* We get the list of texts (if any)
|
||||
* because when undo is called,
|
||||
* all child text will be removed
|
||||
* from the group, and reparented to m_elemeny.
|
||||
* Then the next time redo is called,
|
||||
* the texts will be added to the group
|
||||
*/
|
||||
m_deti_list = m_group.data()->texts();
|
||||
m_group.data()->updateAlignment();
|
||||
}
|
||||
else if(m_group)
|
||||
else
|
||||
{
|
||||
m_element.data()->addTextGroup(m_group.data());
|
||||
for(DynamicElementTextItem *deti : m_deti_list)
|
||||
m_element.data()->addTextToGroup(deti, m_group.data());
|
||||
m_element.data()->addTextToGroup(
|
||||
deti,
|
||||
m_group.data());
|
||||
}
|
||||
m_first_undo = false;
|
||||
}
|
||||
else if(m_group)
|
||||
{
|
||||
m_element.data()->addTextGroup(m_group.data());
|
||||
for(DynamicElementTextItem *deti : m_deti_list)
|
||||
m_element.data()->addTextToGroup(deti, m_group.data());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -169,7 +184,9 @@ void AddTextsGroupCommand::redo()
|
||||
* @param group : the group to remove
|
||||
* @param parent : the parent undo command
|
||||
*/
|
||||
RemoveTextsGroupCommand::RemoveTextsGroupCommand(Element *element, ElementTextItemGroup *group, QUndoCommand *parent) :
|
||||
RemoveTextsGroupCommand::RemoveTextsGroupCommand(Element *element,
|
||||
ElementTextItemGroup *group,
|
||||
QUndoCommand *parent) :
|
||||
QUndoCommand(parent),
|
||||
m_element(element),
|
||||
m_group(group)
|
||||
@@ -191,7 +208,9 @@ void RemoveTextsGroupCommand::undo()
|
||||
|
||||
for(const QPointer<DynamicElementTextItem>& p : m_text_list)
|
||||
if(p)
|
||||
m_element.data()->addTextToGroup(p.data(), m_group.data());
|
||||
m_element.data()->addTextToGroup(
|
||||
p.data(),
|
||||
m_group.data());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -201,7 +220,9 @@ void RemoveTextsGroupCommand::redo()
|
||||
{
|
||||
for(const QPointer<DynamicElementTextItem>& p : m_text_list)
|
||||
if(p)
|
||||
m_element.data()->removeTextFromGroup(p.data(), m_group.data());
|
||||
m_element.data()->removeTextFromGroup(
|
||||
p.data(),
|
||||
m_group.data());
|
||||
|
||||
m_element.data()->removeTextGroup(m_group.data());
|
||||
}
|
||||
@@ -217,7 +238,9 @@ void RemoveTextsGroupCommand::redo()
|
||||
* @param group
|
||||
* @param parent
|
||||
*/
|
||||
AddTextToGroupCommand::AddTextToGroupCommand(DynamicElementTextItem *text, ElementTextItemGroup *group, QUndoCommand *parent) :
|
||||
AddTextToGroupCommand::AddTextToGroupCommand(DynamicElementTextItem *text,
|
||||
ElementTextItemGroup *group,
|
||||
QUndoCommand *parent) :
|
||||
QUndoCommand(parent),
|
||||
m_text(text),
|
||||
m_group(group),
|
||||
@@ -268,7 +291,10 @@ void AddTextToGroupCommand::redo()
|
||||
* @param group
|
||||
* @param parent : parent undo command
|
||||
*/
|
||||
RemoveTextFromGroupCommand::RemoveTextFromGroupCommand(DynamicElementTextItem *text, ElementTextItemGroup *group, QUndoCommand *parent):
|
||||
RemoveTextFromGroupCommand::RemoveTextFromGroupCommand(
|
||||
DynamicElementTextItem *text,
|
||||
ElementTextItemGroup *group,
|
||||
QUndoCommand *parent):
|
||||
QUndoCommand(parent),
|
||||
m_text(text),
|
||||
m_group(group),
|
||||
@@ -313,7 +339,10 @@ void RemoveTextFromGroupCommand::redo()
|
||||
* @param new_alignment : the new alignment of the group
|
||||
* @param parent : the parent QUndoCommand of this undo
|
||||
*/
|
||||
AlignmentTextsGroupCommand::AlignmentTextsGroupCommand(ElementTextItemGroup *group, Qt::Alignment new_alignment, QUndoCommand *parent) :
|
||||
AlignmentTextsGroupCommand::AlignmentTextsGroupCommand(
|
||||
ElementTextItemGroup *group,
|
||||
Qt::Alignment new_alignment,
|
||||
QUndoCommand *parent) :
|
||||
QUndoCommand(parent),
|
||||
m_group(group),
|
||||
m_previous_alignment(group->alignment()),
|
||||
@@ -349,7 +378,8 @@ bool AlignmentTextsGroupCommand::mergeWith(const QUndoCommand *other)
|
||||
if (id() != other->id() || other->childCount())
|
||||
return false;
|
||||
|
||||
AlignmentTextsGroupCommand const *undo = static_cast<const AlignmentTextsGroupCommand *>(other);
|
||||
AlignmentTextsGroupCommand const *undo =
|
||||
static_cast<const AlignmentTextsGroupCommand *>(other);
|
||||
if (m_group != undo->m_group)
|
||||
return false;
|
||||
|
||||
@@ -365,8 +395,8 @@ void AlignmentTextsGroupCommand::undo()
|
||||
if(m_group)
|
||||
{
|
||||
m_group.data()->setAlignment(m_previous_alignment);
|
||||
//The alignment befor this command was free, then we must
|
||||
//to restor the pos of each texts
|
||||
//The alignment befor this command was free, then we must
|
||||
//to restor the pos of each texts
|
||||
if(!m_texts_pos.isEmpty())
|
||||
{
|
||||
for(DynamicElementTextItem *deti : m_group.data()->texts())
|
||||
|
||||
@@ -33,7 +33,9 @@ class ElementTextItemGroup;
|
||||
class AddElementTextCommand : public QUndoCommand
|
||||
{
|
||||
public:
|
||||
AddElementTextCommand(Element *element, DynamicElementTextItem *deti, QUndoCommand *parent = nullptr);
|
||||
AddElementTextCommand(Element *element,
|
||||
DynamicElementTextItem *deti,
|
||||
QUndoCommand *parent = nullptr);
|
||||
~AddElementTextCommand() override;
|
||||
|
||||
void undo() override;
|
||||
@@ -51,9 +53,16 @@ class AddElementTextCommand : public QUndoCommand
|
||||
class AddTextsGroupCommand : public QUndoCommand
|
||||
{
|
||||
public:
|
||||
AddTextsGroupCommand(Element *element, QString groupe_name, QUndoCommand *parent = nullptr);
|
||||
AddTextsGroupCommand(Element *element, const QDomElement& dom_element, QUndoCommand *parent = nullptr);
|
||||
AddTextsGroupCommand(Element *element, QString groupe_name, QList<DynamicElementTextItem *> texts_list, QUndoCommand *parent = nullptr);
|
||||
AddTextsGroupCommand(Element *element,
|
||||
QString groupe_name,
|
||||
QUndoCommand *parent = nullptr);
|
||||
AddTextsGroupCommand(Element *element,
|
||||
const QDomElement& dom_element,
|
||||
QUndoCommand *parent = nullptr);
|
||||
AddTextsGroupCommand(Element *element,
|
||||
QString groupe_name,
|
||||
QList<DynamicElementTextItem *> texts_list,
|
||||
QUndoCommand *parent = nullptr);
|
||||
~AddTextsGroupCommand() override;
|
||||
|
||||
void undo() override;
|
||||
@@ -75,7 +84,9 @@ class AddTextsGroupCommand : public QUndoCommand
|
||||
class RemoveTextsGroupCommand : public QUndoCommand
|
||||
{
|
||||
public:
|
||||
RemoveTextsGroupCommand(Element *element, ElementTextItemGroup *group, QUndoCommand *parent = nullptr);
|
||||
RemoveTextsGroupCommand(Element *element,
|
||||
ElementTextItemGroup *group,
|
||||
QUndoCommand *parent = nullptr);
|
||||
~RemoveTextsGroupCommand() override;
|
||||
|
||||
void undo() override;
|
||||
@@ -90,7 +101,9 @@ class RemoveTextsGroupCommand : public QUndoCommand
|
||||
class AddTextToGroupCommand : public QUndoCommand
|
||||
{
|
||||
public:
|
||||
AddTextToGroupCommand(DynamicElementTextItem *text, ElementTextItemGroup *group, QUndoCommand *parent = nullptr);
|
||||
AddTextToGroupCommand(DynamicElementTextItem *text,
|
||||
ElementTextItemGroup *group,
|
||||
QUndoCommand *parent = nullptr);
|
||||
~AddTextToGroupCommand() override;
|
||||
|
||||
void undo() override;
|
||||
@@ -105,7 +118,9 @@ class AddTextToGroupCommand : public QUndoCommand
|
||||
class RemoveTextFromGroupCommand : public QUndoCommand
|
||||
{
|
||||
public:
|
||||
RemoveTextFromGroupCommand(DynamicElementTextItem *text, ElementTextItemGroup *group, QUndoCommand *parent = nullptr);
|
||||
RemoveTextFromGroupCommand(DynamicElementTextItem *text,
|
||||
ElementTextItemGroup *group,
|
||||
QUndoCommand *parent = nullptr);
|
||||
~RemoveTextFromGroupCommand() override;
|
||||
|
||||
void undo() override;
|
||||
@@ -120,7 +135,9 @@ class RemoveTextFromGroupCommand : public QUndoCommand
|
||||
class AlignmentTextsGroupCommand : public QUndoCommand
|
||||
{
|
||||
public:
|
||||
AlignmentTextsGroupCommand(ElementTextItemGroup *group, Qt::Alignment new_alignment, QUndoCommand *parent = nullptr);
|
||||
AlignmentTextsGroupCommand(ElementTextItemGroup *group,
|
||||
Qt::Alignment new_alignment,
|
||||
QUndoCommand *parent = nullptr);
|
||||
~AlignmentTextsGroupCommand() override;
|
||||
|
||||
int id() const override{return 6;}
|
||||
|
||||
Reference in New Issue
Block a user