| 57 | } |
| 58 | |
| 59 | void encode(KConfig* config, const EnvironmentProfileListPrivate* d) |
| 60 | { |
| 61 | KConfigGroup cfg(config, Strings::envGroup()); |
| 62 | cfg.writeEntry(Strings::defaultEnvProfileKey(), d->m_defaultProfileName); |
| 63 | cfg.writeEntry(Strings::profileListKey(), d->m_profiles.keys()); |
| 64 | const auto oldGroupList = cfg.groupList(); |
| 65 | for (const QString& group : oldGroupList) { |
| 66 | if (!d->m_profiles.contains(group)) { |
| 67 | cfg.deleteGroup(group); |
| 68 | } |
| 69 | } |
| 70 | |
| 71 | for (auto it = d->m_profiles.cbegin(), itEnd = d->m_profiles.cend(); it != itEnd; ++it) { |
| 72 | KConfigGroup envgrp(&cfg, it.key()); |
| 73 | envgrp.deleteGroup(); |
| 74 | |
| 75 | const auto val = it.value(); |
| 76 | for (auto it2 = val.cbegin(), it2End = val.cend(); it2 != it2End; ++it2) { |
| 77 | envgrp.writeEntry(it2.key(), *it2); |
| 78 | } |
| 79 | } |
| 80 | |
| 81 | cfg.sync(); |
| 82 | } |
| 83 | |
| 84 | } |
| 85 |
no test coverage detected