diff --git a/sources/qetapp.cpp b/sources/qetapp.cpp index 82e058989..9c6ef0d12 100644 --- a/sources/qetapp.cpp +++ b/sources/qetapp.cpp @@ -315,6 +315,7 @@ QString QETApp::elementTranslatedInfoKey(const QString &info) else if (info == "machine-manufacturer-reference") return tr("Référence fabricant machine"); else if (info == "location") return tr("Localisation"); else if (info == "function") return tr("Fonction"); + else if (info == "tension-protocol") return tr("Tension / Protocole"); return (info); } @@ -337,6 +338,7 @@ QString QETApp::elementInfoToVar(const QString &info) else if (info == "machine-manufacturer-reference") return QString("%{machine-manufacturer-reference}"); else if (info == "location") return QString("%{location}"); else if (info == "function") return QString("%{function}"); + else if (info == "tension-protocol") return QString("%{tension-protocol}"); return (QString ("%{void}")); } diff --git a/sources/qetgraphicsitem/dynamicelementtextitem.cpp b/sources/qetgraphicsitem/dynamicelementtextitem.cpp index a4f47b6bb..9779b4fba 100644 --- a/sources/qetgraphicsitem/dynamicelementtextitem.cpp +++ b/sources/qetgraphicsitem/dynamicelementtextitem.cpp @@ -21,6 +21,8 @@ #include "qetapp.h" #include "diagram.h" #include "QPropertyUndoCommand/qpropertyundocommand.h" +#include "terminal.h" +#include "conductor.h" #include #include @@ -58,6 +60,27 @@ DynamicElementTextItem::DynamicElementTextItem(Element *parent_element) : if(!parent_element->linkedElements().isEmpty()) masterChanged(); } + if(parent_element->linkType() & Element::AllReport) + { + //Get the report formula, and add connection to keep up to date the formula. + if (parent_element->diagram() && parent_element->diagram()->project()) + { + m_report_formula = parent_element->diagram()->project()->defaultReportProperties(); + m_report_formula_con = connect(parent_element->diagram()->project(), &QETProject::reportPropertiesChanged, this, &DynamicElementTextItem::reportFormulaChanged); + } + + //Add connection to keep up to date the status of the element linked to the parent folio report of this text. + connect(parent_element, &Element::linkedElementChanged, this, &DynamicElementTextItem::reportChanged); + //The parent is already linked, we call reportChanged for init the connection + if(!parent_element->linkedElements().isEmpty()) + reportChanged(); + + //Add connection to keep up date the conductors added or removed to the parent folio report element + connect(parent_element->terminals().first(), &Terminal::conductorWasAdded, this, &DynamicElementTextItem::conductorWasAdded); + connect(parent_element->terminals().first(), &Terminal::conductorWasRemoved, this, &DynamicElementTextItem::conductorWasRemoved); + //Get a conductor in the potential + setPotentialConductor(); + } } DynamicElementTextItem::~DynamicElementTextItem() @@ -144,7 +167,8 @@ void DynamicElementTextItem::fromXml(const QDomElement &dom_elmt) if(m_text_from == ElementInfo || m_text_from == CompositeText) { setNoEditable(true); - if (elementUseForInfo()) + //We don't made the connection below if the parent element is a report, because report haven't got info. + if (!(parentElement()->linkType() & Element::AllReport) && elementUseForInfo()) connect(elementUseForInfo(), &Element::elementInfoChange, this, &DynamicElementTextItem::elementInfoChanged); } else { @@ -315,36 +339,102 @@ void DynamicElementTextItem::setText(const QString &text) */ void DynamicElementTextItem::setInfoName(const QString &info_name) { + QString old_info_name = m_info_name; m_info_name = info_name; - - if(elementUseForInfo()) { + + if (m_parent_element && (m_parent_element.data()->linkType() & Element::AllReport)) //special treatment for report + { + if(old_info_name != info_name) + { + if(old_info_name == "label") { + removeConnectionForReportFormula(m_report_formula); + } + if(info_name == "label") + { + setConnectionForReportFormula(m_report_formula); + updateReportText(); + } + else + conductorPropertiesChanged(); + } + } + else if(elementUseForInfo()) { setPlainText(elementUseForInfo()->elementInformations().value(info_name).toString()); } emit infoNameChanged(info_name); } +/** + * @brief DynamicElementTextItem::infoName + * @return the info name of this text + */ QString DynamicElementTextItem::infoName() const { return m_info_name; } +/** + * @brief DynamicElementTextItem::setCompositeText + * Set the composite text of this text item to @text + * @param text + */ void DynamicElementTextItem::setCompositeText(const QString &text) { + QString old_composite_text = m_composite_text; m_composite_text = text; - DiagramContext dc; - if(elementUseForInfo()) - dc = elementUseForInfo()->elementInformations(); - setPlainText(autonum::AssignVariables::replaceVariable(m_composite_text, dc)); + if (m_parent_element && (m_parent_element.data()->linkType() & Element::AllReport)) //special treatment for report + { + /* + * May be in some case the old and new composite text have both the var %{label}, + * and so we don't have to remove connection and after set conection, + * but for that we must to do several check and because I'm lazy, + * in every case I remove connection and set it after ;) + */ + if(old_composite_text.contains("%{label}")) + removeConnectionForReportFormula(m_report_formula); + if(m_composite_text.contains("%{label}")) + setConnectionForReportFormula(m_report_formula); + + updateReportText(); + } + else + { + DiagramContext dc; + if(elementUseForInfo()) + dc = elementUseForInfo()->elementInformations(); + setPlainText(autonum::AssignVariables::replaceVariable(m_composite_text, dc)); + } emit compositeTextChanged(m_composite_text); } +/** + * @brief DynamicElementTextItem::compositeText + * @return + */ QString DynamicElementTextItem::compositeText() const { return m_composite_text; } +/** + * @brief DynamicElementTextItem::mousePressEvent + * @param event + */ +void DynamicElementTextItem::mousePressEvent(QGraphicsSceneMouseEvent *event) +{ + //The text become selected, we set the real color, otherwise the editor will display the color of text as blue, + //but this is not the color set by the user. + if(m_user_color.isValid()) + { + setDefaultTextColor(m_user_color); + m_user_color = QColor(); //m_user_color is now invalid + } + + DiagramTextItem::mousePressEvent(event); +} + /** * @brief DynamicElementTextItem::mouseMoveEvent * @param event @@ -408,31 +498,100 @@ void DynamicElementTextItem::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *eve { DiagramTextItem::mouseDoubleClickEvent(event); - if(m_parent_element && m_parent_element.data()->linkType() == Element::Slave && m_master_element) + if(!parentElement()) + return; + + Element *zoomed_element = nullptr; + + if(parentElement()->linkType() == Element::Slave && m_master_element) { if ((m_text_from == ElementInfo && m_info_name == "label") || (m_text_from == CompositeText && m_composite_text.contains("%{label}"))) + zoomed_element = m_master_element.data(); + } + if((parentElement()->linkType() & Element::AllReport) && m_other_report) + { + if((m_text_from == ElementInfo && m_info_name == "label") || + (m_text_from == CompositeText && m_composite_text.contains("%{label}"))) + zoomed_element = m_other_report.data(); + } + + if(zoomed_element) + { + //Unselect and ungrab mouse to prevent unwanted + //move when linked element is in the same scene of this. + setSelected(false); + ungrabMouse(); + + if(scene() != zoomed_element->scene()) + zoomed_element->diagram()->showMe(); + zoomed_element->setSelected(true); + + //Zoom to the element + for(QGraphicsView *view : zoomed_element->scene()->views()) { - //Unselect and ungrab mouse to prevent unwanted - //move when linked element is in the same scene of this. - setSelected(false); - ungrabMouse(); - - if(scene() != m_master_element.data()->scene()) - m_master_element.data()->diagram()->showMe(); - m_master_element.data()->setSelected(true); - - //Zoom to the master element - for(QGraphicsView *view : m_master_element.data()->scene()->views()) - { - QRectF fit = m_master_element.data()->sceneBoundingRect(); - fit.adjust(-200, -200, 200, 200); - view->fitInView(fit, Qt::KeepAspectRatioByExpanding); - } + QRectF fit = zoomed_element->sceneBoundingRect(); + fit.adjust(-200, -200, 200, 200); + view->fitInView(fit, Qt::KeepAspectRatioByExpanding); } } } +/** + * @brief DynamicElementTextItem::hoverEnterEvent + * If the parent element of this text is a folio report or a slave element, the element is linked + * and the text display the variable "label" we set the text blue for signal the user that the text act like + * a link when we double click on. + * @param event + */ +void DynamicElementTextItem::hoverEnterEvent(QGraphicsSceneHoverEvent *event) +{ + DiagramTextItem::hoverEnterEvent(event); + + //If the text is selected we set the real color, otherwise the editor will display the color of text as blue, + //but this is not the color set by the user. + if(isSelected()) + return; + + Element::kind type = parentElement()->linkType(); + bool blue = false; + + if ((type & Element::AllReport) && m_other_report) + { + if( (m_text_from == ElementInfo && m_info_name == "label") || + (m_text_from == CompositeText && m_composite_text.contains("%{label}")) ) + blue = true; + } + else if (type == Element::Slave && m_master_element) + { + if( (m_text_from == ElementInfo && m_info_name == "label") || + (m_text_from == CompositeText && m_composite_text.contains("%{label}")) ) + blue = true; + } + + if(blue) + { + m_user_color = color(); + setDefaultTextColor(Qt::blue); + } +} + +/** + * @brief DynamicElementTextItem::hoverLeaveEvent + * @param event + */ +void DynamicElementTextItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) +{ + DiagramTextItem::hoverLeaveEvent(event); + + if(m_user_color.isValid()) + { + setDefaultTextColor(m_user_color); + m_user_color = QColor(); //m_user_color is now invalid + } + +} + void DynamicElementTextItem::elementInfoChanged() { DiagramContext dc; @@ -451,6 +610,11 @@ void DynamicElementTextItem::elementInfoChanged() setPlainText(final_text); } +/** + * @brief DynamicElementTextItem::masterChanged + * This function is only use when the parent element is a slave. + * Call when the master element linked to the parent slave element of this text change + */ void DynamicElementTextItem::masterChanged() { //First we remove the old connection @@ -468,3 +632,265 @@ void DynamicElementTextItem::masterChanged() elementInfoChanged(); } +/** + * @brief DynamicElementTextItem::reportChanged + * This function is only use when parent element of this text is a folio report + * The linked report of the parent element was changed + */ +void DynamicElementTextItem::reportChanged() +{ + /* + * When the dynamic text are added by a drag & drop from the element panel, + * the connection below are made in the constructor. + * If the text are added at load of a .qet file, the text is not yet added to a diagram then the connection is not made. + * We make it now, because when the linked report changed, that mean this text is in a diagram + */ + if(!m_report_formula_con) + { + //Get the report formula, and add connection to keep up to date the formula. + if (parentElement()->diagram() && parentElement()->diagram()->project()) + { + m_report_formula = parentElement()->diagram()->project()->defaultReportProperties(); + m_report_formula_con = connect(parentElement()->diagram()->project(), &QETProject::reportPropertiesChanged, this, &DynamicElementTextItem::reportFormulaChanged); + } + } + + bool text_have_label = false; + + if((textFrom() == ElementInfo && m_info_name == "label") || + (textFrom() == CompositeText && m_composite_text.contains("%{label}"))) + text_have_label = true; + + if(text_have_label) + removeConnectionForReportFormula(m_report_formula); + + m_other_report.clear(); + if(!m_parent_element.data()->linkedElements().isEmpty()) + m_other_report = m_parent_element.data()->linkedElements().first(); + + //Because linked report was changed, we ensure there is a conductor watched + setPotentialConductor(); + + if(text_have_label) + { + setConnectionForReportFormula(m_report_formula); + updateReportText(); + } +} + +/** + * @brief DynamicElementTextItem::reportFormulaChanged + * The report formula use in the project was changed + */ +void DynamicElementTextItem::reportFormulaChanged() +{ + m_report_formula = parentElement()->diagram()->project()->defaultReportProperties(); + + if(m_text_from == ElementInfo && m_info_name == "label") + updateReportText(); +} + +void DynamicElementTextItem::setConnectionForReportFormula(const QString &formula) +{ + if(m_other_report.isNull() || formula.isEmpty()) + return; + + Element *other_elmt = m_other_report.data(); + QString string = formula; + Diagram *other_diagram = m_other_report.data()->diagram(); + + //Because the variable %F is a reference to another text which can contain variables, + //we must to replace %F by the real text, to check if the real text contain the variable %id + if (other_diagram && string.contains("%F")) + { + m_F_str = other_diagram->border_and_titleblock.folio(); + string.replace("%F", other_diagram->border_and_titleblock.folio()); + connect(&other_diagram->border_and_titleblock, &BorderTitleBlock::titleBlockFolioChanged, this, &DynamicElementTextItem::updateReportFormulaConnection); + } + + if (other_diagram && (string.contains("%f") || string.contains("%id"))) + connect(other_diagram->project(), &QETProject::projectDiagramsOrderChanged, this, &DynamicElementTextItem::updateReportText); + if (string.contains("%l")) + connect(other_elmt, &Element::yChanged, this, &DynamicElementTextItem::updateReportText); + if (string.contains("%c")) + connect(other_elmt, &Element::xChanged, this, &DynamicElementTextItem::updateReportText); +} + +void DynamicElementTextItem::removeConnectionForReportFormula(const QString &formula) +{ + if(m_other_report.isNull() || formula.isEmpty()) + return; + + Element *other_element = m_other_report.data(); + QString string = formula; + Diagram *other_diagram = m_other_report.data()->diagram(); + + //Because the variable %F is a reference to another text which can contain variables, + //we must to replace %F by the real text, to check if the real text contain the variable %id + if (other_diagram && string.contains("%F")) + { + string.replace("%F", m_F_str); + disconnect(&other_diagram->border_and_titleblock, &BorderTitleBlock::titleBlockFolioChanged, this, &DynamicElementTextItem::updateReportFormulaConnection); + } + + if (other_diagram && (string.contains("%f") || string.contains("%id"))) + disconnect(other_diagram->project(), &QETProject::projectDiagramsOrderChanged, this, &DynamicElementTextItem::updateReportText); + if (string.contains("%l")) + disconnect(other_element, &Element::yChanged, this, &DynamicElementTextItem::updateReportText); + if (string.contains("%c")) + disconnect(other_element, &Element::xChanged, this, &DynamicElementTextItem::updateReportText); + +} + +void DynamicElementTextItem::updateReportFormulaConnection() +{ + removeConnectionForReportFormula(m_report_formula); + setConnectionForReportFormula(m_report_formula); + updateReportText(); +} + +/** + * @brief DynamicElementTextItem::updateReportText + * This function is only use when this text is owned by a report, and this text have for info the Label. + */ +void DynamicElementTextItem::updateReportText() +{ + if (m_text_from == ElementInfo && m_info_name == "label" && m_other_report) + { + Element *elmt = m_other_report.data(); + QString label = m_report_formula; + label = autonum::AssignVariables::formulaToLabel(label, elmt->rSequenceStruct(), elmt->diagram(), elmt); + setPlainText(label); + } + else if (m_text_from == CompositeText) { + setPlainText(reportReplacedCompositeText()); + } +} + +/** + * @brief DynamicElementTextItem::conductorWasAdded + * Function only use when parent element is a folio report + * @param conductor + */ +void DynamicElementTextItem::conductorWasAdded(Conductor *conductor) +{ + Q_UNUSED(conductor) + setPotentialConductor(); +} + +/** + * @brief DynamicElementTextItem::conductorWasRemoved + * Function only use when parent element is a folio report + * @param conductor + */ +void DynamicElementTextItem::conductorWasRemoved(Conductor *conductor) +{ + if(m_watched_conductor.data() == conductor) + { + disconnect(m_watched_conductor.data(), &Conductor::propertiesChange, this, &DynamicElementTextItem::conductorPropertiesChanged); + m_watched_conductor.clear(); + setPotentialConductor(); + } +} + +/** + * @brief DynamicElementTextItem::setPotentialConductor + * This function is only used when the parent element of this text is a report element + * Get a conductor in the potential of the parent report + */ +void DynamicElementTextItem::setPotentialConductor() +{ + if(parentElement() && (parentElement()->linkType() & Element::AllReport)) + { + /* + * #First case, if m_watched_conductor is a conductor of the parent report, everything is ok + * #Second case, if the conductors list of parent report element is not empty, + * we set one of these conductor as m_watched_conductor, even if m_watched_conductor is already set, + * because that mean the conductor is a conductor of the linked report, and we prefer to set a conductor + * owned by the parent report element of this text. + * #third case, if m_watched_conductor is null, we set a conductor of the linked report, if any. + */ + QList c_list = parentElement()->terminals().first()->conductors(); + + if(!c_list.isEmpty() && c_list.contains(m_watched_conductor.data())) + return; + else if(!c_list.isEmpty()) + { + if(!m_watched_conductor.isNull()) + disconnect(m_watched_conductor.data(), &Conductor::propertiesChange, this, &DynamicElementTextItem::conductorPropertiesChanged); + + m_watched_conductor = c_list.first(); + connect(m_watched_conductor.data(), &Conductor::propertiesChange, this, &DynamicElementTextItem::conductorPropertiesChanged); + } + else if(m_watched_conductor.isNull() && m_other_report) + { + if (!m_other_report.data()->terminals().first()->conductors().isEmpty()) + { + m_watched_conductor = m_other_report.data()->terminals().first()->conductors().first(); + connect(m_watched_conductor.data(), &Conductor::propertiesChange, this, &DynamicElementTextItem::conductorPropertiesChanged); + } + } + } + else //This text haven't got a parent element, then ther isn't a conductor in the potential + { + if(!m_watched_conductor.isNull()) + disconnect(m_watched_conductor.data(), &Conductor::propertiesChange, this, &DynamicElementTextItem::conductorPropertiesChanged); + + m_watched_conductor.clear(); + } +} + +/** + * @brief DynamicElementTextItem::conductorPropertiesChanged + * This function is only used when the parent element of this text is a report element + */ +void DynamicElementTextItem::conductorPropertiesChanged() +{ + if(m_parent_element && (m_parent_element.data()->linkType() & Element::AllReport)) + { + if(m_text_from == ElementInfo) + { + if(m_info_name == "function") + setPlainText(m_watched_conductor? m_watched_conductor.data()->properties().m_function : ""); + else if (m_info_name == "tension-protocol") + setPlainText(m_watched_conductor? m_watched_conductor.data()->properties().m_tension_protocol : ""); + } + else if (m_text_from == CompositeText) { + setPlainText(reportReplacedCompositeText()); + } + } +} + +/** + * @brief DynamicElementTextItem::reportReplacedCompositeText + * This function is only used when the parent element of this text is a report element + * @return the composite text with the variable replaced by the real value. + * If the parent element of this text is not a folio report, return a default QString. + */ +QString DynamicElementTextItem::reportReplacedCompositeText() const +{ + QString string; + + if(m_parent_element.data()->linkType() & Element::AllReport) + { + string = m_composite_text; + + if (string.contains("%{label}") && m_other_report) + { + Element *elmt = m_other_report.data(); + QString label = m_report_formula; + label = autonum::AssignVariables::formulaToLabel(label, elmt->rSequenceStruct(), elmt->diagram(), elmt); + string.replace("%{label}", label); + } + if (m_watched_conductor) + { + if(string.contains("%{function}")) + string.replace("%{function}", m_watched_conductor.data()->properties().m_function); + if(string.contains("%{tension-protocol}")) + string.replace("%{tension-protocol}", m_watched_conductor.data()->properties().m_tension_protocol); + } + } + + return string; +} + diff --git a/sources/qetgraphicsitem/dynamicelementtextitem.h b/sources/qetgraphicsitem/dynamicelementtextitem.h index 9df9c0bb6..7ebdae892 100644 --- a/sources/qetgraphicsitem/dynamicelementtextitem.h +++ b/sources/qetgraphicsitem/dynamicelementtextitem.h @@ -23,6 +23,7 @@ #include class Element; +class Conductor; /** * @brief The DynamicElementTextItem class @@ -32,6 +33,9 @@ class Element; */ class DynamicElementTextItem : public DiagramTextItem { + friend class DynamicTextItemDelegate; + friend class CompositeTextEditDialog; + Q_OBJECT Q_PROPERTY(QString tagg READ tagg WRITE setTagg NOTIFY taggChanged) @@ -83,23 +87,43 @@ class DynamicElementTextItem : public DiagramTextItem QString compositeText() const; protected: + void mousePressEvent(QGraphicsSceneMouseEvent *event) override; void mouseMoveEvent(QGraphicsSceneMouseEvent *event) override; void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override; void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) override; + void hoverEnterEvent(QGraphicsSceneHoverEvent *event) override; + void hoverLeaveEvent(QGraphicsSceneHoverEvent *event) override; private: void elementInfoChanged(); void masterChanged(); + void reportChanged(); + void reportFormulaChanged(); + void setConnectionForReportFormula(const QString &formula); + void removeConnectionForReportFormula(const QString &formula); + void updateReportFormulaConnection(); + void updateReportText(); + void conductorWasAdded(Conductor *conductor); + void conductorWasRemoved(Conductor *conductor); + void setPotentialConductor(); + void conductorPropertiesChanged(); + QString reportReplacedCompositeText() const; private: QPointer m_parent_element, - m_master_element; + m_master_element, + m_other_report; + QPointer m_watched_conductor; QString m_tagg, m_text, m_info_name, - m_composite_text; + m_composite_text, + m_report_formula, + m_F_str; DynamicElementTextItem::TextFrom m_text_from = UserText; - QUuid m_uuid; + QUuid m_uuid; + QMetaObject::Connection m_report_formula_con; + QColor m_user_color; }; #endif // DYNAMICELEMENTTEXTITEM_H diff --git a/sources/ui/compositetexteditdialog.cpp b/sources/ui/compositetexteditdialog.cpp index 65d54f309..8c9571d0f 100644 --- a/sources/ui/compositetexteditdialog.cpp +++ b/sources/ui/compositetexteditdialog.cpp @@ -3,6 +3,7 @@ #include "dynamicelementtextitem.h" #include "element.h" #include "qetapp.h" +#include "conductor.h" CompositeTextEditDialog::CompositeTextEditDialog(DynamicElementTextItem *text, QWidget *parent) : QDialog(parent), @@ -37,18 +38,34 @@ QString CompositeTextEditDialog::plainText() const { void CompositeTextEditDialog::setUpComboBox() { QStringList qstrl; - Element *elmt = m_text->elementUseForInfo(); - if(!elmt) - return; - - QStringList info_list = QETApp::elementInfoKeys(); - info_list.removeAll("formula"); //No need to have formula - DiagramContext dc = elmt->elementInformations(); - - for(QString info : info_list) + if(m_text->parentElement()->linkType() & Element::AllReport) //Special treatment for text owned by a folio report { - if(dc.contains(info)) - qstrl << info; + qstrl << "label"; + + if(!m_text->m_watched_conductor.isNull()) + { + Conductor *cond = m_text->m_watched_conductor.data(); + if (!cond->properties().m_function.isEmpty()) + qstrl << "function"; + if(!cond->properties().m_tension_protocol.isEmpty()) + qstrl << "tension-protocol"; + } + } + else + { + Element *elmt = m_text->elementUseForInfo(); + if(!elmt) + return; + + QStringList info_list = QETApp::elementInfoKeys(); + info_list.removeAll("formula"); //No need to have formula + DiagramContext dc = elmt->elementInformations(); + + for(QString info : info_list) + { + if(dc.contains(info)) + qstrl << info; + } } //We use a QMap because the keys of the map are sorted, then no matter the curent local, diff --git a/sources/ui/dynamicelementtextmodel.cpp b/sources/ui/dynamicelementtextmodel.cpp index d4bf0b8e5..ffc8d515e 100644 --- a/sources/ui/dynamicelementtextmodel.cpp +++ b/sources/ui/dynamicelementtextmodel.cpp @@ -27,6 +27,8 @@ #include "qetapp.h" #include "element.h" #include "compositetexteditdialog.h" +#include "terminal.h" +#include "conductor.h" DynamicElementTextModel::DynamicElementTextModel(QObject *parent) : QStandardItemModel(parent) @@ -628,20 +630,38 @@ void DynamicTextItemDelegate::setModelData(QWidget *editor, QAbstractItemModel * QStringList DynamicTextItemDelegate::availableInfo(DynamicElementTextItem *deti) const { QStringList qstrl; - Element *elmt = deti->elementUseForInfo(); - if(!elmt) - return qstrl; - - QStringList info_list = QETApp::elementInfoKeys(); - info_list.removeAll("formula"); //No need to have formula - DiagramContext dc = elmt->elementInformations(); - - for(QString info : info_list) + if(deti->parentElement()->linkType() & Element::AllReport) //Special treatment for text owned by a folio report { - if(dc.contains(info)) - qstrl << info; + qstrl << "label"; + + if(!deti->m_watched_conductor.isNull()) + { + Conductor *cond = deti->m_watched_conductor.data(); + if (!cond->properties().m_function.isEmpty()) + qstrl << "function"; + if(!cond->properties().m_tension_protocol.isEmpty()) + qstrl << "tension-protocol"; + } + + return qstrl; + } + else + { + Element *elmt = deti->elementUseForInfo(); + if(!elmt) + return qstrl; + + + QStringList info_list = QETApp::elementInfoKeys(); + info_list.removeAll("formula"); //No need to have formula + DiagramContext dc = elmt->elementInformations(); + + for(QString info : info_list) + { + if(dc.contains(info)) + qstrl << info; + } } - return qstrl; }