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.weghorn@posteo.de>
This commit is contained in:
Michael Weghorn 2024-12-07 23:13:25 +01:00
parent 9c33476730
commit 044f2113dc

View file

@ -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());
});