Qt: speed up list refresh

This commit is contained in:
Megamouse 2020-08-06 12:17:54 +02:00
parent e6e753f37f
commit 715f4f0669
3 changed files with 22 additions and 11 deletions

View File

@ -94,6 +94,7 @@ game_list_frame::game_list_frame(std::shared_ptr<gui_settings> gui_settings, std
m_game_list->setAlternatingRowColors(true);
m_game_list->installEventFilter(this);
m_game_list->setColumnCount(gui::column_count);
m_game_list->horizontalHeader()->setSectionResizeMode(gui::column_icon, QHeaderView::Fixed);
m_game_compat = new game_compatibility(m_gui_settings, this);
@ -363,7 +364,9 @@ void game_list_frame::SortGameList()
// Fixate vertical header and row height
m_game_list->verticalHeader()->setMinimumSectionSize(m_icon_size.height());
m_game_list->verticalHeader()->setMaximumSectionSize(m_icon_size.height());
m_game_list->resizeRowsToContents();
// Removed for better performance. I can't see any visual difference with and without this code
// m_game_list->resizeRowsToContents();
// Resize columns if the game list was empty before
if (!old_row_count && !old_game_count)
@ -375,9 +378,6 @@ void game_list_frame::SortGameList()
m_game_list->resizeColumnToContents(gui::column_icon);
}
// Fixate icon column
m_game_list->horizontalHeader()->setSectionResizeMode(gui::column_icon, QHeaderView::Fixed);
// Shorten the last section to remove horizontal scrollbar if possible
m_game_list->resizeColumnToContents(gui::column_count - 1);
}

View File

@ -372,7 +372,14 @@ void save_manager_dialog::UpdateIcons()
icon_item->setData(Qt::DecorationRole, scaled[i]);
}
m_list->resizeRowsToContents();
// Fixate vertical header and row height
m_list->verticalHeader()->setMinimumSectionSize(m_icon_size.height());
m_list->verticalHeader()->setMaximumSectionSize(m_icon_size.height());
// Removed for better performance. I can't see any visual difference with and without this code
// m_list->resizeRowsToContents();
// Resize icon column
m_list->resizeColumnToContents(0);
}

View File

@ -89,6 +89,7 @@ trophy_manager_dialog::trophy_manager_dialog(std::shared_ptr<gui_settings> gui_s
m_game_table->setHorizontalHeaderLabels(QStringList{ tr("Icon"), tr("Game"), tr("Progress") });
m_game_table->horizontalHeader()->setDefaultAlignment(Qt::AlignLeft);
m_game_table->horizontalHeader()->setStretchLastSection(true);
m_game_table->horizontalHeader()->setSectionResizeMode(GameColumns::GameIcon, QHeaderView::Fixed);
m_game_table->verticalHeader()->setSectionResizeMode(QHeaderView::Fixed);
m_game_table->verticalHeader()->setVisible(false);
m_game_table->setAlternatingRowColors(true);
@ -110,6 +111,7 @@ trophy_manager_dialog::trophy_manager_dialog(std::shared_ptr<gui_settings> gui_s
m_trophy_table->setHorizontalHeaderLabels(QStringList{ tr("Icon"), tr("Name"), tr("Description"), tr("Type"), tr("Status"), tr("ID"), tr("Platinum Relevant") });
m_trophy_table->horizontalHeader()->setDefaultAlignment(Qt::AlignLeft);
m_trophy_table->horizontalHeader()->setStretchLastSection(true);
m_trophy_table->horizontalHeader()->setSectionResizeMode(TrophyColumns::Icon, QHeaderView::Fixed);
m_trophy_table->verticalHeader()->setVisible(false);
m_trophy_table->verticalHeader()->setSectionResizeMode(QHeaderView::Fixed);
m_trophy_table->setContextMenuPolicy(Qt::CustomContextMenu);
@ -886,11 +888,12 @@ void trophy_manager_dialog::ReadjustGameTable()
// Fixate vertical header and row height
m_game_table->verticalHeader()->setMinimumSectionSize(m_game_icon_size.height());
m_game_table->verticalHeader()->setMaximumSectionSize(m_game_icon_size.height());
m_game_table->resizeRowsToContents();
// Resize and fixate icon column
// Removed for better performance. I can't see any visual difference with and without this code
// m_game_table->resizeRowsToContents();
// Resize icon column
m_game_table->resizeColumnToContents(GameColumns::GameIcon);
m_game_table->horizontalHeader()->setSectionResizeMode(GameColumns::GameIcon, QHeaderView::Fixed);
// Shorten the last section to remove horizontal scrollbar if possible
m_game_table->resizeColumnToContents(GameColumns::GameColumnsCount - 1);
@ -901,11 +904,12 @@ void trophy_manager_dialog::ReadjustTrophyTable()
// Fixate vertical header and row height
m_trophy_table->verticalHeader()->setMinimumSectionSize(m_icon_height);
m_trophy_table->verticalHeader()->setMaximumSectionSize(m_icon_height);
m_trophy_table->resizeRowsToContents();
// Resize and fixate icon column
// Removed for better performance. I can't see any visual difference with and without this code
// m_trophy_table->resizeRowsToContents();
// Resize icon column
m_trophy_table->resizeColumnToContents(TrophyColumns::Icon);
m_trophy_table->horizontalHeader()->setSectionResizeMode(TrophyColumns::Icon, QHeaderView::Fixed);
// Shorten the last section to remove horizontal scrollbar if possible
m_trophy_table->resizeColumnToContents(TrophyColumns::Count - 1);