From 4625964bb1177df2c0cd463e16c36c9fa47db3e5 Mon Sep 17 00:00:00 2001 From: ispyisail Date: Thu, 18 Jun 2026 21:09:49 +1200 Subject: [PATCH 1/2] Fix #159: reset unused-element highlight when elements become used again ElementsCollectionModel::highlightUnusedElement() only ever painted the currently-unused elements red; it never cleared the background of items that were no longer unused. So when an element was re-added to a project and saved, its red 'unused' highlight persisted until the model was rebuilt from scratch. Reset every item's background before re-applying the highlight to the current unused set. --- sources/ElementsCollection/elementscollectionmodel.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/sources/ElementsCollection/elementscollectionmodel.cpp b/sources/ElementsCollection/elementscollectionmodel.cpp index a55eb523e..ae687da72 100644 --- a/sources/ElementsCollection/elementscollectionmodel.cpp +++ b/sources/ElementsCollection/elementscollectionmodel.cpp @@ -538,6 +538,11 @@ QList ElementsCollectionModel::project() const */ void ElementsCollectionModel::highlightUnusedElement() { + //Reset the background of every item first, so elements that are no + //longer unused lose their previous red highlight (issue #159). + for (ElementCollectionItem *eci : items()) + eci->setBackground(QBrush()); + QList unused; foreach (QETProject *project, m_project_list) From 8791d2d202c49d9882b4e92d670a59f8fb9b3549 Mon Sep 17 00:00:00 2001 From: ispyisail Date: Thu, 18 Jun 2026 22:29:42 +1200 Subject: [PATCH 2/2] Highlight reset: only clear the red unused-highlight Per review (plc-user): scope the reset to items currently painted with the red Dense4Pattern instead of clearing every item's background. This avoids clobbering other backgrounds (e.g. the amber "show this dir" highlight) and skips needless item updates on large collections. --- .../ElementsCollection/elementscollectionmodel.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/sources/ElementsCollection/elementscollectionmodel.cpp b/sources/ElementsCollection/elementscollectionmodel.cpp index ae687da72..8eeac33a6 100644 --- a/sources/ElementsCollection/elementscollectionmodel.cpp +++ b/sources/ElementsCollection/elementscollectionmodel.cpp @@ -538,10 +538,15 @@ QList ElementsCollectionModel::project() const */ void ElementsCollectionModel::highlightUnusedElement() { - //Reset the background of every item first, so elements that are no - //longer unused lose their previous red highlight (issue #159). + //Reset only the items currently highlighted in red, so elements that + //are no longer unused lose the highlight. Scoping to the red + //Dense4Pattern avoids touching other backgrounds (e.g. the amber + //"show this dir" highlight) and avoids needless updates on big + //collections (issue #159). for (ElementCollectionItem *eci : items()) - eci->setBackground(QBrush()); + if (eci->background().style() == Qt::Dense4Pattern && + eci->background().color() == Qt::red) + eci->setBackground(QBrush()); QList unused;