mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-02-12 20:09:58 +01:00
Use pugixml for parse local name of directory and element informations
This commit is contained in:
@@ -570,7 +570,6 @@ pugi::xml_document ElementsLocation::pugiXml() const
|
||||
{
|
||||
if (!m_project)
|
||||
{
|
||||
QFile file (m_file_system_path);
|
||||
pugi::xml_document docu;
|
||||
if (docu.load_file(m_file_system_path.toStdString().c_str()))
|
||||
return docu;
|
||||
@@ -680,7 +679,8 @@ QUuid ElementsLocation::uuid() const
|
||||
QSettings set;
|
||||
if(set.value("use_pugixml").toBool())
|
||||
{
|
||||
pugi::xml_node uuid_node = pugiXml().document_element().child("uuid");
|
||||
auto document = pugiXml();
|
||||
auto uuid_node = document.document_element().child("uuid");
|
||||
if (uuid_node.empty()) {
|
||||
return QUuid();
|
||||
}
|
||||
@@ -765,8 +765,16 @@ DiagramContext ElementsLocation::elementInformations() const
|
||||
return context;
|
||||
}
|
||||
|
||||
QDomElement dom = this->xml().firstChildElement("elementInformations");
|
||||
context.fromXml(dom, "elementInformation");
|
||||
QSettings set;
|
||||
if (set.value("use_pugixml").toBool())
|
||||
{
|
||||
context.fromXml(pugiXml().document_element().child("elementInformations"), "elementInformation");
|
||||
}
|
||||
else
|
||||
{
|
||||
QDomElement dom = this->xml().firstChildElement("elementInformations");
|
||||
context.fromXml(dom, "elementInformation");
|
||||
}
|
||||
return context;
|
||||
}
|
||||
|
||||
|
||||
@@ -120,20 +120,39 @@ QString FileElementCollectionItem::localName()
|
||||
else
|
||||
setText(QObject::tr("Collection inconnue"));
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
QSettings set;
|
||||
if (set.value("use_pugixml").toBool())
|
||||
{
|
||||
QString str(fileSystemPath() + "/qet_directory");
|
||||
pugi::xml_document docu;
|
||||
if(docu.load_file(str.toStdString().c_str()))
|
||||
{
|
||||
if (QString(docu.document_element().name()) == "qet-directory")
|
||||
{
|
||||
NamesList nl;
|
||||
nl.fromXml(docu.document_element());
|
||||
setText(nl.name());
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//Open the qet_directory file, to get the traductions name of this dir
|
||||
QFile dir_conf(fileSystemPath() + "/qet_directory");
|
||||
QFile dir_conf(fileSystemPath() + "/qet_directory");
|
||||
|
||||
if (dir_conf.exists() && dir_conf.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
||||
if (dir_conf.exists() && dir_conf.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
||||
|
||||
//Get the content of the file
|
||||
QDomDocument document;
|
||||
if (document.setContent(&dir_conf)) {
|
||||
QDomElement root = document.documentElement();
|
||||
if (root.tagName() == "qet-directory") {
|
||||
NamesList nl;
|
||||
nl.fromXml(root);
|
||||
setText(nl.name());
|
||||
QDomDocument document;
|
||||
if (document.setContent(&dir_conf)) {
|
||||
QDomElement root = document.documentElement();
|
||||
if (root.tagName() == "qet-directory") {
|
||||
NamesList nl;
|
||||
nl.fromXml(root);
|
||||
setText(nl.name());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user