Fix wrong behavior when edit the element information

In the diagram editor, when we edit the element information in the side
panel, each time we tip something in the text field the cursor always go
to the end if the "label" information is empty.
This commit is contained in:
joshua
2022-05-25 23:16:13 +02:00
parent a2b73ea2bc
commit 899caeabe9
2 changed files with 24 additions and 3 deletions

View File

@@ -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();
}