Qt: Clean and remove empty game settings
This commit is contained in:
@ -135,6 +135,11 @@ void INISettingsInterface::Clear()
|
||||
m_ini.Reset();
|
||||
}
|
||||
|
||||
bool INISettingsInterface::IsEmpty()
|
||||
{
|
||||
return (m_ini.GetKeyCount() == 0);
|
||||
}
|
||||
|
||||
bool INISettingsInterface::GetIntValue(const char* section, const char* key, s32* value) const
|
||||
{
|
||||
const char* str_value = m_ini.GetValue(section, key);
|
||||
@ -279,6 +284,29 @@ void INISettingsInterface::ClearSection(const char* section)
|
||||
m_ini.SetValue(section, nullptr, nullptr);
|
||||
}
|
||||
|
||||
void INISettingsInterface::RemoveSection(const char* section)
|
||||
{
|
||||
if (!m_ini.GetSection(section))
|
||||
return;
|
||||
|
||||
m_dirty = true;
|
||||
m_ini.Delete(section, nullptr);
|
||||
}
|
||||
|
||||
void INISettingsInterface::RemoveEmptySections()
|
||||
{
|
||||
std::list<CSimpleIniA::Entry> entries;
|
||||
m_ini.GetAllSections(entries);
|
||||
for (const CSimpleIniA::Entry& entry : entries)
|
||||
{
|
||||
if (m_ini.GetSectionSize(entry.pItem) > 0)
|
||||
continue;
|
||||
|
||||
m_dirty = true;
|
||||
m_ini.Delete(entry.pItem, nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<std::string> INISettingsInterface::GetStringList(const char* section, const char* key) const
|
||||
{
|
||||
std::list<CSimpleIniA::Entry> entries;
|
||||
|
||||
@ -22,6 +22,7 @@ public:
|
||||
bool Save(Error* error = nullptr) override;
|
||||
|
||||
void Clear() override;
|
||||
bool IsEmpty() override;
|
||||
|
||||
bool GetIntValue(const char* section, const char* key, s32* value) const override;
|
||||
bool GetUIntValue(const char* section, const char* key, u32* value) const override;
|
||||
@ -40,6 +41,8 @@ public:
|
||||
bool ContainsValue(const char* section, const char* key) const override;
|
||||
void DeleteValue(const char* section, const char* key) override;
|
||||
void ClearSection(const char* section) override;
|
||||
void RemoveSection(const char* section) override;
|
||||
void RemoveEmptySections() override;
|
||||
|
||||
std::vector<std::string> GetStringList(const char* section, const char* key) const override;
|
||||
void SetStringList(const char* section, const char* key, const std::vector<std::string>& items) override;
|
||||
|
||||
Reference in New Issue
Block a user