While the intent was good, saving column width/sort was unfortunately not handling the addition of new columns and old configs were losing columns. If this is restored, it should have some check on column with invalidation of config.
authornemo
Wed, 14 Mar 2018 11:36:43 -0400
changeset 13201 25502e6b3e08
parent 13200 a0ce9573bfe8
child 13202 2fe85d497e0f
While the intent was good, saving column width/sort was unfortunately not handling the addition of new columns and old configs were losing columns. If this is restored, it should have some check on column with invalidation of config.
QTfrontend/ui/page/pageroomslist.cpp
QTfrontend/ui/page/pageroomslist.h
--- a/QTfrontend/ui/page/pageroomslist.cpp	Wed Mar 14 16:25:54 2018 +0100
+++ b/QTfrontend/ui/page/pageroomslist.cpp	Wed Mar 14 11:36:43 2018 -0400
@@ -590,25 +590,16 @@
     h->setSortIndicator(RoomsListModel::StateColumn, Qt::AscendingOrder);
     h->setSectionResizeMode(RoomsListModel::NameColumn, QHeaderView::Stretch);
 
-    if (!restoreHeaderState())
-    {
-        h->resizeSection(RoomsListModel::PlayerCountColumn, 32);
-        h->resizeSection(RoomsListModel::TeamCountColumn, 32);
-        h->resizeSection(RoomsListModel::OwnerColumn, 100);
-        h->resizeSection(RoomsListModel::MapColumn, 100);
-        h->resizeSection(RoomsListModel::SchemeColumn, 100);
-        h->resizeSection(RoomsListModel::WeaponsColumn, 100);
-    }
+	h->resizeSection(RoomsListModel::PlayerCountColumn, 32);
+	h->resizeSection(RoomsListModel::TeamCountColumn, 32);
+	h->resizeSection(RoomsListModel::OwnerColumn, 100);
+	h->resizeSection(RoomsListModel::MapColumn, 100);
+	h->resizeSection(RoomsListModel::SchemeColumn, 100);
+	h->resizeSection(RoomsListModel::WeaponsColumn, 100);
 
     // hide column used for filtering
     roomsList->hideColumn(RoomsListModel::StateColumn);
 
-    // save header state on change
-    connect(roomsList->horizontalHeader(), SIGNAL(sortIndicatorChanged(int, Qt::SortOrder)),
-            this, SLOT(saveHeaderState()));
-    connect(roomsList->horizontalHeader(), SIGNAL(sectionResized(int, int, int)),
-            this, SLOT(saveHeaderState()));
-
     roomsList->repaint();
 }
 
@@ -671,27 +662,3 @@
 {
     m_gameSettings = settings;
 }
-
-bool PageRoomsList::restoreHeaderState()
-{
-    if (m_gameSettings->contains("frontend/roomslist_splitter"))
-    {
-        m_splitter->restoreState(QByteArray::fromBase64(
-            (m_gameSettings->value("frontend/roomslist_splitter").toByteArray())));
-    }
-
-    if (m_gameSettings->contains("frontend/roomslist_header"))
-    {
-        return roomsList->horizontalHeader()->restoreState(QByteArray::fromBase64(
-            (m_gameSettings->value("frontend/roomslist_header").toByteArray())));
-    } else return false;
-}
-
-void PageRoomsList::saveHeaderState()
-{
-    m_gameSettings->setValue("frontend/roomslist_header",
-        QString(roomsList->horizontalHeader()->saveState().toBase64()));
-
-    m_gameSettings->setValue("frontend/roomslist_splitter",
-        QString(m_splitter->saveState().toBase64()));
-}
--- a/QTfrontend/ui/page/pageroomslist.h	Wed Mar 14 16:25:54 2018 +0100
+++ b/QTfrontend/ui/page/pageroomslist.h	Wed Mar 14 11:36:43 2018 -0400
@@ -84,7 +84,6 @@
         void onJoinConfirmation(const QString &);
         void onSortIndicatorChanged(int logicalIndex, Qt::SortOrder order);
         void onFilterChanged();
-        void saveHeaderState();
         void onRoomNameChosen(const QString &, const QString &password);
         void roomSelectionChanged(const QModelIndex &, const QModelIndex &);
         void moveSelectionUp();