Take the label field off the sheet while the name is hidden

An element whose name must not be drawn left its label field behind
as an empty frame: selected along with the element, ready to click,
drawing nothing. The field now follows the Show name box both ways:

- a field bound to the label is hidden while Element::labelShown()
  says no, and shown again the moment the box is ticked again, both
  through the same signals which refresh the text (elementInfoChange,
  the label connection refresh, binding the field to another
  information), so it can never get stuck on one side;
- a hidden field is deselected and gets no resize handles, and one
  which comes back gets its handles back when its element is still
  selected;
- every other field, composite texts included, is drawn as always,
  and the data of the element never changes - only the drawing.

Adds a test: the field is visible, goes away with the name, and
comes back with it.
This commit is contained in:
Kellermorph
2026-10-22 13:18:55 +02:00
parent edf761c2b6
commit 337502edfc
4 changed files with 76 additions and 2 deletions
+30
View File
@@ -335,6 +335,36 @@ private slots:
QVERIFY(!element->actualLabel().isEmpty());
QCOMPARE(element->labelForDisplay(), element->actualLabel());
}
//The field of a hidden name does not stay on the sheet as an empty
//frame to select: it leaves the sheet with the box and comes back
//with it, both ways through the same signal
void hiddenNameHidesTheLabelField()
{
QetSettings::setTerminalLabelSplit(false);
const QString fixture = QFINDTESTDATA("fixtures/every_feature.qet");
QETProject project(fixture);
QCOMPARE(project.state(), QETProject::Ok);
Element *element = terminalWithLabel(project, QStringLiteral("X1:1"));
QVERIFY(element);
DynamicElementTextItem *label = fieldBoundTo(element, QETInformation::ELMT_LABEL);
QVERIFY(label);
QVERIFY(label->isVisible());
hideName(element);
QVERIFY(!label->isVisible());
//The box ticked again: the element drops the information,
//and the field is drawn as it was before
DiagramContext dc = element->elementInformations();
dc.remove(QStringLiteral("label_shown"));
element->setElementInformations(dc);
QVERIFY(label->isVisible());
QCOMPARE(label->toPlainText(), QStringLiteral("X1:1"));
}
};
QET_APP_TEST_MAIN(tst_terminallabeldisplay)