| 173 | } |
| 174 | |
| 175 | void CheckSetSelectionManager::saveCheckSetSelections(QVector<CheckSetSelection>& checkSetSelections) |
| 176 | { |
| 177 | // TODO: do not save if locked by someone else -> needs passing of our lock? or just registering our own and check? |
| 178 | // create and set unique id |
| 179 | std::for_each(checkSetSelections.begin(), checkSetSelections.end(), [this](CheckSetSelection& checkSetSelection) { |
| 180 | const QString checkSetSelectionId = checkSetSelection.id(); |
| 181 | |
| 182 | bool needsId = true; |
| 183 | if (!checkSetSelectionId.isEmpty()) { |
| 184 | // already existing? |
| 185 | auto hasCheckSetSelectionId = [&checkSetSelectionId] (const CheckSetSelection& existingProfile) { |
| 186 | return (checkSetSelectionId == existingProfile.id()); |
| 187 | }; |
| 188 | if (std::any_of(m_checkSetSelections.constBegin(), m_checkSetSelections.constEnd(), hasCheckSetSelectionId)) { |
| 189 | needsId = false; |
| 190 | } |
| 191 | } |
| 192 | |
| 193 | // set new uuid for non-existing |
| 194 | if (needsId) { |
| 195 | checkSetSelection.setId(QUuid::createUuid().toString()); |
| 196 | } |
| 197 | |
| 198 | saveCheckSetSelection(checkSetSelection); |
| 199 | }); |
| 200 | } |
| 201 | |
| 202 | void CheckSetSelectionManager::removeCheckSetSelections(const QVector<QString>& checkSetSelectionIds) |
| 203 | { |