diff --git a/sources/ElementsCollection/fileelementcollectionitem.cpp b/sources/ElementsCollection/fileelementcollectionitem.cpp index ad53e843e..8c6b37bc0 100644 --- a/sources/ElementsCollection/fileelementcollectionitem.cpp +++ b/sources/ElementsCollection/fileelementcollectionitem.cpp @@ -183,13 +183,14 @@ QString FileElementCollectionItem::name() const */ QString FileElementCollectionItem::collectionPath() const { + QStandardItem* parent_ = parent(); if (isCollectionRoot()) { if (m_path == QETApp::commonElementsDirN()) return "common://"; else return "custom://"; } - else if (parent() && parent()->type() == FileElementCollectionItem::Type) { + else if (parent_ && parent()->type() == FileElementCollectionItem::Type) { ElementCollectionItem *eci = static_cast(parent()); if (eci->isCollectionRoot()) return eci->collectionPath() + m_path; diff --git a/sources/qetgraphicsitem/diagramtextitem.cpp b/sources/qetgraphicsitem/diagramtextitem.cpp index b9f8d9024..99aabf7a2 100644 --- a/sources/qetgraphicsitem/diagramtextitem.cpp +++ b/sources/qetgraphicsitem/diagramtextitem.cpp @@ -20,6 +20,8 @@ #include "qetapp.h" #include "richtext/richtexteditor_p.h" #include "diagram.h" +#include "dynamicelementtextitem.h" + /** * @brief DiagramTextItem::DiagramTextItem @@ -211,12 +213,24 @@ QRectF DiagramTextItem::frameRect() const void DiagramTextItem::setHtml(const QString &text) { + DynamicElementTextItem* abc = dynamic_cast(this); + if (abc) { + if (abc->searchedElement) { + int stop = 1; + } + } QGraphicsTextItem::setHtml(text); m_is_html = true; } void DiagramTextItem::setPlainText(const QString &text) { + DynamicElementTextItem* abc = dynamic_cast(this); + if (abc) { + if (abc->searchedElement) { + int stop = 1; + } + } QGraphicsTextItem::setPlainText(text); m_is_html = false; } @@ -235,6 +249,16 @@ bool DiagramTextItem::isHtml() const { */ void DiagramTextItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) { + + DynamicElementTextItem* abc = dynamic_cast(this); + if (abc) { + if (abc->searchedElement) { + int stop = 1; + QString text = toPlainText(); + qDebug() << text; + } + } + painter -> setRenderHint(QPainter::Antialiasing, false); QGraphicsTextItem::paint(painter, option, widget); diff --git a/sources/qetgraphicsitem/dynamicelementtextitem.cpp b/sources/qetgraphicsitem/dynamicelementtextitem.cpp index f8b7c798c..fee849b55 100644 --- a/sources/qetgraphicsitem/dynamicelementtextitem.cpp +++ b/sources/qetgraphicsitem/dynamicelementtextitem.cpp @@ -323,6 +323,9 @@ DynamicElementTextItem::TextFrom DynamicElementTextItem::textFrom() const { */ void DynamicElementTextItem::setTextFrom(DynamicElementTextItem::TextFrom text_from) { + + if (searchedElement) + int stop = true; if(m_text_from == text_from) return; @@ -386,6 +389,9 @@ QString DynamicElementTextItem::text() const { */ void DynamicElementTextItem::setText(const QString &text) { + if (m_text == "14" && text == "") + int a = 54; + m_text_old = m_text; m_text = text; if(m_text_from == DynamicElementTextItem::UserText) setPlainText(m_text); @@ -402,6 +408,9 @@ void DynamicElementTextItem::setInfoName(const QString &info_name) QString old_info_name = m_info_name; m_info_name = info_name; + if (searchedElement) + int stop = true; + if(old_info_name == "label") { @@ -1321,6 +1330,17 @@ void DynamicElementTextItem::updateXref() void DynamicElementTextItem::setPlainText(const QString &text) { + DynamicElementTextItem* abc = this; + + int abcedwer; + abcedwer += 5; + + if (text == "14") + searchedElement = true; + if (text == "") + int a = 5; + if (m_text_old == "14" && m_text == "") + int a = 5; if (toPlainText() == text) return; diff --git a/sources/qetgraphicsitem/dynamicelementtextitem.h b/sources/qetgraphicsitem/dynamicelementtextitem.h index 53e4d3b14..e7d691d96 100644 --- a/sources/qetgraphicsitem/dynamicelementtextitem.h +++ b/sources/qetgraphicsitem/dynamicelementtextitem.h @@ -103,6 +103,7 @@ class DynamicElementTextItem : public DiagramTextItem void setPlainText(const QString &text); void setTextWidth(qreal width); void setXref_item(Qt::AlignmentFlag m_exHrefPos); + bool searchedElement{false}; protected: void mousePressEvent(QGraphicsSceneMouseEvent *event) override; @@ -141,6 +142,7 @@ class DynamicElementTextItem : public DiagramTextItem m_other_report; QPointer m_watched_conductor; QString m_text, + m_text_old, m_info_name, m_composite_text, m_report_formula, diff --git a/sources/qetgraphicsitem/element.cpp b/sources/qetgraphicsitem/element.cpp index e68875217..10c2bb959 100644 --- a/sources/qetgraphicsitem/element.cpp +++ b/sources/qetgraphicsitem/element.cpp @@ -71,7 +71,7 @@ class ElementXmlRetroCompatibility * @param state, state of the instanciation */ Element::Element(const ElementsLocation &location, QGraphicsItem *parent, int *state, kind link_type) : - QetGraphicsItem(parent), + QetGraphicsItem(parent), m_link_type (link_type), m_location (location) { @@ -419,7 +419,8 @@ bool Element::buildFromXml(const QDomElement &xml_def_elmt, int *state) if (elmts.tagName() == "description") { //Minor workaround to find if there is a "input" tagg as label. - //If not, we set the tagg "label" to the first "input. + //If not, we set the tagg "label" to the first "input. Why one must have a tagg label? + // is label a required field? QList input_field; bool have_label = false; for (QDomElement input_node = node.firstChildElement("input") ; !input_node.isNull() ; input_node = input_node.nextSiblingElement("input")) @@ -715,6 +716,8 @@ bool Element::fromXml(QDomElement &e, QHash &table_id_adr, bool QString fl = e.attribute("freezeLabel", "false"); m_freeze_label = fl == "false"? false : true; + // TODO: why element information is not read? + //Load Sequential Values if (e.hasAttribute("sequ_1") || e.hasAttribute("sequf_1") || e.hasAttribute("seqt_1") || e.hasAttribute("seqtf_1") || e.hasAttribute("seqh_1") || e.hasAttribute("sequf_1")) ElementXmlRetroCompatibility::loadSequential(e, this); @@ -745,7 +748,9 @@ bool Element::fromXml(QDomElement &e, QHash &table_id_adr, bool //************************// //***Dynamic texts item***// - //************************// read from the diagram section + //************************// + // read from the diagram section + // this is not done in the older versions, because there only inputs are available. for (const QDomElement& qde : QET::findInDomElement(e, "dynamic_texts", DynamicElementTextItem::xmlTagName())) { DynamicElementTextItem *deti = new DynamicElementTextItem(this); @@ -763,14 +768,16 @@ bool Element::fromXml(QDomElement &e, QHash &table_id_adr, bool const QList conv_deti_list = m_converted_text_from_xml_description.keys(); QList successfully_converted; const QList dom_inputs = inputs; - // TODO: legacy??? + // TODO: Legacy (0.7 and prior) for (DynamicElementTextItem *deti : conv_deti_list) // elements read from the element collection definition { - for(const QDomElement& dom_input : dom_inputs) + for(const QDomElement& dom_input : dom_inputs) // elements in the diagram section { //we use the same method used in ElementTextItem::fromXml to compar and know if the input dom element is for one of the text stored. //The comparaison is made from the text position : if the position of the text is the same as the position stored in 'input' dom element //that mean this is the good text + // This is only used when in the diagram description the text elements are stored in the "inputs" section. In 0.8 and higher, + // texts are stored in directly in the "dynamic_elmt_text" section if (qFuzzyCompare(qreal(dom_input.attribute("x").toDouble()), m_converted_text_from_xml_description.value(deti).x()) && qFuzzyCompare(qreal(dom_input.attribute("y").toDouble()), m_converted_text_from_xml_description.value(deti).y())) { diff --git a/sources/qetgraphicsitem/element.h b/sources/qetgraphicsitem/element.h index a5f2c9689..441bbc3d6 100644 --- a/sources/qetgraphicsitem/element.h +++ b/sources/qetgraphicsitem/element.h @@ -55,7 +55,7 @@ class Element : public QetGraphicsItem // TODO: derive from propertiesInterface! Slave = 16, Terminale = 32}; - Element(const ElementsLocation &location, QGraphicsItem * = nullptr, int *state = nullptr, Element::kind link_type = Element::Simple); + Element(const ElementsLocation &location, QGraphicsItem * parent= nullptr, int *state = nullptr, Element::kind link_type = Element::Simple); ~Element() override; private: Element(const Element &); diff --git a/sources/qetgraphicsitem/slaveelement.cpp b/sources/qetgraphicsitem/slaveelement.cpp index 3c61830d3..d69b778bd 100644 --- a/sources/qetgraphicsitem/slaveelement.cpp +++ b/sources/qetgraphicsitem/slaveelement.cpp @@ -29,8 +29,8 @@ * @param s parent diagram * @param state int used to know if the creation of element have error */ -SlaveElement::SlaveElement(const ElementsLocation &location, QGraphicsItem *qgi, int *state) : - Element(location, qgi, state, Element::Slave) +SlaveElement::SlaveElement(const ElementsLocation &location, QGraphicsItem *parent, int *state) : + Element(location, parent, state, Element::Slave) { } diff --git a/sources/qetgraphicsitem/slaveelement.h b/sources/qetgraphicsitem/slaveelement.h index fe5067da9..3117451da 100644 --- a/sources/qetgraphicsitem/slaveelement.h +++ b/sources/qetgraphicsitem/slaveelement.h @@ -25,7 +25,7 @@ class SlaveElement : public Element { Q_OBJECT public: - explicit SlaveElement (const ElementsLocation &, QGraphicsItem * = nullptr, int * = nullptr); + explicit SlaveElement (const ElementsLocation &, QGraphicsItem * parent= nullptr, int * = nullptr); ~SlaveElement() override; void linkToElement(Element *elmt) override; void unlinkAllElements() override; diff --git a/sources/ui/dynamicelementtextmodel.cpp b/sources/ui/dynamicelementtextmodel.cpp index fc9709d9e..7b9c12e26 100644 --- a/sources/ui/dynamicelementtextmodel.cpp +++ b/sources/ui/dynamicelementtextmodel.cpp @@ -1158,6 +1158,8 @@ void DynamicElementTextModel::enableGroupRotationAndPos(ElementTextItemGroup *gr void DynamicElementTextModel::itemDataChanged(QStandardItem *qsi) { DynamicElementTextItem *deti = textFromItem(qsi); + if (deti->searchedElement) + int stop = 1; ElementTextItemGroup *etig = groupFromItem(qsi); if (!deti && !etig) return; @@ -1297,6 +1299,10 @@ void DynamicElementTextModel::setConnection(ElementTextItemGroup *group, bool se void DynamicElementTextModel::updateDataFromText(DynamicElementTextItem *deti, ValueType type) { + + if (deti->searchedElement) + int stop = 1; + QStandardItem *qsi = m_texts_list.value(deti); if (!qsi) return;