mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-10-05 18:54:14 +02:00
Tested in list display on a real project: neighbouring references on the same row were raised alternately (980 / 927 / 980...) although nothing visibly overlapped.
Linux build and tests / Build and test (Qt 6, Debug) (push) Failing after 1m52s
Linux build and tests / Build and test (Qt 6, Debug) (push) Failing after 1m52s
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]
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user