mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-17 20:50:34 +01:00
Minor improvement about using pugixml
This commit is contained in:
@@ -494,14 +494,8 @@ NamesList ElementsLocation::nameList()
|
|||||||
{
|
{
|
||||||
NamesList nl;
|
NamesList nl;
|
||||||
|
|
||||||
if (isElement())
|
if (isElement()) {
|
||||||
{
|
nl.fromXml(pugiXml());
|
||||||
QSettings set;
|
|
||||||
if (set.value("use_pugixml").toBool()) {
|
|
||||||
nl.fromXml(pugiXml());
|
|
||||||
} else {
|
|
||||||
nl.fromXml(xml());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isDirectory())
|
if (isDirectory())
|
||||||
|
|||||||
@@ -231,11 +231,11 @@ void FileElementCollectionItem::addChildAtPath(const QString &collection_name)
|
|||||||
*/
|
*/
|
||||||
void FileElementCollectionItem::setUpData()
|
void FileElementCollectionItem::setUpData()
|
||||||
{
|
{
|
||||||
//Setup the displayed name
|
|
||||||
localName();
|
|
||||||
|
|
||||||
if (isDir())
|
if (isDir())
|
||||||
|
{
|
||||||
|
localName();
|
||||||
setFlags(Qt::ItemIsSelectable | Qt::ItemIsDragEnabled | Qt::ItemIsDropEnabled | Qt::ItemIsEnabled);
|
setFlags(Qt::ItemIsSelectable | Qt::ItemIsDragEnabled | Qt::ItemIsDropEnabled | Qt::ItemIsEnabled);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
setFlags(Qt::ItemIsSelectable | Qt::ItemIsDragEnabled | Qt::ItemIsEnabled);
|
setFlags(Qt::ItemIsSelectable | Qt::ItemIsDragEnabled | Qt::ItemIsEnabled);
|
||||||
|
|||||||
@@ -168,9 +168,10 @@ bool ElementsCollectionCache::fetchElement(ElementsLocation &location)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
auto uuid = location.uuid();
|
||||||
QString element_path = location.toString();
|
QString element_path = location.toString();
|
||||||
bool got_name = fetchNameFromCache(element_path, location.uuid());
|
bool got_name = fetchNameFromCache(element_path, uuid);
|
||||||
bool got_pixmap = fetchPixmapFromCache(element_path, location.uuid());
|
bool got_pixmap = fetchPixmapFromCache(element_path, uuid);
|
||||||
|
|
||||||
if (got_name && got_pixmap) {
|
if (got_name && got_pixmap) {
|
||||||
return(true);
|
return(true);
|
||||||
@@ -178,8 +179,8 @@ bool ElementsCollectionCache::fetchElement(ElementsLocation &location)
|
|||||||
|
|
||||||
if (fetchData(location))
|
if (fetchData(location))
|
||||||
{
|
{
|
||||||
cacheName(element_path, location.uuid());
|
cacheName(element_path, uuid);
|
||||||
cachePixmap(element_path, location.uuid());
|
cachePixmap(element_path, uuid);
|
||||||
}
|
}
|
||||||
return(true);
|
return(true);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,9 +40,10 @@ Element * ElementFactory::createElement(const ElementsLocation &location, QGraph
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (location.xml().hasAttribute("link_type"))
|
auto doc = location.pugiXml();
|
||||||
|
if (doc.document_element().attribute("link_type"))
|
||||||
{
|
{
|
||||||
QString link_type = location.xml().attribute("link_type");
|
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 == "next_report" || link_type == "previous_report") return (new ReportElement(location, link_type, qgi, state));
|
||||||
if (link_type == "master") return (new MasterElement (location, qgi, state));
|
if (link_type == "master") return (new MasterElement (location, qgi, state));
|
||||||
if (link_type == "slave") return (new SlaveElement (location, qgi, state));
|
if (link_type == "slave") return (new SlaveElement (location, qgi, state));
|
||||||
|
|||||||
@@ -83,15 +83,15 @@ QPixmap ElementPictureFactory::pixmap(const ElementsLocation &location)
|
|||||||
|
|
||||||
if(build(location))
|
if(build(location))
|
||||||
{
|
{
|
||||||
QDomElement dom = location.xml();
|
auto doc = location.pugiXml();
|
||||||
//size
|
//size
|
||||||
int w = dom.attribute("width").toInt();
|
int w = doc.document_element().attribute("width").as_int();
|
||||||
int h = dom.attribute("height").toInt();
|
int h = doc.document_element().attribute("height").as_int();
|
||||||
while (w % 10) ++ w;
|
while (w % 10) ++ w;
|
||||||
while (h % 10) ++ h;
|
while (h % 10) ++ h;
|
||||||
//hotspot
|
//hotspot
|
||||||
int hsx = qMin(dom.attribute("hotspot_x").toInt(), w);
|
int hsx = qMin(doc.document_element().attribute("hotspot_x").as_int(), w);
|
||||||
int hsy = qMin(dom.attribute("hotspot_y").toInt(), h);
|
int hsy = qMin(doc.document_element().attribute("hotspot_y").as_int(), h);
|
||||||
|
|
||||||
QPixmap pix(w, h);
|
QPixmap pix(w, h);
|
||||||
pix.fill(QColor(255, 255, 255, 0));
|
pix.fill(QColor(255, 255, 255, 0));
|
||||||
|
|||||||
Reference in New Issue
Block a user