GeckoCodeWidget: Add a Sort button

This commit is contained in:
Justin Futrell 2018-05-20 11:04:30 +02:00 committed by Léo Lam
parent fc525bdf8f
commit c7f0c7484d
2 changed files with 11 additions and 0 deletions

View File

@ -66,6 +66,7 @@ void GeckoCodeWidget::CreateWidgets()
m_edit_code = new QPushButton(tr("&Edit Code..."));
m_remove_code = new QPushButton(tr("&Remove Code"));
m_download_codes = new QPushButton(tr("Download Codes"));
m_sort_codes = new QPushButton(tr("Sort Codes"));
m_download_codes->setToolTip(tr("Download Codes from the WiiRD Database"));
@ -102,6 +103,7 @@ void GeckoCodeWidget::CreateWidgets()
btn_layout->addWidget(m_edit_code);
btn_layout->addWidget(m_remove_code);
btn_layout->addWidget(m_download_codes);
btn_layout->addWidget(m_sort_codes);
layout->addLayout(btn_layout);
@ -118,6 +120,7 @@ void GeckoCodeWidget::ConnectWidgets()
connect(m_remove_code, &QPushButton::pressed, this, &GeckoCodeWidget::RemoveCode);
connect(m_edit_code, &QPushButton::pressed, this, &GeckoCodeWidget::EditCode);
connect(m_download_codes, &QPushButton::pressed, this, &GeckoCodeWidget::DownloadCodes);
connect(m_sort_codes, &QPushButton::pressed, this, &GeckoCodeWidget::SortCodesLexicographically);
connect(m_warning, &CheatWarningWidget::OpenCheatEnableSettings, this,
&GeckoCodeWidget::OpenGeneralSettings);
@ -221,6 +224,12 @@ void GeckoCodeWidget::SaveCodes()
game_ini_local.Save(File::GetUserPath(D_GAMESETTINGS_IDX) + m_game_id + ".ini");
}
void GeckoCodeWidget::SortCodesLexicographically()
{
m_code_list->setSortingEnabled(!m_code_list->isSortingEnabled());
GeckoCodeWidget::UpdateList();
}
void GeckoCodeWidget::UpdateList()
{
m_code_list->clear();

View File

@ -46,6 +46,7 @@ private:
void RemoveCode();
void DownloadCodes();
void SaveCodes();
void SortCodesLexicographically();
const UICommon::GameFile& m_game;
std::string m_game_id;
@ -61,6 +62,7 @@ private:
QPushButton* m_edit_code;
QPushButton* m_remove_code;
QPushButton* m_download_codes;
QPushButton* m_sort_codes;
std::vector<Gecko::GeckoCode> m_gecko_codes;
bool m_restart_required;
};