[qet] [3520] Delete an element linked to others unlink it. |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/qet Archives
]
Revision: 3520
Author: blacksun
Date: 2014-11-26 23:05:37 +0100 (Wed, 26 Nov 2014)
Log Message:
-----------
Delete an element linked to others unlink it.
Undo this action relink other element elements
Modified Paths:
--------------
trunk/sources/diagramcommands.cpp
trunk/sources/diagramcommands.h
Modified: trunk/sources/diagramcommands.cpp
===================================================================
--- trunk/sources/diagramcommands.cpp 2014-11-26 18:48:24 UTC (rev 3519)
+++ trunk/sources/diagramcommands.cpp 2014-11-26 22:05:37 UTC (rev 3520)
@@ -77,17 +77,18 @@
/// annule les suppressions
void DeleteElementsCommand::undo() {
diagram -> showMe();
- // remet les elements
+
foreach(Element *e, removed_content.elements) {
diagram -> addItem(e);
+ //Relink this element with other
+ foreach (Element *elmt, m_link_hash[e])
+ e -> linkToElement(elmt);
}
- // remet les conducteurs
foreach(Conductor *c, removed_content.conductors(DiagramContent::AnyConductor)) {
diagram -> addItem(c);
}
- // remet les textes
foreach(IndependentTextItem *t, removed_content.textFields) {
diagram -> addItem(t);
}
@@ -113,7 +114,7 @@
diagram -> removeItem(c);
//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)
+ //current conductor is visible (that mean the conductor have 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()) {
@@ -127,6 +128,9 @@
// Remove elements
foreach(Element *e, removed_content.elements) {
+ //Get linked element, for relink it at undo
+ if (!e->linkedElements().isEmpty())
+ m_link_hash.insert(e, e->linkedElements());
diagram -> removeItem(e);
}
Modified: trunk/sources/diagramcommands.h
===================================================================
--- trunk/sources/diagramcommands.h 2014-11-26 18:48:24 UTC (rev 3519)
+++ trunk/sources/diagramcommands.h 2014-11-26 22:05:37 UTC (rev 3520)
@@ -101,6 +101,8 @@
DiagramContent removed_content;
/// diagram which the content is removed from
Diagram *diagram;
+ /// keep linked element for each removed element linked to other element.
+ QHash <Element *, QList<Element *> > m_link_hash;
};
/**