2017-08-03 17:36:08 +00:00
|
|
|
/*
|
2021-02-06 18:33:42 +01:00
|
|
|
Copyright 2006-2021 The QElectroTech Team
|
2017-08-03 17:36:08 +00:00
|
|
|
This file is part of QElectroTech.
|
2020-12-08 19:57:35 +01:00
|
|
|
|
2017-08-03 17:36:08 +00:00
|
|
|
QElectroTech is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
2020-12-08 19:57:35 +01:00
|
|
|
|
2017-08-03 17:36:08 +00:00
|
|
|
QElectroTech is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
2020-12-08 19:57:35 +01:00
|
|
|
|
2017-08-03 17:36:08 +00:00
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
#include "addelementtextcommand.h"
|
2020-12-08 19:57:35 +01:00
|
|
|
|
|
|
|
#include "../qetgraphicsitem/dynamicelementtextitem.h"
|
|
|
|
#include "../qetgraphicsitem/element.h"
|
|
|
|
#include "../qetgraphicsitem/elementtextitemgroup.h"
|
2017-11-29 14:49:12 +00:00
|
|
|
|
2017-08-03 17:36:08 +00:00
|
|
|
#include <QGraphicsScene>
|
2018-07-19 14:14:31 +00:00
|
|
|
#include <utility>
|
2017-08-03 17:36:08 +00:00
|
|
|
|
2017-11-29 14:49:12 +00:00
|
|
|
/************************
|
|
|
|
* AddElementTextCommand*
|
|
|
|
* **********************/
|
|
|
|
|
2020-08-12 21:53:02 +02:00
|
|
|
/**
|
|
|
|
@brief AddElementTextCommand::AddElementTextCommand
|
|
|
|
@param element
|
|
|
|
@param deti
|
|
|
|
@param parent
|
|
|
|
*/
|
2020-08-12 19:33:29 +02:00
|
|
|
AddElementTextCommand::AddElementTextCommand(Element *element,
|
|
|
|
DynamicElementTextItem *deti,
|
|
|
|
QUndoCommand *parent):
|
2017-08-03 17:36:08 +00:00
|
|
|
QUndoCommand(parent),
|
|
|
|
m_element(element),
|
|
|
|
m_text(deti)
|
|
|
|
{
|
|
|
|
setText(QObject::tr("Ajouter un texte d'élément"));
|
|
|
|
}
|
|
|
|
|
2020-08-12 21:53:02 +02:00
|
|
|
/**
|
|
|
|
@brief AddElementTextCommand::~AddElementTextCommand
|
|
|
|
*/
|
2017-08-03 17:36:08 +00:00
|
|
|
AddElementTextCommand::~AddElementTextCommand()
|
|
|
|
{
|
2017-11-27 19:37:39 +00:00
|
|
|
if(m_text->parentGroup())
|
|
|
|
return;
|
|
|
|
|
2017-08-03 17:36:08 +00:00
|
|
|
if(!m_element->dynamicTextItems().contains(m_text))
|
|
|
|
delete m_text;
|
|
|
|
}
|
|
|
|
|
2020-08-12 21:53:02 +02:00
|
|
|
/**
|
|
|
|
@brief AddElementTextCommand::undo
|
|
|
|
*/
|
2017-08-03 17:36:08 +00:00
|
|
|
void AddElementTextCommand::undo()
|
|
|
|
{
|
|
|
|
m_element->removeDynamicTextItem(m_text);
|
|
|
|
if(m_text->scene())
|
|
|
|
m_text->scene()->removeItem(m_text);
|
|
|
|
}
|
|
|
|
|
2020-08-12 21:53:02 +02:00
|
|
|
/**
|
|
|
|
@brief AddElementTextCommand::redo
|
|
|
|
*/
|
2017-08-03 17:36:08 +00:00
|
|
|
void AddElementTextCommand::redo()
|
|
|
|
{
|
|
|
|
m_text->setParentItem(m_element);
|
|
|
|
m_element->addDynamicTextItem(m_text);
|
|
|
|
}
|
|
|
|
|
2017-11-29 14:49:12 +00:00
|
|
|
|
|
|
|
/***********************
|
|
|
|
* AddTextsGroupCommand*
|
|
|
|
* *********************/
|
|
|
|
/**
|
2020-08-12 21:53:02 +02:00
|
|
|
@brief AddTextsGroupCommand::AddTextsGroupCommand
|
|
|
|
@param element : the element to add a new group
|
|
|
|
@param groupe_name : the name of the group
|
|
|
|
@param parent : parent undo
|
|
|
|
*/
|
2020-08-12 19:33:29 +02:00
|
|
|
AddTextsGroupCommand::AddTextsGroupCommand(Element *element,
|
|
|
|
QString groupe_name,
|
|
|
|
QUndoCommand *parent) :
|
2017-11-29 14:49:12 +00:00
|
|
|
QUndoCommand(parent),
|
|
|
|
m_element(element),
|
2018-07-19 14:14:31 +00:00
|
|
|
m_name(std::move(groupe_name))
|
2017-11-29 14:49:12 +00:00
|
|
|
{
|
|
|
|
setText(QObject::tr("Ajouter un groupe de textes d'élément"));
|
|
|
|
}
|
|
|
|
|
2017-12-30 14:41:25 +00:00
|
|
|
/**
|
2020-08-12 21:53:02 +02:00
|
|
|
@brief AddTextsGroupCommand::AddTextsGroupCommand
|
|
|
|
@param element : The element to add a new group
|
|
|
|
@param dom_element : the first time the group is created,
|
|
|
|
we call the function fromXml of the group,
|
2020-08-18 21:28:52 +02:00
|
|
|
and give dom_element has argument.
|
2020-08-12 21:53:02 +02:00
|
|
|
@param parent : parent undo
|
|
|
|
*/
|
2020-08-12 19:33:29 +02:00
|
|
|
AddTextsGroupCommand::AddTextsGroupCommand(Element *element,
|
|
|
|
const QDomElement& dom_element,
|
|
|
|
QUndoCommand *parent) :
|
2017-12-30 14:41:25 +00:00
|
|
|
QUndoCommand(parent),
|
|
|
|
m_element(element),
|
|
|
|
m_dom_element(dom_element)
|
|
|
|
{
|
2018-05-18 21:46:36 +00:00
|
|
|
setText(QObject::tr("Ajouter un groupe de textes d'élément"));
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2020-08-12 21:53:02 +02:00
|
|
|
@brief AddTextsGroupCommand::AddTextsGroupCommand
|
|
|
|
@param element : The element to add a new group
|
2020-08-20 21:57:35 +02:00
|
|
|
@param groupe_name
|
2020-08-12 21:53:02 +02:00
|
|
|
@param texts_list : a list of texts to add to the created group
|
|
|
|
(texts must be child of element)
|
|
|
|
@param parent : parent undo
|
|
|
|
*/
|
2020-08-12 19:33:29 +02:00
|
|
|
AddTextsGroupCommand::AddTextsGroupCommand(
|
|
|
|
Element *element,
|
|
|
|
QString groupe_name,
|
|
|
|
QList<DynamicElementTextItem *> texts_list,
|
|
|
|
QUndoCommand *parent) :
|
2018-05-18 21:46:36 +00:00
|
|
|
QUndoCommand(parent),
|
|
|
|
m_element(element),
|
2018-07-19 14:14:31 +00:00
|
|
|
m_name(std::move(groupe_name))
|
2018-05-18 21:46:36 +00:00
|
|
|
{
|
|
|
|
for(DynamicElementTextItem *deti : texts_list)
|
|
|
|
{
|
|
|
|
deti->setSelected(false);
|
|
|
|
if(deti->parentElement() == element)
|
|
|
|
{
|
|
|
|
m_deti_list << deti;
|
|
|
|
deti->setSelected(false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
setText(QObject::tr("Grouper des textes d'élément"));
|
2017-12-30 14:41:25 +00:00
|
|
|
}
|
|
|
|
|
2017-11-29 14:49:12 +00:00
|
|
|
/**
|
2020-08-12 21:53:02 +02:00
|
|
|
@brief AddTextsGroupCommand::~AddTextsGroupCommand
|
|
|
|
Destructor
|
|
|
|
*/
|
2017-11-29 14:49:12 +00:00
|
|
|
AddTextsGroupCommand::~AddTextsGroupCommand()
|
|
|
|
{}
|
|
|
|
|
2020-08-12 21:53:02 +02:00
|
|
|
/**
|
|
|
|
@brief AddTextsGroupCommand::undo
|
|
|
|
*/
|
2017-11-29 14:49:12 +00:00
|
|
|
void AddTextsGroupCommand::undo()
|
|
|
|
{
|
|
|
|
if(m_element && m_group)
|
|
|
|
m_element.data()->removeTextGroup(m_group);
|
|
|
|
}
|
|
|
|
|
2020-08-12 21:53:02 +02:00
|
|
|
/**
|
|
|
|
@brief AddTextsGroupCommand::redo
|
|
|
|
*/
|
2017-11-29 14:49:12 +00:00
|
|
|
void AddTextsGroupCommand::redo()
|
|
|
|
{
|
2020-08-12 19:33:29 +02:00
|
|
|
if(!m_element)
|
|
|
|
return;
|
|
|
|
if(m_first_undo)
|
2017-11-29 14:49:12 +00:00
|
|
|
{
|
2020-08-12 19:33:29 +02:00
|
|
|
m_group = m_element.data()->addTextGroup(m_name);
|
|
|
|
if(!m_dom_element.isNull())
|
2017-11-29 14:49:12 +00:00
|
|
|
{
|
2020-08-12 19:33:29 +02:00
|
|
|
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();
|
2017-11-29 14:49:12 +00:00
|
|
|
}
|
2020-08-12 19:33:29 +02:00
|
|
|
else
|
2017-12-30 14:41:25 +00:00
|
|
|
{
|
|
|
|
for(DynamicElementTextItem *deti : m_deti_list)
|
2020-08-12 19:33:29 +02:00
|
|
|
m_element.data()->addTextToGroup(
|
|
|
|
deti,
|
|
|
|
m_group.data());
|
2017-12-30 14:41:25 +00:00
|
|
|
}
|
2020-08-12 19:33:29 +02:00
|
|
|
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());
|
2017-11-29 14:49:12 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**************************
|
|
|
|
* RemoveTextsGroupCommand*
|
|
|
|
* ************************/
|
|
|
|
/**
|
2020-08-12 21:53:02 +02:00
|
|
|
@brief RemoveTextsGroupCommand::RemoveTextsGroupCommand
|
|
|
|
@param element : The element where we remove a group
|
|
|
|
@param group : the group to remove
|
|
|
|
@param parent : the parent undo command
|
|
|
|
*/
|
2020-08-12 19:33:29 +02:00
|
|
|
RemoveTextsGroupCommand::RemoveTextsGroupCommand(Element *element,
|
|
|
|
ElementTextItemGroup *group,
|
|
|
|
QUndoCommand *parent) :
|
2017-11-29 14:49:12 +00:00
|
|
|
QUndoCommand(parent),
|
|
|
|
m_element(element),
|
|
|
|
m_group(group)
|
|
|
|
{
|
|
|
|
setText(QObject::tr("Supprimer un groupe de textes d'élément"));
|
2017-12-01 18:36:57 +00:00
|
|
|
|
|
|
|
for(DynamicElementTextItem *deti : group->texts())
|
|
|
|
m_text_list.append(deti);
|
2017-11-29 14:49:12 +00:00
|
|
|
}
|
|
|
|
|
2020-08-12 21:53:02 +02:00
|
|
|
/**
|
|
|
|
@brief RemoveTextsGroupCommand::~RemoveTextsGroupCommand
|
|
|
|
*/
|
2017-11-29 14:49:12 +00:00
|
|
|
RemoveTextsGroupCommand::~RemoveTextsGroupCommand()
|
|
|
|
{}
|
2020-08-12 21:53:02 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
@brief RemoveTextsGroupCommand::undo
|
|
|
|
*/
|
2017-11-29 14:49:12 +00:00
|
|
|
void RemoveTextsGroupCommand::undo()
|
|
|
|
{
|
|
|
|
if(m_element && m_group)
|
2017-12-01 18:36:57 +00:00
|
|
|
{
|
2017-11-29 14:49:12 +00:00
|
|
|
m_element.data()->addTextGroup(m_group.data());
|
2017-12-01 18:36:57 +00:00
|
|
|
|
2018-07-19 14:14:31 +00:00
|
|
|
for(const QPointer<DynamicElementTextItem>& p : m_text_list)
|
2017-12-01 18:36:57 +00:00
|
|
|
if(p)
|
2020-08-12 19:33:29 +02:00
|
|
|
m_element.data()->addTextToGroup(
|
|
|
|
p.data(),
|
|
|
|
m_group.data());
|
2017-12-01 18:36:57 +00:00
|
|
|
}
|
2017-11-29 14:49:12 +00:00
|
|
|
}
|
|
|
|
|
2020-08-12 21:53:02 +02:00
|
|
|
/**
|
|
|
|
@brief RemoveTextsGroupCommand::redo
|
|
|
|
*/
|
2017-11-29 14:49:12 +00:00
|
|
|
void RemoveTextsGroupCommand::redo()
|
|
|
|
{
|
|
|
|
if(m_element && m_group)
|
2017-12-01 18:36:57 +00:00
|
|
|
{
|
2018-07-19 14:14:31 +00:00
|
|
|
for(const QPointer<DynamicElementTextItem>& p : m_text_list)
|
2017-12-01 18:36:57 +00:00
|
|
|
if(p)
|
2020-08-12 19:33:29 +02:00
|
|
|
m_element.data()->removeTextFromGroup(
|
|
|
|
p.data(),
|
|
|
|
m_group.data());
|
2017-12-01 18:36:57 +00:00
|
|
|
|
2017-11-29 14:49:12 +00:00
|
|
|
m_element.data()->removeTextGroup(m_group.data());
|
2017-12-01 18:36:57 +00:00
|
|
|
}
|
2017-11-29 14:49:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/************************
|
|
|
|
* AddTextToGroupCommand*
|
|
|
|
* **********************/
|
|
|
|
/**
|
2020-08-12 21:53:02 +02:00
|
|
|
@brief AddTextToGroupCommand::AddTextToGroupCommand
|
|
|
|
@param text
|
|
|
|
@param group
|
|
|
|
@param parent
|
|
|
|
*/
|
2020-08-12 19:33:29 +02:00
|
|
|
AddTextToGroupCommand::AddTextToGroupCommand(DynamicElementTextItem *text,
|
|
|
|
ElementTextItemGroup *group,
|
|
|
|
QUndoCommand *parent) :
|
2017-11-29 14:49:12 +00:00
|
|
|
QUndoCommand(parent),
|
|
|
|
m_text(text),
|
|
|
|
m_group(group),
|
|
|
|
m_element(group->parentElement())
|
|
|
|
{
|
|
|
|
setText(QObject::tr("Insérer un texte d'élément dans un groupe de textes"));
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2020-08-12 21:53:02 +02:00
|
|
|
@brief AddTextToGroupCommand::~AddTextToGroupCommand
|
|
|
|
Destructor
|
|
|
|
*/
|
2017-11-29 14:49:12 +00:00
|
|
|
AddTextToGroupCommand::~AddTextToGroupCommand()
|
|
|
|
{
|
|
|
|
if(m_group && m_text && m_element)
|
|
|
|
{
|
|
|
|
if(!m_group.data()->texts().contains(m_text.data()) &&
|
|
|
|
!m_element.data()->dynamicTextItems().contains(m_text.data()))
|
|
|
|
delete m_text.data();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-12 21:53:02 +02:00
|
|
|
/**
|
|
|
|
@brief AddTextToGroupCommand::undo
|
|
|
|
*/
|
2017-11-29 14:49:12 +00:00
|
|
|
void AddTextToGroupCommand::undo()
|
|
|
|
{
|
|
|
|
if(m_element && m_group && m_text)
|
|
|
|
m_element.data()->removeTextFromGroup(m_text, m_group);
|
|
|
|
}
|
|
|
|
|
2020-08-12 21:53:02 +02:00
|
|
|
/**
|
|
|
|
@brief AddTextToGroupCommand::redo
|
|
|
|
*/
|
2017-11-29 14:49:12 +00:00
|
|
|
void AddTextToGroupCommand::redo()
|
|
|
|
{
|
|
|
|
if(m_element && m_group && m_text)
|
2017-12-01 18:36:57 +00:00
|
|
|
{
|
|
|
|
if(m_text.data()->isSelected())
|
|
|
|
{
|
|
|
|
m_text.data()->setSelected(false);
|
|
|
|
m_group.data()->setSelected(true);
|
|
|
|
}
|
2017-11-29 14:49:12 +00:00
|
|
|
m_element.data()->addTextToGroup(m_text, m_group);
|
2017-12-01 18:36:57 +00:00
|
|
|
}
|
2017-11-29 14:49:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************
|
|
|
|
* RemoveTextFromGroupCommand*
|
|
|
|
* ***************************/
|
|
|
|
/**
|
2020-08-12 21:53:02 +02:00
|
|
|
@brief RemoveTextFromGroupCommand::RemoveTextFromGroupCommand
|
2020-08-18 21:28:52 +02:00
|
|
|
@param text : text to add to group
|
2020-08-12 21:53:02 +02:00
|
|
|
@param group
|
|
|
|
@param parent : parent undo command
|
|
|
|
*/
|
2020-08-12 19:33:29 +02:00
|
|
|
RemoveTextFromGroupCommand::RemoveTextFromGroupCommand(
|
|
|
|
DynamicElementTextItem *text,
|
|
|
|
ElementTextItemGroup *group,
|
|
|
|
QUndoCommand *parent):
|
2017-11-29 14:49:12 +00:00
|
|
|
QUndoCommand(parent),
|
|
|
|
m_text(text),
|
|
|
|
m_group(group),
|
|
|
|
m_element(group->parentElement())
|
|
|
|
{
|
|
|
|
setText(QObject::tr("Enlever un texte d'élément d'un groupe de textes"));
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2020-08-12 21:53:02 +02:00
|
|
|
@brief RemoveTextFromGroupCommand::~RemoveTextFromGroupCommand
|
|
|
|
Destructor
|
|
|
|
*/
|
2017-11-29 14:49:12 +00:00
|
|
|
RemoveTextFromGroupCommand::~RemoveTextFromGroupCommand()
|
|
|
|
{
|
|
|
|
if(m_group && m_text && m_element)
|
|
|
|
{
|
|
|
|
if(!m_group.data()->texts().contains(m_text.data()) &&
|
|
|
|
!m_element.data()->dynamicTextItems().contains(m_text.data()))
|
|
|
|
delete m_text.data();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-12 21:53:02 +02:00
|
|
|
/**
|
|
|
|
@brief RemoveTextFromGroupCommand::undo
|
|
|
|
*/
|
2017-11-29 14:49:12 +00:00
|
|
|
void RemoveTextFromGroupCommand::undo()
|
|
|
|
{
|
|
|
|
if(m_element && m_group && m_text)
|
|
|
|
m_element.data()->addTextToGroup(m_text, m_group);
|
|
|
|
}
|
|
|
|
|
2020-08-12 21:53:02 +02:00
|
|
|
/**
|
|
|
|
@brief RemoveTextFromGroupCommand::redo
|
|
|
|
*/
|
2017-11-29 14:49:12 +00:00
|
|
|
void RemoveTextFromGroupCommand::redo()
|
|
|
|
{
|
|
|
|
if(m_element && m_group && m_text)
|
|
|
|
m_element.data()->removeTextFromGroup(m_text, m_group);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*****************************
|
|
|
|
* AlignmentTextsGroupCommand*
|
|
|
|
* ***************************/
|
|
|
|
/**
|
2020-08-12 21:53:02 +02:00
|
|
|
@brief AlignmentTextsGroupCommand::AlignmentTextsGroupCommand
|
|
|
|
@param group : Group to change the alignment
|
|
|
|
@param new_alignment : the new alignment of the group
|
|
|
|
@param parent : the parent QUndoCommand of this undo
|
|
|
|
*/
|
2020-08-12 19:33:29 +02:00
|
|
|
AlignmentTextsGroupCommand::AlignmentTextsGroupCommand(
|
|
|
|
ElementTextItemGroup *group,
|
|
|
|
Qt::Alignment new_alignment,
|
|
|
|
QUndoCommand *parent) :
|
2017-11-29 14:49:12 +00:00
|
|
|
QUndoCommand(parent),
|
|
|
|
m_group(group),
|
|
|
|
m_previous_alignment(group->alignment()),
|
|
|
|
m_new_alignment(new_alignment)
|
|
|
|
{
|
|
|
|
setText(QObject::tr("Modifier l'alignement d'un groupe de textes"));
|
|
|
|
|
|
|
|
//Text haven't got alignment
|
|
|
|
if(m_previous_alignment != Qt::AlignLeft ||
|
|
|
|
m_previous_alignment != Qt::AlignVCenter ||
|
|
|
|
m_previous_alignment != Qt::AlignRight)
|
|
|
|
{
|
|
|
|
for(DynamicElementTextItem *deti : group->texts())
|
|
|
|
m_texts_pos.insert(deti, deti->pos());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2020-08-12 21:53:02 +02:00
|
|
|
@brief AlignmentTextsGroupCommand::~AlignmentTextsGroupCommand
|
|
|
|
Destructor
|
|
|
|
*/
|
2017-11-29 14:49:12 +00:00
|
|
|
AlignmentTextsGroupCommand::~AlignmentTextsGroupCommand()
|
|
|
|
{}
|
|
|
|
|
|
|
|
/**
|
2020-08-12 21:53:02 +02:00
|
|
|
@brief AlignmentTextsGroupCommand::mergeWith
|
|
|
|
Try to merge this command with other command
|
|
|
|
@param other
|
|
|
|
@return true if was merged, else false
|
|
|
|
*/
|
2017-11-29 14:49:12 +00:00
|
|
|
bool AlignmentTextsGroupCommand::mergeWith(const QUndoCommand *other)
|
|
|
|
{
|
|
|
|
if (id() != other->id() || other->childCount())
|
|
|
|
return false;
|
|
|
|
|
2020-08-12 19:33:29 +02:00
|
|
|
AlignmentTextsGroupCommand const *undo =
|
|
|
|
static_cast<const AlignmentTextsGroupCommand *>(other);
|
2017-11-29 14:49:12 +00:00
|
|
|
if (m_group != undo->m_group)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
m_new_alignment= undo->m_new_alignment;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2020-08-12 21:53:02 +02:00
|
|
|
@brief AlignmentTextsGroupCommand::undo
|
|
|
|
*/
|
2017-11-29 14:49:12 +00:00
|
|
|
void AlignmentTextsGroupCommand::undo()
|
|
|
|
{
|
|
|
|
if(m_group)
|
|
|
|
{
|
|
|
|
m_group.data()->setAlignment(m_previous_alignment);
|
2020-08-12 19:33:29 +02:00
|
|
|
//The alignment befor this command was free, then we must
|
|
|
|
//to restor the pos of each texts
|
2017-11-29 14:49:12 +00:00
|
|
|
if(!m_texts_pos.isEmpty())
|
|
|
|
{
|
|
|
|
for(DynamicElementTextItem *deti : m_group.data()->texts())
|
|
|
|
{
|
|
|
|
if(m_texts_pos.keys().contains(deti))
|
|
|
|
deti->setPos(m_texts_pos.value(deti));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2020-08-12 21:53:02 +02:00
|
|
|
@brief AlignmentTextsGroupCommand::redo
|
|
|
|
*/
|
2017-11-29 14:49:12 +00:00
|
|
|
void AlignmentTextsGroupCommand::redo()
|
|
|
|
{
|
|
|
|
if(m_group)
|
|
|
|
m_group.data()->setAlignment(m_new_alignment);
|
|
|
|
}
|