mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-09-13 20:23:04 +02:00
Merge branch 'XMLProperties' of ssh://git.tuxfamily.org/gitroot/qet/qet into XMLProperties
This commit is contained in:
commit
eb5494c360
@ -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<ElementCollectionItem*>(parent());
|
||||
if (eci->isCollectionRoot())
|
||||
return eci->collectionPath() + m_path;
|
||||
|
@ -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<DynamicElementTextItem*>(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<DynamicElementTextItem*>(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<DynamicElementTextItem*>(this);
|
||||
if (abc) {
|
||||
if (abc->searchedElement) {
|
||||
int stop = 1;
|
||||
QString text = toPlainText();
|
||||
qDebug() << text;
|
||||
}
|
||||
}
|
||||
|
||||
painter -> setRenderHint(QPainter::Antialiasing, false);
|
||||
QGraphicsTextItem::paint(painter, option, widget);
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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 <Conductor> m_watched_conductor;
|
||||
QString m_text,
|
||||
m_text_old,
|
||||
m_info_name,
|
||||
m_composite_text,
|
||||
m_report_formula,
|
||||
|
@ -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 <QDomElement> 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<int, Terminal *> &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<int, Terminal *> &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<int, Terminal *> &table_id_adr, bool
|
||||
const QList <DynamicElementTextItem *> conv_deti_list = m_converted_text_from_xml_description.keys();
|
||||
QList <DynamicElementTextItem *> successfully_converted;
|
||||
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(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()))
|
||||
{
|
||||
|
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user