Bladeren bron

UI: Don't reselect SceneTree items if tree is clearing

In the scene tree, we currently prevent deselecting items by
automatically reselecting a new one to workaround a regression in Qt 6.2
that would let users unselect items even in SingleSelection QItemViews.
When clearing however, we explicitly want to unselect the currently
selected item, so we should avoid reselecting it in the SceneTree.
gxalpha 3 jaren geleden
bovenliggende
commit
dc30cf0843
2 gewijzigde bestanden met toevoegingen van 6 en 1 verwijderingen
  1. 4 0
      UI/item-widget-helpers.cpp
  2. 2 1
      UI/scene-tree.cpp

+ 4 - 0
UI/item-widget-helpers.cpp

@@ -37,10 +37,14 @@ void DeleteListItem(QListWidget *widget, QListWidgetItem *item)
 
 
 void ClearListItems(QListWidget *widget)
 void ClearListItems(QListWidget *widget)
 {
 {
+	// Workaround for the SceneTree workaround for QTBUG-105870
+	widget->setProperty("clearing", true);
+
 	widget->setCurrentItem(nullptr, QItemSelectionModel::Clear);
 	widget->setCurrentItem(nullptr, QItemSelectionModel::Clear);
 
 
 	for (int i = 0; i < widget->count(); i++)
 	for (int i = 0; i < widget->count(); i++)
 		delete widget->itemWidget(widget->item(i));
 		delete widget->itemWidget(widget->item(i));
 
 
 	widget->clear();
 	widget->clear();
+	widget->setProperty("clearing", false);
 }
 }

+ 2 - 1
UI/scene-tree.cpp

@@ -252,6 +252,7 @@ void SceneTree::rowsInserted(const QModelIndex &parent, int start, int end)
 void SceneTree::selectionChanged(const QItemSelection &selected,
 void SceneTree::selectionChanged(const QItemSelection &selected,
 				 const QItemSelection &deselected)
 				 const QItemSelection &deselected)
 {
 {
-	if (selected.count() == 0 && deselected.count() > 0)
+	if (selected.count() == 0 && deselected.count() > 0 &&
+	    !property("clearing").toBool())
 		setCurrentRow(deselected.indexes().front().row());
 		setCurrentRow(deselected.indexes().front().row());
 }
 }