| 228 | } |
| 229 | |
| 230 | void InstanceList::setInstanceGroup(const InstanceId& id, const GroupId& name) |
| 231 | { |
| 232 | auto inst = getInstanceById(id); |
| 233 | if (!inst) { |
| 234 | qDebug() << "Attempt to set a null instance's group"; |
| 235 | return; |
| 236 | } |
| 237 | |
| 238 | bool changed = false; |
| 239 | auto iter = m_instanceGroupIndex.find(inst->id()); |
| 240 | if (iter != m_instanceGroupIndex.end()) { |
| 241 | if (*iter != name) { |
| 242 | *iter = name; |
| 243 | changed = true; |
| 244 | } |
| 245 | } else { |
| 246 | changed = true; |
| 247 | m_instanceGroupIndex[id] = name; |
| 248 | } |
| 249 | |
| 250 | if (changed) { |
| 251 | m_groupNameCache.insert(name); |
| 252 | auto idx = getInstIndex(inst.get()); |
| 253 | emit dataChanged(index(idx), index(idx), { GroupRole }); |
| 254 | saveGroupList(); |
| 255 | } |
| 256 | } |
| 257 | |
| 258 | QStringList InstanceList::getGroups() |
| 259 | { |