diff --git a/sources/qetgraphicsitem/element.cpp b/sources/qetgraphicsitem/element.cpp index 4c09aa1a2..1b49b5283 100644 --- a/sources/qetgraphicsitem/element.cpp +++ b/sources/qetgraphicsitem/element.cpp @@ -1347,9 +1347,13 @@ void Element::setElementInformations(DiagramContext dc) return; } - DiagramContext old_info = m_data.m_informations; + const auto old_info = m_data.m_informations; m_data.m_informations = dc; - m_data.m_informations.addValue(QStringLiteral("label"), actualLabel()); //Update the label if there is a formula + + const auto actual_label{actualLabel()}; + if (!actual_label.isEmpty()) { + m_data.m_informations.addValue(QStringLiteral("label"), actual_label); //Update the label if there is a formula + } emit elementInfoChange(old_info, m_data.m_informations); } diff --git a/sources/ui/elementinfowidget.cpp b/sources/ui/elementinfowidget.cpp index e4978d624..8c51e64b5 100644 --- a/sources/ui/elementinfowidget.cpp +++ b/sources/ui/elementinfowidget.cpp @@ -191,6 +191,7 @@ void ElementInfoWidget::buildInterface() ui->scroll_vlayout->addWidget(eipw); m_eipw_list << eipw; } + ui->scroll_vlayout->addStretch(); } @@ -277,6 +278,22 @@ void ElementInfoWidget::firstActivated() */ void ElementInfoWidget::elementInfoChange() { - if(currentInfo() != m_element->elementInformations()) + auto elmt_info = m_element->elementInformations(); + auto current_info = currentInfo(); + + //If both info have a formula, we remove the label + //value before compare the equality, because the + //label of the information returned by the element + //can be different of the current label because + //updated by the element to reflect the actual + //displayed label according the current formula. + if (current_info.contains(QETInformation::ELMT_FORMULA) && + elmt_info.contains(QETInformation::ELMT_FORMULA)) + { + elmt_info.remove(QETInformation::ELMT_LABEL); + current_info.remove((QETInformation::ELMT_LABEL )); + } + + if(current_info != elmt_info) updateUi(); }