| 289 | } |
| 290 | |
| 291 | PackProfile::Result PackProfile::load() |
| 292 | { |
| 293 | auto filename = componentsFilePath(); |
| 294 | |
| 295 | // load the new component list and swap it with the current one... |
| 296 | ComponentContainer newComponents; |
| 297 | if (auto result = loadPackProfile(this, filename, patchesPattern(), newComponents); !result) { |
| 298 | qCritical() << d->m_instance->name() << "|" << "Failed to load the component config"; |
| 299 | return result; |
| 300 | } |
| 301 | // FIXME: actually use fine-grained updates, not this... |
| 302 | beginResetModel(); |
| 303 | // disconnect all the old components |
| 304 | for (auto component : d->components) { |
| 305 | disconnect(component.get(), &Component::dataChanged, this, &PackProfile::componentDataChanged); |
| 306 | } |
| 307 | d->components.clear(); |
| 308 | d->componentIndex.clear(); |
| 309 | for (auto component : newComponents) { |
| 310 | if (d->componentIndex.contains(component->m_uid)) { |
| 311 | qWarning() << d->m_instance->name() << "|" << "Ignoring duplicate component entry" << component->m_uid; |
| 312 | continue; |
| 313 | } |
| 314 | connect(component.get(), &Component::dataChanged, this, &PackProfile::componentDataChanged); |
| 315 | d->components.append(component); |
| 316 | d->componentIndex[component->m_uid] = component; |
| 317 | } |
| 318 | endResetModel(); |
| 319 | d->loaded = true; |
| 320 | return Result::Success(); |
| 321 | } |
| 322 | |
| 323 | PackProfile::Result PackProfile::reload(Net::Mode netmode) |
| 324 | { |