Qt: Fix game list sorting by column

This commit is contained in:
Connor McLaughlin 2020-03-02 11:08:20 +10:00
parent 69f03959aa
commit c8954a3089

View file

@ -232,7 +232,7 @@ public:
const QVariant left = source_left.data(Qt::InitialSortOrderRole); const QVariant left = source_left.data(Qt::InitialSortOrderRole);
const QVariant right = source_right.data(Qt::InitialSortOrderRole); const QVariant right = source_right.data(Qt::InitialSortOrderRole);
if (left != right) if (left != right)
return ascending ? (left < right) : (right < left); return ascending ? (left < right) : (right > left);
// fallback to sorting by title for equal items // fallback to sorting by title for equal items
return m_model->titlesLessThan(source_left.row(), source_right.row(), ascending); return m_model->titlesLessThan(source_left.row(), source_right.row(), ascending);
@ -270,6 +270,9 @@ void GameListWidget::initialize(QtHostInterface* host_interface)
m_table_view->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn); m_table_view->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
m_table_view->resizeColumnsToContents(); m_table_view->resizeColumnsToContents();
// sort by disc type, then title
m_table_sort_model->sort(0, Qt::AscendingOrder);
connect(m_table_view->selectionModel(), &QItemSelectionModel::currentChanged, this, connect(m_table_view->selectionModel(), &QItemSelectionModel::currentChanged, this,
&GameListWidget::onSelectionModelCurrentChanged); &GameListWidget::onSelectionModelCurrentChanged);
connect(m_table_view, &QTableView::doubleClicked, this, &GameListWidget::onTableViewItemDoubleClicked); connect(m_table_view, &QTableView::doubleClicked, this, &GameListWidget::onTableViewItemDoubleClicked);