mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-10-14 09:14:14 +02:00
Open with every folio built when the database must come from them
With QET_LAZY_FOLIOS=1, a project whose database cannot be filled from the file (folios or symbols with no saved uuid, two symbols sharing one, a folio number using %autonum, wires naming their ends the older way) had its folios left unbuilt, then built all at once while the database was filled from them. That is slower than building them as they are read: a 17 MB project reported on the pull request took 24.8 s to open instead of 19.2 s, and most files saved by an older version have no folio uuids. The file is now checked for those reasons before the folios are read; when one applies the project opens as without QET_LAZY_FOLIOS. The rarer reasons, which need the definitions or every folio's links, still fall back as before. tst_lazyfolios opens a copy of industrial.qet with one symbol's uuid given to another, and checks no folio is built after reading. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -253,6 +253,58 @@ void projectDataBase::updateDB(const QDomDocument &document)
|
||||
updateDB();
|
||||
}
|
||||
|
||||
/**
|
||||
@brief projectDataBase::documentRefusal
|
||||
@return why populateFromDocument() will refuse @p document, for the
|
||||
reasons it gives that the document alone can tell -- a folio, symbol
|
||||
or wire with no saved uuid, two symbols sharing one, a folio number
|
||||
using %autonum -- or an empty string. The other reasons need the
|
||||
project's definitions or every folio's links; a document refused for
|
||||
one of those is still filled from the folios, only later.
|
||||
*/
|
||||
QString projectDataBase::documentRefusal(const QDomDocument &document)
|
||||
{
|
||||
if (qEnvironmentVariableIntValue("QET_DATABASE_FROM_FOLIOS") == 1) {
|
||||
return QStringLiteral("QET_DATABASE_FROM_FOLIOS is set");
|
||||
}
|
||||
QSet<QUuid> element_uuids;
|
||||
const QDomNodeList diagram_nodes = document.elementsByTagName(QStringLiteral("diagram"));
|
||||
for (int i = 0 ; i < diagram_nodes.size() ; ++i)
|
||||
{
|
||||
QDomElement diagram_xml = diagram_nodes.at(i).toElement();
|
||||
if (QUuid(diagram_xml.attribute(QStringLiteral("uuid"))).isNull()) {
|
||||
return QStringLiteral("a folio has no saved uuid");
|
||||
}
|
||||
if (diagram_xml.attribute(QStringLiteral("folio")).contains(QStringLiteral("%autonum"))) {
|
||||
return QStringLiteral("a folio number uses %autonum");
|
||||
}
|
||||
for (QDomElement element_xml : QET::findInDomElement(
|
||||
diagram_xml, QStringLiteral("elements"), QStringLiteral("element")))
|
||||
{
|
||||
//Skipped by Diagram::fromXml() as well
|
||||
if (!Element::valideXml(element_xml)) {
|
||||
continue;
|
||||
}
|
||||
const QUuid uuid(element_xml.attribute(QStringLiteral("uuid")));
|
||||
if (uuid.isNull() || element_uuids.contains(uuid)) {
|
||||
return QStringLiteral("an element has no saved uuid, or shares one");
|
||||
}
|
||||
element_uuids.insert(uuid);
|
||||
}
|
||||
for (QDomElement conductor_xml : QET::findInDomElement(
|
||||
diagram_xml, QStringLiteral("conductors"), QStringLiteral("conductor")))
|
||||
{
|
||||
if (Conductor::valideXml(conductor_xml)
|
||||
&& (QUuid(conductor_xml.attribute(QStringLiteral("uuid"))).isNull()
|
||||
|| !conductor_xml.hasAttribute(QStringLiteral("element1"))
|
||||
|| !conductor_xml.hasAttribute(QStringLiteral("element2")))) {
|
||||
return QStringLiteral("a conductor has no saved uuid, or names its ends the older way");
|
||||
}
|
||||
}
|
||||
}
|
||||
return QString();
|
||||
}
|
||||
|
||||
namespace {
|
||||
struct DocumentTerminal
|
||||
{
|
||||
|
||||
@@ -67,6 +67,14 @@ class projectDataBase : public QObject
|
||||
populateFromDocument()), from the built folios otherwise.
|
||||
*/
|
||||
void updateDB(const QDomDocument &document);
|
||||
/**
|
||||
Why updateDB(document) will fill the tables from the folios
|
||||
rather than from @p document, for the reasons the document
|
||||
alone can tell; empty when it knows of none. Read before the
|
||||
folios are: a project whose tables will come from the folios
|
||||
builds every folio as it opens, even with QET_LAZY_FOLIOS.
|
||||
*/
|
||||
static QString documentRefusal(const QDomDocument &document);
|
||||
/**
|
||||
Suppress the full rebuild performed by updateDB().
|
||||
|
||||
|
||||
Reference in New Issue
Block a user