2007-12-01 10:47:15 +00:00
|
|
|
/*
|
2020-06-15 17:42:37 +02:00
|
|
|
Copyright 2006-2020 The QElectroTech Team
|
2007-12-01 10:47:15 +00:00
|
|
|
This file is part of QElectroTech.
|
|
|
|
|
|
|
|
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.
|
|
|
|
|
|
|
|
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.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
2007-09-25 23:24:36 +00:00
|
|
|
#include "diagramcommands.h"
|
2013-11-14 10:11:22 +00:00
|
|
|
#include "qetgraphicsitem/element.h"
|
|
|
|
#include "qetgraphicsitem/conductor.h"
|
|
|
|
#include "qetgraphicsitem/conductortextitem.h"
|
2007-09-25 23:24:36 +00:00
|
|
|
#include "diagram.h"
|
2013-11-14 10:11:22 +00:00
|
|
|
#include "qetgraphicsitem/independenttextitem.h"
|
2007-09-25 23:24:36 +00:00
|
|
|
#include "qgimanager.h"
|
2010-04-18 17:59:54 +00:00
|
|
|
#include "diagram.h"
|
2013-11-14 10:11:22 +00:00
|
|
|
#include "qetgraphicsitem/diagramtextitem.h"
|
|
|
|
#include "qetgraphicsitem/diagramimageitem.h"
|
2017-12-05 20:51:54 +00:00
|
|
|
#include "elementtextitemgroup.h"
|
2014-07-09 16:50:30 +00:00
|
|
|
#include <QPropertyAnimation>
|
2010-04-18 17:59:54 +00:00
|
|
|
|
2014-10-11 17:45:11 +00:00
|
|
|
QString itemText(const QetGraphicsItem *item) {
|
|
|
|
return item->name();
|
2014-02-28 14:30:59 +00:00
|
|
|
}
|
2014-10-11 17:45:11 +00:00
|
|
|
|
|
|
|
QString itemText(const IndependentTextItem *item) {
|
2020-06-21 16:25:34 +02:00
|
|
|
Q_UNUSED(item)
|
2014-10-10 08:58:44 +00:00
|
|
|
return QObject::tr("un champ texte");
|
2014-02-28 14:30:59 +00:00
|
|
|
}
|
2014-10-11 17:45:11 +00:00
|
|
|
|
|
|
|
QString itemText(const Conductor *item) {
|
2020-06-21 16:25:34 +02:00
|
|
|
Q_UNUSED(item)
|
2014-10-10 08:58:44 +00:00
|
|
|
return QObject::tr("un conducteur");
|
2007-09-25 23:24:36 +00:00
|
|
|
}
|
|
|
|
|
2007-09-26 12:36:31 +00:00
|
|
|
/**
|
2015-07-12 15:05:59 +00:00
|
|
|
* @brief PasteDiagramCommand::PasteDiagramCommand
|
|
|
|
* Constructor
|
|
|
|
* @param dia : diagram where we must to paste
|
|
|
|
* @param c : content to past
|
|
|
|
* @param parent : parent undo command
|
|
|
|
*/
|
|
|
|
PasteDiagramCommand::PasteDiagramCommand( Diagram *dia, const DiagramContent &c, QUndoCommand *parent) :
|
2007-09-26 12:36:31 +00:00
|
|
|
QUndoCommand(parent),
|
2007-11-09 13:06:51 +00:00
|
|
|
content(c),
|
2007-09-26 12:36:31 +00:00
|
|
|
diagram(dia),
|
2014-10-21 20:29:16 +00:00
|
|
|
filter(DiagramContent::Elements|DiagramContent::TextFields|DiagramContent::Images|DiagramContent::ConductorsToMove | DiagramContent::Shapes),
|
2007-09-26 12:36:31 +00:00
|
|
|
first_redo(true)
|
|
|
|
{
|
2015-07-12 15:05:59 +00:00
|
|
|
setText(QObject::tr("coller %1", "undo caption - %1 is a sentence listing the content to paste").arg(content.sentence(filter)));
|
2007-11-11 16:12:45 +00:00
|
|
|
diagram -> qgiManager().manage(content.items(filter));
|
2007-09-26 12:36:31 +00:00
|
|
|
}
|
|
|
|
|
2015-07-12 15:05:59 +00:00
|
|
|
/**
|
|
|
|
* @brief PasteDiagramCommand::~PasteDiagramCommand
|
|
|
|
* Destructor
|
|
|
|
*/
|
2007-09-26 12:36:31 +00:00
|
|
|
PasteDiagramCommand::~PasteDiagramCommand() {
|
2007-11-11 16:12:45 +00:00
|
|
|
diagram -> qgiManager().release(content.items(filter));
|
2007-09-26 12:36:31 +00:00
|
|
|
}
|
|
|
|
|
2015-07-12 15:05:59 +00:00
|
|
|
/**
|
|
|
|
* @brief PasteDiagramCommand::undo
|
|
|
|
* Undo this command
|
|
|
|
*/
|
|
|
|
void PasteDiagramCommand::undo()
|
|
|
|
{
|
2014-01-11 22:38:30 +00:00
|
|
|
diagram -> showMe();
|
2013-09-02 12:30:28 +00:00
|
|
|
|
2017-02-05 16:18:50 +00:00
|
|
|
foreach(QGraphicsItem *item, content.items(filter))
|
2015-07-12 15:05:59 +00:00
|
|
|
diagram->removeItem(item);
|
2007-09-26 12:36:31 +00:00
|
|
|
}
|
|
|
|
|
2014-10-23 08:05:53 +00:00
|
|
|
/**
|
|
|
|
* @brief PasteDiagramCommand::redo
|
2015-07-12 15:05:59 +00:00
|
|
|
* Redo this commnand
|
2014-10-23 08:05:53 +00:00
|
|
|
*/
|
2015-07-12 15:05:59 +00:00
|
|
|
void PasteDiagramCommand::redo()
|
|
|
|
{
|
2014-01-11 22:38:30 +00:00
|
|
|
diagram -> showMe();
|
2016-08-04 09:54:43 +00:00
|
|
|
QSettings settings;
|
2014-10-23 08:05:53 +00:00
|
|
|
|
2017-03-10 22:53:29 +00:00
|
|
|
if (first_redo)
|
|
|
|
{
|
2014-01-28 10:45:45 +00:00
|
|
|
first_redo = false;
|
2014-10-23 08:05:53 +00:00
|
|
|
|
2016-07-30 13:36:24 +00:00
|
|
|
//this is the first paste, we do some actions for the new element
|
2018-04-12 16:24:44 +00:00
|
|
|
const QList <Element *> elmts_list = content.m_elements;
|
2017-03-10 22:53:29 +00:00
|
|
|
for (Element *e : elmts_list)
|
|
|
|
{
|
2016-07-30 13:36:24 +00:00
|
|
|
//make new uuid, because old uuid are the uuid of the copied element
|
2014-10-23 08:05:53 +00:00
|
|
|
e -> newUuid();
|
2018-03-25 14:33:49 +00:00
|
|
|
|
2018-04-21 17:48:22 +00:00
|
|
|
if (settings.value("diagramcommands/erase-label-on-copy", true).toBool())
|
2017-03-10 22:53:29 +00:00
|
|
|
{
|
|
|
|
//Reset the information about the label, the comment and location
|
2018-06-03 18:13:25 +00:00
|
|
|
DiagramContext dc = e->elementInformations();
|
|
|
|
dc.addValue("formula", "");
|
|
|
|
dc.addValue("label", "");
|
|
|
|
dc.addValue("comment", "");
|
|
|
|
dc.addValue("location", "");
|
|
|
|
e->setElementInformations(dc);
|
2017-03-10 22:53:29 +00:00
|
|
|
|
|
|
|
//Reset the text of conductors
|
2018-04-23 13:50:36 +00:00
|
|
|
const QList <Conductor *> conductors_list = content.m_conductors_to_move;
|
2017-03-10 22:53:29 +00:00
|
|
|
for (Conductor *c : conductors_list)
|
|
|
|
{
|
2016-08-04 12:29:35 +00:00
|
|
|
ConductorProperties cp = c -> properties();
|
|
|
|
cp.text = c->diagram() ? c -> diagram() -> defaultConductorProperties.text : "_";
|
|
|
|
c -> setProperties(cp);
|
2017-03-10 22:53:29 +00:00
|
|
|
}
|
|
|
|
}
|
2014-10-23 08:05:53 +00:00
|
|
|
}
|
2014-01-28 10:45:45 +00:00
|
|
|
}
|
2017-03-10 22:53:29 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
const QList <QGraphicsItem *> qgis_list = content.items(filter);
|
2019-03-21 19:42:16 +00:00
|
|
|
for (QGraphicsItem *item : qgis_list) {
|
2015-07-12 15:05:59 +00:00
|
|
|
diagram->addItem(item);
|
2016-07-31 01:30:42 +00:00
|
|
|
}
|
2007-09-26 12:36:31 +00:00
|
|
|
}
|
2016-07-30 13:36:24 +00:00
|
|
|
|
2017-03-10 22:53:29 +00:00
|
|
|
const QList <QGraphicsItem *> qgis_list = content.items();
|
|
|
|
for (QGraphicsItem *qgi : qgis_list)
|
2016-07-30 13:36:24 +00:00
|
|
|
qgi -> setSelected(true);
|
2007-09-26 12:36:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2020-07-15 18:02:11 +02:00
|
|
|
@brief CutDiagramCommand::CutDiagramCommand
|
2007-09-26 12:36:31 +00:00
|
|
|
Constructeur
|
2007-10-10 17:50:26 +00:00
|
|
|
@param dia Schema dont on coupe des elements et conducteurs
|
2007-11-09 13:06:51 +00:00
|
|
|
@param content Contenu coupe
|
2007-09-26 12:36:31 +00:00
|
|
|
@param parent QUndoCommand parent
|
|
|
|
*/
|
|
|
|
CutDiagramCommand::CutDiagramCommand(
|
|
|
|
Diagram *dia,
|
2007-11-09 13:06:51 +00:00
|
|
|
const DiagramContent &content,
|
2007-09-26 12:36:31 +00:00
|
|
|
QUndoCommand *parent
|
|
|
|
) :
|
2017-08-03 17:36:08 +00:00
|
|
|
DeleteQGraphicsItemCommand(dia, content, parent)
|
2007-09-26 12:36:31 +00:00
|
|
|
{
|
2009-04-03 19:30:25 +00:00
|
|
|
setText(
|
|
|
|
QString(
|
|
|
|
QObject::tr(
|
|
|
|
"couper %1",
|
|
|
|
"undo caption - %1 is a sentence listing the content to cut"
|
|
|
|
).arg(content.sentence(DiagramContent::All))
|
|
|
|
)
|
|
|
|
);
|
2007-09-26 12:36:31 +00:00
|
|
|
}
|
|
|
|
|
2020-07-15 18:02:11 +02:00
|
|
|
/**
|
|
|
|
@brief CutDiagramCommand::~CutDiagramCommand
|
|
|
|
Destructeur
|
|
|
|
*/
|
2007-09-26 12:36:31 +00:00
|
|
|
CutDiagramCommand::~CutDiagramCommand() {
|
|
|
|
}
|
2007-09-26 17:14:09 +00:00
|
|
|
|
|
|
|
/**
|
2014-06-15 18:03:25 +00:00
|
|
|
* @brief MoveElementsCommand::MoveElementsCommand
|
|
|
|
* Constructor
|
|
|
|
* @param dia diagram
|
|
|
|
* @param diagram_content diagram content (contain all items to be moved)
|
|
|
|
* @param m movement to applied
|
|
|
|
* @param parent parent undo command
|
|
|
|
*/
|
2007-09-26 17:14:09 +00:00
|
|
|
MoveElementsCommand::MoveElementsCommand(
|
|
|
|
Diagram *dia,
|
2007-11-09 13:06:51 +00:00
|
|
|
const DiagramContent &diagram_content,
|
2007-09-26 17:14:09 +00:00
|
|
|
const QPointF &m,
|
|
|
|
QUndoCommand *parent
|
|
|
|
) :
|
2015-01-09 17:18:16 +00:00
|
|
|
QUndoCommand (parent),
|
|
|
|
diagram (dia),
|
|
|
|
content_to_move (diagram_content),
|
|
|
|
movement (m),
|
|
|
|
m_anim_group (nullptr),
|
|
|
|
first_redo (true)
|
2007-09-26 17:14:09 +00:00
|
|
|
{
|
2009-04-03 19:30:25 +00:00
|
|
|
QString moved_content_sentence = content_to_move.sentence(
|
|
|
|
DiagramContent::Elements |
|
|
|
|
DiagramContent::TextFields |
|
|
|
|
DiagramContent::ConductorsToUpdate |
|
2013-08-24 15:18:45 +00:00
|
|
|
DiagramContent::ConductorsToMove |
|
2014-03-07 08:47:56 +00:00
|
|
|
DiagramContent::Images |
|
2019-03-16 11:34:52 +00:00
|
|
|
DiagramContent::Shapes |
|
|
|
|
DiagramContent::ElementTextFields
|
2009-04-03 19:30:25 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
setText(
|
|
|
|
QString(
|
|
|
|
QObject::tr(
|
2015-03-02 20:14:56 +00:00
|
|
|
"déplacer %1",
|
2009-04-03 19:30:25 +00:00
|
|
|
"undo caption - %1 is a sentence listing the moved content"
|
|
|
|
).arg(moved_content_sentence)
|
|
|
|
)
|
|
|
|
);
|
2007-09-26 17:14:09 +00:00
|
|
|
}
|
|
|
|
|
2014-06-15 18:03:25 +00:00
|
|
|
/**
|
|
|
|
* @brief MoveElementsCommand::~MoveElementsCommand
|
|
|
|
* Destructor
|
|
|
|
*/
|
2007-09-26 17:14:09 +00:00
|
|
|
MoveElementsCommand::~MoveElementsCommand() {
|
2014-07-09 16:50:30 +00:00
|
|
|
delete m_anim_group;
|
2007-09-26 17:14:09 +00:00
|
|
|
}
|
|
|
|
|
2014-06-15 18:03:25 +00:00
|
|
|
/**
|
|
|
|
* @brief MoveElementsCommand::undo
|
|
|
|
*/
|
2007-09-26 17:14:09 +00:00
|
|
|
void MoveElementsCommand::undo() {
|
2014-01-11 22:38:30 +00:00
|
|
|
diagram -> showMe();
|
2015-01-09 17:18:16 +00:00
|
|
|
m_anim_group->setDirection(QAnimationGroup::Forward);
|
|
|
|
m_anim_group->start();
|
|
|
|
QUndoCommand::undo();
|
2007-09-26 17:14:09 +00:00
|
|
|
}
|
|
|
|
|
2014-06-15 18:03:25 +00:00
|
|
|
/**
|
|
|
|
* @brief MoveElementsCommand::redo
|
|
|
|
*/
|
2007-09-26 17:14:09 +00:00
|
|
|
void MoveElementsCommand::redo() {
|
2014-01-11 22:38:30 +00:00
|
|
|
diagram -> showMe();
|
2014-07-09 16:50:30 +00:00
|
|
|
if (first_redo) {
|
|
|
|
first_redo = false;
|
|
|
|
move(-movement);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
m_anim_group->setDirection(QAnimationGroup::Backward);
|
|
|
|
m_anim_group->start();
|
|
|
|
}
|
2015-01-09 17:18:16 +00:00
|
|
|
QUndoCommand::redo();
|
2007-09-26 17:14:09 +00:00
|
|
|
}
|
|
|
|
|
2007-09-26 22:57:53 +00:00
|
|
|
/**
|
2014-06-15 18:03:25 +00:00
|
|
|
* @brief MoveElementsCommand::move
|
|
|
|
* Move item and conductor to @actual_movement
|
|
|
|
* @param actual_movement movement to be applied
|
|
|
|
*/
|
2017-12-05 20:51:54 +00:00
|
|
|
void MoveElementsCommand::move(const QPointF &actual_movement)
|
|
|
|
{
|
2014-06-15 18:03:25 +00:00
|
|
|
typedef DiagramContent dc;
|
|
|
|
|
2017-12-05 20:51:54 +00:00
|
|
|
//Move every movable items, except conductor
|
2020-06-21 16:25:34 +02:00
|
|
|
for (QGraphicsItem *qgi : content_to_move.items(dc::Elements | dc::TextFields | dc::Images | dc::Shapes | dc::TextGroup | dc::ElementTextFields | dc::Tables))
|
2017-12-05 20:51:54 +00:00
|
|
|
{
|
|
|
|
//If curent item have parent, and parent item is in content_to_move
|
|
|
|
//we don't apply movement to this item, because this item will be moved by is parent.
|
|
|
|
if (qgi->parentItem())
|
2014-10-17 21:30:42 +00:00
|
|
|
if (content_to_move.items().contains(qgi->parentItem()))
|
|
|
|
continue;
|
2017-12-05 20:51:54 +00:00
|
|
|
|
|
|
|
if(qgi->toGraphicsObject())
|
2014-07-09 16:50:30 +00:00
|
|
|
setupAnimation(qgi->toGraphicsObject(), "pos", qgi->pos(), qgi->pos() + actual_movement);
|
2017-12-05 20:51:54 +00:00
|
|
|
else if(qgi->type() == QGraphicsItemGroup::Type) //ElementTextItemGroup is a QObject but not a QGraphicsObject
|
|
|
|
{
|
2018-07-30 15:24:29 +00:00
|
|
|
if(ElementTextItemGroup *etig = dynamic_cast<ElementTextItemGroup *>(qgi))
|
2017-12-05 20:51:54 +00:00
|
|
|
setupAnimation(etig, "pos", etig->pos(), etig->pos() + actual_movement);
|
2014-07-09 16:50:30 +00:00
|
|
|
}
|
|
|
|
else qgi -> setPos(qgi->pos() + actual_movement);
|
2007-09-26 17:14:09 +00:00
|
|
|
}
|
|
|
|
|
2017-12-05 20:51:54 +00:00
|
|
|
// Move some conductors
|
|
|
|
for (Conductor *conductor : content_to_move.m_conductors_to_move)
|
2014-07-09 16:50:30 +00:00
|
|
|
setupAnimation(conductor, "pos", conductor->pos(), conductor->pos() + actual_movement);
|
2007-09-26 17:14:09 +00:00
|
|
|
|
2017-12-05 20:51:54 +00:00
|
|
|
// Recalcul the path of other conductor
|
|
|
|
for (Conductor *conductor : content_to_move.m_conductors_to_update)
|
2014-07-09 16:50:30 +00:00
|
|
|
setupAnimation(conductor, "animPath", 1, 1);
|
2007-09-26 17:14:09 +00:00
|
|
|
}
|
2007-09-26 22:57:53 +00:00
|
|
|
|
2014-07-09 16:50:30 +00:00
|
|
|
/**
|
|
|
|
* @brief MoveElementsCommand::setupAnimation
|
|
|
|
* Set up the animation for this undo command
|
|
|
|
* @param target object to anim
|
|
|
|
* @param propertyName property to animate
|
|
|
|
* @param start value at start
|
|
|
|
* @param end value at end
|
|
|
|
*/
|
2018-07-19 14:14:31 +00:00
|
|
|
void MoveElementsCommand::setupAnimation(QObject *target, const QByteArray &propertyName, const QVariant& start, const QVariant& end) {
|
2014-07-09 16:50:30 +00:00
|
|
|
//create animation group if not yet.
|
|
|
|
if (m_anim_group == nullptr) m_anim_group = new QParallelAnimationGroup();
|
2018-07-30 15:24:29 +00:00
|
|
|
QPropertyAnimation *animation = new QPropertyAnimation(target, propertyName);
|
2014-07-09 16:50:30 +00:00
|
|
|
animation->setDuration(300);
|
|
|
|
animation->setStartValue(start);
|
|
|
|
animation->setEndValue(end);
|
|
|
|
animation->setEasingCurve(QEasingCurve::OutQuad);
|
|
|
|
m_anim_group->addAnimation(animation);
|
|
|
|
}
|
|
|
|
|
2010-05-08 21:24:43 +00:00
|
|
|
/**
|
2020-07-15 18:02:11 +02:00
|
|
|
@brief MoveConductorsTextsCommand::MoveConductorsTextsCommand
|
2010-05-08 21:24:43 +00:00
|
|
|
Constructeur
|
|
|
|
@param diagram Schema sur lequel on deplace des champs de texte
|
|
|
|
@param parent QUndoCommand parent
|
|
|
|
*/
|
|
|
|
MoveConductorsTextsCommand::MoveConductorsTextsCommand(
|
|
|
|
Diagram *diagram,
|
|
|
|
QUndoCommand *parent
|
|
|
|
) :
|
|
|
|
QUndoCommand(parent),
|
|
|
|
diagram(diagram),
|
|
|
|
first_redo(true)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2020-07-15 18:02:11 +02:00
|
|
|
/**
|
|
|
|
@brief MoveConductorsTextsCommand::~MoveConductorsTextsCommand
|
|
|
|
Destructeur
|
|
|
|
*/
|
2010-05-08 21:24:43 +00:00
|
|
|
MoveConductorsTextsCommand::~MoveConductorsTextsCommand() {
|
|
|
|
}
|
|
|
|
|
2020-07-15 18:02:11 +02:00
|
|
|
/**
|
|
|
|
@brief MoveConductorsTextsCommand::undo
|
|
|
|
annule le deplacement
|
|
|
|
*/
|
2010-05-08 21:24:43 +00:00
|
|
|
void MoveConductorsTextsCommand::undo() {
|
2014-01-11 22:38:30 +00:00
|
|
|
diagram -> showMe();
|
2017-02-05 16:18:50 +00:00
|
|
|
foreach(ConductorTextItem *cti, texts_to_move_.keys()) {
|
2010-05-08 21:24:43 +00:00
|
|
|
QPointF movement = texts_to_move_[cti].first;
|
|
|
|
bool was_already_moved = texts_to_move_[cti].second;
|
|
|
|
|
|
|
|
cti -> forceMovedByUser(was_already_moved);
|
|
|
|
if (was_already_moved) {
|
|
|
|
cti -> setPos(cti -> pos() - movement);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-07-15 18:02:11 +02:00
|
|
|
/**
|
|
|
|
@brief MoveConductorsTextsCommand::redo
|
|
|
|
refait le deplacement
|
|
|
|
*/
|
2010-05-08 21:24:43 +00:00
|
|
|
void MoveConductorsTextsCommand::redo() {
|
2014-01-11 22:38:30 +00:00
|
|
|
diagram -> showMe();
|
2010-05-08 21:24:43 +00:00
|
|
|
if (first_redo) {
|
|
|
|
first_redo = false;
|
|
|
|
} else {
|
2017-02-05 16:18:50 +00:00
|
|
|
foreach(ConductorTextItem *cti, texts_to_move_.keys()) {
|
2010-05-08 21:24:43 +00:00
|
|
|
QPointF movement = texts_to_move_[cti].first;
|
|
|
|
|
|
|
|
cti -> forceMovedByUser(true);
|
|
|
|
cti -> setPos(cti -> pos() + movement);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2020-07-15 18:02:11 +02:00
|
|
|
@brief MoveConductorsTextsCommand::addTextMovement
|
2010-05-08 21:24:43 +00:00
|
|
|
Ajout un mouvement de champ de texte a cet objet
|
2020-07-15 18:02:11 +02:00
|
|
|
@param text_item Champ de texte deplace ;
|
|
|
|
si celui-ci est deja connu de l'objet d'annulation,
|
|
|
|
il sera ignore
|
2010-05-08 21:24:43 +00:00
|
|
|
@param old_pos Position du champ de texte avant le mouvement
|
|
|
|
@param new_pos Position du champ de texte apres le mouvement
|
2020-07-15 18:02:11 +02:00
|
|
|
@param alread_moved true si le champ de texte etait deja a une position
|
|
|
|
personnalisee par l'utilisateur, false sinon
|
2010-05-08 21:24:43 +00:00
|
|
|
*/
|
|
|
|
void MoveConductorsTextsCommand::addTextMovement(ConductorTextItem *text_item, const QPointF &old_pos, const QPointF &new_pos, bool already_moved) {
|
|
|
|
// si le champ de texte est deja connu de l'objet d'annulation, il sera ignore
|
|
|
|
if (texts_to_move_.contains(text_item)) return;
|
|
|
|
|
|
|
|
// on memorise le champ de texte, en l'associant au mouvement effectue et a son etat avant le deplacement
|
|
|
|
texts_to_move_.insert(text_item, qMakePair(new_pos - old_pos, already_moved));
|
|
|
|
|
|
|
|
// met a jour la description de l'objet d'annulation
|
|
|
|
regenerateTextLabel();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2020-07-15 18:02:11 +02:00
|
|
|
@brief MoveConductorsTextsCommand::regenerateTextLabel
|
2010-05-08 21:24:43 +00:00
|
|
|
Genere la description de l'objet d'annulation
|
|
|
|
*/
|
|
|
|
void MoveConductorsTextsCommand::regenerateTextLabel() {
|
|
|
|
QString moved_content_sentence = QET::ElementsAndConductorsSentence(0, 0, texts_to_move_.count());
|
|
|
|
|
|
|
|
setText(
|
|
|
|
QString(
|
|
|
|
QObject::tr(
|
2015-03-02 20:14:56 +00:00
|
|
|
"déplacer %1",
|
2010-05-08 21:24:43 +00:00
|
|
|
"undo caption - %1 is a sentence listing the moved content"
|
|
|
|
).arg(moved_content_sentence)
|
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2007-09-26 22:57:53 +00:00
|
|
|
/**
|
2020-07-15 18:02:11 +02:00
|
|
|
@brief ChangeDiagramTextCommand::ChangeDiagramTextCommand
|
2007-09-26 22:57:53 +00:00
|
|
|
Constructeur
|
|
|
|
@param dti Champ de texte modifie
|
|
|
|
@param before texte avant
|
|
|
|
@param after texte apres
|
|
|
|
@param parent QUndoCommand parent
|
|
|
|
*/
|
|
|
|
ChangeDiagramTextCommand::ChangeDiagramTextCommand(
|
|
|
|
DiagramTextItem *dti,
|
|
|
|
const QString &before,
|
|
|
|
const QString &after,
|
|
|
|
QUndoCommand *parent
|
|
|
|
) :
|
2009-04-03 19:30:25 +00:00
|
|
|
QUndoCommand(QObject::tr("modifier le texte", "undo caption"), parent),
|
2007-09-26 22:57:53 +00:00
|
|
|
text_item(dti),
|
|
|
|
text_before(before),
|
|
|
|
text_after(after),
|
2014-01-06 18:21:58 +00:00
|
|
|
first_redo(true),
|
|
|
|
diagram(dti->diagram())
|
2007-09-26 22:57:53 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2020-07-15 18:02:11 +02:00
|
|
|
/**
|
|
|
|
@brief ChangeDiagramTextCommand::~ChangeDiagramTextCommand
|
|
|
|
destructeur
|
|
|
|
*/
|
2007-09-26 22:57:53 +00:00
|
|
|
ChangeDiagramTextCommand::~ChangeDiagramTextCommand() {
|
|
|
|
}
|
|
|
|
|
2020-07-15 18:02:11 +02:00
|
|
|
/**
|
|
|
|
@brief ChangeDiagramTextCommand::undo
|
|
|
|
annule la modification de texte
|
|
|
|
*/
|
2007-09-26 22:57:53 +00:00
|
|
|
void ChangeDiagramTextCommand::undo() {
|
2014-01-11 22:38:30 +00:00
|
|
|
diagram -> showMe();
|
2013-03-22 23:17:39 +00:00
|
|
|
text_item -> setHtml(text_before);
|
2007-09-26 22:57:53 +00:00
|
|
|
}
|
|
|
|
|
2019-05-09 19:36:51 +00:00
|
|
|
/**
|
2020-07-15 18:02:11 +02:00
|
|
|
@brief ChangeDiagramTextCommand::redo
|
|
|
|
*/
|
2019-05-09 19:36:51 +00:00
|
|
|
void ChangeDiagramTextCommand::redo()
|
|
|
|
{
|
2014-01-11 22:38:30 +00:00
|
|
|
diagram -> showMe();
|
2019-05-09 19:36:51 +00:00
|
|
|
text_item->setHtml(text_after);
|
2007-09-26 22:57:53 +00:00
|
|
|
}
|
2007-09-27 15:36:15 +00:00
|
|
|
|
2007-09-27 17:42:02 +00:00
|
|
|
/**
|
2020-07-15 18:02:11 +02:00
|
|
|
@brief ChangeConductorCommand::ChangeConductorCommand
|
2007-09-27 17:42:02 +00:00
|
|
|
Constructeur
|
|
|
|
@param c Conducteur modifie
|
|
|
|
@param old_p ancien profil du conducteur
|
|
|
|
@param new_p nouveau profil du conducteur
|
2007-12-05 21:16:01 +00:00
|
|
|
@param path_t Trajectoire du trajet modifie
|
2007-09-27 17:42:02 +00:00
|
|
|
@param parent QUndoCommand parent
|
|
|
|
*/
|
2007-10-03 17:02:39 +00:00
|
|
|
ChangeConductorCommand::ChangeConductorCommand(
|
|
|
|
Conductor *c,
|
|
|
|
const ConductorProfile &old_p,
|
|
|
|
const ConductorProfile &new_p,
|
2007-10-22 20:27:39 +00:00
|
|
|
Qt::Corner path_t,
|
2007-09-27 17:42:02 +00:00
|
|
|
QUndoCommand *parent
|
|
|
|
) :
|
2009-04-03 19:30:25 +00:00
|
|
|
QUndoCommand(QObject::tr("modifier un conducteur", "undo caption"), parent),
|
2007-10-03 17:02:39 +00:00
|
|
|
conductor(c),
|
2007-09-27 17:42:02 +00:00
|
|
|
old_profile(old_p),
|
|
|
|
new_profile(new_p),
|
2007-10-22 20:27:39 +00:00
|
|
|
path_type(path_t),
|
2014-01-06 18:21:58 +00:00
|
|
|
first_redo(true),
|
|
|
|
diagram (c->diagram())
|
2007-09-27 17:42:02 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2020-07-15 18:02:11 +02:00
|
|
|
/**
|
|
|
|
@brief ChangeConductorCommand::~ChangeConductorCommand
|
|
|
|
Destructeur
|
|
|
|
*/
|
2007-10-03 17:02:39 +00:00
|
|
|
ChangeConductorCommand::~ChangeConductorCommand() {
|
2007-09-27 17:42:02 +00:00
|
|
|
}
|
|
|
|
|
2020-07-15 18:02:11 +02:00
|
|
|
/**
|
|
|
|
@brief ChangeConductorCommand::undo
|
|
|
|
Annule la modification du conducteur
|
|
|
|
*/
|
2007-10-03 17:02:39 +00:00
|
|
|
void ChangeConductorCommand::undo() {
|
2014-01-11 22:38:30 +00:00
|
|
|
diagram -> showMe();
|
2007-10-22 20:27:39 +00:00
|
|
|
conductor -> setProfile(old_profile, path_type);
|
2010-05-08 21:24:43 +00:00
|
|
|
conductor -> textItem() -> setPos(text_pos_before_mov_);
|
2007-09-27 17:42:02 +00:00
|
|
|
}
|
|
|
|
|
2020-07-15 18:02:11 +02:00
|
|
|
/**
|
|
|
|
@brief ChangeConductorCommand::redo
|
|
|
|
Refait la modification du conducteur
|
|
|
|
*/
|
2007-10-03 17:02:39 +00:00
|
|
|
void ChangeConductorCommand::redo() {
|
2014-01-11 22:38:30 +00:00
|
|
|
diagram -> showMe();
|
2010-05-08 21:24:43 +00:00
|
|
|
if (first_redo) {
|
|
|
|
first_redo = false;
|
|
|
|
} else {
|
|
|
|
conductor -> setProfile(new_profile, path_type);
|
|
|
|
conductor -> textItem() -> setPos(text_pos_after_mov_);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2020-07-15 18:02:11 +02:00
|
|
|
@brief ChangeConductorCommand::setConductorTextItemMove
|
2010-05-08 21:24:43 +00:00
|
|
|
Integre dans cet objet d'annulation le repositionnement du champ de texte
|
|
|
|
du conducteur
|
|
|
|
@param pos_before Position du texte avant la modification du conducteur
|
|
|
|
@param pos_after Position du texte apres la modification du conducteur
|
|
|
|
*/
|
|
|
|
void ChangeConductorCommand::setConductorTextItemMove(const QPointF &pos_before, const QPointF &pos_after) {
|
|
|
|
text_pos_before_mov_ = pos_before;
|
|
|
|
text_pos_after_mov_ = pos_after;
|
2007-09-27 17:42:02 +00:00
|
|
|
}
|
2007-09-28 17:39:30 +00:00
|
|
|
|
2007-10-06 18:37:21 +00:00
|
|
|
/**
|
2014-10-19 10:08:55 +00:00
|
|
|
* @brief ResetConductorCommand::ResetConductorCommand
|
|
|
|
* @param cp
|
|
|
|
* @param parent
|
|
|
|
*/
|
2007-10-06 18:37:21 +00:00
|
|
|
ResetConductorCommand::ResetConductorCommand(
|
2007-10-22 20:27:39 +00:00
|
|
|
const QHash<Conductor *, ConductorProfilesGroup> &cp,
|
2007-10-06 18:37:21 +00:00
|
|
|
QUndoCommand *parent
|
|
|
|
) :
|
2009-04-03 19:30:25 +00:00
|
|
|
QUndoCommand(parent),
|
2014-01-06 18:21:58 +00:00
|
|
|
conductors_profiles(cp),
|
|
|
|
diagram(cp.keys().first()->diagram())
|
2007-10-06 18:37:21 +00:00
|
|
|
{
|
2009-04-03 19:30:25 +00:00
|
|
|
setText(
|
|
|
|
QObject::tr(
|
2015-03-02 20:14:56 +00:00
|
|
|
"Réinitialiser %1",
|
2009-04-03 19:30:25 +00:00
|
|
|
"undo caption - %1 is a sentence listing the reset content"
|
|
|
|
).arg(QET::ElementsAndConductorsSentence(0, cp.count()))
|
|
|
|
);
|
2007-10-06 18:37:21 +00:00
|
|
|
}
|
|
|
|
|
2014-10-19 10:08:55 +00:00
|
|
|
/**
|
|
|
|
* @brief ResetConductorCommand::~ResetConductorCommand
|
|
|
|
*/
|
2007-10-06 18:37:21 +00:00
|
|
|
ResetConductorCommand::~ResetConductorCommand() {
|
|
|
|
}
|
|
|
|
|
2014-10-19 10:08:55 +00:00
|
|
|
/**
|
|
|
|
* @brief ResetConductorCommand::undo
|
|
|
|
*/
|
2007-10-06 18:37:21 +00:00
|
|
|
void ResetConductorCommand::undo() {
|
2014-01-11 22:38:30 +00:00
|
|
|
diagram -> showMe();
|
2017-02-05 16:18:50 +00:00
|
|
|
foreach(Conductor *c, conductors_profiles.keys()) {
|
2007-10-22 20:27:39 +00:00
|
|
|
c -> setProfiles(conductors_profiles[c]);
|
2007-10-06 18:37:21 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-10-19 10:08:55 +00:00
|
|
|
/**
|
|
|
|
* @brief ResetConductorCommand::redo
|
|
|
|
*/
|
2007-10-06 18:37:21 +00:00
|
|
|
void ResetConductorCommand::redo() {
|
2014-01-11 22:38:30 +00:00
|
|
|
diagram -> showMe();
|
2017-02-05 16:18:50 +00:00
|
|
|
foreach(Conductor *c, conductors_profiles.keys()) {
|
2014-10-19 10:08:55 +00:00
|
|
|
c -> textItem() -> forceMovedByUser (false);
|
|
|
|
c -> textItem() -> forceRotateByUser (false);
|
2007-10-22 20:27:39 +00:00
|
|
|
c -> setProfiles(ConductorProfilesGroup());
|
2007-10-06 18:37:21 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-09-28 21:48:59 +00:00
|
|
|
/**
|
2020-07-15 18:02:11 +02:00
|
|
|
@brief ChangeBorderCommand::ChangeBorderCommand
|
2007-09-28 21:48:59 +00:00
|
|
|
Constructeur
|
|
|
|
@param dia Schema modifie
|
2009-11-22 16:12:22 +00:00
|
|
|
@param old_bp Anciennes proprietes du cadre du schema
|
|
|
|
@param new_bp Nouvelles proprietes du cadre du schema
|
2007-09-28 21:48:59 +00:00
|
|
|
@param parent QUndoCommand parent
|
|
|
|
*/
|
2020-07-15 18:02:11 +02:00
|
|
|
ChangeBorderCommand::ChangeBorderCommand(Diagram *dia,
|
|
|
|
const BorderProperties &old_bp,
|
|
|
|
const BorderProperties &new_bp,
|
|
|
|
QUndoCommand *parent) :
|
|
|
|
QUndoCommand(
|
|
|
|
QObject::tr("modifier les dimensions du folio", "undo caption"),
|
|
|
|
parent),
|
2007-09-28 21:48:59 +00:00
|
|
|
diagram(dia),
|
2008-08-15 12:46:22 +00:00
|
|
|
old_properties(old_bp),
|
|
|
|
new_properties(new_bp)
|
2007-09-28 21:48:59 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2020-07-15 18:02:11 +02:00
|
|
|
/**
|
|
|
|
@brief ChangeBorderCommand::~ChangeBorderCommand
|
|
|
|
Destructeur
|
|
|
|
*/
|
2007-09-28 21:48:59 +00:00
|
|
|
ChangeBorderCommand::~ChangeBorderCommand() {
|
|
|
|
}
|
|
|
|
|
2020-07-15 18:02:11 +02:00
|
|
|
/**
|
|
|
|
@brief ChangeBorderCommand::undo
|
|
|
|
Annule les changements apportes au schema
|
|
|
|
*/
|
2007-09-28 21:48:59 +00:00
|
|
|
void ChangeBorderCommand::undo() {
|
2014-01-11 22:38:30 +00:00
|
|
|
diagram -> showMe();
|
2010-12-20 02:45:36 +00:00
|
|
|
diagram -> border_and_titleblock.importBorder(old_properties);
|
2007-09-28 21:48:59 +00:00
|
|
|
}
|
|
|
|
|
2020-07-15 18:02:11 +02:00
|
|
|
/**
|
|
|
|
@brief ChangeBorderCommand::redo
|
|
|
|
Refait les changements apportes au schema
|
|
|
|
*/
|
2007-09-28 21:48:59 +00:00
|
|
|
void ChangeBorderCommand::redo() {
|
2014-01-11 22:38:30 +00:00
|
|
|
diagram -> showMe();
|
2010-12-20 02:45:36 +00:00
|
|
|
diagram -> border_and_titleblock.importBorder(new_properties);
|
2007-09-28 21:48:59 +00:00
|
|
|
}
|