Qt: Fix that some columns are not hidden properly

This commit is contained in:
spycrab 2017-05-10 11:04:21 +02:00
parent d21f1b24f8
commit 4d4dc03801
1 changed files with 13 additions and 8 deletions

View File

@ -9,6 +9,7 @@
#include <QFileInfo> #include <QFileInfo>
#include <QHeaderView> #include <QHeaderView>
#include <QKeyEvent> #include <QKeyEvent>
#include <QMap>
#include <QMenu> #include <QMenu>
#include <QMessageBox> #include <QMessageBox>
#include <QProgressDialog> #include <QProgressDialog>
@ -392,14 +393,18 @@ void GameList::keyReleaseEvent(QKeyEvent* event)
void GameList::OnColumnVisibilityToggled(const QString& row, bool visible) void GameList::OnColumnVisibilityToggled(const QString& row, bool visible)
{ {
for (int i = 0; i < m_table->model()->columnCount(); i++) static const QMap<QString, int> rowname_to_col_index = {
{ {tr("Banner"), GameListModel::COL_BANNER},
if (m_table->model()->headerData(i, Qt::Horizontal).toString() == row) {tr("Country"), GameListModel::COL_COUNTRY},
{ {tr("Description"), GameListModel::COL_DESCRIPTION},
m_table->setColumnHidden(i, !visible); {tr("ID"), GameListModel::COL_ID},
return; {tr("Maker"), GameListModel::COL_MAKER},
} {tr("Platform"), GameListModel::COL_PLATFORM},
} {tr("Size"), GameListModel::COL_SIZE},
{tr("Title"), GameListModel::COL_TITLE},
{tr("Quality"), GameListModel::COL_RATING}};
m_table->setColumnHidden(rowname_to_col_index[row], !visible);
} }
static bool CompressCB(const std::string& text, float percent, void* ptr) static bool CompressCB(const std::string& text, float percent, void* ptr)