mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-17 20:50:34 +01:00
Bug fix (unable to load element from .qet file)
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@4379 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
@@ -79,6 +79,8 @@ XmlElementCollection::XmlElementCollection(const QDomElement &dom_element, QObje
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief XmlElementCollection::root
|
* @brief XmlElementCollection::root
|
||||||
|
* The root is the beginning of the xml collection, the tag name
|
||||||
|
* of the dom element is : collection
|
||||||
* @return The root QDomElement of the collection
|
* @return The root QDomElement of the collection
|
||||||
*/
|
*/
|
||||||
QDomElement XmlElementCollection::root() const {
|
QDomElement XmlElementCollection::root() const {
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ QColor Diagram::background_color = Qt::white;
|
|||||||
*/
|
*/
|
||||||
Diagram::Diagram(QETProject *project) :
|
Diagram::Diagram(QETProject *project) :
|
||||||
QGraphicsScene (project),
|
QGraphicsScene (project),
|
||||||
project_ (nullptr),
|
m_project (nullptr),
|
||||||
diagram_qet_version_ (-1),
|
diagram_qet_version_ (-1),
|
||||||
draw_grid_ (true),
|
draw_grid_ (true),
|
||||||
use_border_ (true),
|
use_border_ (true),
|
||||||
@@ -638,7 +638,7 @@ bool Diagram::fromXml(QDomElement &document, QPointF position, bool consider_inf
|
|||||||
qreal project_qet_version = declaredQElectroTechVersion(true);
|
qreal project_qet_version = declaredQElectroTechVersion(true);
|
||||||
bool handle_inputs_rotation = (
|
bool handle_inputs_rotation = (
|
||||||
project_qet_version != -1 && project_qet_version < 0.3 &&
|
project_qet_version != -1 && project_qet_version < 0.3 &&
|
||||||
project_ -> state() == QETProject::ProjectParsingRunning
|
m_project -> state() == QETProject::ProjectParsingRunning
|
||||||
);
|
);
|
||||||
|
|
||||||
//Load all elements from the XML
|
//Load all elements from the XML
|
||||||
@@ -650,8 +650,13 @@ bool Diagram::fromXml(QDomElement &document, QPointF position, bool consider_inf
|
|||||||
|
|
||||||
// cree un element dont le type correspond a l'id type
|
// cree un element dont le type correspond a l'id type
|
||||||
QString type_id = element_xml.attribute("type");
|
QString type_id = element_xml.attribute("type");
|
||||||
ElementsLocation element_location = ElementsLocation(type_id);
|
ElementsLocation element_location;
|
||||||
if (type_id.startsWith("embed://")) element_location.setProject(project_);
|
if (type_id.startsWith("embed://")) {
|
||||||
|
element_location = ElementsLocation(type_id, m_project);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
element_location = ElementsLocation(type_id);
|
||||||
|
}
|
||||||
|
|
||||||
int state = 0;
|
int state = 0;
|
||||||
Element *nvel_elmt = ElementFactory::Instance() -> createElement(element_location, 0, &state);
|
Element *nvel_elmt = ElementFactory::Instance() -> createElement(element_location, 0, &state);
|
||||||
@@ -932,7 +937,7 @@ void Diagram::titleBlockTemplateChanged(const QString &template_name) {
|
|||||||
void Diagram::titleBlockTemplateRemoved(const QString &template_name, const QString &new_template)
|
void Diagram::titleBlockTemplateRemoved(const QString &template_name, const QString &new_template)
|
||||||
{
|
{
|
||||||
if (border_and_titleblock.titleBlockTemplateName() != template_name) return;
|
if (border_and_titleblock.titleBlockTemplateName() != template_name) return;
|
||||||
const TitleBlockTemplate *final_template = project_->embeddedTitleBlockTemplatesCollection()->getTemplate(new_template);
|
const TitleBlockTemplate *final_template = m_project->embeddedTitleBlockTemplatesCollection()->getTemplate(new_template);
|
||||||
border_and_titleblock.titleBlockTemplateRemoved(template_name, final_template);
|
border_and_titleblock.titleBlockTemplateRemoved(template_name, final_template);
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
@@ -943,10 +948,10 @@ void Diagram::titleBlockTemplateRemoved(const QString &template_name, const QStr
|
|||||||
*/
|
*/
|
||||||
void Diagram::setTitleBlockTemplate(const QString &template_name)
|
void Diagram::setTitleBlockTemplate(const QString &template_name)
|
||||||
{
|
{
|
||||||
if (!project_) return;
|
if (!m_project) return;
|
||||||
|
|
||||||
QString current_name = border_and_titleblock.titleBlockTemplateName();
|
QString current_name = border_and_titleblock.titleBlockTemplateName();
|
||||||
const TitleBlockTemplate *titleblock_template = project_->embeddedTitleBlockTemplatesCollection()->getTemplate(template_name);
|
const TitleBlockTemplate *titleblock_template = m_project->embeddedTitleBlockTemplatesCollection()->getTemplate(template_name);
|
||||||
border_and_titleblock.titleBlockTemplateRemoved(current_name, titleblock_template);
|
border_and_titleblock.titleBlockTemplateRemoved(current_name, titleblock_template);
|
||||||
|
|
||||||
if (template_name != current_name)
|
if (template_name != current_name)
|
||||||
@@ -1266,7 +1271,7 @@ bool Diagram::clipboardMayContainDiagram() {
|
|||||||
independant.
|
independant.
|
||||||
*/
|
*/
|
||||||
QETProject *Diagram::project() const {
|
QETProject *Diagram::project() const {
|
||||||
return(project_);
|
return(m_project);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1276,19 +1281,19 @@ QETProject *Diagram::project() const {
|
|||||||
*/
|
*/
|
||||||
void Diagram::setProject(QETProject *project)
|
void Diagram::setProject(QETProject *project)
|
||||||
{
|
{
|
||||||
if (project_ == project) return;
|
if (m_project == project) return;
|
||||||
|
|
||||||
if (project_)
|
if (m_project)
|
||||||
{
|
{
|
||||||
disconnect (project_, SIGNAL(reportPropertiesChanged(QString)), this, SIGNAL(reportPropertiesChanged(QString)));
|
disconnect (m_project, SIGNAL(reportPropertiesChanged(QString)), this, SIGNAL(reportPropertiesChanged(QString)));
|
||||||
disconnect (project_, SIGNAL(XRefPropertiesChanged()), this, SIGNAL(XRefPropertiesChanged()));
|
disconnect (m_project, SIGNAL(XRefPropertiesChanged()), this, SIGNAL(XRefPropertiesChanged()));
|
||||||
}
|
}
|
||||||
|
|
||||||
project_ = project;
|
m_project = project;
|
||||||
setParent (project);
|
setParent (project);
|
||||||
|
|
||||||
connect (project_, SIGNAL(reportPropertiesChanged(QString)), this, SIGNAL(reportPropertiesChanged(QString)));
|
connect (m_project, SIGNAL(reportPropertiesChanged(QString)), this, SIGNAL(reportPropertiesChanged(QString)));
|
||||||
connect (project_, SIGNAL(XRefPropertiesChanged()), this, SIGNAL(XRefPropertiesChanged()));
|
connect (m_project, SIGNAL(XRefPropertiesChanged()), this, SIGNAL(XRefPropertiesChanged()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1296,8 +1301,8 @@ void Diagram::setProject(QETProject *project)
|
|||||||
if it is has no parent project
|
if it is has no parent project
|
||||||
*/
|
*/
|
||||||
int Diagram::folioIndex() const {
|
int Diagram::folioIndex() const {
|
||||||
if (!project_) return(-1);
|
if (!m_project) return(-1);
|
||||||
return(project_ -> folioIndex(this));
|
return(m_project -> folioIndex(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1310,8 +1315,8 @@ qreal Diagram::declaredQElectroTechVersion(bool fallback_to_project) const {
|
|||||||
if (diagram_qet_version_ != -1) {
|
if (diagram_qet_version_ != -1) {
|
||||||
return diagram_qet_version_;
|
return diagram_qet_version_;
|
||||||
}
|
}
|
||||||
if (fallback_to_project && project_) {
|
if (fallback_to_project && m_project) {
|
||||||
return(project_ -> declaredQElectroTechVersion());
|
return(m_project -> declaredQElectroTechVersion());
|
||||||
}
|
}
|
||||||
return(-1);
|
return(-1);
|
||||||
}
|
}
|
||||||
@@ -1323,7 +1328,7 @@ qreal Diagram::declaredQElectroTechVersion(bool fallback_to_project) const {
|
|||||||
*/
|
*/
|
||||||
bool Diagram::isReadOnly() const
|
bool Diagram::isReadOnly() const
|
||||||
{
|
{
|
||||||
return project_ -> isReadOnly();
|
return m_project -> isReadOnly();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -89,7 +89,7 @@ class Diagram : public QGraphicsScene
|
|||||||
ElementsMover *elements_mover_;
|
ElementsMover *elements_mover_;
|
||||||
ElementTextsMover *element_texts_mover_;
|
ElementTextsMover *element_texts_mover_;
|
||||||
QGIManager *qgi_manager_;
|
QGIManager *qgi_manager_;
|
||||||
QETProject *project_;
|
QETProject *m_project;
|
||||||
|
|
||||||
QDomDocument xml_document_;
|
QDomDocument xml_document_;
|
||||||
|
|
||||||
@@ -119,8 +119,8 @@ class Diagram : public QGraphicsScene
|
|||||||
void setEventInterface (DiagramEventInterface *event_interface);
|
void setEventInterface (DiagramEventInterface *event_interface);
|
||||||
|
|
||||||
//methods related to xref properties
|
//methods related to xref properties
|
||||||
QString defaultReportProperties () const {return project_ -> defaultReportProperties();}
|
QString defaultReportProperties () const {return m_project -> defaultReportProperties();}
|
||||||
XRefProperties defaultXRefProperties (const QString &str) const {return project_ -> defaultXRefProperties(str);}
|
XRefProperties defaultXRefProperties (const QString &str) const {return m_project -> defaultXRefProperties(str);}
|
||||||
|
|
||||||
//methods related to autonum
|
//methods related to autonum
|
||||||
QString conductorsAutonumName() const;
|
QString conductorsAutonumName() const;
|
||||||
|
|||||||
@@ -79,7 +79,11 @@ ElementsLocation::ElementsLocation(const QMimeData *data)
|
|||||||
*/
|
*/
|
||||||
ElementsLocation &ElementsLocation::operator=(const ElementsLocation &other) {
|
ElementsLocation &ElementsLocation::operator=(const ElementsLocation &other) {
|
||||||
m_collection_path = other.m_collection_path;
|
m_collection_path = other.m_collection_path;
|
||||||
|
m_file_system_path = other.m_file_system_path;
|
||||||
m_project = other.m_project;
|
m_project = other.m_project;
|
||||||
|
m_xml = other.m_xml;
|
||||||
|
m_uuid = other.m_uuid;
|
||||||
|
m_icon = other.m_icon;
|
||||||
return(*this);
|
return(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user