mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-19 14:50:53 +01:00
Use QStringLiteral and QLatin1String.
This commit is contained in:
@@ -46,10 +46,14 @@ Element * ElementFactory::createElement(const ElementsLocation &location, QGraph
|
|||||||
if (doc.document_element().attribute("link_type"))
|
if (doc.document_element().attribute("link_type"))
|
||||||
{
|
{
|
||||||
QString link_type(doc.document_element().attribute("link_type").as_string());
|
QString link_type(doc.document_element().attribute("link_type").as_string());
|
||||||
if (link_type == "next_report" || link_type == "previous_report") return (new ReportElement(location, link_type, qgi, state));
|
if (link_type == QLatin1String("next_report") || link_type == QLatin1String("previous_report"))
|
||||||
if (link_type == "master") return (new MasterElement (location, qgi, state));
|
return (new ReportElement(location, link_type, qgi, state));
|
||||||
if (link_type == "slave") return (new SlaveElement (location, qgi, state));
|
if (link_type == QLatin1String("master"))
|
||||||
if (link_type == "terminal") return (new TerminalElement (location, qgi, state));
|
return (new MasterElement (location, qgi, state));
|
||||||
|
if (link_type == QLatin1String("slave"))
|
||||||
|
return (new SlaveElement (location, qgi, state));
|
||||||
|
if (link_type == QLatin1String("terminal"))
|
||||||
|
return (new TerminalElement (location, qgi, state));
|
||||||
}
|
}
|
||||||
|
|
||||||
//default if nothing match for link_type
|
//default if nothing match for link_type
|
||||||
|
|||||||
@@ -62,12 +62,12 @@ class ElementXmlRetroCompatibility
|
|||||||
{
|
{
|
||||||
autonum::sequentialNumbers sn;
|
autonum::sequentialNumbers sn;
|
||||||
|
|
||||||
loadSequential(dom_element,"sequ_",&sn.unit);
|
loadSequential(dom_element, QStringLiteral("sequ_"), &sn.unit);
|
||||||
loadSequential(dom_element,"sequf_",&sn.unit_folio);
|
loadSequential(dom_element, QStringLiteral("sequf_"), &sn.unit_folio);
|
||||||
loadSequential(dom_element,"seqt_",&sn.ten);
|
loadSequential(dom_element, QStringLiteral("seqt_"), &sn.ten);
|
||||||
loadSequential(dom_element,"seqtf_",&sn.ten_folio);
|
loadSequential(dom_element, QStringLiteral("seqtf_"), &sn.ten_folio);
|
||||||
loadSequential(dom_element,"seqh_",&sn.hundred);
|
loadSequential(dom_element, QStringLiteral("seqh_"), &sn.hundred);
|
||||||
loadSequential(dom_element,"seqhf_",&sn.hundred_folio);
|
loadSequential(dom_element, QStringLiteral("seqhf_"), &sn.hundred_folio);
|
||||||
|
|
||||||
element->rSequenceStruct() = sn;
|
element->rSequenceStruct() = sn;
|
||||||
}
|
}
|
||||||
@@ -326,7 +326,7 @@ void Element::drawAxes(
|
|||||||
QPainter *painter,
|
QPainter *painter,
|
||||||
const QStyleOptionGraphicsItem *options)
|
const QStyleOptionGraphicsItem *options)
|
||||||
{
|
{
|
||||||
Q_UNUSED(options);
|
Q_UNUSED(options)
|
||||||
painter -> setPen(Qt::blue);
|
painter -> setPen(Qt::blue);
|
||||||
painter -> drawLine(0, 0, 10, 0);
|
painter -> drawLine(0, 0, 10, 0);
|
||||||
painter -> drawLine(7,-3, 10, 0);
|
painter -> drawLine(7,-3, 10, 0);
|
||||||
@@ -348,7 +348,7 @@ void Element::drawSelection(
|
|||||||
QPainter *painter,
|
QPainter *painter,
|
||||||
const QStyleOptionGraphicsItem *options)
|
const QStyleOptionGraphicsItem *options)
|
||||||
{
|
{
|
||||||
Q_UNUSED(options);
|
Q_UNUSED(options)
|
||||||
painter -> save();
|
painter -> save();
|
||||||
// Annulation des renderhints
|
// Annulation des renderhints
|
||||||
painter -> setRenderHint(QPainter::Antialiasing, false);
|
painter -> setRenderHint(QPainter::Antialiasing, false);
|
||||||
@@ -376,7 +376,7 @@ void Element::drawHighlight(
|
|||||||
QPainter *painter,
|
QPainter *painter,
|
||||||
const QStyleOptionGraphicsItem *options)
|
const QStyleOptionGraphicsItem *options)
|
||||||
{
|
{
|
||||||
Q_UNUSED(options);
|
Q_UNUSED(options)
|
||||||
painter -> save();
|
painter -> save();
|
||||||
|
|
||||||
qreal gradient_radius = qMin(boundingRect().width(),
|
qreal gradient_radius = qMin(boundingRect().width(),
|
||||||
@@ -417,8 +417,8 @@ bool Element::buildFromXml(const QDomElement &xml_def_elmt, int *state)
|
|||||||
{
|
{
|
||||||
m_state = QET::GIBuildingFromXml;
|
m_state = QET::GIBuildingFromXml;
|
||||||
|
|
||||||
if (xml_def_elmt.tagName() != "definition"
|
if (xml_def_elmt.tagName() != QLatin1String("definition")
|
||||||
|| xml_def_elmt.attribute("type") != "element")
|
|| xml_def_elmt.attribute(QStringLiteral("type")) != QLatin1String("element"))
|
||||||
{
|
{
|
||||||
if (state) *state = 4;
|
if (state) *state = 4;
|
||||||
m_state = QET::GIOK;
|
m_state = QET::GIOK;
|
||||||
@@ -426,11 +426,11 @@ bool Element::buildFromXml(const QDomElement &xml_def_elmt, int *state)
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Check if the curent version can read the xml description
|
//Check if the curent version can read the xml description
|
||||||
if (xml_def_elmt.hasAttribute("version"))
|
if (xml_def_elmt.hasAttribute(QStringLiteral("version")))
|
||||||
{
|
{
|
||||||
bool conv_ok;
|
bool conv_ok;
|
||||||
qreal element_version = xml_def_elmt.attribute(
|
qreal element_version = xml_def_elmt.attribute(
|
||||||
"version").toDouble(&conv_ok);
|
QStringLiteral("version")).toDouble(&conv_ok);
|
||||||
if (conv_ok && QET::version.toDouble() < element_version)
|
if (conv_ok && QET::version.toDouble() < element_version)
|
||||||
{
|
{
|
||||||
std::cerr << qPrintable(
|
std::cerr << qPrintable(
|
||||||
@@ -442,13 +442,12 @@ bool Element::buildFromXml(const QDomElement &xml_def_elmt, int *state)
|
|||||||
}
|
}
|
||||||
|
|
||||||
//This attribute must be present and valid
|
//This attribute must be present and valid
|
||||||
int w, h, hot_x, hot_y;
|
int w = 0, h = 0, hot_x = 0, hot_y = 0;
|
||||||
if (
|
if (!QET::attributeIsAnInteger(xml_def_elmt, QStringLiteral("width"), &w) ||
|
||||||
!QET::attributeIsAnInteger(xml_def_elmt, QString("width"), &w) ||\
|
!QET::attributeIsAnInteger(xml_def_elmt, QStringLiteral("height"), &h) ||
|
||||||
!QET::attributeIsAnInteger(xml_def_elmt, QString("height"), &h) ||\
|
!QET::attributeIsAnInteger(xml_def_elmt, QStringLiteral("hotspot_x"), &hot_x) ||
|
||||||
!QET::attributeIsAnInteger(xml_def_elmt, QString("hotspot_x"), &hot_x) ||\
|
!QET::attributeIsAnInteger(xml_def_elmt, QStringLiteral("hotspot_y"), &hot_y))
|
||||||
!QET::attributeIsAnInteger(xml_def_elmt, QString("hotspot_y"), &hot_y)
|
{
|
||||||
) {
|
|
||||||
if (state) *state = 5;
|
if (state) *state = 5;
|
||||||
m_state = QET::GIOK;
|
m_state = QET::GIOK;
|
||||||
return(false);
|
return(false);
|
||||||
@@ -470,12 +469,12 @@ bool Element::buildFromXml(const QDomElement &xml_def_elmt, int *state)
|
|||||||
|
|
||||||
//load kind informations
|
//load kind informations
|
||||||
m_kind_informations.fromXml(
|
m_kind_informations.fromXml(
|
||||||
xml_def_elmt.firstChildElement("kindInformations"),
|
xml_def_elmt.firstChildElement(QStringLiteral("kindInformations")),
|
||||||
"kindInformation");
|
QStringLiteral("kindInformation"));
|
||||||
//load element information
|
//load element information
|
||||||
m_data.m_informations.fromXml(
|
m_data.m_informations.fromXml(
|
||||||
xml_def_elmt.firstChildElement("elementInformations"),
|
xml_def_elmt.firstChildElement(QStringLiteral("elementInformations")),
|
||||||
"elementInformation");
|
QStringLiteral("elementInformation"));
|
||||||
|
|
||||||
//scroll of the Children of the Definition: Parts of the Drawing
|
//scroll of the Children of the Definition: Parts of the Drawing
|
||||||
int parsed_elements_count = 0;
|
int parsed_elements_count = 0;
|
||||||
@@ -487,27 +486,26 @@ bool Element::buildFromXml(const QDomElement &xml_def_elmt, int *state)
|
|||||||
if (elmts.isNull())
|
if (elmts.isNull())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (elmts.tagName() == "description")
|
if (elmts.tagName() == QLatin1String("description"))
|
||||||
{
|
{
|
||||||
//Minor workaround to find if there is a "input" tagg as label.
|
//Minor workaround to find if there is a "input" tagg as label.
|
||||||
//If not, we set the tagg "label" to the first "input.
|
//If not, we set the tagg "label" to the first "input.
|
||||||
QList <QDomElement> input_field;
|
QList <QDomElement> input_field;
|
||||||
bool have_label = false;
|
bool have_label = false;
|
||||||
for (QDomElement input_node = node.firstChildElement("input") ;
|
for (QDomElement input_node = node.firstChildElement(QStringLiteral("input")) ;
|
||||||
!input_node.isNull() ;
|
!input_node.isNull() ;
|
||||||
input_node = input_node.nextSiblingElement("input"))
|
input_node = input_node.nextSiblingElement(QStringLiteral("input")))
|
||||||
{
|
{
|
||||||
if (!input_node.isNull())
|
if (!input_node.isNull())
|
||||||
{
|
{
|
||||||
input_field << input_node;
|
input_field << input_node;
|
||||||
if (input_node.attribute("tagg", "none")
|
if (input_node.attribute(QStringLiteral("tagg"), QStringLiteral("none"))
|
||||||
== "label")
|
== QLatin1String("label"))
|
||||||
have_label = true;
|
have_label = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(!have_label && !input_field.isEmpty())
|
if(!have_label && !input_field.isEmpty())
|
||||||
input_field.first().setAttribute("tagg",
|
input_field.first().setAttribute(QStringLiteral("tagg"), QStringLiteral("label"));
|
||||||
"label");
|
|
||||||
|
|
||||||
//Parse the definition
|
//Parse the definition
|
||||||
for (QDomNode n = node.firstChild() ;
|
for (QDomNode n = node.firstChild() ;
|
||||||
@@ -565,9 +563,9 @@ bool Element::buildFromXml(const QDomElement &xml_def_elmt, int *state)
|
|||||||
*/
|
*/
|
||||||
bool Element::parseElement(const QDomElement &dom)
|
bool Element::parseElement(const QDomElement &dom)
|
||||||
{
|
{
|
||||||
if (dom.tagName() == "terminal") return(parseTerminal(dom));
|
if (dom.tagName() == QLatin1String("terminal")) return(parseTerminal(dom));
|
||||||
else if (dom.tagName() == "input") return(parseInput(dom));
|
else if (dom.tagName() == QLatin1String("input")) return(parseInput(dom));
|
||||||
else if (dom.tagName() == "dynamic_text") return(parseDynamicText(dom));
|
else if (dom.tagName() == QLatin1String("dynamic_text")) return(parseDynamicText(dom));
|
||||||
else return(true);
|
else return(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -583,26 +581,24 @@ bool Element::parseInput(const QDomElement &dom_element)
|
|||||||
{
|
{
|
||||||
qreal pos_x, pos_y;
|
qreal pos_x, pos_y;
|
||||||
int size;
|
int size;
|
||||||
if (
|
if (!QET::attributeIsAReal(dom_element, QStringLiteral("x"), &pos_x) ||
|
||||||
!QET::attributeIsAReal(dom_element, "x", &pos_x) ||\
|
!QET::attributeIsAReal(dom_element, QStringLiteral("y"), &pos_y) ||
|
||||||
!QET::attributeIsAReal(dom_element, "y", &pos_y) ||\
|
!QET::attributeIsAnInteger(dom_element, QStringLiteral("size"), &size)) {
|
||||||
!QET::attributeIsAnInteger(dom_element, "size", &size)
|
return(false);
|
||||||
) return(false);
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
DynamicElementTextItem *deti = new DynamicElementTextItem(this);
|
DynamicElementTextItem *deti = new DynamicElementTextItem(this);
|
||||||
deti->setText(dom_element.attribute("text", "_"));
|
deti->setText(dom_element.attribute(QStringLiteral("text"), QStringLiteral("_")));
|
||||||
QFont font = deti->font();
|
QFont font = deti->font();
|
||||||
font.setPointSize(dom_element.attribute("size",
|
font.setPointSize(dom_element.attribute(QStringLiteral("size"),
|
||||||
QString::number(9)).toInt());
|
QString::number(9)).toInt());
|
||||||
deti->setFont(font);
|
deti->setFont(font);
|
||||||
deti->setRotation(dom_element.attribute("rotation",
|
deti->setRotation(dom_element.attribute(QStringLiteral("rotation"),
|
||||||
QString::number(0)).toDouble());
|
QString::number(0)).toDouble());
|
||||||
|
|
||||||
if(dom_element.attribute("tagg", "none") != "none")
|
if(dom_element.attribute(QStringLiteral("tagg"), QStringLiteral("none")) != QLatin1String("none"))
|
||||||
{
|
{
|
||||||
deti->setTextFrom(DynamicElementTextItem::ElementInfo);
|
deti->setTextFrom(DynamicElementTextItem::ElementInfo);
|
||||||
deti->setInfoName(dom_element.attribute("tagg"));
|
deti->setInfoName(dom_element.attribute(QStringLiteral("tagg")));
|
||||||
}
|
}
|
||||||
|
|
||||||
//the origin transformation point of PartDynamicTextField is the top left corner, no matter the font size
|
//the origin transformation point of PartDynamicTextField is the top left corner, no matter the font size
|
||||||
@@ -610,17 +606,17 @@ bool Element::parseInput(const QDomElement &dom_element)
|
|||||||
//We need to use a QTransform to find the pos of this text from the saved pos of text item
|
//We need to use a QTransform to find the pos of this text from the saved pos of text item
|
||||||
QTransform transform;
|
QTransform transform;
|
||||||
//First make the rotation
|
//First make the rotation
|
||||||
transform.rotate(dom_element.attribute("rotation",
|
transform.rotate(dom_element.attribute(QStringLiteral("rotation"),
|
||||||
"0").toDouble());
|
QStringLiteral("0")).toDouble());
|
||||||
QPointF pos = transform.map(
|
QPointF pos = transform.map(
|
||||||
QPointF(0,
|
QPointF(0,
|
||||||
-deti->boundingRect().height()/2));
|
-deti->boundingRect().height()/2));
|
||||||
transform.reset();
|
transform.reset();
|
||||||
//Second translate to the pos
|
//Second translate to the pos
|
||||||
QPointF p(dom_element.attribute("x",
|
QPointF p(dom_element.attribute(QStringLiteral("x"),
|
||||||
QString::number(0)).toDouble(),
|
QString::number(0)).toDouble(),
|
||||||
dom_element.attribute("y",
|
dom_element.attribute(QStringLiteral("y"),
|
||||||
QString::number(0)).toDouble());
|
QString::number(0)).toDouble());
|
||||||
transform.translate(p.x(), p.y());
|
transform.translate(p.x(), p.y());
|
||||||
deti->setPos(transform.map(pos));
|
deti->setPos(transform.map(pos));
|
||||||
m_dynamic_text_list.append(deti);
|
m_dynamic_text_list.append(deti);
|
||||||
@@ -687,23 +683,22 @@ Terminal *Element::parseTerminal(const QDomElement &dom_element)
|
|||||||
@param e Le QDomElement a valide
|
@param e Le QDomElement a valide
|
||||||
@return true si l'element XML est un Element, false sinon
|
@return true si l'element XML est un Element, false sinon
|
||||||
*/
|
*/
|
||||||
bool Element::valideXml(QDomElement &e) {
|
bool Element::valideXml(QDomElement &e)
|
||||||
// verifie le nom du tag
|
{
|
||||||
if (e.tagName() != "element") return(false);
|
if (e.tagName() != QLatin1String("element") ||
|
||||||
|
!e.hasAttribute(QStringLiteral("type")) ||
|
||||||
// verifie la presence des attributs minimaux
|
!e.hasAttribute(QStringLiteral("x")) ||
|
||||||
if (!e.hasAttribute("type")) return(false);
|
!e.hasAttribute(QStringLiteral("y"))) {
|
||||||
if (!e.hasAttribute("x")) return(false);
|
return(false);
|
||||||
if (!e.hasAttribute("y")) return(false);
|
}
|
||||||
|
|
||||||
bool conv_ok;
|
bool conv_ok;
|
||||||
// parse l'abscisse
|
e.attribute(QStringLiteral("x")).toDouble(&conv_ok);
|
||||||
e.attribute("x").toDouble(&conv_ok);
|
|
||||||
if (!conv_ok) return(false);
|
if (!conv_ok) return(false);
|
||||||
|
|
||||||
// parse l'ordonnee
|
e.attribute(QStringLiteral("y")).toDouble(&conv_ok);
|
||||||
e.attribute("y").toDouble(&conv_ok);
|
|
||||||
if (!conv_ok) return(false);
|
if (!conv_ok) return(false);
|
||||||
|
|
||||||
return(true);
|
return(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -719,10 +714,8 @@ bool Element::valideXml(QDomElement &e) {
|
|||||||
and the addresses in memory. If the import succeeds, it must be add the right couples (id, address).
|
and the addresses in memory. If the import succeeds, it must be add the right couples (id, address).
|
||||||
@return
|
@return
|
||||||
*/
|
*/
|
||||||
bool Element::fromXml(
|
bool Element::fromXml(QDomElement &e,
|
||||||
QDomElement &e,
|
QHash<int,Terminal *> &table_id_adr)
|
||||||
QHash<int,
|
|
||||||
Terminal *> &table_id_adr)
|
|
||||||
{
|
{
|
||||||
m_state = QET::GILoadingFromXml;
|
m_state = QET::GILoadingFromXml;
|
||||||
/*
|
/*
|
||||||
@@ -730,22 +723,25 @@ bool Element::fromXml(
|
|||||||
ce recensement servira lors de la mise en place des fils
|
ce recensement servira lors de la mise en place des fils
|
||||||
*/
|
*/
|
||||||
QList<QDomElement> liste_terminals;
|
QList<QDomElement> liste_terminals;
|
||||||
foreach(QDomElement qde,
|
for (auto qde :
|
||||||
QET::findInDomElement(e, "terminals", "terminal")) {
|
QET::findInDomElement(e, QStringLiteral("terminals"), QStringLiteral("terminal"))) {
|
||||||
if (Terminal::valideXml(qde)) liste_terminals << qde;
|
if (Terminal::valideXml(qde)) liste_terminals << qde;
|
||||||
}
|
}
|
||||||
|
|
||||||
QHash<int, Terminal *> priv_id_adr;
|
QHash<int, Terminal *> priv_id_adr;
|
||||||
int terminals_non_trouvees = 0;
|
int terminals_non_trouvees = 0;
|
||||||
foreach(QGraphicsItem *qgi, childItems()) {
|
|
||||||
if (Terminal *p = qgraphicsitem_cast<Terminal *>(qgi)) {
|
for (auto *qgi : childItems())
|
||||||
|
{
|
||||||
|
if (Terminal *p = qgraphicsitem_cast<Terminal *>(qgi))
|
||||||
|
{
|
||||||
bool terminal_trouvee = false;
|
bool terminal_trouvee = false;
|
||||||
foreach(QDomElement qde, liste_terminals) {
|
for(auto qde : liste_terminals)
|
||||||
if (p -> fromXml(qde)) {
|
{
|
||||||
priv_id_adr.insert(
|
if (p -> fromXml(qde))
|
||||||
qde.attribute(
|
{
|
||||||
"id").toInt(),
|
priv_id_adr.insert(qde.attribute(QStringLiteral("id")).toInt(),
|
||||||
p);
|
p);
|
||||||
terminal_trouvee = true;
|
terminal_trouvee = true;
|
||||||
// We used to break here, because we did not expect
|
// We used to break here, because we did not expect
|
||||||
// several terminals to share the same position.
|
// several terminals to share the same position.
|
||||||
@@ -782,11 +778,11 @@ bool Element::fromXml(
|
|||||||
|
|
||||||
//load uuid of connected elements
|
//load uuid of connected elements
|
||||||
QList <QDomElement> uuid_list = QET::findInDomElement(e,
|
QList <QDomElement> uuid_list = QET::findInDomElement(e,
|
||||||
"links_uuids",
|
QStringLiteral("links_uuids"),
|
||||||
"link_uuid");
|
QStringLiteral("link_uuid"));
|
||||||
foreach (QDomElement qdo, uuid_list)
|
foreach (QDomElement qdo, uuid_list)
|
||||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) // ### Qt 6: remove
|
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) // ### Qt 6: remove
|
||||||
tmp_uuids_link << qdo.attribute("uuid");
|
tmp_uuids_link << qdo.attribute(QStringLiteral("uuid"));
|
||||||
#else
|
#else
|
||||||
#if TODO_LIST
|
#if TODO_LIST
|
||||||
#pragma message("@TODO remove code for QT 6 or later")
|
#pragma message("@TODO remove code for QT 6 or later")
|
||||||
@@ -794,36 +790,36 @@ bool Element::fromXml(
|
|||||||
qDebug()<<"Help code for QT 6 or later";
|
qDebug()<<"Help code for QT 6 or later";
|
||||||
#endif
|
#endif
|
||||||
//uuid of this element
|
//uuid of this element
|
||||||
m_uuid= QUuid(e.attribute("uuid", QUuid::createUuid().toString()));
|
m_uuid = QUuid(e.attribute(QStringLiteral("uuid"), QUuid::createUuid().toString()));
|
||||||
|
|
||||||
//load prefix
|
//load prefix
|
||||||
m_prefix = e.attribute("prefix");
|
m_prefix = e.attribute(QStringLiteral("prefix"));
|
||||||
|
|
||||||
QString fl = e.attribute("freezeLabel", "false");
|
QString fl = e.attribute(QStringLiteral("freezeLabel"), QStringLiteral("false"));
|
||||||
m_freeze_label = fl == "false"? false : true;
|
m_freeze_label = fl == QLatin1String("false") ? false : true;
|
||||||
|
|
||||||
//Load Sequential Values
|
//Load Sequential Values
|
||||||
if (e.hasAttribute("sequ_1")
|
if (e.hasAttribute(QStringLiteral("sequ_1"))
|
||||||
|| e.hasAttribute("sequf_1")
|
|| e.hasAttribute(QStringLiteral("sequf_1"))
|
||||||
|| e.hasAttribute("seqt_1")
|
|| e.hasAttribute(QStringLiteral("seqt_1"))
|
||||||
|| e.hasAttribute("seqtf_1")
|
|| e.hasAttribute(QStringLiteral("seqtf_1"))
|
||||||
|| e.hasAttribute("seqh_1")
|
|| e.hasAttribute(QStringLiteral("seqh_1"))
|
||||||
|| e.hasAttribute("sequf_1"))
|
|| e.hasAttribute(QStringLiteral("sequf_1")))
|
||||||
ElementXmlRetroCompatibility::loadSequential(e, this);
|
ElementXmlRetroCompatibility::loadSequential(e, this);
|
||||||
else
|
else
|
||||||
m_autoNum_seq.fromXml(e.firstChildElement("sequentialNumbers"));
|
m_autoNum_seq.fromXml(e.firstChildElement(QStringLiteral("sequentialNumbers")));
|
||||||
|
|
||||||
//Position and selection.
|
//Position and selection.
|
||||||
//We directly call setPos from QGraphicsObject, because QetGraphicsItem will snap to grid
|
//We directly call setPos from QGraphicsObject, because QetGraphicsItem will snap to grid
|
||||||
QGraphicsObject::setPos(e.attribute("x").toDouble(),
|
QGraphicsObject::setPos(e.attribute(QStringLiteral("x")).toDouble(),
|
||||||
e.attribute("y").toDouble());
|
e.attribute(QStringLiteral("y")).toDouble());
|
||||||
setZValue(e.attribute("z", QString::number(this->zValue())).toDouble());
|
setZValue(e.attribute(QStringLiteral("z"), QString::number(this->zValue())).toDouble());
|
||||||
setFlags(QGraphicsItem::ItemIsMovable
|
setFlags(QGraphicsItem::ItemIsMovable
|
||||||
| QGraphicsItem::ItemIsSelectable);
|
| QGraphicsItem::ItemIsSelectable);
|
||||||
|
|
||||||
// orientation
|
// orientation
|
||||||
bool conv_ok;
|
bool conv_ok;
|
||||||
int read_ori = e.attribute("orientation").toInt(&conv_ok);
|
int read_ori = e.attribute(QStringLiteral("orientation")).toInt(&conv_ok);
|
||||||
if (!conv_ok || read_ori < 0 || read_ori > 3) {
|
if (!conv_ok || read_ori < 0 || read_ori > 3) {
|
||||||
read_ori = 0;
|
read_ori = 0;
|
||||||
}
|
}
|
||||||
@@ -840,7 +836,7 @@ bool Element::fromXml(
|
|||||||
//************************//
|
//************************//
|
||||||
for (const QDomElement& qde : QET::findInDomElement(
|
for (const QDomElement& qde : QET::findInDomElement(
|
||||||
e,
|
e,
|
||||||
"dynamic_texts",
|
QStringLiteral("dynamic_texts"),
|
||||||
DynamicElementTextItem::xmlTagName()))
|
DynamicElementTextItem::xmlTagName()))
|
||||||
{
|
{
|
||||||
DynamicElementTextItem *deti = new DynamicElementTextItem(this);
|
DynamicElementTextItem *deti = new DynamicElementTextItem(this);
|
||||||
@@ -850,18 +846,18 @@ bool Element::fromXml(
|
|||||||
|
|
||||||
for (QDomElement qde : QET::findInDomElement(
|
for (QDomElement qde : QET::findInDomElement(
|
||||||
e,
|
e,
|
||||||
"texts_groups",
|
QStringLiteral("texts_groups"),
|
||||||
ElementTextItemGroup::xmlTaggName()))
|
ElementTextItemGroup::xmlTaggName()))
|
||||||
{
|
{
|
||||||
ElementTextItemGroup *group =
|
ElementTextItemGroup *group =
|
||||||
addTextGroup("loaded_from_xml_group");
|
addTextGroup(QStringLiteral("loaded_from_xml_group"));
|
||||||
group->fromXml(qde);
|
group->fromXml(qde);
|
||||||
}
|
}
|
||||||
|
|
||||||
//load informations
|
//load informations
|
||||||
DiagramContext dc;
|
DiagramContext dc;
|
||||||
dc.fromXml(e.firstChildElement("elementInformations"),
|
dc.fromXml(e.firstChildElement(QStringLiteral("elementInformations")),
|
||||||
"elementInformation");
|
QStringLiteral("elementInformation"));
|
||||||
|
|
||||||
//We must to block the update of the alignment when load the information
|
//We must to block the update of the alignment when load the information
|
||||||
//otherwise the pos of the text will not be the same as it was at save time.
|
//otherwise the pos of the text will not be the same as it was at save time.
|
||||||
@@ -896,19 +892,19 @@ QDomElement Element::toXml(
|
|||||||
QHash<Terminal *,
|
QHash<Terminal *,
|
||||||
int> &table_adr_id) const
|
int> &table_adr_id) const
|
||||||
{
|
{
|
||||||
QDomElement element = document.createElement("element");
|
QDomElement element = document.createElement(QStringLiteral("element"));
|
||||||
|
|
||||||
// type
|
// type
|
||||||
element.setAttribute("type", m_location.path());
|
element.setAttribute(QStringLiteral("type"), m_location.path());
|
||||||
|
|
||||||
// uuid
|
// uuid
|
||||||
element.setAttribute("uuid", uuid().toString());
|
element.setAttribute(QStringLiteral("uuid"), uuid().toString());
|
||||||
|
|
||||||
// prefix
|
// prefix
|
||||||
element.setAttribute("prefix", m_prefix);
|
element.setAttribute(QStringLiteral("prefix"), m_prefix);
|
||||||
|
|
||||||
//frozen label
|
//frozen label
|
||||||
element.setAttribute("freezeLabel", m_freeze_label? "true" : "false");
|
element.setAttribute(QStringLiteral("freezeLabel"), m_freeze_label? QStringLiteral("true") : QStringLiteral("false"));
|
||||||
|
|
||||||
// sequential num
|
// sequential num
|
||||||
QDomElement seq = m_autoNum_seq.toXml(document);
|
QDomElement seq = m_autoNum_seq.toXml(document);
|
||||||
@@ -916,10 +912,10 @@ QDomElement Element::toXml(
|
|||||||
element.appendChild(seq);
|
element.appendChild(seq);
|
||||||
|
|
||||||
// position, selection et orientation
|
// position, selection et orientation
|
||||||
element.setAttribute("x", QString::number(pos().x()));
|
element.setAttribute(QStringLiteral("x"), QString::number(pos().x()));
|
||||||
element.setAttribute("y", QString::number(pos().y()));
|
element.setAttribute(QStringLiteral("y"), QString::number(pos().y()));
|
||||||
element.setAttribute("z", QString::number(this->zValue()));
|
element.setAttribute(QStringLiteral("z"), QString::number(this->zValue()));
|
||||||
element.setAttribute("orientation", QString::number(orientation()));
|
element.setAttribute(QStringLiteral("orientation"), QString::number(orientation()));
|
||||||
|
|
||||||
/* get the first id to use for the bounds of this element
|
/* get the first id to use for the bounds of this element
|
||||||
* recupere le premier id a utiliser pour les bornes de cet element */
|
* recupere le premier id a utiliser pour les bornes de cet element */
|
||||||
@@ -935,30 +931,30 @@ QDomElement Element::toXml(
|
|||||||
|
|
||||||
// registration of device terminals
|
// registration of device terminals
|
||||||
// enregistrement des bornes de l'appareil
|
// enregistrement des bornes de l'appareil
|
||||||
QDomElement xml_terminals = document.createElement("terminals");
|
QDomElement xml_terminals = document.createElement(QStringLiteral("terminals"));
|
||||||
// for each child of the element
|
// for each child of the element
|
||||||
// pour chaque enfant de l'element
|
// pour chaque enfant de l'element
|
||||||
foreach(Terminal *t, terminals()) {
|
foreach(Terminal *t, terminals()) {
|
||||||
// alors on enregistre la borne
|
// alors on enregistre la borne
|
||||||
QDomElement terminal = t -> toXml(document);
|
QDomElement terminal = t -> toXml(document);
|
||||||
terminal.setAttribute("id", id_terminal); // for backward compatibility
|
terminal.setAttribute(QStringLiteral("id"), id_terminal); // for backward compatibility
|
||||||
table_adr_id.insert(t, id_terminal ++);
|
table_adr_id.insert(t, id_terminal ++);
|
||||||
xml_terminals.appendChild(terminal);
|
xml_terminals.appendChild(terminal);
|
||||||
}
|
}
|
||||||
element.appendChild(xml_terminals);
|
element.appendChild(xml_terminals);
|
||||||
|
|
||||||
// enregistrement des champ de texte de l'appareil
|
// enregistrement des champ de texte de l'appareil
|
||||||
QDomElement inputs = document.createElement("inputs");
|
QDomElement inputs = document.createElement(QStringLiteral("inputs"));
|
||||||
element.appendChild(inputs);
|
element.appendChild(inputs);
|
||||||
|
|
||||||
//if this element is linked to other elements,
|
//if this element is linked to other elements,
|
||||||
//save the uuid of each other elements
|
//save the uuid of each other elements
|
||||||
if (! isFree()) {
|
if (! isFree()) {
|
||||||
QDomElement links_uuids = document.createElement("links_uuids");
|
QDomElement links_uuids = document.createElement(QStringLiteral("links_uuids"));
|
||||||
foreach (Element *elmt, connected_elements) {
|
foreach (Element *elmt, connected_elements) {
|
||||||
QDomElement link_uuid =
|
QDomElement link_uuid =
|
||||||
document.createElement("link_uuid");
|
document.createElement(QStringLiteral("link_uuid"));
|
||||||
link_uuid.setAttribute("uuid", elmt->uuid().toString());
|
link_uuid.setAttribute(QStringLiteral("uuid"), elmt->uuid().toString());
|
||||||
links_uuids.appendChild(link_uuid);
|
links_uuids.appendChild(link_uuid);
|
||||||
}
|
}
|
||||||
element.appendChild(links_uuids);
|
element.appendChild(links_uuids);
|
||||||
@@ -967,17 +963,17 @@ QDomElement Element::toXml(
|
|||||||
//save information of this element
|
//save information of this element
|
||||||
if (! m_data.m_informations.keys().isEmpty()) {
|
if (! m_data.m_informations.keys().isEmpty()) {
|
||||||
QDomElement infos =
|
QDomElement infos =
|
||||||
document.createElement("elementInformations");
|
document.createElement(QStringLiteral("elementInformations"));
|
||||||
m_data.m_informations.toXml(infos, "elementInformation");
|
m_data.m_informations.toXml(infos, QStringLiteral("elementInformation"));
|
||||||
element.appendChild(infos);
|
element.appendChild(infos);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Dynamic texts
|
//Dynamic texts
|
||||||
QDomElement dyn_text = document.createElement("dynamic_texts");
|
QDomElement dyn_text = document.createElement(QStringLiteral("dynamic_texts"));
|
||||||
for (DynamicElementTextItem *deti : m_dynamic_text_list)
|
for (DynamicElementTextItem *deti : m_dynamic_text_list)
|
||||||
dyn_text.appendChild(deti->toXml(document));
|
dyn_text.appendChild(deti->toXml(document));
|
||||||
|
|
||||||
QDomElement texts_group = document.createElement("texts_groups");
|
QDomElement texts_group = document.createElement(QStringLiteral("texts_groups"));
|
||||||
|
|
||||||
//Dynamic texts owned by groups
|
//Dynamic texts owned by groups
|
||||||
for(ElementTextItemGroup *group : m_texts_group)
|
for(ElementTextItemGroup *group : m_texts_group)
|
||||||
@@ -1288,19 +1284,19 @@ QString Element::linkTypeToString() const
|
|||||||
switch (m_link_type)
|
switch (m_link_type)
|
||||||
{
|
{
|
||||||
case Simple:
|
case Simple:
|
||||||
return "Simple";
|
return QStringLiteral("Simple");
|
||||||
case NextReport :
|
case NextReport :
|
||||||
return "NextReport";
|
return QStringLiteral("NextReport");
|
||||||
case PreviousReport:
|
case PreviousReport:
|
||||||
return "PreviousReport";
|
return QStringLiteral("PreviousReport");
|
||||||
case Master:
|
case Master:
|
||||||
return "Master";
|
return QStringLiteral("Master");
|
||||||
case Slave:
|
case Slave:
|
||||||
return "Slave";
|
return QStringLiteral("Slave");
|
||||||
case Terminale:
|
case Terminale:
|
||||||
return "Terminale";
|
return QStringLiteral("Terminale");
|
||||||
default:
|
default:
|
||||||
return "Unknown";
|
return QStringLiteral("Unknown");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1318,7 +1314,7 @@ void Element::setElementInformations(DiagramContext dc)
|
|||||||
|
|
||||||
DiagramContext old_info = m_data.m_informations;
|
DiagramContext old_info = m_data.m_informations;
|
||||||
m_data.m_informations = dc;
|
m_data.m_informations = dc;
|
||||||
m_data.m_informations.addValue("label", actualLabel()); //Update the label if there is a formula
|
m_data.m_informations.addValue(QStringLiteral("label"), actualLabel()); //Update the label if there is a formula
|
||||||
emit elementInfoChange(old_info, m_data.m_informations);
|
emit elementInfoChange(old_info, m_data.m_informations);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1442,7 +1438,7 @@ void Element::setUpFormula(bool code_letter)
|
|||||||
->project()
|
->project()
|
||||||
->elementAutoNumCurrentFormula();
|
->elementAutoNumCurrentFormula();
|
||||||
|
|
||||||
m_data.m_informations.addValue("formula", formula);
|
m_data.m_informations.addValue(QStringLiteral("formula"), formula);
|
||||||
|
|
||||||
QString element_currentAutoNum = diagram()
|
QString element_currentAutoNum = diagram()
|
||||||
->project()
|
->project()
|
||||||
@@ -1464,7 +1460,7 @@ void Element::setUpFormula(bool code_letter)
|
|||||||
if(!m_freeze_label && !formula.isEmpty())
|
if(!m_freeze_label && !formula.isEmpty())
|
||||||
{
|
{
|
||||||
DiagramContext dc = m_data.m_informations;
|
DiagramContext dc = m_data.m_informations;
|
||||||
m_data.m_informations.addValue("label", actualLabel());
|
m_data.m_informations.addValue(QStringLiteral("label"), actualLabel());
|
||||||
emit elementInfoChange(dc, m_data.m_informations);
|
emit elementInfoChange(dc, m_data.m_informations);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1518,12 +1514,12 @@ void Element::freezeNewAddedElement()
|
|||||||
*/
|
*/
|
||||||
QString Element::actualLabel()
|
QString Element::actualLabel()
|
||||||
{
|
{
|
||||||
if (m_data.m_informations.value("formula").toString().isEmpty()) {
|
if (m_data.m_informations.value(QStringLiteral("formula")).toString().isEmpty()) {
|
||||||
return m_data.m_informations.value("label").toString();
|
return m_data.m_informations.value(QStringLiteral("label")).toString();
|
||||||
} else {
|
} else {
|
||||||
return autonum::AssignVariables::formulaToLabel(
|
return autonum::AssignVariables::formulaToLabel(
|
||||||
m_data.m_informations.value(
|
m_data.m_informations.value(
|
||||||
"formula").toString(),
|
QStringLiteral("formula")).toString(),
|
||||||
m_autoNum_seq,
|
m_autoNum_seq,
|
||||||
diagram(),
|
diagram(),
|
||||||
this);
|
this);
|
||||||
|
|||||||
Reference in New Issue
Block a user