mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-19 14:50:53 +01:00
Use QStringLiteral and QLatin1String.
According to the Qt documentation (https://doc.qt.io/qt-5/qstring.html#QStringLiteral) (https://woboq.com/blog/qstringliteral.html), use QStringLiteral and QLatin1String is better on some conditions (faster). This commit change the code related to the loading of a project (in qetproject class), let see if loading time is improved.
This commit is contained in:
@@ -159,7 +159,7 @@ void QETProject::init()
|
||||
writeBackup();
|
||||
|
||||
QSettings settings;
|
||||
int autosave_interval = settings.value("diagrameditor/autosave-interval", 0).toInt();
|
||||
int autosave_interval = settings.value(QStringLiteral("diagrameditor/autosave-interval"), 0).toInt();
|
||||
if(autosave_interval > 0)
|
||||
{
|
||||
int ms = autosave_interval*60*1000;
|
||||
@@ -1280,13 +1280,13 @@ void QETProject::readProjectXml(QDomDocument &xml_project)
|
||||
m_state = ProjectParsingRunning;
|
||||
|
||||
//The roots of the xml document must be a "project" element
|
||||
if (root_elmt.tagName() == "project")
|
||||
if (root_elmt.tagName() == QLatin1String("project"))
|
||||
{
|
||||
//Normal opening mode
|
||||
if (root_elmt.hasAttribute("version"))
|
||||
if (root_elmt.hasAttribute(QStringLiteral("version")))
|
||||
{
|
||||
bool conv_ok;
|
||||
m_project_qet_version = root_elmt.attribute("version").toDouble(&conv_ok);
|
||||
m_project_qet_version = root_elmt.attribute(QStringLiteral("version")).toDouble(&conv_ok);
|
||||
#if TODO_LIST
|
||||
#pragma message("@TODO use of version convert")
|
||||
#endif
|
||||
@@ -1333,7 +1333,7 @@ void QETProject::readProjectXml(QDomDocument &xml_project)
|
||||
}
|
||||
}
|
||||
}
|
||||
setTitle(root_elmt.attribute("title"));
|
||||
setTitle(root_elmt.attribute(QStringLiteral("title")));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1383,7 +1383,7 @@ void QETProject::readDiagramsXml(QDomDocument &xml_project)
|
||||
}
|
||||
|
||||
//Search the diagrams in the project
|
||||
QDomNodeList diagram_nodes = xml_project.elementsByTagName("diagram");
|
||||
QDomNodeList diagram_nodes = xml_project.elementsByTagName(QStringLiteral("diagram"));
|
||||
|
||||
if(dlgWaiting)
|
||||
dlgWaiting->setProgressBarRange(0, diagram_nodes.length()*3);
|
||||
@@ -1402,7 +1402,7 @@ void QETProject::readDiagramsXml(QDomDocument &xml_project)
|
||||
|
||||
int diagram_order = -1;
|
||||
if (!QET::attributeIsAnInteger(diagram_xml_element,
|
||||
"order",
|
||||
QStringLiteral("order"),
|
||||
&diagram_order))
|
||||
diagram_order = 500000;
|
||||
|
||||
@@ -1445,7 +1445,7 @@ void QETProject::readDiagramsXml(QDomDocument &xml_project)
|
||||
void QETProject::readElementsCollectionXml(QDomDocument &xml_project)
|
||||
{
|
||||
//Get the embedded elements collection of the project
|
||||
QDomNodeList collection_roots = xml_project.elementsByTagName("collection");
|
||||
QDomNodeList collection_roots = xml_project.elementsByTagName(QStringLiteral("collection"));
|
||||
QDomElement collection_root;
|
||||
|
||||
if (!collection_roots.isEmpty())
|
||||
@@ -1470,8 +1470,8 @@ void QETProject::readElementsCollectionXml(QDomDocument &xml_project)
|
||||
*/
|
||||
void QETProject::readProjectPropertiesXml(QDomDocument &xml_project)
|
||||
{
|
||||
foreach (QDomElement e, QET::findInDomElement(xml_project.documentElement(), "properties"))
|
||||
m_project_properties.fromXml(e);
|
||||
for (auto dom_elmt : QET::findInDomElement(xml_project.documentElement(), QStringLiteral("properties")))
|
||||
m_project_properties.fromXml(dom_elmt);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1483,7 +1483,7 @@ void QETProject::readProjectPropertiesXml(QDomDocument &xml_project)
|
||||
void QETProject::readDefaultPropertiesXml(QDomDocument &xml_project)
|
||||
{
|
||||
// Find xml element where is stored properties for new diagram
|
||||
QDomNodeList newdiagrams_nodes = xml_project.elementsByTagName("newdiagrams");
|
||||
QDomNodeList newdiagrams_nodes = xml_project.elementsByTagName(QStringLiteral("newdiagrams"));
|
||||
if (newdiagrams_nodes.isEmpty()) return;
|
||||
|
||||
QDomElement newdiagrams_elmt = newdiagrams_nodes.at(0).toElement();
|
||||
@@ -1503,21 +1503,21 @@ void QETProject::readDefaultPropertiesXml(QDomDocument &xml_project)
|
||||
QDomElement child_elmt = child.toElement();
|
||||
if (child_elmt.isNull()) continue;
|
||||
|
||||
if (child_elmt.tagName() == "border")
|
||||
if (child_elmt.tagName() == QLatin1String("border"))
|
||||
border_elmt = child_elmt;
|
||||
else if (child_elmt.tagName() == "inset")
|
||||
else if (child_elmt.tagName() == QLatin1String("inset"))
|
||||
titleblock_elmt = child_elmt;
|
||||
else if (child_elmt.tagName() == "conductors")
|
||||
else if (child_elmt.tagName() == QLatin1String("conductors"))
|
||||
conductors_elmt = child_elmt;
|
||||
else if (child_elmt.tagName() == "report")
|
||||
else if (child_elmt.tagName() == QLatin1String("report"))
|
||||
report_elmt = child_elmt;
|
||||
else if (child_elmt.tagName() == "xrefs")
|
||||
else if (child_elmt.tagName() == QLatin1String("xrefs"))
|
||||
xref_elmt = child_elmt;
|
||||
else if (child_elmt.tagName() == "conductors_autonums")
|
||||
else if (child_elmt.tagName() == QLatin1String("conductors_autonums"))
|
||||
conds_autonums = child_elmt;
|
||||
else if (child_elmt.tagName()== "folio_autonums")
|
||||
else if (child_elmt.tagName()== QLatin1String("folio_autonums"))
|
||||
folio_autonums = child_elmt;
|
||||
else if (child_elmt.tagName()== "element_autonums")
|
||||
else if (child_elmt.tagName()== QLatin1String("element_autonums"))
|
||||
element_autonums = child_elmt;
|
||||
}
|
||||
|
||||
@@ -1525,21 +1525,21 @@ void QETProject::readDefaultPropertiesXml(QDomDocument &xml_project)
|
||||
if (!border_elmt.isNull()) default_border_properties_.fromXml(border_elmt);
|
||||
if (!titleblock_elmt.isNull()) default_titleblock_properties_.fromXml(titleblock_elmt);
|
||||
if (!conductors_elmt.isNull()) default_conductor_properties_.fromXml(conductors_elmt);
|
||||
if (!report_elmt.isNull()) setDefaultReportProperties(report_elmt.attribute("label"));
|
||||
if (!report_elmt.isNull()) setDefaultReportProperties(report_elmt.attribute(QStringLiteral("label")));
|
||||
if (!xref_elmt.isNull())
|
||||
{
|
||||
foreach(QDomElement elmt, QET::findInDomElement(xref_elmt, "xref"))
|
||||
for (auto elmt : QET::findInDomElement(xref_elmt, QStringLiteral("xref")))
|
||||
{
|
||||
XRefProperties xrp;
|
||||
xrp.fromXml(elmt);
|
||||
m_default_xref_properties.insert(elmt.attribute("type"), xrp);
|
||||
m_default_xref_properties.insert(elmt.attribute(QStringLiteral("type")), xrp);
|
||||
}
|
||||
}
|
||||
if (!conds_autonums.isNull())
|
||||
{
|
||||
m_current_conductor_autonum = conds_autonums.attribute("current_autonum");
|
||||
m_freeze_new_conductors = conds_autonums.attribute("freeze_new_conductors") == "true";
|
||||
foreach (QDomElement elmt, QET::findInDomElement(conds_autonums, "conductor_autonum"))
|
||||
m_current_conductor_autonum = conds_autonums.attribute(QStringLiteral("current_autonum"));
|
||||
m_freeze_new_conductors = conds_autonums.attribute(QStringLiteral("freeze_new_conductors")) == QLatin1String("true");
|
||||
for (auto elmt : QET::findInDomElement(conds_autonums, QStringLiteral("conductor_autonum")))
|
||||
{
|
||||
NumerotationContext nc;
|
||||
nc.fromXml(elmt);
|
||||
@@ -1548,22 +1548,22 @@ void QETProject::readDefaultPropertiesXml(QDomDocument &xml_project)
|
||||
}
|
||||
if (!folio_autonums.isNull())
|
||||
{
|
||||
foreach (QDomElement elmt, QET::findInDomElement(folio_autonums, "folio_autonum"))
|
||||
for (auto elmt : QET::findInDomElement(folio_autonums, QStringLiteral("folio_autonum")))
|
||||
{
|
||||
NumerotationContext nc;
|
||||
nc.fromXml(elmt);
|
||||
m_folio_autonum.insert(elmt.attribute("title"), nc);
|
||||
m_folio_autonum.insert(elmt.attribute(QStringLiteral("title")), nc);
|
||||
}
|
||||
}
|
||||
if (!element_autonums.isNull())
|
||||
{
|
||||
m_current_element_autonum = element_autonums.attribute("current_autonum");
|
||||
m_freeze_new_elements = element_autonums.attribute("freeze_new_elements") == "true";
|
||||
foreach (QDomElement elmt, QET::findInDomElement(element_autonums, "element_autonum"))
|
||||
m_current_element_autonum = element_autonums.attribute(QStringLiteral("current_autonum"));
|
||||
m_freeze_new_elements = element_autonums.attribute(QStringLiteral("freeze_new_elements")) == QLatin1String("true");
|
||||
for (auto elmt : QET::findInDomElement(element_autonums, QStringLiteral("element_autonum")))
|
||||
{
|
||||
NumerotationContext nc;
|
||||
nc.fromXml(elmt);
|
||||
m_element_autonum.insert(elmt.attribute("title"), nc);
|
||||
m_element_autonum.insert(elmt.attribute(QStringLiteral("title")), nc);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user