SkylandersPortalWindow: Mark helpers as const/static where applicable

These helpers don't directly modify class state.
This commit is contained in:
Lioncash 2023-11-25 21:44:04 -05:00
parent 6d47d6c08e
commit 24c009f7ce
2 changed files with 19 additions and 19 deletions

View File

@ -875,7 +875,7 @@ void SkylanderPortalWindow::UpdateSlotNames()
} }
// Helpers // Helpers
bool SkylanderPortalWindow::PassesFilter(QString name, u16 id, u16 var) bool SkylanderPortalWindow::PassesFilter(const QString& name, u16 id, u16 var) const
{ {
const auto skypair = IOS::HLE::USB::list_skylanders.find(std::make_pair(id, var)); const auto skypair = IOS::HLE::USB::list_skylanders.find(std::make_pair(id, var));
IOS::HLE::USB::SkyData character; IOS::HLE::USB::SkyData character;
@ -916,7 +916,7 @@ bool SkylanderPortalWindow::PassesFilter(QString name, u16 id, u16 var)
return true; return true;
} }
QString SkylanderPortalWindow::GetFilePath(u16 id, u16 var) QString SkylanderPortalWindow::GetFilePath(u16 id, u16 var) const
{ {
const QDir collection = QDir(m_collection_path); const QDir collection = QDir(m_collection_path);
auto& system = Core::System::GetInstance(); auto& system = Core::System::GetInstance();
@ -938,12 +938,12 @@ QString SkylanderPortalWindow::GetFilePath(u16 id, u16 var)
return file.filePath(); return file.filePath();
} }
} }
return QString(); return {};
} }
u8 SkylanderPortalWindow::GetCurrentSlot() u8 SkylanderPortalWindow::GetCurrentSlot() const
{ {
for (auto radio : m_slot_radios) for (const auto* radio : m_slot_radios)
{ {
if (radio->isChecked()) if (radio->isChecked())
{ {
@ -953,9 +953,9 @@ u8 SkylanderPortalWindow::GetCurrentSlot()
return 0; return 0;
} }
int SkylanderPortalWindow::GetElementRadio() int SkylanderPortalWindow::GetElementRadio() const
{ {
for (auto radio : m_element_filter) for (const auto* radio : m_element_filter)
{ {
if (radio->isChecked()) if (radio->isChecked())
{ {
@ -965,9 +965,9 @@ int SkylanderPortalWindow::GetElementRadio()
return -1; return -1;
} }
int SkylanderPortalWindow::GetTypeRadio() int SkylanderPortalWindow::GetTypeRadio() const
{ {
for (auto radio : m_type_filter) for (const auto* radio : m_type_filter)
{ {
if (radio->isChecked()) if (radio->isChecked())
{ {
@ -984,7 +984,7 @@ QBrush SkylanderPortalWindow::GetBaseColor(std::pair<const u16, const u16> ids,
if (skylander == IOS::HLE::USB::list_skylanders.end()) if (skylander == IOS::HLE::USB::list_skylanders.end())
return QBrush(dark_theme ? QColor(32, 32, 32) : QColor(255, 255, 255)); return QBrush(dark_theme ? QColor(32, 32, 32) : QColor(255, 255, 255));
switch ((*skylander).second.game) switch (skylander->second.game)
{ {
case Game::SpyrosAdv: case Game::SpyrosAdv:
return QBrush(dark_theme ? QColor(10, 42, 90) : QColor(240, 255, 240)); return QBrush(dark_theme ? QColor(10, 42, 90) : QColor(240, 255, 240));

View File

@ -76,15 +76,15 @@ private:
void UpdateSlotNames(); void UpdateSlotNames();
// Helpers // Helpers
bool PassesFilter(QString name, u16 id, u16 var); bool PassesFilter(const QString& name, u16 id, u16 var) const;
QString GetFilePath(u16 id, u16 var); QString GetFilePath(u16 id, u16 var) const;
u8 GetCurrentSlot(); u8 GetCurrentSlot() const;
int GetElementRadio(); int GetElementRadio() const;
int GetTypeRadio(); int GetTypeRadio() const;
QBrush GetBaseColor(std::pair<const u16, const u16> ids, bool dark_theme); static QBrush GetBaseColor(std::pair<const u16, const u16> ids, bool dark_theme);
int GetGameID(Game game); static int GetGameID(Game game);
int GetElementID(Element elem); static int GetElementID(Element elem);
int GetTypeID(Type type); static int GetTypeID(Type type);
bool m_emulating; bool m_emulating;
QCheckBox* m_enabled_checkbox; QCheckBox* m_enabled_checkbox;