From 36ab4833c96bf9568e7fb06880c01729f2c75ece Mon Sep 17 00:00:00 2001 From: Michael Weghorn Date: Sat, 7 Dec 2024 20:02:08 +0100 Subject: [PATCH] tdf#130857 qt weld: Implement QtInstanceTreeView::columns_autosize QTreeView::resizeColumnToContents [1] looks like the Qt equivalent for GTK's gtk_tree_view_columns_autosize [2]. [1] https://doc.qt.io/qt-6/qtreeview.html#resizeColumnToContents [2] https://docs.gtk.org/gtk3/method.TreeView.columns_autosize.html Change-Id: I4771896fb932834f51fa48ceaa3557181f474fcc Reviewed-on: https://gerrit.libreoffice.org/c/core/+/178062 Tested-by: Jenkins Reviewed-by: Michael Weghorn --- vcl/qt5/QtInstanceTreeView.cxx | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/vcl/qt5/QtInstanceTreeView.cxx b/vcl/qt5/QtInstanceTreeView.cxx index 23fe407e8033..d65bcdd4746e 100644 --- a/vcl/qt5/QtInstanceTreeView.cxx +++ b/vcl/qt5/QtInstanceTreeView.cxx @@ -653,7 +653,15 @@ int QtInstanceTreeView::get_height_rows(int) const return 0; } -void QtInstanceTreeView::columns_autosize() { assert(false && "Not implemented yet"); } +void QtInstanceTreeView::columns_autosize() +{ + SolarMutexGuard g; + + GetQtInstance().RunInMainThread([&] { + for (int i = 0; i < m_pModel->columnCount(); i++) + m_pTreeView->resizeColumnToContents(i); + }); +} void QtInstanceTreeView::set_column_fixed_widths(const std::vector&) {