vcl/qt5/QtInstanceTreeView.cxx |    4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

New commits:
commit 8ebcedc3562514bfe48a3bec19324503f619738b
Author:     Michael Weghorn <[email protected]>
AuthorDate: Wed Aug 13 11:14:17 2025 +0200
Commit:     Michael Weghorn <[email protected]>
CommitDate: Wed Aug 13 21:47:36 2025 +0200

    tdf#130857 qt weld: Simplify QtInstanceTreeView::set_cursor
    
    Instead of going via the selection model, use
    QAbstractItemView::setCurrentIndex [1] which also
    takes care of setting the selection. Quoting from
    the doc:
    
    > Unless the current selection mode is NoSelection, the item is also
    > selected. Note that this function also updates the starting position for
    > any new selections the user performs.
    
    The scenario described in
    
        commit 08c8f9483312b531d7184785633f8121821d9725
        Author: Michael Weghorn <[email protected]>
        Date:   Fri Feb 21 19:42:57 2025 +0100
    
            tdf#130857 qt weld: Also select item in 
QtInstanceTreeView::set_cursor
    
    still behaves the same.
    
    Using QAbstractItemView::setCurrentIndex also aligns
    this with the upcoming implementation for
    QtInstanceTreeView::get_cursor which will use
    QAbstractItemView::currentIndex [2].
    
    [1] https://doc.qt.io/qt-6/qabstractitemview.html#setCurrentIndex
    [2] https://doc.qt.io/qt-6/qabstractitemview.html#currentIndex
    
    Change-Id: If179b7714b0498e99cd0dbed9f14a3085eb47623
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/189504
    Tested-by: Jenkins
    Reviewed-by: Michael Weghorn <[email protected]>

diff --git a/vcl/qt5/QtInstanceTreeView.cxx b/vcl/qt5/QtInstanceTreeView.cxx
index fc2598750707..0ba4934380b3 100644
--- a/vcl/qt5/QtInstanceTreeView.cxx
+++ b/vcl/qt5/QtInstanceTreeView.cxx
@@ -366,9 +366,7 @@ void QtInstanceTreeView::set_cursor(const weld::TreeIter& 
rIter)
 {
     SolarMutexGuard g;
 
-    GetQtInstance().RunInMainThread([&] {
-        m_pSelectionModel->setCurrentIndex(modelIndex(rIter), 
QItemSelectionModel::Select);
-    });
+    GetQtInstance().RunInMainThread([&] { 
m_pTreeView->setCurrentIndex(modelIndex(rIter)); });
 }
 
 bool QtInstanceTreeView::get_iter_first(weld::TreeIter& rIter) const

Reply via email to