UI: FirewallConf: Simplify toVariant().

This commit is contained in:
Nodir Temirkhodjaev 2021-05-15 20:25:30 +03:00
parent 60d80bbed5
commit 8e3440511a

View File

@ -406,23 +406,26 @@ QVariant FirewallConf::toVariant(bool onlyFlags) const
{ {
QVariantMap map; QVariantMap map;
const uint flags = onlyFlags ? editedFlags() : AllEdited;
if (onlyFlags) { if (onlyFlags) {
map = editedFlagsToVariant(m_editedFlags).toMap(); map = editedFlagsToVariant(flags).toMap();
} }
if (!onlyFlags || optEdited()) { if ((flags & OptEdited) != 0) {
map["addressGroups"] = addressesToVariant(); map["addressGroups"] = addressesToVariant();
map["appGroups"] = appGroupsToVariant(); map["appGroups"] = appGroupsToVariant();
map["removedAppGroupIdList"] = removedAppGroupIdListToVariant(); map["removedAppGroupIdList"] = removedAppGroupIdListToVariant();
} }
if (!onlyFlags || flagsEdited()) { if ((flags & FlagsEdited) != 0) {
map["flags"] = flagsToVariant(); map["flags"] = flagsToVariant();
} }
if (!onlyFlags || iniEdited()) { if ((flags & IniEdited) != 0) {
if (!ini().map().isEmpty()) { const auto map = ini().map();
map["ini"] = ini().map(); if (!map.isEmpty()) {
map["ini"] = map;
} }
} }