Skip to content

Commit

Permalink
Fix wrapping redundant cities in the economics view
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
lmoureaux authored and jwrober committed Jul 14, 2024
1 parent 427df5a commit 22e1f9f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
7 changes: 6 additions & 1 deletion client/views/view_economics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

/**
Expand Down
8 changes: 7 additions & 1 deletion client/views/view_economics.ui
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,12 @@
<property name="selectionBehavior">
<enum>QAbstractItemView::SelectRows</enum>
</property>
<property name="verticalScrollMode">
<enum>QAbstractItemView::ScrollPerPixel</enum>
</property>
<property name="horizontalScrollMode">
<enum>QAbstractItemView::ScrollPerPixel</enum>
</property>
<property name="showGrid">
<bool>false</bool>
</property>
Expand All @@ -83,7 +89,7 @@
<bool>false</bool>
</attribute>
<attribute name="horizontalHeaderStretchLastSection">
<bool>false</bool>
<bool>true</bool>
</attribute>
<attribute name="verticalHeaderVisible">
<bool>false</bool>
Expand Down

0 comments on commit 22e1f9f

Please sign in to comment.