mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-20 08:10:52 +01:00
Compare commits
2 Commits
XMLPropert
...
XMLPropert
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
eb5494c360 | ||
|
|
f79b1a52bb |
@@ -183,13 +183,14 @@ QString FileElementCollectionItem::name() const
|
|||||||
*/
|
*/
|
||||||
QString FileElementCollectionItem::collectionPath() const
|
QString FileElementCollectionItem::collectionPath() const
|
||||||
{
|
{
|
||||||
|
QStandardItem* parent_ = parent();
|
||||||
if (isCollectionRoot()) {
|
if (isCollectionRoot()) {
|
||||||
if (m_path == QETApp::commonElementsDirN())
|
if (m_path == QETApp::commonElementsDirN())
|
||||||
return "common://";
|
return "common://";
|
||||||
else
|
else
|
||||||
return "custom://";
|
return "custom://";
|
||||||
}
|
}
|
||||||
else if (parent() && parent()->type() == FileElementCollectionItem::Type) {
|
else if (parent_ && parent()->type() == FileElementCollectionItem::Type) {
|
||||||
ElementCollectionItem *eci = static_cast<ElementCollectionItem*>(parent());
|
ElementCollectionItem *eci = static_cast<ElementCollectionItem*>(parent());
|
||||||
if (eci->isCollectionRoot())
|
if (eci->isCollectionRoot())
|
||||||
return eci->collectionPath() + m_path;
|
return eci->collectionPath() + m_path;
|
||||||
|
|||||||
@@ -20,6 +20,8 @@
|
|||||||
#include "qetapp.h"
|
#include "qetapp.h"
|
||||||
#include "richtext/richtexteditor_p.h"
|
#include "richtext/richtexteditor_p.h"
|
||||||
#include "diagram.h"
|
#include "diagram.h"
|
||||||
|
#include "dynamicelementtextitem.h"
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief DiagramTextItem::DiagramTextItem
|
* @brief DiagramTextItem::DiagramTextItem
|
||||||
@@ -211,12 +213,24 @@ QRectF DiagramTextItem::frameRect() const
|
|||||||
|
|
||||||
void DiagramTextItem::setHtml(const QString &text)
|
void DiagramTextItem::setHtml(const QString &text)
|
||||||
{
|
{
|
||||||
|
DynamicElementTextItem* abc = dynamic_cast<DynamicElementTextItem*>(this);
|
||||||
|
if (abc) {
|
||||||
|
if (abc->searchedElement) {
|
||||||
|
int stop = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
QGraphicsTextItem::setHtml(text);
|
QGraphicsTextItem::setHtml(text);
|
||||||
m_is_html = true;
|
m_is_html = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DiagramTextItem::setPlainText(const QString &text)
|
void DiagramTextItem::setPlainText(const QString &text)
|
||||||
{
|
{
|
||||||
|
DynamicElementTextItem* abc = dynamic_cast<DynamicElementTextItem*>(this);
|
||||||
|
if (abc) {
|
||||||
|
if (abc->searchedElement) {
|
||||||
|
int stop = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
QGraphicsTextItem::setPlainText(text);
|
QGraphicsTextItem::setPlainText(text);
|
||||||
m_is_html = false;
|
m_is_html = false;
|
||||||
}
|
}
|
||||||
@@ -235,6 +249,16 @@ bool DiagramTextItem::isHtml() const {
|
|||||||
*/
|
*/
|
||||||
void DiagramTextItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
void DiagramTextItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
DynamicElementTextItem* abc = dynamic_cast<DynamicElementTextItem*>(this);
|
||||||
|
if (abc) {
|
||||||
|
if (abc->searchedElement) {
|
||||||
|
int stop = 1;
|
||||||
|
QString text = toPlainText();
|
||||||
|
qDebug() << text;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
painter -> setRenderHint(QPainter::Antialiasing, false);
|
painter -> setRenderHint(QPainter::Antialiasing, false);
|
||||||
QGraphicsTextItem::paint(painter, option, widget);
|
QGraphicsTextItem::paint(painter, option, widget);
|
||||||
|
|
||||||
|
|||||||
@@ -323,6 +323,9 @@ DynamicElementTextItem::TextFrom DynamicElementTextItem::textFrom() const {
|
|||||||
*/
|
*/
|
||||||
void DynamicElementTextItem::setTextFrom(DynamicElementTextItem::TextFrom text_from)
|
void DynamicElementTextItem::setTextFrom(DynamicElementTextItem::TextFrom text_from)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
if (searchedElement)
|
||||||
|
int stop = true;
|
||||||
if(m_text_from == text_from)
|
if(m_text_from == text_from)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -386,6 +389,9 @@ QString DynamicElementTextItem::text() const {
|
|||||||
*/
|
*/
|
||||||
void DynamicElementTextItem::setText(const QString &text)
|
void DynamicElementTextItem::setText(const QString &text)
|
||||||
{
|
{
|
||||||
|
if (m_text == "14" && text == "")
|
||||||
|
int a = 54;
|
||||||
|
m_text_old = m_text;
|
||||||
m_text = text;
|
m_text = text;
|
||||||
if(m_text_from == DynamicElementTextItem::UserText)
|
if(m_text_from == DynamicElementTextItem::UserText)
|
||||||
setPlainText(m_text);
|
setPlainText(m_text);
|
||||||
@@ -402,6 +408,9 @@ void DynamicElementTextItem::setInfoName(const QString &info_name)
|
|||||||
QString old_info_name = m_info_name;
|
QString old_info_name = m_info_name;
|
||||||
m_info_name = info_name;
|
m_info_name = info_name;
|
||||||
|
|
||||||
|
if (searchedElement)
|
||||||
|
int stop = true;
|
||||||
|
|
||||||
|
|
||||||
if(old_info_name == "label")
|
if(old_info_name == "label")
|
||||||
{
|
{
|
||||||
@@ -1321,6 +1330,17 @@ void DynamicElementTextItem::updateXref()
|
|||||||
|
|
||||||
void DynamicElementTextItem::setPlainText(const QString &text)
|
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)
|
if (toPlainText() == text)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|||||||
@@ -103,6 +103,7 @@ class DynamicElementTextItem : public DiagramTextItem
|
|||||||
void setPlainText(const QString &text);
|
void setPlainText(const QString &text);
|
||||||
void setTextWidth(qreal width);
|
void setTextWidth(qreal width);
|
||||||
void setXref_item(Qt::AlignmentFlag m_exHrefPos);
|
void setXref_item(Qt::AlignmentFlag m_exHrefPos);
|
||||||
|
bool searchedElement{false};
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void mousePressEvent(QGraphicsSceneMouseEvent *event) override;
|
void mousePressEvent(QGraphicsSceneMouseEvent *event) override;
|
||||||
@@ -141,6 +142,7 @@ class DynamicElementTextItem : public DiagramTextItem
|
|||||||
m_other_report;
|
m_other_report;
|
||||||
QPointer <Conductor> m_watched_conductor;
|
QPointer <Conductor> m_watched_conductor;
|
||||||
QString m_text,
|
QString m_text,
|
||||||
|
m_text_old,
|
||||||
m_info_name,
|
m_info_name,
|
||||||
m_composite_text,
|
m_composite_text,
|
||||||
m_report_formula,
|
m_report_formula,
|
||||||
|
|||||||
@@ -419,7 +419,8 @@ bool Element::buildFromXml(const QDomElement &xml_def_elmt, int *state)
|
|||||||
if (elmts.tagName() == "description")
|
if (elmts.tagName() == "description")
|
||||||
{
|
{
|
||||||
//Minor workaround to find if there is a "input" tagg as label.
|
//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 <QDomElement> input_field;
|
QList <QDomElement> input_field;
|
||||||
bool have_label = false;
|
bool have_label = false;
|
||||||
for (QDomElement input_node = node.firstChildElement("input") ; !input_node.isNull() ; input_node = input_node.nextSiblingElement("input"))
|
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<int, Terminal *> &table_id_adr, bool
|
|||||||
QString fl = e.attribute("freezeLabel", "false");
|
QString fl = e.attribute("freezeLabel", "false");
|
||||||
m_freeze_label = fl == "false"? false : true;
|
m_freeze_label = fl == "false"? false : true;
|
||||||
|
|
||||||
|
// TODO: why element information is not read?
|
||||||
|
|
||||||
//Load Sequential Values
|
//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"))
|
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);
|
ElementXmlRetroCompatibility::loadSequential(e, this);
|
||||||
@@ -745,7 +748,9 @@ bool Element::fromXml(QDomElement &e, QHash<int, Terminal *> &table_id_adr, bool
|
|||||||
|
|
||||||
//************************//
|
//************************//
|
||||||
//***Dynamic texts item***//
|
//***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()))
|
for (const QDomElement& qde : QET::findInDomElement(e, "dynamic_texts", DynamicElementTextItem::xmlTagName()))
|
||||||
{
|
{
|
||||||
DynamicElementTextItem *deti = new DynamicElementTextItem(this);
|
DynamicElementTextItem *deti = new DynamicElementTextItem(this);
|
||||||
@@ -763,14 +768,16 @@ bool Element::fromXml(QDomElement &e, QHash<int, Terminal *> &table_id_adr, bool
|
|||||||
const QList <DynamicElementTextItem *> conv_deti_list = m_converted_text_from_xml_description.keys();
|
const QList <DynamicElementTextItem *> conv_deti_list = m_converted_text_from_xml_description.keys();
|
||||||
QList <DynamicElementTextItem *> successfully_converted;
|
QList <DynamicElementTextItem *> successfully_converted;
|
||||||
const QList <QDomElement> dom_inputs = inputs;
|
const QList <QDomElement> 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 (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.
|
//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
|
//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
|
//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()) &&
|
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()))
|
qFuzzyCompare(qreal(dom_input.attribute("y").toDouble()), m_converted_text_from_xml_description.value(deti).y()))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1158,6 +1158,8 @@ void DynamicElementTextModel::enableGroupRotationAndPos(ElementTextItemGroup *gr
|
|||||||
void DynamicElementTextModel::itemDataChanged(QStandardItem *qsi)
|
void DynamicElementTextModel::itemDataChanged(QStandardItem *qsi)
|
||||||
{
|
{
|
||||||
DynamicElementTextItem *deti = textFromItem(qsi);
|
DynamicElementTextItem *deti = textFromItem(qsi);
|
||||||
|
if (deti->searchedElement)
|
||||||
|
int stop = 1;
|
||||||
ElementTextItemGroup *etig = groupFromItem(qsi);
|
ElementTextItemGroup *etig = groupFromItem(qsi);
|
||||||
if (!deti && !etig)
|
if (!deti && !etig)
|
||||||
return;
|
return;
|
||||||
@@ -1297,6 +1299,10 @@ void DynamicElementTextModel::setConnection(ElementTextItemGroup *group, bool se
|
|||||||
|
|
||||||
void DynamicElementTextModel::updateDataFromText(DynamicElementTextItem *deti, ValueType type)
|
void DynamicElementTextModel::updateDataFromText(DynamicElementTextItem *deti, ValueType type)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
if (deti->searchedElement)
|
||||||
|
int stop = 1;
|
||||||
|
|
||||||
QStandardItem *qsi = m_texts_list.value(deti);
|
QStandardItem *qsi = m_texts_list.value(deti);
|
||||||
if (!qsi)
|
if (!qsi)
|
||||||
return;
|
return;
|
||||||
|
|||||||
Reference in New Issue
Block a user