diff --git a/sources/ghostelement.cpp b/sources/ghostelement.cpp index 86a15314d..7ead6f030 100644 --- a/sources/ghostelement.cpp +++ b/sources/ghostelement.cpp @@ -19,6 +19,7 @@ #include "qet.h" #include "terminal.h" #include "elementtextitem.h" +#include "diagramcommands.h" /** Constructeur @@ -53,7 +54,7 @@ GhostElement::~GhostElement() { ajouter les bons couples (id, adresse). @return true si l'import a reussi, false sinon */ -bool GhostElement::fromXml(QDomElement &e, QHash &table_id_adr) { +bool GhostElement::fromXml(QDomElement &e, QHash &table_id_adr, bool handle_inputs_rotation) { // instancie les bornes decrites dans l'element XML terminalsFromXml(e, table_id_adr); @@ -78,14 +79,19 @@ bool GhostElement::fromXml(QDomElement &e, QHash &table_id_adr) // on peut desormais confectionner le rendu de l'element generateDrawings(); - // position, selection et orientation + // position, selection setPos(e.attribute("x").toDouble(), e.attribute("y").toDouble()); setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable); + + // orientation bool conv_ok; int read_ori = e.attribute("orientation").toInt(&conv_ok); if (!conv_ok || read_ori < 0 || read_ori > 3) read_ori = ori.defaultOrientation(); - setOrientation((QET::Orientation)read_ori); - + if (handle_inputs_rotation) { + RotateElementsCommand::rotateElement(this, (QET::Orientation)read_ori); + } else { + setOrientation((QET::Orientation)read_ori); + } return(true); } diff --git a/sources/ghostelement.h b/sources/ghostelement.h index 1b90264a1..7dbb0326b 100644 --- a/sources/ghostelement.h +++ b/sources/ghostelement.h @@ -44,7 +44,7 @@ class GhostElement : public CustomElement { // methodes public: - bool fromXml(QDomElement &, QHash &); + virtual bool fromXml(QDomElement &, QHash &, bool = false); protected: QRectF minimalBoundingRect() const;