2007-12-01 10:47:15 +00:00
|
|
|
/*
|
2014-01-29 18:37:45 +00:00
|
|
|
Copyright 2006-2014 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/elementtextitem.h"
|
|
|
|
#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"
|
2014-02-06 21:35:13 +00:00
|
|
|
#include "conductorautonumerotation.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) {
|
2014-10-10 08:58:44 +00:00
|
|
|
Q_UNUSED(item);
|
|
|
|
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) {
|
2014-10-10 08:58:44 +00:00
|
|
|
Q_UNUSED(item);
|
|
|
|
return QObject::tr("un conducteur");
|
2007-09-25 23:24:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
Constructeur
|
2007-09-26 12:36:31 +00:00
|
|
|
@param dia Schema dont on supprime des elements et conducteurs
|
2007-11-09 13:06:51 +00:00
|
|
|
@param content Contenu supprime
|
2007-09-26 12:36:31 +00:00
|
|
|
@param parent QUndoCommand parent
|
2007-09-25 23:24:36 +00:00
|
|
|
*/
|
|
|
|
DeleteElementsCommand::DeleteElementsCommand(
|
|
|
|
Diagram *dia,
|
2007-11-09 13:06:51 +00:00
|
|
|
const DiagramContent &content,
|
2007-09-25 23:24:36 +00:00
|
|
|
QUndoCommand *parent
|
|
|
|
) :
|
|
|
|
QUndoCommand(parent),
|
2007-11-09 13:06:51 +00:00
|
|
|
removed_content(content),
|
2007-09-25 23:24:36 +00:00
|
|
|
diagram(dia)
|
|
|
|
{
|
2009-04-03 19:30:25 +00:00
|
|
|
setText(
|
|
|
|
QString(
|
|
|
|
QObject::tr(
|
|
|
|
"supprimer %1",
|
|
|
|
"undo caption - %1 is a sentence listing the removed content"
|
|
|
|
)
|
|
|
|
).arg(removed_content.sentence(DiagramContent::All))
|
|
|
|
);
|
2007-11-11 16:12:45 +00:00
|
|
|
diagram -> qgiManager().manage(removed_content.items(DiagramContent::All));
|
2007-09-25 23:24:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/// Destructeur
|
|
|
|
DeleteElementsCommand::~DeleteElementsCommand() {
|
2007-11-11 16:12:45 +00:00
|
|
|
diagram -> qgiManager().release(removed_content.items(DiagramContent::All));
|
2007-09-25 23:24:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/// annule les suppressions
|
|
|
|
void DeleteElementsCommand::undo() {
|
2014-01-11 22:38:30 +00:00
|
|
|
diagram -> showMe();
|
2007-09-25 23:24:36 +00:00
|
|
|
// remet les elements
|
2007-11-09 13:06:51 +00:00
|
|
|
foreach(Element *e, removed_content.elements) {
|
2014-10-10 08:58:44 +00:00
|
|
|
diagram -> addItem(e);
|
2007-09-25 23:24:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// remet les conducteurs
|
2007-11-11 16:12:45 +00:00
|
|
|
foreach(Conductor *c, removed_content.conductors(DiagramContent::AnyConductor)) {
|
2014-10-10 08:58:44 +00:00
|
|
|
diagram -> addItem(c);
|
2007-09-25 23:24:36 +00:00
|
|
|
}
|
2007-10-27 13:18:17 +00:00
|
|
|
|
|
|
|
// remet les textes
|
2010-04-18 17:59:54 +00:00
|
|
|
foreach(IndependentTextItem *t, removed_content.textFields) {
|
2014-10-10 08:58:44 +00:00
|
|
|
diagram -> addItem(t);
|
2007-10-27 13:18:17 +00:00
|
|
|
}
|
2013-08-24 15:18:45 +00:00
|
|
|
|
|
|
|
foreach(DiagramImageItem *dii, removed_content.images) {
|
|
|
|
diagram -> addItem(dii);
|
|
|
|
}
|
2014-03-06 14:04:19 +00:00
|
|
|
|
|
|
|
foreach(QetShapeItem *dsi, removed_content.shapes) {
|
|
|
|
diagram -> addItem(dsi);
|
|
|
|
}
|
2007-09-25 23:24:36 +00:00
|
|
|
}
|
|
|
|
|
2014-10-06 08:33:17 +00:00
|
|
|
/**
|
|
|
|
* @brief DeleteElementsCommand::redo
|
|
|
|
* Redo the delete command
|
|
|
|
*/
|
2007-09-25 23:24:36 +00:00
|
|
|
void DeleteElementsCommand::redo() {
|
2014-01-11 22:38:30 +00:00
|
|
|
diagram -> showMe();
|
2014-10-06 08:33:17 +00:00
|
|
|
|
|
|
|
// Remove Conductor
|
2007-11-11 16:12:45 +00:00
|
|
|
foreach(Conductor *c, removed_content.conductors(DiagramContent::AnyConductor)) {
|
2014-10-10 08:58:44 +00:00
|
|
|
diagram -> removeItem(c);
|
2014-10-06 08:33:17 +00:00
|
|
|
|
|
|
|
//If option one text per folio is enable, and the text item of
|
|
|
|
//current conductor is visible (that mean the conductor own the single displayed text)
|
|
|
|
//We call adjustTextItemPosition to other conductor at the same potential to keep
|
|
|
|
//a visible text on this potential.
|
|
|
|
if (diagram -> defaultConductorProperties.m_one_text_per_folio && c -> textItem() -> isVisible()) {
|
|
|
|
QList <Conductor *> conductor_list;
|
|
|
|
conductor_list << c -> relatedPotentialConductors(false).toList();
|
|
|
|
if (conductor_list.count()) {
|
2014-10-07 19:51:26 +00:00
|
|
|
conductor_list.first() -> calculateTextItemPosition();
|
2014-10-06 08:33:17 +00:00
|
|
|
}
|
|
|
|
}
|
2007-09-25 23:24:36 +00:00
|
|
|
}
|
|
|
|
|
2014-10-06 08:33:17 +00:00
|
|
|
// Remove elements
|
2007-11-09 13:06:51 +00:00
|
|
|
foreach(Element *e, removed_content.elements) {
|
2014-10-10 08:58:44 +00:00
|
|
|
diagram -> removeItem(e);
|
2007-09-25 23:24:36 +00:00
|
|
|
}
|
2007-10-27 13:18:17 +00:00
|
|
|
|
2014-10-06 08:33:17 +00:00
|
|
|
// Remove texts
|
2010-04-18 17:59:54 +00:00
|
|
|
foreach(IndependentTextItem *t, removed_content.textFields) {
|
2014-10-10 08:58:44 +00:00
|
|
|
diagram -> removeItem(t);
|
2007-10-27 13:18:17 +00:00
|
|
|
}
|
2013-08-24 15:18:45 +00:00
|
|
|
|
2014-10-06 08:33:17 +00:00
|
|
|
// Remove images
|
2013-08-24 15:18:45 +00:00
|
|
|
foreach(DiagramImageItem *dii, removed_content.images) {
|
|
|
|
diagram -> removeItem(dii);
|
|
|
|
}
|
2014-03-06 14:04:19 +00:00
|
|
|
|
2014-10-06 08:33:17 +00:00
|
|
|
// Remove shapes
|
2014-03-06 14:04:19 +00:00
|
|
|
foreach(QetShapeItem *dsi, removed_content.shapes) {
|
|
|
|
diagram -> removeItem(dsi);
|
|
|
|
}
|
2007-09-25 23:24:36 +00:00
|
|
|
}
|
2007-09-26 12:36:31 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Constructeur
|
|
|
|
@param dia Schema sur lequel on colle les elements et conducteurs
|
2007-12-05 21:16:01 +00:00
|
|
|
@param c Contenu a coller sur le schema
|
2007-09-26 12:36:31 +00:00
|
|
|
@param parent QUndoCommand parent
|
|
|
|
*/
|
|
|
|
PasteDiagramCommand::PasteDiagramCommand(
|
|
|
|
Diagram *dia,
|
2007-11-09 13:06:51 +00:00
|
|
|
const DiagramContent &c,
|
2007-09-26 12:36:31 +00:00
|
|
|
QUndoCommand *parent
|
|
|
|
) :
|
|
|
|
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)
|
|
|
|
{
|
2007-11-11 16:12:45 +00:00
|
|
|
|
2009-04-03 19:30:25 +00:00
|
|
|
setText(
|
|
|
|
QString(
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
/// Destructeur
|
|
|
|
PasteDiagramCommand::~PasteDiagramCommand() {
|
2007-11-11 16:12:45 +00:00
|
|
|
diagram -> qgiManager().release(content.items(filter));
|
2007-09-26 12:36:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/// annule le coller
|
|
|
|
void PasteDiagramCommand::undo() {
|
2014-01-11 22:38:30 +00:00
|
|
|
diagram -> showMe();
|
2013-09-02 12:30:28 +00:00
|
|
|
// remove the conductors
|
2014-10-10 08:58:44 +00:00
|
|
|
foreach(Conductor *c, content.conductorsToMove) diagram -> removeItem(c);
|
2007-09-26 12:36:31 +00:00
|
|
|
|
2013-09-02 12:30:28 +00:00
|
|
|
// remove the elements
|
2014-10-10 08:58:44 +00:00
|
|
|
foreach(Element *e, content.elements) diagram -> removeItem(e);
|
2007-10-27 13:18:17 +00:00
|
|
|
|
2013-09-02 12:30:28 +00:00
|
|
|
// remove the texts
|
2014-10-10 08:58:44 +00:00
|
|
|
foreach(IndependentTextItem *t, content.textFields) diagram -> removeItem(t);
|
2013-09-02 12:30:28 +00:00
|
|
|
|
2014-10-10 08:58:44 +00:00
|
|
|
// remove the images and shapes
|
|
|
|
foreach(QGraphicsItem *qgi, content.items(DiagramContent::Images | DiagramContent::Shapes)) diagram -> removeItem(qgi);
|
2007-09-26 12:36:31 +00:00
|
|
|
}
|
|
|
|
|
2014-10-23 08:05:53 +00:00
|
|
|
/**
|
|
|
|
* @brief PasteDiagramCommand::redo
|
|
|
|
*/
|
2007-09-26 12:36:31 +00:00
|
|
|
void PasteDiagramCommand::redo() {
|
2014-01-11 22:38:30 +00:00
|
|
|
diagram -> showMe();
|
2014-10-23 08:05:53 +00:00
|
|
|
|
2014-01-28 10:45:45 +00:00
|
|
|
if (first_redo) {
|
|
|
|
first_redo = false;
|
2014-10-23 08:05:53 +00:00
|
|
|
|
|
|
|
//this is the first paste, we do some actions for the new element
|
|
|
|
foreach(Element *e, content.elements) {
|
|
|
|
//make new uuid, because old uuid are the uuid of the copied element
|
|
|
|
e -> newUuid();
|
|
|
|
|
|
|
|
//Reset the text of report element
|
|
|
|
if (e -> linkType() & Element::AllReport) {
|
|
|
|
if (e->texts().size())
|
|
|
|
e->texts().first()->setPlainText("/");
|
|
|
|
} else {
|
|
|
|
//Reset the information about the label and the comment
|
|
|
|
e -> rElementInformations().addValue("label", "");
|
|
|
|
e -> rElementInformations().addValue("comment", "");
|
|
|
|
|
|
|
|
//Reset the text field tagged "label
|
2014-10-23 19:38:49 +00:00
|
|
|
if (ElementTextItem *eti = e ->taggedText("label"))
|
|
|
|
eti -> setPlainText("_");
|
2014-10-23 08:05:53 +00:00
|
|
|
}
|
|
|
|
}
|
2014-11-17 22:32:06 +00:00
|
|
|
|
|
|
|
//Reset the text of conductors
|
|
|
|
foreach (Conductor *c, content.conductorsToMove) {
|
|
|
|
ConductorProperties cp = c -> properties();
|
|
|
|
cp.text = c->diagram() ? c -> diagram() -> defaultConductorProperties.text : "_";
|
|
|
|
c -> setProperties(cp);
|
|
|
|
}
|
2014-01-28 10:45:45 +00:00
|
|
|
}
|
2007-09-26 12:36:31 +00:00
|
|
|
else {
|
2013-09-02 12:30:28 +00:00
|
|
|
// paste the elements
|
2014-10-10 08:58:44 +00:00
|
|
|
foreach(Element *e, content.elements) diagram -> addItem(e);
|
2007-09-26 12:36:31 +00:00
|
|
|
|
2013-09-02 12:30:28 +00:00
|
|
|
// paste the conductors
|
2014-10-10 08:58:44 +00:00
|
|
|
foreach(Conductor *c, content.conductorsToMove) diagram -> addItem(c);
|
2007-10-27 13:18:17 +00:00
|
|
|
|
2013-09-02 12:30:28 +00:00
|
|
|
// paste the texts
|
2014-10-10 08:58:44 +00:00
|
|
|
foreach(IndependentTextItem *t, content.textFields) diagram -> addItem(t);
|
2013-09-02 12:30:28 +00:00
|
|
|
|
2014-10-10 08:58:44 +00:00
|
|
|
// paste the images and shapes
|
|
|
|
foreach(QGraphicsItem *qgi, content.items(DiagramContent::Images | DiagramContent::Shapes)) diagram -> addItem(qgi);
|
2007-09-26 12:36:31 +00:00
|
|
|
}
|
2014-10-10 08:58:44 +00:00
|
|
|
foreach (QGraphicsItem *qgi, content.items()) qgi -> setSelected(true);
|
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
|
|
|
|
) :
|
2007-11-09 13:06:51 +00:00
|
|
|
DeleteElementsCommand(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
|
|
|
}
|
|
|
|
|
|
|
|
/// Destructeur
|
|
|
|
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
|
|
|
|
) :
|
|
|
|
QUndoCommand(parent),
|
|
|
|
diagram(dia),
|
2007-11-09 13:06:51 +00:00
|
|
|
content_to_move(diagram_content),
|
2007-10-27 13:18:17 +00:00
|
|
|
movement(m),
|
2014-07-09 16:50:30 +00:00
|
|
|
m_anim_group(nullptr),
|
2007-10-27 13:18:17 +00:00
|
|
|
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 |
|
|
|
|
DiagramContent::Shapes
|
2009-04-03 19:30:25 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
setText(
|
|
|
|
QString(
|
|
|
|
QObject::tr(
|
|
|
|
"d\351placer %1",
|
|
|
|
"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();
|
2014-07-09 16:50:30 +00:00
|
|
|
m_anim_group->setDirection(QAnimationGroup::Forward);
|
|
|
|
m_anim_group->start();
|
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();
|
|
|
|
}
|
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
|
|
|
|
*/
|
2007-09-26 17:14:09 +00:00
|
|
|
void MoveElementsCommand::move(const QPointF &actual_movement) {
|
2014-06-15 18:03:25 +00:00
|
|
|
typedef DiagramContent dc;
|
|
|
|
|
|
|
|
//Move every movable item, except conductor
|
2014-10-25 21:21:52 +00:00
|
|
|
foreach (QGraphicsItem *qgi, content_to_move.items(dc::Elements | dc::TextFields | dc::Images | dc::Shapes)) {
|
2014-10-17 21:30:42 +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()) {
|
|
|
|
if (content_to_move.items().contains(qgi->parentItem()))
|
|
|
|
continue;
|
|
|
|
}
|
2014-07-09 16:50:30 +00:00
|
|
|
if(qgi->toGraphicsObject()) {
|
|
|
|
setupAnimation(qgi->toGraphicsObject(), "pos", qgi->pos(), qgi->pos() + actual_movement);
|
|
|
|
}
|
|
|
|
else qgi -> setPos(qgi->pos() + actual_movement);
|
2007-09-26 17:14:09 +00:00
|
|
|
}
|
|
|
|
|
2014-06-15 18:03:25 +00:00
|
|
|
// Move some conductors
|
2007-11-09 13:06:51 +00:00
|
|
|
foreach(Conductor *conductor, content_to_move.conductorsToMove) {
|
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
|
|
|
}
|
|
|
|
|
2014-06-15 18:03:25 +00:00
|
|
|
// Recalcul the path of other conductor
|
2010-05-04 20:18:30 +00:00
|
|
|
foreach(Conductor *conductor, content_to_move.conductorsToUpdate) {
|
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
|
|
|
|
*/
|
|
|
|
void MoveElementsCommand::setupAnimation(QObject *target, const QByteArray &propertyName, const QVariant start, const QVariant end) {
|
|
|
|
//create animation group if not yet.
|
|
|
|
if (m_anim_group == nullptr) m_anim_group = new QParallelAnimationGroup();
|
|
|
|
QPropertyAnimation *animation = new QPropertyAnimation(target, propertyName);
|
|
|
|
animation->setDuration(300);
|
|
|
|
animation->setStartValue(start);
|
|
|
|
animation->setEndValue(end);
|
|
|
|
animation->setEasingCurve(QEasingCurve::OutQuad);
|
|
|
|
m_anim_group->addAnimation(animation);
|
|
|
|
}
|
|
|
|
|
2014-10-25 21:21:52 +00:00
|
|
|
/**
|
|
|
|
Constructeur
|
|
|
|
@param diagram Schema sur lequel on deplace des champs de texte
|
|
|
|
@param texts Liste des textes deplaces
|
|
|
|
@param m translation subie par les elements
|
|
|
|
@param parent QUndoCommand parent
|
|
|
|
*/
|
|
|
|
MoveElementsTextsCommand::MoveElementsTextsCommand(
|
|
|
|
Diagram *diagram,
|
|
|
|
const QSet<ElementTextItem *> &texts,
|
|
|
|
const QPointF &m,
|
|
|
|
QUndoCommand *parent
|
|
|
|
) :
|
|
|
|
QUndoCommand(parent),
|
|
|
|
diagram(diagram),
|
|
|
|
texts_to_move(texts),
|
|
|
|
movement(m),
|
|
|
|
first_redo(true)
|
|
|
|
{
|
|
|
|
QString moved_content_sentence = QET::ElementsAndConductorsSentence(0, 0, texts_to_move.count());
|
|
|
|
setText(
|
|
|
|
QString(
|
|
|
|
QObject::tr(
|
|
|
|
"d\351placer %1",
|
|
|
|
"undo caption - %1 is a sentence listing the moved content"
|
|
|
|
).arg(moved_content_sentence)
|
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Destructeur
|
|
|
|
MoveElementsTextsCommand::~MoveElementsTextsCommand() {
|
|
|
|
}
|
|
|
|
|
|
|
|
/// annule le deplacement
|
|
|
|
void MoveElementsTextsCommand::undo() {
|
|
|
|
diagram -> showMe();
|
|
|
|
move(-movement);
|
|
|
|
}
|
|
|
|
|
|
|
|
/// refait le deplacement
|
|
|
|
void MoveElementsTextsCommand::redo() {
|
|
|
|
diagram -> showMe();
|
|
|
|
if (first_redo) first_redo = false;
|
|
|
|
else move(movement);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
deplace les elements et conducteurs
|
|
|
|
@param actual_movement translation a effectuer sur les elements et conducteurs
|
|
|
|
*/
|
|
|
|
void MoveElementsTextsCommand::move(const QPointF &actual_movement) {
|
|
|
|
// deplace les textes
|
|
|
|
foreach(ElementTextItem *text, texts_to_move) {
|
|
|
|
QPointF applied_movement = text -> mapMovementToParent(text -> mapMovementFromScene(actual_movement));
|
|
|
|
text -> setPos(text -> pos() + applied_movement);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-05-08 21:24:43 +00:00
|
|
|
/**
|
|
|
|
Constructeur
|
|
|
|
@param diagram Schema sur lequel on deplace des champs de texte
|
|
|
|
@param texts Textes deplaces : chaque ConductorTextItem est associe a un
|
|
|
|
couple de position : avant et apres le deplacement
|
|
|
|
@param m translation subie par les elements
|
|
|
|
@param parent QUndoCommand parent
|
|
|
|
*/
|
|
|
|
MoveConductorsTextsCommand::MoveConductorsTextsCommand(
|
|
|
|
Diagram *diagram,
|
|
|
|
QUndoCommand *parent
|
|
|
|
) :
|
|
|
|
QUndoCommand(parent),
|
|
|
|
diagram(diagram),
|
|
|
|
first_redo(true)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Destructeur
|
|
|
|
MoveConductorsTextsCommand::~MoveConductorsTextsCommand() {
|
|
|
|
}
|
|
|
|
|
|
|
|
/// annule le deplacement
|
|
|
|
void MoveConductorsTextsCommand::undo() {
|
2014-01-11 22:38:30 +00:00
|
|
|
diagram -> showMe();
|
2010-05-08 21:24:43 +00:00
|
|
|
foreach(ConductorTextItem *cti, texts_to_move_.keys()) {
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/// refait le deplacement
|
|
|
|
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 {
|
|
|
|
foreach(ConductorTextItem *cti, texts_to_move_.keys()) {
|
|
|
|
QPointF movement = texts_to_move_[cti].first;
|
|
|
|
|
|
|
|
cti -> forceMovedByUser(true);
|
|
|
|
cti -> setPos(cti -> pos() + movement);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
Ajout un mouvement de champ de texte a cet objet
|
|
|
|
@param text_item Champ de texte deplace ; si celui-ci est deja connu de l'objet d'annulation, il sera ignore
|
|
|
|
@param old_pos Position du champ de texte avant le mouvement
|
|
|
|
@param new_pos Position du champ de texte apres le mouvement
|
|
|
|
@param alread_moved true si le champ de texte etait deja a une position personnalisee par l'utilisateur, false sinon
|
|
|
|
*/
|
|
|
|
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();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
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(
|
|
|
|
"d\351placer %1",
|
|
|
|
"undo caption - %1 is a sentence listing the moved content"
|
|
|
|
).arg(moved_content_sentence)
|
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
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
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/// destructeur
|
|
|
|
ChangeDiagramTextCommand::~ChangeDiagramTextCommand() {
|
|
|
|
}
|
|
|
|
|
|
|
|
/// annule la modification de texte
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
/// refait la modification de texte
|
|
|
|
void ChangeDiagramTextCommand::redo() {
|
2014-01-11 22:38:30 +00:00
|
|
|
diagram -> showMe();
|
2010-04-23 22:39:59 +00:00
|
|
|
if (first_redo) {
|
|
|
|
first_redo = false;
|
|
|
|
} else {
|
2013-03-22 23:17:39 +00:00
|
|
|
text_item -> setHtml(text_after);
|
2007-09-26 22:57:53 +00:00
|
|
|
}
|
|
|
|
}
|
2007-09-27 15:36:15 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Constructeur
|
|
|
|
@param elements Elements a pivoter associes a leur orientation d'origine
|
2010-05-02 22:00:53 +00:00
|
|
|
@param texts Textes a pivoter
|
2007-09-27 15:36:15 +00:00
|
|
|
@param parent QUndoCommand parent
|
|
|
|
*/
|
2013-11-14 10:11:22 +00:00
|
|
|
RotateElementsCommand::RotateElementsCommand(const QList<Element *> &elements, const QList<DiagramTextItem *> &texts, const QList<DiagramImageItem *> &images, QUndoCommand *parent) :
|
2009-04-03 19:30:25 +00:00
|
|
|
QUndoCommand(parent),
|
2009-11-29 21:56:48 +00:00
|
|
|
elements_to_rotate(elements),
|
2010-02-11 23:35:04 +00:00
|
|
|
texts_to_rotate(texts),
|
2013-08-24 15:18:45 +00:00
|
|
|
images_to_rotate(images),
|
2014-01-08 21:06:26 +00:00
|
|
|
applied_rotation_angle_(90.0)
|
2007-09-27 15:36:15 +00:00
|
|
|
{
|
2014-01-08 21:06:26 +00:00
|
|
|
if(elements_to_rotate.size()) diagram = elements_to_rotate.first()->diagram();
|
|
|
|
else if (texts_to_rotate.size()) diagram = texts_to_rotate.first()->diagram();
|
|
|
|
else if (images_to_rotate.size()) diagram = images_to_rotate.first()->diagram();
|
|
|
|
|
2009-04-03 19:30:25 +00:00
|
|
|
setText(
|
|
|
|
QString(
|
|
|
|
QObject::tr(
|
|
|
|
"pivoter %1",
|
|
|
|
"undo caption - %1 is a sentence listing the rotated content"
|
|
|
|
)
|
2013-08-24 15:18:45 +00:00
|
|
|
).arg(QET::ElementsAndConductorsSentence(elements.count(), 0, texts.count(), images.count()))
|
2009-04-03 19:30:25 +00:00
|
|
|
);
|
2007-09-27 15:36:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/// Destructeur
|
|
|
|
RotateElementsCommand::~RotateElementsCommand() {
|
|
|
|
}
|
|
|
|
|
|
|
|
/// defait le pivotement
|
|
|
|
void RotateElementsCommand::undo() {
|
2014-01-11 22:38:30 +00:00
|
|
|
diagram -> showMe();
|
2013-11-14 10:11:22 +00:00
|
|
|
foreach(Element *e, elements_to_rotate) {
|
|
|
|
e -> rotateBy(-applied_rotation_angle_);
|
2007-09-27 15:36:15 +00:00
|
|
|
}
|
2009-11-29 21:56:48 +00:00
|
|
|
foreach(DiagramTextItem *dti, texts_to_rotate) {
|
2013-06-19 21:40:28 +00:00
|
|
|
//ConductorTextItem have a default rotation angle, we apply a specific treatment
|
2013-06-09 19:09:27 +00:00
|
|
|
if (ConductorTextItem *cti = qgraphicsitem_cast<ConductorTextItem *>(dti)) {
|
2013-06-19 21:40:28 +00:00
|
|
|
cti -> forceRotateByUser(previous_rotate_by_user_[cti]);
|
2013-11-14 10:11:22 +00:00
|
|
|
(cti -> wasRotateByUser()) ? cti -> rotateBy(-applied_rotation_angle_) :
|
2014-10-07 19:51:26 +00:00
|
|
|
cti -> parentConductor() -> calculateTextItemPosition();
|
2013-06-09 19:09:27 +00:00
|
|
|
}
|
2013-06-19 21:40:28 +00:00
|
|
|
else {dti -> rotateBy(-applied_rotation_angle_);}
|
2009-11-29 21:56:48 +00:00
|
|
|
}
|
2013-08-24 15:18:45 +00:00
|
|
|
foreach(DiagramImageItem *dii, images_to_rotate) dii -> rotateBy(-applied_rotation_angle_);
|
2007-09-27 15:36:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/// refait le pivotement
|
|
|
|
void RotateElementsCommand::redo() {
|
2014-01-11 22:38:30 +00:00
|
|
|
diagram -> showMe();
|
2013-11-14 10:11:22 +00:00
|
|
|
foreach(Element *e, elements_to_rotate) {
|
|
|
|
e -> rotateBy(applied_rotation_angle_);
|
2009-11-29 21:56:48 +00:00
|
|
|
}
|
|
|
|
foreach(DiagramTextItem *dti, texts_to_rotate) {
|
2013-06-19 21:40:28 +00:00
|
|
|
//we grab the previous rotation by user of each ConductorTextItem
|
2013-06-09 19:09:27 +00:00
|
|
|
if (ConductorTextItem *cti = qgraphicsitem_cast<ConductorTextItem *>(dti)) {
|
2013-06-19 21:40:28 +00:00
|
|
|
previous_rotate_by_user_.insert(cti, cti -> wasRotateByUser());
|
2013-06-09 19:09:27 +00:00
|
|
|
cti -> forceRotateByUser(true);
|
|
|
|
}
|
2010-02-11 23:35:04 +00:00
|
|
|
dti -> rotateBy(applied_rotation_angle_);
|
2007-09-27 15:36:15 +00:00
|
|
|
}
|
2013-08-24 15:18:45 +00:00
|
|
|
foreach(DiagramImageItem *dii, images_to_rotate) dii -> rotateBy(applied_rotation_angle_);
|
2007-09-27 15:36:15 +00:00
|
|
|
}
|
2007-09-27 17:42:02 +00:00
|
|
|
|
2010-02-11 23:35:04 +00:00
|
|
|
/**
|
|
|
|
Constructeur
|
|
|
|
@param previous_state Hash associant les textes impactes par l'action et leur angle de rotation avant l'action
|
|
|
|
@param applied_rotation Nouvel angle de rotation, a appliquer au textes concernes
|
|
|
|
@param parent QUndoCommand parent
|
|
|
|
*/
|
|
|
|
RotateTextsCommand::RotateTextsCommand(const QHash<DiagramTextItem *, double> &previous_state, double applied_rotation, QUndoCommand *parent) :
|
|
|
|
QUndoCommand(parent),
|
|
|
|
texts_to_rotate(previous_state),
|
2014-01-06 18:21:58 +00:00
|
|
|
applied_rotation_angle_(applied_rotation),
|
|
|
|
diagram(previous_state.key(0)->diagram())
|
2010-02-11 23:35:04 +00:00
|
|
|
{
|
|
|
|
defineCommandName();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
Constructeur
|
|
|
|
@param texts Liste des textes impactes par l'action. L'objet retiendra leur angle de rotation au moment de sa construction.
|
|
|
|
@param applied_rotation Nouvel angle de rotation, a appliquer au textes concernes
|
|
|
|
@param parent QUndoCommand parent
|
|
|
|
*/
|
|
|
|
RotateTextsCommand::RotateTextsCommand(const QList<DiagramTextItem *> &texts, double applied_rotation, QUndoCommand *parent) :
|
|
|
|
QUndoCommand(parent),
|
2014-01-13 20:26:04 +00:00
|
|
|
applied_rotation_angle_(applied_rotation),
|
|
|
|
diagram(texts.first()->diagram())
|
2010-02-11 23:35:04 +00:00
|
|
|
{
|
|
|
|
foreach(DiagramTextItem *text, texts) {
|
|
|
|
texts_to_rotate.insert(text, text -> rotationAngle());
|
|
|
|
}
|
|
|
|
defineCommandName();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
Destructeur
|
|
|
|
*/
|
|
|
|
RotateTextsCommand::~RotateTextsCommand() {
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
Annule la rotation des textes
|
|
|
|
*/
|
|
|
|
void RotateTextsCommand::undo() {
|
2014-01-11 22:38:30 +00:00
|
|
|
diagram -> showMe();
|
2010-02-11 23:35:04 +00:00
|
|
|
foreach(DiagramTextItem *text, texts_to_rotate.keys()) {
|
2013-06-19 21:40:28 +00:00
|
|
|
if (ConductorTextItem *cti = qgraphicsitem_cast<ConductorTextItem *>(text))
|
|
|
|
cti -> forceRotateByUser(previous_rotate_by_user_[cti]);
|
2010-02-11 23:35:04 +00:00
|
|
|
text -> setRotationAngle(texts_to_rotate[text]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
Applique l'angle de rotation aux textes
|
|
|
|
*/
|
|
|
|
void RotateTextsCommand::redo() {
|
2014-01-11 22:38:30 +00:00
|
|
|
diagram -> showMe();
|
2010-02-11 23:35:04 +00:00
|
|
|
foreach(DiagramTextItem *text, texts_to_rotate.keys()) {
|
2013-06-13 17:42:37 +00:00
|
|
|
if (ConductorTextItem *cti = qgraphicsitem_cast<ConductorTextItem *>(text)) {
|
2013-06-19 21:40:28 +00:00
|
|
|
//we grab the previous rotation by user of each ConductorTextItem
|
|
|
|
previous_rotate_by_user_.insert(cti, cti -> wasRotateByUser());
|
2013-06-13 17:42:37 +00:00
|
|
|
cti -> forceRotateByUser(true);
|
|
|
|
}
|
2010-02-11 23:35:04 +00:00
|
|
|
text -> setRotationAngle(applied_rotation_angle_);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
Definit le nom de la commande d'annulation
|
|
|
|
*/
|
|
|
|
void RotateTextsCommand::defineCommandName() {
|
|
|
|
setText(
|
|
|
|
QString(
|
|
|
|
QObject::tr(
|
|
|
|
"orienter %1 \340 %2\260",
|
|
|
|
"undo caption - %1 looks like '42 texts', %2 is a rotation angle"
|
|
|
|
)
|
|
|
|
).arg(QET::ElementsAndConductorsSentence(0, 0, texts_to_rotate.count()))
|
|
|
|
.arg(applied_rotation_angle_)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
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
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Destructeur
|
2007-10-03 17:02:39 +00:00
|
|
|
ChangeConductorCommand::~ChangeConductorCommand() {
|
2007-09-27 17:42:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/// 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
|
|
|
}
|
|
|
|
|
|
|
|
/// 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_);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
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(
|
|
|
|
"R\351initialiser %1",
|
|
|
|
"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();
|
2007-10-06 18:37:21 +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();
|
2007-10-06 18:37:21 +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 17:39:30 +00:00
|
|
|
/**
|
|
|
|
Constructeur
|
|
|
|
@param d Schema dont on modifie le cartouche
|
2007-10-10 17:50:26 +00:00
|
|
|
@param old_ip Anciennes proprietes du cartouche
|
|
|
|
@param new_ip Nouvelles proprietes du cartouche
|
2007-09-28 17:39:30 +00:00
|
|
|
@param parent QUndoCommand parent
|
|
|
|
*/
|
2010-12-20 02:45:36 +00:00
|
|
|
ChangeTitleBlockCommand::ChangeTitleBlockCommand(
|
2007-09-28 17:39:30 +00:00
|
|
|
Diagram *d,
|
2010-12-20 02:45:36 +00:00
|
|
|
const TitleBlockProperties &old_ip,
|
|
|
|
const TitleBlockProperties &new_ip,
|
2007-09-28 17:39:30 +00:00
|
|
|
QUndoCommand *parent
|
|
|
|
) :
|
2009-04-03 19:30:25 +00:00
|
|
|
QUndoCommand(QObject::tr("modifier le cartouche", "undo caption"), parent),
|
2007-09-28 17:39:30 +00:00
|
|
|
diagram(d),
|
2010-12-20 02:45:36 +00:00
|
|
|
old_titleblock(old_ip),
|
|
|
|
new_titleblock(new_ip)
|
2007-09-28 17:39:30 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Destructeur
|
2010-12-20 02:45:36 +00:00
|
|
|
ChangeTitleBlockCommand::~ChangeTitleBlockCommand() {
|
2007-09-28 17:39:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/// Annule la modification de cartouche
|
2010-12-20 02:45:36 +00:00
|
|
|
void ChangeTitleBlockCommand::undo() {
|
2014-01-11 22:38:30 +00:00
|
|
|
diagram -> showMe();
|
2010-12-20 02:45:36 +00:00
|
|
|
diagram -> border_and_titleblock.importTitleBlock(old_titleblock);
|
2007-10-15 19:42:18 +00:00
|
|
|
diagram -> invalidate(diagram -> border());
|
2007-09-28 17:39:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/// Refait la modification de cartouche
|
2010-12-20 02:45:36 +00:00
|
|
|
void ChangeTitleBlockCommand::redo() {
|
2014-01-11 22:38:30 +00:00
|
|
|
diagram -> showMe();
|
2010-12-20 02:45:36 +00:00
|
|
|
diagram -> border_and_titleblock.importTitleBlock(new_titleblock);
|
2007-10-15 19:42:18 +00:00
|
|
|
diagram -> invalidate(diagram -> border());
|
2007-09-28 17:39:30 +00:00
|
|
|
}
|
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
|
|
|
|
*/
|
2008-08-15 12:46:22 +00:00
|
|
|
ChangeBorderCommand::ChangeBorderCommand(Diagram *dia, const BorderProperties &old_bp, const BorderProperties &new_bp, QUndoCommand *parent) :
|
2009-04-03 19:30:25 +00:00
|
|
|
QUndoCommand(QObject::tr("modifier les dimensions du sch\351ma", "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
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Destructeur
|
|
|
|
ChangeBorderCommand::~ChangeBorderCommand() {
|
|
|
|
}
|
|
|
|
|
2007-10-10 17:50:26 +00:00
|
|
|
/// 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
|
|
|
}
|
|
|
|
|
2007-10-10 17:50:26 +00:00
|
|
|
/// 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
|
|
|
}
|
2007-10-03 15:51:04 +00:00
|
|
|
|
2007-10-10 17:50:26 +00:00
|
|
|
/**
|
|
|
|
Constructeur
|
|
|
|
@param c Le conducteur dont on modifie les proprietes
|
|
|
|
@param parent QUndoCommand parent
|
|
|
|
*/
|
2007-10-03 17:02:39 +00:00
|
|
|
ChangeConductorPropertiesCommand::ChangeConductorPropertiesCommand(Conductor *c, QUndoCommand *parent) :
|
2009-04-03 19:30:25 +00:00
|
|
|
QUndoCommand(QObject::tr("modifier les propri\351t\351s d'un conducteur", "undo caption"), parent),
|
2007-10-03 17:02:39 +00:00
|
|
|
conductor(c),
|
2007-10-03 15:51:04 +00:00
|
|
|
old_settings_set(false),
|
2014-01-06 18:21:58 +00:00
|
|
|
new_settings_set(false),
|
|
|
|
diagram(c->diagram())
|
2007-10-03 15:51:04 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2007-10-10 17:50:26 +00:00
|
|
|
/// Destructeur
|
2007-10-03 17:02:39 +00:00
|
|
|
ChangeConductorPropertiesCommand::~ChangeConductorPropertiesCommand() {
|
2007-10-03 15:51:04 +00:00
|
|
|
}
|
|
|
|
|
2007-10-10 17:50:26 +00:00
|
|
|
/// definit l'ancienne configuration
|
2007-10-14 14:44:33 +00:00
|
|
|
void ChangeConductorPropertiesCommand::setOldSettings(const ConductorProperties &properties) {
|
|
|
|
old_properties = properties;
|
2007-10-03 15:51:04 +00:00
|
|
|
old_settings_set = true;
|
|
|
|
}
|
|
|
|
|
2007-10-10 17:50:26 +00:00
|
|
|
/// definit la nouvelle configuration
|
2007-10-14 14:44:33 +00:00
|
|
|
void ChangeConductorPropertiesCommand::setNewSettings(const ConductorProperties &properties) {
|
|
|
|
new_properties = properties;
|
2007-10-03 15:51:04 +00:00
|
|
|
new_settings_set = true;
|
|
|
|
}
|
|
|
|
|
2007-10-10 17:50:26 +00:00
|
|
|
/**
|
|
|
|
Annule les changements - Attention : les anciens et nouveaux parametres
|
|
|
|
doivent avoir ete definis a l'aide de setNewSettings et setOldSettings
|
|
|
|
*/
|
2007-10-03 17:02:39 +00:00
|
|
|
void ChangeConductorPropertiesCommand::undo() {
|
2014-01-11 22:38:30 +00:00
|
|
|
diagram -> showMe();
|
2007-10-03 15:51:04 +00:00
|
|
|
if (old_settings_set && new_settings_set) {
|
2007-10-14 14:44:33 +00:00
|
|
|
conductor -> setProperties(old_properties);
|
2007-10-03 17:02:39 +00:00
|
|
|
conductor -> update();
|
2007-10-03 15:51:04 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-10-10 17:50:26 +00:00
|
|
|
/**
|
|
|
|
Refait les changements - Attention : les anciens et nouveaux parametres
|
|
|
|
doivent avoir ete definis a l'aide de setNewSettings et setOldSettings
|
|
|
|
*/
|
2007-10-03 17:02:39 +00:00
|
|
|
void ChangeConductorPropertiesCommand::redo() {
|
2014-01-11 22:38:30 +00:00
|
|
|
diagram -> showMe();
|
2007-10-03 15:51:04 +00:00
|
|
|
if (old_settings_set && new_settings_set) {
|
2007-10-14 14:44:33 +00:00
|
|
|
conductor -> setProperties(new_properties);
|
2007-10-03 17:02:39 +00:00
|
|
|
conductor -> update();
|
2007-10-03 15:51:04 +00:00
|
|
|
}
|
|
|
|
}
|
2013-04-04 16:57:15 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Constructeur
|
|
|
|
@param c La liste des conducteurs dont on modifie les proprietes
|
|
|
|
@param parent QUndoCommand parent
|
|
|
|
*/
|
2014-01-06 18:21:58 +00:00
|
|
|
ChangeSeveralConductorsPropertiesCommand::ChangeSeveralConductorsPropertiesCommand(QList<Conductor *>c, QUndoCommand *parent) :
|
2013-04-04 16:57:15 +00:00
|
|
|
QUndoCommand(QObject::tr("modifier les propri\351t\351s de plusieurs conducteurs", "undo caption"), parent),
|
|
|
|
conductors(c),
|
|
|
|
old_settings_set(false),
|
2014-01-06 18:21:58 +00:00
|
|
|
new_settings_set(false),
|
|
|
|
diagram(c.first()->diagram())
|
2013-04-04 16:57:15 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Destructeur
|
|
|
|
ChangeSeveralConductorsPropertiesCommand::~ChangeSeveralConductorsPropertiesCommand() {
|
|
|
|
}
|
|
|
|
|
|
|
|
/// definit l'ancienne configuration
|
|
|
|
void ChangeSeveralConductorsPropertiesCommand::setOldSettings(const QList<ConductorProperties> &properties) {
|
2013-11-21 21:34:49 +00:00
|
|
|
if (!old_settings_set) {
|
|
|
|
old_properties = properties;
|
|
|
|
old_settings_set = true;
|
|
|
|
}
|
2013-04-04 16:57:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/// definit la nouvelle configuration
|
|
|
|
void ChangeSeveralConductorsPropertiesCommand::setNewSettings(const QList<ConductorProperties> &properties) {
|
2013-11-21 21:34:49 +00:00
|
|
|
if (!new_settings_set) {
|
|
|
|
new_properties = properties;
|
|
|
|
new_settings_set = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void ChangeSeveralConductorsPropertiesCommand::setNewSettings(const ConductorProperties &properties) {
|
|
|
|
if (!new_settings_set) {
|
|
|
|
single_new_properties = properties;
|
|
|
|
new_settings_set = true;
|
|
|
|
}
|
2013-04-04 16:57:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
Annule les changements - Attention : les anciens et nouveaux parametres
|
|
|
|
doivent avoir ete definis a l'aide de setNewSettings et setOldSettings
|
|
|
|
*/
|
|
|
|
void ChangeSeveralConductorsPropertiesCommand::undo() {
|
2014-01-11 22:38:30 +00:00
|
|
|
diagram -> showMe();
|
2013-04-04 16:57:15 +00:00
|
|
|
if (old_settings_set && new_settings_set) {
|
|
|
|
int i=0;
|
|
|
|
foreach(Conductor *c, conductors) {
|
|
|
|
c -> setProperties(old_properties.at(i));
|
|
|
|
c -> update();
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
Refait les changements - Attention : les anciens et nouveaux parametres
|
|
|
|
doivent avoir ete definis a l'aide de setNewSettings et setOldSettings
|
|
|
|
*/
|
|
|
|
void ChangeSeveralConductorsPropertiesCommand::redo() {
|
2014-01-11 22:38:30 +00:00
|
|
|
diagram -> showMe();
|
2013-04-04 16:57:15 +00:00
|
|
|
if (old_settings_set && new_settings_set) {
|
2013-11-21 21:34:49 +00:00
|
|
|
|
|
|
|
//new propertie are the same for each conductor
|
|
|
|
if (new_properties.isEmpty()) {
|
|
|
|
foreach(Conductor *c, conductors) {
|
|
|
|
c -> setProperties(single_new_properties);
|
|
|
|
c -> update();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//new propertie are different for each conductor
|
|
|
|
else {
|
|
|
|
int i=0;
|
|
|
|
foreach(Conductor *c, conductors) {
|
|
|
|
c -> setProperties(new_properties.at(i));
|
|
|
|
c -> update();
|
|
|
|
i++;
|
|
|
|
}
|
2013-04-04 16:57:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2013-09-09 13:29:28 +00:00
|
|
|
|
|
|
|
/**
|
2014-06-14 16:04:34 +00:00
|
|
|
* @brief ItemResizerCommand::ItemResizerCommand
|
|
|
|
* Change the size of @qgi
|
|
|
|
* @param qgi item to resize
|
|
|
|
* @param old_ old size
|
|
|
|
* @param new_ new size
|
|
|
|
* @param text text to display
|
|
|
|
* @param parent undo parent
|
2013-09-09 13:29:28 +00:00
|
|
|
*/
|
2014-06-14 16:04:34 +00:00
|
|
|
ItemResizerCommand::ItemResizerCommand (QetGraphicsItem *qgi, qreal &old_, qreal &new_, const QString &text, QUndoCommand *parent):
|
2013-09-09 13:29:28 +00:00
|
|
|
QUndoCommand(parent),
|
2014-06-14 16:04:34 +00:00
|
|
|
m_qgi ( qgi ),
|
|
|
|
old_size ( old_ ),
|
|
|
|
new_size ( new_ ),
|
|
|
|
diagram ( qgi->diagram() ),
|
|
|
|
m_text ( text )
|
2013-09-09 13:29:28 +00:00
|
|
|
{}
|
|
|
|
|
|
|
|
/**
|
2014-06-14 16:04:34 +00:00
|
|
|
* @brief ItemResizerCommand::~ItemResizerCommand
|
2013-09-09 13:29:28 +00:00
|
|
|
*/
|
2014-06-14 16:04:34 +00:00
|
|
|
ItemResizerCommand::~ItemResizerCommand() {}
|
2013-09-09 13:29:28 +00:00
|
|
|
|
|
|
|
/**
|
2014-06-14 16:04:34 +00:00
|
|
|
* @brief ItemResizerCommand::undo
|
2013-09-09 13:29:28 +00:00
|
|
|
*/
|
2014-06-14 16:04:34 +00:00
|
|
|
void ItemResizerCommand::undo() {
|
2014-01-11 22:38:30 +00:00
|
|
|
diagram -> showMe();
|
2014-06-14 16:04:34 +00:00
|
|
|
m_qgi -> setScale(old_size);
|
|
|
|
QUndoCommand::undo();
|
2013-09-09 13:29:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2014-06-14 16:04:34 +00:00
|
|
|
* @brief ItemResizerCommand::redo
|
2013-09-09 13:29:28 +00:00
|
|
|
*/
|
2014-06-14 16:04:34 +00:00
|
|
|
void ItemResizerCommand::redo() {
|
2014-01-11 22:38:30 +00:00
|
|
|
diagram -> showMe();
|
2014-06-14 16:04:34 +00:00
|
|
|
if (old_size<new_size) setText(QObject::tr("Agrandire %1 \340 %2 %").arg(m_text).arg(new_size*100));
|
|
|
|
else setText(QObject::tr("R\351duire %1 \340 %2 %").arg(m_text).arg(new_size*100));
|
|
|
|
m_qgi -> setScale(new_size);
|
|
|
|
QUndoCommand::redo();
|
2013-09-09 13:29:28 +00:00
|
|
|
}
|
2014-01-07 20:11:28 +00:00
|
|
|
|
2014-03-07 08:05:25 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief ChangeShapeStyleCommand::ChangeShapeStyleCommand Constructor
|
|
|
|
* @param shape
|
|
|
|
* @param old_ old style of shape
|
|
|
|
* @param new_ new style of shape
|
|
|
|
* @param parent undocommand parent
|
|
|
|
*/
|
|
|
|
ChangeShapeStyleCommand::ChangeShapeStyleCommand(QetShapeItem *shape, Qt::PenStyle &old_, Qt::PenStyle &new_, QUndoCommand *parent):
|
|
|
|
QUndoCommand(parent),
|
|
|
|
shape_(shape),
|
|
|
|
old_style (old_),
|
|
|
|
new_style (new_),
|
|
|
|
diagram(shape->diagram())
|
2014-06-14 16:04:34 +00:00
|
|
|
{
|
|
|
|
setText(QObject::tr("Changer le style d'une shape"));
|
|
|
|
}
|
2014-03-07 08:05:25 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief ChangeShapeStyleCommand::~ChangeShapeStyleCommand destructor
|
|
|
|
*/
|
|
|
|
ChangeShapeStyleCommand::~ChangeShapeStyleCommand() {}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief ChangeShapeStyleCommand::undo set the old style
|
|
|
|
*/
|
|
|
|
void ChangeShapeStyleCommand::undo() {
|
|
|
|
shape_ -> setStyle(old_style);
|
|
|
|
diagram -> showMe();
|
|
|
|
QUndoCommand::undo();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief ChangeShapeStyleCommand::redo set the new style
|
|
|
|
*/
|
|
|
|
void ChangeShapeStyleCommand::redo() {
|
|
|
|
shape_ -> setStyle(new_style);
|
|
|
|
diagram -> showMe();
|
|
|
|
QUndoCommand::redo();
|
|
|
|
}
|
|
|
|
|
2014-01-07 20:11:28 +00:00
|
|
|
/**
|
|
|
|
* @brief LinkElementsCommand::LinkElementsCommand
|
|
|
|
*Constructor
|
|
|
|
* @param elmt1 element to Link
|
|
|
|
* @param elmt2 element to link
|
|
|
|
* @param parent parent undo command
|
|
|
|
*/
|
|
|
|
LinkElementsCommand::LinkElementsCommand(Element *elmt1, Element *elmt2, QUndoCommand *parent) :
|
|
|
|
QUndoCommand(parent),
|
|
|
|
diagram_(elmt1->diagram()),
|
2014-02-26 23:57:22 +00:00
|
|
|
element_(elmt1),
|
2014-02-06 21:35:13 +00:00
|
|
|
first_redo(true)
|
2014-01-07 20:11:28 +00:00
|
|
|
{
|
2014-02-26 23:57:22 +00:00
|
|
|
elmt_list << elmt2;
|
2014-01-07 20:11:28 +00:00
|
|
|
if (elmt1->linkType() & Element::AllReport &&
|
2014-01-08 19:27:38 +00:00
|
|
|
elmt2->linkType() & Element::AllReport) {
|
2014-01-07 20:11:28 +00:00
|
|
|
setText(QObject::tr("Lier deux reports de folio",
|
|
|
|
"title for undo LinkElementsCommand if two elements are folio report"));
|
2014-01-08 19:27:38 +00:00
|
|
|
}
|
2014-03-12 09:32:56 +00:00
|
|
|
else if (element_->linkType() & (Element::Master|Element::Slave))
|
2014-02-26 23:57:22 +00:00
|
|
|
setText(QObject::tr("Editer les r\351f\351rence crois\351", "edite the cross reference"));
|
|
|
|
else setText(QObject::tr("Lier deux éléments"));
|
2014-03-12 09:32:56 +00:00
|
|
|
|
|
|
|
previous_linked = elmt1->linkedElements();
|
2014-02-26 23:57:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
LinkElementsCommand::LinkElementsCommand(Element *elmt1, QList<Element *> &elmtList, QUndoCommand *parent) :
|
|
|
|
QUndoCommand(parent),
|
|
|
|
diagram_(elmt1->diagram()),
|
|
|
|
element_(elmt1),
|
|
|
|
elmt_list(elmtList),
|
|
|
|
first_redo(true)
|
|
|
|
{
|
2014-03-12 09:32:56 +00:00
|
|
|
if (element_->linkType() & (Element::Master|Element::Slave))
|
2014-02-26 23:57:22 +00:00
|
|
|
setText(QObject::tr("Editer les r\351f\351rence crois\351"));
|
2014-01-07 20:11:28 +00:00
|
|
|
else setText(QObject::tr("Lier deux éléments"));
|
2014-03-12 09:32:56 +00:00
|
|
|
previous_linked = elmt1->linkedElements();
|
2014-01-07 20:11:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief LinkElementsCommand::~LinkElementsCommand
|
|
|
|
*destructor
|
|
|
|
*/
|
|
|
|
LinkElementsCommand::~LinkElementsCommand(){}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief LinkElementsCommand::undo
|
|
|
|
*Undo command
|
|
|
|
*/
|
|
|
|
void LinkElementsCommand::undo() {
|
|
|
|
diagram_->showMe();
|
2014-02-26 23:57:22 +00:00
|
|
|
|
|
|
|
foreach (Element *elmt, elmt_list)
|
|
|
|
element_->unlinkElement(elmt);
|
|
|
|
|
2014-03-12 09:32:56 +00:00
|
|
|
foreach (Element *elmt, previous_linked)
|
|
|
|
element_->linkToElement(elmt);
|
|
|
|
|
2014-02-26 23:57:22 +00:00
|
|
|
QUndoCommand::undo();
|
2014-01-07 20:11:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief LinkElementsCommand::redo
|
|
|
|
*redo command
|
|
|
|
*/
|
|
|
|
void LinkElementsCommand::redo() {
|
|
|
|
diagram_->showMe();
|
2014-02-26 23:57:22 +00:00
|
|
|
|
|
|
|
foreach (Element *elmt, elmt_list)
|
|
|
|
element_->linkToElement(elmt);
|
|
|
|
|
|
|
|
//If element are report, check if text of this potential is identical.
|
|
|
|
if ((element_->linkType() &Element::AllReport) && first_redo) {
|
|
|
|
if(element_->conductors().count() && elmt_list.first()->conductors().count()) {
|
|
|
|
ConductorAutoNumerotation::checkPotential(element_->conductors().first());
|
2014-02-06 21:35:13 +00:00
|
|
|
}
|
|
|
|
first_redo = false;
|
|
|
|
}
|
2014-02-26 23:57:22 +00:00
|
|
|
QUndoCommand::redo();
|
2014-01-07 20:11:28 +00:00
|
|
|
}
|
2014-01-08 19:27:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief unlinkElementsCommand::unlinkElementsCommand
|
|
|
|
* Constructor, unlink elmt2 or all elements if elmt2 isn't specified
|
|
|
|
* @param elmt1 element to set undo command
|
|
|
|
* @param elmt2 element to be unlinked
|
|
|
|
* @param parent undo parent
|
|
|
|
*/
|
|
|
|
unlinkElementsCommand::unlinkElementsCommand(Element *elmt1, Element *elmt2, QUndoCommand *parent):
|
|
|
|
QUndoCommand(parent),
|
|
|
|
diagram_(elmt1->diagram()),
|
|
|
|
element_(elmt1)
|
|
|
|
{
|
|
|
|
if (elmt2) elmt_list << elmt2;
|
|
|
|
else elmt_list << elmt1->linkedElements();
|
|
|
|
setText(QObject::tr("D\351lier %n \351l\351ment(s)", "", elmt_list.size()));
|
|
|
|
}
|
|
|
|
|
2014-02-26 23:57:22 +00:00
|
|
|
/**
|
|
|
|
* @brief unlinkElementsCommand::unlinkElementsCommand
|
|
|
|
* @param elmt1 Element to set the link
|
|
|
|
* @param elmtList list of all element to be linked to elmt1
|
|
|
|
* @param parent undo command
|
|
|
|
*/
|
|
|
|
unlinkElementsCommand::unlinkElementsCommand(Element *elmt1, QList<Element *> &elmtList, QUndoCommand *parent):
|
|
|
|
QUndoCommand(parent),
|
|
|
|
diagram_(elmt1->diagram()),
|
|
|
|
element_(elmt1),
|
|
|
|
elmt_list(elmtList)
|
|
|
|
{
|
|
|
|
setText(QObject::tr("D\351lier %n \351l\351ment(s)", "", elmt_list.size()));
|
|
|
|
}
|
|
|
|
|
2014-01-08 19:27:38 +00:00
|
|
|
/**
|
|
|
|
* @brief unlinkElementsCommand::~unlinkElementsCommand
|
|
|
|
* destructor
|
|
|
|
*/
|
|
|
|
unlinkElementsCommand::~unlinkElementsCommand(){}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief unlinkElementsCommand::undo
|
|
|
|
*undo command
|
|
|
|
*/
|
|
|
|
void unlinkElementsCommand::undo() {
|
|
|
|
foreach (Element *elmt, elmt_list)
|
|
|
|
element_->linkToElement(elmt);
|
2014-02-26 23:57:22 +00:00
|
|
|
QUndoCommand::undo();
|
2014-01-08 19:27:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief unlinkElementsCommand::redo
|
|
|
|
*redo command
|
|
|
|
*/
|
|
|
|
void unlinkElementsCommand::redo() {
|
|
|
|
foreach (Element *elmt, elmt_list)
|
|
|
|
element_->unlinkElement(elmt);
|
2014-02-26 23:57:22 +00:00
|
|
|
QUndoCommand::redo();
|
2014-01-08 19:27:38 +00:00
|
|
|
}
|