| 236 | } |
| 237 | |
| 238 | void InstanceList::setInstanceGroup(const InstanceId& id, GroupId name) |
| 239 | { |
| 240 | if (name.isEmpty() && !name.isNull()) |
| 241 | name = QString(); |
| 242 | |
| 243 | auto inst = getInstanceById(id); |
| 244 | if (!inst) { |
| 245 | qDebug() << "Attempt to set a null instance's group"; |
| 246 | return; |
| 247 | } |
| 248 | |
| 249 | bool changed = false; |
| 250 | auto iter = m_instanceGroupIndex.find(inst->id()); |
| 251 | if (iter != m_instanceGroupIndex.end()) { |
| 252 | if (*iter != name) { |
| 253 | decreaseGroupCount(*iter); |
| 254 | *iter = name; |
| 255 | changed = true; |
| 256 | } |
| 257 | } else { |
| 258 | changed = true; |
| 259 | m_instanceGroupIndex[id] = name; |
| 260 | } |
| 261 | |
| 262 | if (changed) { |
| 263 | increaseGroupCount(name); |
| 264 | auto idx = getInstIndex(inst); |
| 265 | emit dataChanged(index(idx), index(idx), { GroupRole }); |
| 266 | saveGroupList(); |
| 267 | } |
| 268 | } |
| 269 | |
| 270 | QStringList InstanceList::getGroups() |
| 271 | { |
no test coverage detected