From bbb8e5d2e2eb37d00941ef2a6b294d455ad8c698 Mon Sep 17 00:00:00 2001 From: Laurent Trinques Date: Sun, 4 Oct 2026 09:32:12 +0200 Subject: [PATCH] Tested in list display on a real project: neighbouring references on the same row were raised alternately (980 / 927 / 980...) although nothing visibly overlapped. Cause: in list mode `drawAsContacts()` adds a margin (`adjust(-30, -4, 4, 4)`) to `boundingRect()`, and the horizontal test in `stackAtBottom()` uses that rect. Two lists overlapping only inside the empty margin (1.4 units in my log) count as overlapping. `gap` only changes how far the raised ones move, not which ones. Fix: test the content only in list mode (`rect.adjust(30, 0, -4, 0)`), with the two margins as constants shared with `drawAsContacts()`. Result: all references stay at the bottom (980 -> 980), none raised by mistake, also when moving an element sideways. Checked: [to complete: same-column coils in list mode still stack, cross mode unchanged] --- sources/qetgraphicsitem/crossrefitem.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/sources/qetgraphicsitem/crossrefitem.cpp b/sources/qetgraphicsitem/crossrefitem.cpp index 595fcdfad..fb710a968 100644 --- a/sources/qetgraphicsitem/crossrefitem.cpp +++ b/sources/qetgraphicsitem/crossrefitem.cpp @@ -37,6 +37,10 @@ static int header = 5; //define the minimal height of the cross (without header) static int cross_min_height = 33; +//margins added around the contacts by drawAsContacts() in the bounding +//rect of a cross displayed as a list of contacts. +static const qreal list_margin_left = 30; +static const qreal list_margin_right = 4; /** @brief CrossRefItem::CrossRefItem @@ -379,7 +383,14 @@ void CrossRefItem::stackAtBottom() if (xref->boundingRect().isEmpty()) continue; // Move up past every cross already placed that it would overlap. + // A list of contacts has an empty margin in its bounding rect: + // only its content is tested, so side by side lists do not + // count as overlapping. + const bool list = xref->m_properties.displayHas() + == XRefProperties::Contacts; QRectF rect = xref->sceneBoundingRect(); + if (list) + rect.adjust(list_margin_left, 0, -list_margin_right, 0); const qreal bottom = rect.bottom(); for (bool moved = true; moved; ) { moved = false; @@ -967,7 +978,7 @@ void CrossRefItem::drawAsContacts(QPainter &painter) drawLinkedSlaveContacts(painter, elmt)); } - bounding_rect.adjust(-30, -4, 4, 4); + bounding_rect.adjust(-list_margin_left, -4, list_margin_right, 4); prepareGeometryChange(); m_bounding_rect = bounding_rect; m_shape_path.addRect(bounding_rect);