Auto scroll to constraint on click (#18859)

* Auto scroll to constraint on click

When clicking on a contrasint in Sketcher, that constraint is now
automatically scrolled to in the Constraints listview. If selecting
multiple constraints, the last one is scrolled to.
Closes #17361

* Check model() for nullptr

* scrollTo only on select, not de-select #18859
This commit is contained in:
Beep6581
2025-01-21 18:33:51 +01:00
committed by GitHub
parent 1ae8524dce
commit a1f5d36584

View File

@@ -1371,6 +1371,10 @@ void TaskSketcherConstraints::onSelectionChanged(const Gui::SelectionChanges& ms
auto tmpBlock = ui->listWidgetConstraints->blockSignals(true);
item->setSelected(select);
ui->listWidgetConstraints->blockSignals(tmpBlock);
if (select && ui->listWidgetConstraints->model()) { // scrollTo only on select, not de-select
QModelIndex index = ui->listWidgetConstraints->model()->index(i, 0);
ui->listWidgetConstraints->scrollTo(index, QAbstractItemView::PositionAtCenter);
}
break;
}
}