View > Show: keep the wire text of a potential when its wire is deleted

With "one text per potential", deleting the wire that carries the text
moves it to another wire of the potential, but only if the text
isVisible(). While wire texts were hidden by View > Show none was, so the
text was never moved and the potential came back with no text.

ShownKinds::wantsVisible() also counts a text hidden only by its kind.
Also drop the always-true/false enum range checks clang warned about.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
ispyisail
2026-10-04 00:07:16 +13:00
parent 649f06b3b8
commit 17e9f53b81
4 changed files with 36 additions and 3 deletions
+12 -2
View File
@@ -30,7 +30,7 @@ namespace
*/
bool ShownKinds::isShown(Kind kind)
{
return kind < 0 || kind >= KindCount || !hidden[kind];
return kind >= KindCount || !hidden[kind];
}
/**
@@ -39,7 +39,7 @@ bool ShownKinds::isShown(Kind kind)
*/
void ShownKinds::setShown(Kind kind, bool shown)
{
if (kind >= 0 && kind < KindCount) {
if (kind < KindCount) {
hidden[kind] = !shown;
}
}
@@ -106,6 +106,16 @@ bool ShownKinds::isHidden(const QGraphicsItem *item)
return false;
}
/**
@return true if @a item is visible, or would be but for its kind being
hidden. For code that asks isVisible() to learn what an item's own code
decided (which wire carries the text of a potential).
*/
bool ShownKinds::wantsVisible(const QGraphicsItem *item)
{
return item && (item->isVisible() || item->data(hidden_key).toBool());
}
/**
Bring the items of @a kind on @a scene in line with the current state:
hide the ones that are visible, or show again the ones hidden for it.