From 67d4372ed58a33003819257910cb82b5d5e5876b Mon Sep 17 00:00:00 2001
From: John Robertson <jro@advops.com>
Date: Sat, 27 Dec 2025 20:44:35 -0700
Subject: [PATCH] include preservation of column order for the City Panel

---
 client/gui-qt/cityrep.cpp   | 8 +++-----
 client/gui-qt/fc_client.cpp | 8 +++++++-
 client/gui-qt/fc_client.h   | 3 +--
 3 files changed, 11 insertions(+), 8 deletions(-)

diff --git a/client/gui-qt/cityrep.cpp b/client/gui-qt/cityrep.cpp
index 37ebe17a35..bf0a285161 100644
--- a/client/gui-qt/cityrep.cpp
+++ b/client/gui-qt/cityrep.cpp
@@ -1214,8 +1214,7 @@ city_widget::~city_widget()
   delete c_i_d;
   delete list_model;
   delete filter_model;
-  gui()->qt_settings.city_repo_sort_col = header()->sortIndicatorSection();
-  gui()->qt_settings.city_report_sort = header()->sortIndicatorOrder();
+  gui()->qt_settings.city_repo_columns = header()->saveState();
 }
 
 /***********************************************************************//**
@@ -1225,9 +1224,8 @@ city_report::city_report(): QWidget()
 {
   layout = new QVBoxLayout;
   city_wdg = new city_widget(this);
-  if (gui()->qt_settings.city_repo_sort_col != -1) {
-    city_wdg->sortByColumn(gui()->qt_settings.city_repo_sort_col,
-                           gui()->qt_settings.city_report_sort);
+  if (!gui()->qt_settings.city_repo_columns.isEmpty()) {
+    city_wdg->header()->restoreState(gui()->qt_settings.city_repo_columns);
   }
   layout->addWidget(city_wdg);
   setLayout(layout);
diff --git a/client/gui-qt/fc_client.cpp b/client/gui-qt/fc_client.cpp
index 0eff5db65e..3f9cf1ace2 100644
--- a/client/gui-qt/fc_client.cpp
+++ b/client/gui-qt/fc_client.cpp
@@ -748,7 +748,12 @@ void fc_client::read_settings()
     qt_settings.battlelog_y = 0.0;
   }
   qt_settings.player_repo_sort_col = -1;
-  qt_settings.city_repo_sort_col = -1;
+
+  if (s.contains("city_repo_columns")) {
+    qt_settings.city_repo_columns = s.value("city_repo_columns").toByteArray();
+  } else {
+    qt_settings.city_repo_columns = QByteArray();
+  }
 
   if (qt_settings.chat_fx_pos < 0 || qt_settings.chat_fx_pos >= 1) {
     qt_settings.chat_fx_pos = 0.0;
@@ -813,6 +818,7 @@ void fc_client::write_settings()
   s.setValue("battlelog_y", qt_settings.battlelog_y);
   s.setValue("new_turn_text", qt_settings.show_new_turn_text);
   s.setValue("show_battle_log", qt_settings.show_battle_log);
+  s.setValue("city_repo_columns", qt_settings.city_repo_columns);
   write_shortcuts();
 }
 
diff --git a/client/gui-qt/fc_client.h b/client/gui-qt/fc_client.h
index ba93130a09..3d739b4830 100644
--- a/client/gui-qt/fc_client.h
+++ b/client/gui-qt/fc_client.h
@@ -128,8 +128,7 @@ struct fc_settings
   bool show_new_turn_text;
   bool show_battle_log;
   Qt::SortOrder player_report_sort;
-  int city_repo_sort_col;
-  Qt::SortOrder city_report_sort;
+  QByteArray city_repo_columns;
   QByteArray city_geometry;
   QByteArray city_splitter1;
   QByteArray city_splitter2;
-- 
2.43.0

