| 303 | } |
| 304 | |
| 305 | bool PackProfile::load() |
| 306 | { |
| 307 | auto filename = componentsFilePath(); |
| 308 | |
| 309 | // load the new component list and swap it with the current one... |
| 310 | ComponentContainer newComponents; |
| 311 | if(!loadPackProfile(this, filename, patchesPattern(), newComponents)) |
| 312 | { |
| 313 | qCritical() << "Failed to load the component config for instance" << d->m_instance->name(); |
| 314 | return false; |
| 315 | } |
| 316 | else |
| 317 | { |
| 318 | // FIXME: actually use fine-grained updates, not this... |
| 319 | beginResetModel(); |
| 320 | // disconnect all the old components |
| 321 | for(auto component: d->components) |
| 322 | { |
| 323 | disconnect(component.get(), &Component::dataChanged, this, &PackProfile::componentDataChanged); |
| 324 | } |
| 325 | d->components.clear(); |
| 326 | d->componentIndex.clear(); |
| 327 | for(auto component: newComponents) |
| 328 | { |
| 329 | if(d->componentIndex.contains(component->m_uid)) |
| 330 | { |
| 331 | qWarning() << "Ignoring duplicate component entry" << component->m_uid; |
| 332 | continue; |
| 333 | } |
| 334 | connect(component.get(), &Component::dataChanged, this, &PackProfile::componentDataChanged); |
| 335 | d->components.append(component); |
| 336 | d->componentIndex[component->m_uid] = component; |
| 337 | } |
| 338 | endResetModel(); |
| 339 | d->loaded = true; |
| 340 | return true; |
| 341 | } |
| 342 | } |
| 343 | |
| 344 | void PackProfile::reload(Net::Mode netmode) |
| 345 | { |
no test coverage detected