mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-17 12:40:35 +01:00
Conductor : fix weird bug (not so weird when found) with the position of text item when was moved by user
and also the two element linked by the conductor was moved. git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@3484 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
@@ -956,9 +956,14 @@ bool Conductor::hasClickedOn(QPointF press_point, QPointF point) const {
|
||||
@return true si le chargement a reussi, false sinon
|
||||
*/
|
||||
bool Conductor::fromXml(QDomElement &e) {
|
||||
// recupere la "configuration" du conducteur
|
||||
//Get the "configuration" of conductor
|
||||
properties_.fromXml(e);
|
||||
readProperties();
|
||||
|
||||
setPos(e.attribute("x", 0).toDouble(),
|
||||
e.attribute("y", 0).toDouble());
|
||||
|
||||
//Get the pos of text item
|
||||
qreal user_pos_x, user_pos_y;
|
||||
if (
|
||||
QET::attributeIsAReal(e, "userx", &user_pos_x) &&
|
||||
@@ -997,8 +1002,12 @@ bool Conductor::fromXml(QDomElement &e) {
|
||||
}
|
||||
}
|
||||
|
||||
// s'il n'y a pas de segments, on renvoie true
|
||||
if (!segments_x.size()) return(true);
|
||||
//If there isn't segment we generate automatic path and return true
|
||||
if (!segments_x.size()) {
|
||||
generateConductorPath(terminal1 -> dockConductor(), terminal1 -> orientation(), terminal2 -> dockConductor(), terminal2 -> orientation());
|
||||
return(true);
|
||||
}
|
||||
|
||||
// les longueurs recueillies doivent etre coherentes avec les positions des bornes
|
||||
qreal width = 0.0, height = 0.0;
|
||||
foreach (qreal t, segments_x) width += t;
|
||||
@@ -1020,7 +1029,7 @@ bool Conductor::fromXml(QDomElement &e) {
|
||||
/* on recree les segments a partir des donnes XML */
|
||||
// cree la liste de points
|
||||
QList<QPointF> points_list;
|
||||
points_list << t1;
|
||||
points_list << mapFromScene(t1);
|
||||
for (int i = 0 ; i < segments_x.size() ; ++ i) {
|
||||
points_list << QPointF(
|
||||
points_list.last().x() + segments_x.at(i),
|
||||
@@ -1047,6 +1056,9 @@ bool Conductor::fromXml(QDomElement &e) {
|
||||
*/
|
||||
QDomElement Conductor::toXml(QDomDocument &d, QHash<Terminal *, int> &table_adr_id) const {
|
||||
QDomElement e = d.createElement("conductor");
|
||||
|
||||
e.setAttribute("x", pos().x());
|
||||
e.setAttribute("y", pos().y());
|
||||
e.setAttribute("terminal1", table_adr_id.value(terminal1));
|
||||
e.setAttribute("terminal2", table_adr_id.value(terminal2));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user