diff --git a/diagram.cpp b/diagram.cpp index d4c8ea648..1abed5912 100644 --- a/diagram.cpp +++ b/diagram.cpp @@ -20,7 +20,7 @@ Diagram::Diagram(QObject *parent) : QGraphicsScene(parent) { poseur_de_conducer -> setLine(QLineF(QPointF(0.0, 0.0), QPointF(0.0, 0.0))); draw_grid = true; use_border = true; - connect(this, SIGNAL(changed(const QList &)), this, SLOT(slot_checkSelectionChange())); + connect(this, SIGNAL(changed(const QList &)), this, SLOT(slot_checkSelectionEmptinessChange())); } /** @@ -340,6 +340,20 @@ void Diagram::slot_checkSelectionChange() { cache_selecteditems = selecteditems; } +/** + Verifie si la selection est passe d'un etat ou elle est vide a un etat ou + elle ne l'est pas, et inversement. Si c'est le cas, le signal + EmptinessChanged() est emis. +*/ +void Diagram::slot_checkSelectionEmptinessChange() { + static bool selection_was_empty = true; + bool selection_is_empty = selectedItems().isEmpty(); + if (selection_was_empty != selection_is_empty) { + emit(selectionEmptinessChanged()); + selection_was_empty = selection_is_empty; + } +} + /** @return Le rectangle (coordonnees par rapport a la scene) delimitant le bord du schema */ diff --git a/diagram.h b/diagram.h index 4dbe41371..321a7fb3d 100644 --- a/diagram.h +++ b/diagram.h @@ -60,8 +60,10 @@ private slots: void slot_checkSelectionChange(); + void slot_checkSelectionEmptinessChange(); signals: void selectionChanged(); + void selectionEmptinessChanged(); }; #endif diff --git a/diagramview.cpp b/diagramview.cpp index 02db57fdc..efda03136 100644 --- a/diagramview.cpp +++ b/diagramview.cpp @@ -22,7 +22,7 @@ void DiagramView::initialise() { setResizeAnchor(QGraphicsView::AnchorUnderMouse); setAlignment(Qt::AlignLeft | Qt::AlignTop); setSceneRect(QRectF(0.0, 0.0, scene -> border_and_inset.borderWidth() + 10.0, scene -> border_and_inset.borderHeight() + 10.0)); - connect(scene, SIGNAL(selectionChanged()), this, SLOT(slot_selectionChanged())); + connect(scene, SIGNAL(selectionEmptinessChanged()), this, SLOT(slot_selectionChanged())); } /** diff --git a/element.cpp b/element.cpp index 10e71f609..8a1c5a897 100644 --- a/element.cpp +++ b/element.cpp @@ -439,8 +439,8 @@ QList Element::findInDomElement(QDomElement e, QString parent, QStr // parcours des enfants de l'element XML "parent" for (QDomNode node_children = parents.firstChild() ; !node_children.isNull() ; node_children = node_children.nextSibling()) { // on s'interesse a l'element XML "children" - QDomElement children = node_children.toElement(); - if (!children.isNull()) return_list.append(children); + QDomElement n_children = node_children.toElement(); + if (!n_children.isNull() && n_children.tagName() == children) return_list.append(n_children); } } return(return_list);