mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-18 13:30:34 +01:00
Delete an element linked to others unlink it.
Undo this action relink other element elements git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@3520 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
@@ -77,17 +77,18 @@ DeleteElementsCommand::~DeleteElementsCommand() {
|
|||||||
/// annule les suppressions
|
/// annule les suppressions
|
||||||
void DeleteElementsCommand::undo() {
|
void DeleteElementsCommand::undo() {
|
||||||
diagram -> showMe();
|
diagram -> showMe();
|
||||||
// remet les elements
|
|
||||||
foreach(Element *e, removed_content.elements) {
|
foreach(Element *e, removed_content.elements) {
|
||||||
diagram -> addItem(e);
|
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)) {
|
foreach(Conductor *c, removed_content.conductors(DiagramContent::AnyConductor)) {
|
||||||
diagram -> addItem(c);
|
diagram -> addItem(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
// remet les textes
|
|
||||||
foreach(IndependentTextItem *t, removed_content.textFields) {
|
foreach(IndependentTextItem *t, removed_content.textFields) {
|
||||||
diagram -> addItem(t);
|
diagram -> addItem(t);
|
||||||
}
|
}
|
||||||
@@ -113,7 +114,7 @@ void DeleteElementsCommand::redo() {
|
|||||||
diagram -> removeItem(c);
|
diagram -> removeItem(c);
|
||||||
|
|
||||||
//If option one text per folio is enable, and the text item of
|
//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
|
//We call adjustTextItemPosition to other conductor at the same potential to keep
|
||||||
//a visible text on this potential.
|
//a visible text on this potential.
|
||||||
if (diagram -> defaultConductorProperties.m_one_text_per_folio && c -> textItem() -> isVisible()) {
|
if (diagram -> defaultConductorProperties.m_one_text_per_folio && c -> textItem() -> isVisible()) {
|
||||||
@@ -127,6 +128,9 @@ void DeleteElementsCommand::redo() {
|
|||||||
|
|
||||||
// Remove elements
|
// Remove elements
|
||||||
foreach(Element *e, removed_content.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);
|
diagram -> removeItem(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -101,6 +101,8 @@ class DeleteElementsCommand : public QUndoCommand {
|
|||||||
DiagramContent removed_content;
|
DiagramContent removed_content;
|
||||||
/// diagram which the content is removed from
|
/// diagram which the content is removed from
|
||||||
Diagram *diagram;
|
Diagram *diagram;
|
||||||
|
/// keep linked element for each removed element linked to other element.
|
||||||
|
QHash <Element *, QList<Element *> > m_link_hash;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user