mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-10-14 09:14:14 +02:00
Speed up opening big projects with lazy folios
This commit is contained in:
@@ -25,6 +25,7 @@
|
||||
#include "../conductorsegment.h"
|
||||
#include "../conductorsegmentprofile.h"
|
||||
#include "../diagram.h"
|
||||
#include "../dataBase/projectdatabase.h"
|
||||
#include "../diagramcommands.h"
|
||||
#include "../qetdiagrameditor.h"
|
||||
#include "../qetgraphicsitem/terminal.h"
|
||||
@@ -118,6 +119,8 @@ Conductor::Conductor(Terminal *p1, Terminal* p2) :
|
||||
setZValue(11);
|
||||
m_previous_z_value = zValue();
|
||||
m_uuid = QUuid::createUuid();
|
||||
static quint64 created = 0;
|
||||
m_creation_rank = ++created;
|
||||
|
||||
//Add this conductor to the list of conductors of each of the two terminals
|
||||
bool ajout_p1 = terminal1 -> addConductor(this);
|
||||
@@ -1114,6 +1117,7 @@ void Conductor::pointsToSegments(const QList<QPointF>& points_list) {
|
||||
*/
|
||||
bool Conductor::fromXml(QDomElement &dom_element)
|
||||
{
|
||||
const QUuid old_uuid = m_uuid;
|
||||
//Older project files have no conductor uuid attribute at all --
|
||||
//generate one on load, same treatment terminal uuids got when
|
||||
//that field was introduced (see terminal1/terminal2 handling in
|
||||
@@ -1129,6 +1133,7 @@ bool Conductor::fromXml(QDomElement &dom_element)
|
||||
//single load-and-resave (see #754).
|
||||
m_uuid = QUuid::createUuid();
|
||||
}
|
||||
uuidChanged(old_uuid);
|
||||
|
||||
//"nan" and "inf" parse as numbers; a non-finite position is kept at 0
|
||||
const qreal x = dom_element.attribute("x", nullptr).toDouble();
|
||||
@@ -1235,7 +1240,7 @@ QDomElement Conductor::toXml(QDomDocument &dom_document,
|
||||
dom_element.appendChild(dom_seq);
|
||||
|
||||
// Export the properties and text
|
||||
m_properties. toXml(dom_element);
|
||||
properties().toXml(dom_element);
|
||||
if(m_text_item->wasMovedByUser())
|
||||
{
|
||||
dom_element.setAttribute("userx", QString::number(m_text_item->pos().x()));
|
||||
@@ -1735,6 +1740,7 @@ void Conductor::refreshText()
|
||||
m_properties.text = m_properties.m_formula;
|
||||
m_text_item->setPlainText(m_properties.text);
|
||||
}
|
||||
storeProperties();
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1833,6 +1839,7 @@ void Conductor::setProperties(const ConductorProperties &property)
|
||||
calculateTextItemPosition();
|
||||
update();
|
||||
|
||||
storeProperties();
|
||||
emit propertiesChange();
|
||||
}
|
||||
|
||||
@@ -1842,9 +1849,75 @@ void Conductor::setProperties(const ConductorProperties &property)
|
||||
*/
|
||||
ConductorProperties Conductor::properties() const
|
||||
{
|
||||
if (projectDataBase *store = placedStore())
|
||||
return store->conductorProperties(m_uuid);
|
||||
return(m_properties);
|
||||
}
|
||||
|
||||
/**
|
||||
@brief Conductor::placedStore
|
||||
@return the project database holding this wire's properties
|
||||
(DB-ACCESSORS-PLAN.md stage 4.5), or nullptr if it is not placed in a
|
||||
project, or shares its uuid with another wire for the moment a copy
|
||||
takes to get its own
|
||||
*/
|
||||
projectDataBase *Conductor::placedStore() const
|
||||
{
|
||||
Diagram *d = diagram();
|
||||
QETProject *project = d ? d->project() : nullptr;
|
||||
projectDataBase *store = project ? project->dataBase() : nullptr;
|
||||
return store && store->hasConductorProperties(m_uuid)
|
||||
&& store->placedConductorCount(m_uuid) == 1 ? store : nullptr;
|
||||
}
|
||||
|
||||
/**
|
||||
@brief Conductor::storeProperties
|
||||
Write this wire's properties to its project's store, once it is placed:
|
||||
every change of a placed wire's properties comes through here.
|
||||
*/
|
||||
void Conductor::storeProperties()
|
||||
{
|
||||
Diagram *d = diagram();
|
||||
QETProject *project = d ? d->project() : nullptr;
|
||||
if (project && project->dataBase() && project->dataBase()->hasConductorProperties(m_uuid))
|
||||
project->dataBase()->conductorPropertiesStored(this, m_properties);
|
||||
}
|
||||
|
||||
/**
|
||||
@brief Conductor::newUuid
|
||||
Make a new uuid for this conductor; its stored properties and its row
|
||||
follow it.
|
||||
*/
|
||||
void Conductor::newUuid()
|
||||
{
|
||||
setUuid(QUuid::createUuid());
|
||||
}
|
||||
|
||||
/**
|
||||
@brief Conductor::setUuid
|
||||
@param uuid : the uuid of this conductor, saved from now on
|
||||
*/
|
||||
void Conductor::setUuid(const QUuid &uuid)
|
||||
{
|
||||
const QUuid old_uuid = m_uuid;
|
||||
m_uuid = uuid;
|
||||
m_persist_uuid = true;
|
||||
uuidChanged(old_uuid);
|
||||
}
|
||||
|
||||
/**
|
||||
@brief Conductor::uuidChanged
|
||||
Tell the project's store this placed wire's uuid changed from
|
||||
@p old_uuid (a paste renews it, a file gives it).
|
||||
*/
|
||||
void Conductor::uuidChanged(const QUuid &old_uuid)
|
||||
{
|
||||
Diagram *d = diagram();
|
||||
QETProject *project = d ? d->project() : nullptr;
|
||||
if (project && project->dataBase())
|
||||
project->dataBase()->conductorUuidChanged(this, old_uuid);
|
||||
}
|
||||
|
||||
/**
|
||||
@brief Conductor::setCableReference
|
||||
Record the cable core this conductor shows, together with the label
|
||||
@@ -1868,6 +1941,7 @@ void Conductor::setCableReference(const QString &label,
|
||||
m_properties.m_cable = label;
|
||||
m_properties.m_cable_uuid = cable_uuid;
|
||||
m_properties.m_cable_slot = slot;
|
||||
storeProperties();
|
||||
emit propertiesChange();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user