vcl/inc/qt5/QtInstanceTreeView.hxx |    2 +-
 vcl/qt5/QtInstanceTreeView.cxx     |   11 ++++++++---
 2 files changed, 9 insertions(+), 4 deletions(-)

New commits:
commit 254743e93f67fb6d623b659b33a8c78387f23a1a
Author:     Michael Weghorn <m.wegh...@posteo.de>
AuthorDate: Sat Dec 7 23:29:44 2024 +0100
Commit:     Michael Weghorn <m.wegh...@posteo.de>
CommitDate: Sun Dec 8 09:55:44 2024 +0100

    tdf#130857 qt weld: Implement QtInstanceTreeView::remove
    
    Side note: In Writer's "Tool" > "XML Filter Settings" dialog,
    trying to always delete the first entry works 3 times
    (when using a fresh profile), but doing it again after then
    doesn't remove the entry from the treeview, but the entry is
    still gone when closing and reopening the dialog.
    
    That's the same with gtk3 however, weld::TreeView::remove
    doesn't get called. So it's not a problem in the weld::TreeView
    implementations, but probably in XMLFilterSettingsDialog
    or some other underlying logic.
    
    Change-Id: Ic91b3d1d62b66574b9e0710b17b2d9606d27a0fb
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/178068
    Reviewed-by: Michael Weghorn <m.wegh...@posteo.de>
    Tested-by: Jenkins

diff --git a/vcl/inc/qt5/QtInstanceTreeView.hxx 
b/vcl/inc/qt5/QtInstanceTreeView.hxx
index 110bc09c8bd2..a57734ed9079 100644
--- a/vcl/inc/qt5/QtInstanceTreeView.hxx
+++ b/vcl/inc/qt5/QtInstanceTreeView.hxx
@@ -42,7 +42,7 @@ public:
     virtual int get_selected_index() const override;
     virtual void select(int nPos) override;
     virtual void unselect(int nPos) override;
-    virtual void remove(int pos) override;
+    virtual void remove(int nPos) override;
     virtual OUString get_text(int nRow, int nCol = -1) const override;
     virtual void set_text(int nRow, const OUString& rText, int nCol = -1) 
override;
     virtual void set_sensitive(int row, bool bSensitive, int col = -1) 
override;
diff --git a/vcl/qt5/QtInstanceTreeView.cxx b/vcl/qt5/QtInstanceTreeView.cxx
index 34bf6dee0c13..613987c44a80 100644
--- a/vcl/qt5/QtInstanceTreeView.cxx
+++ b/vcl/qt5/QtInstanceTreeView.cxx
@@ -142,7 +142,12 @@ void QtInstanceTreeView::unselect(int nPos)
     });
 }
 
