From 22e1f9fa014290860383c050391f5f60a9f1986a Mon Sep 17 00:00:00 2001 From: Louis Moureaux Date: Sun, 14 Jul 2024 04:11:10 +0200 Subject: [PATCH] Fix wrapping redundant cities in the economics view We were resizing columns to avoid wrapping with resizeColumnsToContents, then resizing rows. This produced horizontal scrolling and strange behaviour when the redundant list got long. Fix this by: 1) Setting the last column (redundant cities) to use all remaining space, and 2) Adjusting the width of all columns except the last. Closes #2289. --- client/views/view_economics.cpp | 7 ++++++- client/views/view_economics.ui | 8 +++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/client/views/view_economics.cpp b/client/views/view_economics.cpp index 0313c7bf28..6532f48b12 100644 --- a/client/views/view_economics.cpp +++ b/client/views/view_economics.cpp @@ -185,8 +185,13 @@ void eco_report::update_report() .arg(QString::number(tax), QString::number(building_total + unit_total)); ui.eco_label->setText(buf); + + // Resize all columns except the last (which we want to wrap). + for (int i = 0; i < ui.eco_widget->columnCount() - 1; ++i) { + ui.eco_widget->resizeColumnToContents(i); + } + // Resize rows to let text wrap around. ui.eco_widget->resizeRowsToContents(); - ui.eco_widget->resizeColumnsToContents(); } /** diff --git a/client/views/view_economics.ui b/client/views/view_economics.ui index f6869cac0e..68abdccfca 100644 --- a/client/views/view_economics.ui +++ b/client/views/view_economics.ui @@ -73,6 +73,12 @@ QAbstractItemView::SelectRows + + QAbstractItemView::ScrollPerPixel + + + QAbstractItemView::ScrollPerPixel + false @@ -83,7 +89,7 @@ false - false + true false