| 214 | } |
| 215 | |
| 216 | void InstanceList::setInstanceGroup(const InstanceId& id, const GroupId& name) |
| 217 | { |
| 218 | auto inst = getInstanceById(id); |
| 219 | if(!inst) |
| 220 | { |
| 221 | qDebug() << "Attempt to set a null instance's group"; |
| 222 | return; |
| 223 | } |
| 224 | |
| 225 | bool changed = false; |
| 226 | auto iter = m_instanceGroupIndex.find(inst->id()); |
| 227 | if(iter != m_instanceGroupIndex.end()) |
| 228 | { |
| 229 | if(*iter != name) |
| 230 | { |
| 231 | *iter = name; |
| 232 | changed = true; |
| 233 | } |
| 234 | } |
| 235 | else |
| 236 | { |
| 237 | changed = true; |
| 238 | m_instanceGroupIndex[id] = name; |
| 239 | } |
| 240 | |
| 241 | if(changed) |
| 242 | { |
| 243 | m_groupNameCache.insert(name); |
| 244 | auto idx = getInstIndex(inst.get()); |
| 245 | emit dataChanged(index(idx), index(idx), {GroupRole}); |
| 246 | saveGroupList(); |
| 247 | } |
| 248 | } |
| 249 | |
| 250 | QStringList InstanceList::getGroups() |
| 251 | { |