-void QtInstanceTreeView::remove(int) { assert(false && "Not implemented yet"); 
}
+void QtInstanceTreeView::remove(int nPos)
+{
+    SolarMutexGuard g;
+
+    GetQtInstance().RunInMainThread([&] { m_pModel->removeRow(nPos); });
+}
 
 OUString QtInstanceTreeView::get_text(int nRow, int nCol) const
 {
commit 044f2113dc3f5e76fa3b56e57823c9c9b7f390b6
Author:     Michael Weghorn <m.wegh...@posteo.de>
AuthorDate: Sat Dec 7 23:13:25 2024 +0100
Commit:     Michael Weghorn <m.wegh...@posteo.de>
CommitDate: Sun Dec 8 09:55:36 2024 +0100

    tdf#130857 qt weld: Report selected tree view row only once
    
    Now that support for multiple columns has been implemented
    in QtInstanceTreeView, iterating over all selected model
    indices and appending their row index to the vector
    results in the row being appended once fore each column
    of the selected row. (Index seen twice in `aRows` in
    XMLFilterSettingsDialog::updateStates while debugging
    another issue in the "Tools" > "XML Filter Settings" dialog
    with the qt6 VCL plugin and SAL_VCL_QT_USE_WELDED_WIDGETS=1).
    
    Use QItemSelectionModel::selectedRows (with the default column
    index of 0) instead of QItemSelectionModel::selectedIndexes
    to prevent that.
    
    Change-Id: Ic8caa299549d954ed844c39c4b2ba957edf2b404
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/178067
    Tested-by: Jenkins
    Reviewed-by: Michael Weghorn <m.wegh...@posteo.de>

diff --git a/vcl/qt5/QtInstanceTreeView.cxx b/vcl/qt5/QtInstanceTreeView.cxx
index 8e26055cf1f9..34bf6dee0c13 100644
--- a/vcl/qt5/QtInstanceTreeView.cxx
+++ b/vcl/qt5/QtInstanceTreeView.cxx
@@ -236,7 +236,7 @@ std::vector<int> QtInstanceTreeView::get_selected_rows() 
const
     std::vector<int> aSelectedRows;
 
     GetQtInstance().RunInMainThread([&] {
-        const QModelIndexList aSelectionIndexes = 
m_pSelectionModel->selection().indexes();
+        const QModelIndexList aSelectionIndexes = 
m_pSelectionModel->selectedRows();
         for (const QModelIndex& aIndex : aSelectionIndexes)
             aSelectedRows.push_back(aIndex.row());
     });
commit 9c334767305ec0b24bdf05f3eb3df1fa41aa330c
Author:     Michael Weghorn <m.wegh...@posteo.de>
AuthorDate: Sat Dec 7 23:02:08 2024 +0100
Commit:     Michael Weghorn <m.wegh...@posteo.de>
CommitDate: Sun Dec 8 09:55:29 2024 +0100

    tdf#130857 qt weld: Fix incorrect param order for row/col
    
    In QtInstanceTreeView::get_id, the nPos param is the
    row number, but was incorrectly passed as the
    second parameter to QStandardItemModel::index [1]
    which is for the column. Swap the params to fix that.
    
    Passing incorrectly would trigger a crash in a WIP branch
    for Writer's "Tools" -> "XML Filter Settings" dialog when
    clicking on the second row, as the ID data is only set
    for the item in the first, not the second column,
    so `pInfo` in XMLFilterSettingsDialog::updateStates
    would be null.
    
    Backtrace:
    
        1 XMLFilterSettingsDialog::updateStates xmlfiltersettingsdialog.cxx 183 
0x7f3eb862194e
        2 XMLFilterSettingsDialog::SelectionChangedHdl_Impl 
xmlfiltersettingsdialog.cxx 153 0x7f3eb8621859
        3 XMLFilterSettingsDialog::LinkStubSelectionChangedHdl_Impl 
xmlfiltersettingsdialog.cxx 151 0x7f3eb861e8cd
        4 Link<weld::TreeView&, void>::Call link.hxx 111 0x7f3eeb997aa1
        5 weld::TreeView::signal_selection_changed weld.hxx 989 0x7f3eeb99733c
        6 QtInstanceTreeView::handleSelectionChanged QtInstanceTreeView.cxx 781 
0x7f3eeb98cb2d
        7 QtPrivate::FunctorCall<std::integer_sequence<unsigned long>, 
QtPrivate::List<>, void, void (QtInstanceTreeView:: *)()>::call(void 
(QtInstanceTreeView:: *)(), QtInstanceTreeView *, void * 
*)::{lambda()#1}::operator()() const qobjectdefs_impl.h 127 0x7f3eeb998141
        8 QtPrivate::FunctorCallBase::call_internal<void, 
QtPrivate::FunctorCall<std::integer_sequence<unsigned long>, QtPrivate::List<>, 
void, void (QtInstanceTreeView:: *)()>::call(void (QtInstanceTreeView:: *)(), 
QtInstanceTreeView *, void * *)::{lambda()#1}>(void * *, 
QtPrivate::FunctorCall<std::integer_sequence<unsigned long>, QtPrivate::List<>, 
void, void (QtInstanceTreeView:: *)()>::call(void (QtInstanceTreeView:: *)(), 
QtInstanceTreeView *, void * *)::{lambda()#1}&&) qobjectdefs_impl.h 65 
0x7f3eeb998079
        9 QtPrivate::FunctorCall<std::integer_sequence<unsigned long>, 
QtPrivate::List<>, void, void (QtInstanceTreeView:: *)()>::call(void 
(QtInstanceTreeView:: *)(), QtInstanceTreeView *, void * *) qobjectdefs_impl.h 
126 0x7f3eeb997fab
        10 QtPrivate::FunctionPointer<void (QtInstanceTreeView:: 
*)()>::call<QtPrivate::List<>, void>(void (QtInstanceTreeView:: *)(), 
QtInstanceTreeView *, void * *) qobjectdefs_impl.h 174 0x7f3eeb997f2d
        11 QtPrivate::QCallableObject<void (QtInstanceTreeView:: *)(), 
QtPrivate::List<>, void>::impl(int, QtPrivate::QSlotObjectBase *, QObject *, 
void * *, bool *) qobjectdefs_impl.h 545 0x7f3eeb997e56
        12 QtPrivate::QSlotObjectBase::call qobjectdefs_impl.h 461 
0x7f3eeaa5ce22
        13 doActivate<false> qobject.cpp 4139 0x7f3eeab1c644
        14 QMetaObject::activate qobject.cpp 4199 0x7f3eeab121b3
        15 QMetaObject::activate<void, QItemSelection, QItemSelection> 
qobjectdefs.h 306 0x7f3eeaf93da5
        16 QItemSelectionModel::selectionChanged moc_qitemselectionmodel.cpp 
390 0x7f3eeaf85b76
        17 QItemSelectionModel::emitSelectionChanged qitemselectionmodel.cpp 
2029 0x7f3eeaf87a2f
        18 QItemSelectionModel::select qitemselectionmodel.cpp 1372 
0x7f3eeaf872f9
        19 QTreeViewPrivate::select qtreeview.cpp 4016 0x7f3ee906f2ec
        20 QTreeView::setSelection qtreeview.cpp 2393 0x7f3ee906eaae
        ... <More>
    
    Change-Id: Icf6b3004ab95991da69c0ff86201421d620aaa43
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/178066
    Reviewed-by: Michael Weghorn <m.wegh...@posteo.de>
    Tested-by: Jenkins

diff --git a/vcl/qt5/QtInstanceTreeView.cxx b/vcl/qt5/QtInstanceTreeView.cxx
index 10fb36413f6f..8e26055cf1f9 100644
--- a/vcl/qt5/QtInstanceTreeView.cxx
+++ b/vcl/qt5/QtInstanceTreeView.cxx
@@ -301,7 +301,7 @@ OUString QtInstanceTreeView::get_id(int nPos) const
 
     OUString sId;
     GetQtInstance().RunInMainThread([&] {
-        QVariant aRoleData = m_pModel->data(m_pModel->index(0, nPos), ROLE_ID);
+        QVariant aRoleData = m_pModel->data(m_pModel->index(nPos, 0), ROLE_ID);
         if (aRoleData.canConvert<QString>())
             sId = toOUString(aRoleData.toString());
     });

Reply via email to