2010-04-18 17:59:54 +00:00
|
|
|
/*
|
2019-01-13 16:56:12 +00:00
|
|
|
Copyright 2006-2019 The QElectroTech Team
|
2010-04-18 17:59:54 +00:00
|
|
|
This file is part of QElectroTech.
|
|
|
|
|
|
|
|
QElectroTech is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
QElectroTech is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
#include "independenttextitem.h"
|
2018-03-25 18:20:54 +00:00
|
|
|
#include "qet.h"
|
2014-10-17 21:30:42 +00:00
|
|
|
#include <QDomElement>
|
2010-04-18 17:59:54 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Constructeur
|
|
|
|
@param parent_diagram Le schema auquel est rattache le champ de texte
|
|
|
|
*/
|
2014-12-14 13:06:21 +00:00
|
|
|
IndependentTextItem::IndependentTextItem() :
|
2017-08-05 02:06:59 +00:00
|
|
|
DiagramTextItem(nullptr)
|
2014-10-17 21:30:42 +00:00
|
|
|
{}
|
2010-04-18 17:59:54 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Constructeur
|
|
|
|
@param text Le texte affiche par le champ de texte
|
|
|
|
@param parent_diagram Le schema auquel est rattache le champ de texte
|
|
|
|
*/
|
2014-12-14 13:06:21 +00:00
|
|
|
IndependentTextItem::IndependentTextItem(const QString &text) :
|
2017-08-05 02:06:59 +00:00
|
|
|
DiagramTextItem(text, nullptr)
|
2014-10-17 21:30:42 +00:00
|
|
|
{}
|
2010-04-18 17:59:54 +00:00
|
|
|
|
|
|
|
/// Destructeur
|
|
|
|
IndependentTextItem::~IndependentTextItem() {
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
Permet de lire le texte a mettre dans le champ a partir d'un element XML.
|
|
|
|
Cette methode se base sur la position du champ pour assigner ou non la
|
|
|
|
valeur a ce champ.
|
|
|
|
@param e L'element XML representant le champ de texte
|
|
|
|
*/
|
|
|
|
void IndependentTextItem::fromXml(const QDomElement &e) {
|
|
|
|
setPos(e.attribute("x").toDouble(), e.attribute("y").toDouble());
|
2013-03-22 23:17:39 +00:00
|
|
|
setHtml(e.attribute("text"));
|
2018-03-25 18:42:18 +00:00
|
|
|
setRotation(e.attribute("rotation").toDouble());
|
2010-04-18 17:59:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
@param document Le document XML a utiliser
|
|
|
|
@return L'element XML representant ce champ de texte
|
|
|
|
*/
|
|
|
|
QDomElement IndependentTextItem::toXml(QDomDocument &document) const {
|
|
|
|
QDomElement result = document.createElement("input");
|
|
|
|
result.setAttribute("x", QString("%1").arg(pos().x()));
|
|
|
|
result.setAttribute("y", QString("%1").arg(pos().y()));
|
2013-03-22 23:17:39 +00:00
|
|
|
result.setAttribute("text", toHtml());
|
2018-03-25 18:20:54 +00:00
|
|
|
if (rotation()) {
|
|
|
|
result.setAttribute("rotation", QString::number(QET::correctAngle(rotation())));
|
2010-04-18 17:59:54 +00:00
|
|
|
}
|
|
|
|
return(result);
|
|
|
|
}
|