| 270 | } |
| 271 | |
| 272 | bool PackProfile::load() |
| 273 | { |
| 274 | auto filename = componentsFilePath(); |
| 275 | QFile componentsFile(filename); |
| 276 | |
| 277 | // migrate old config to new one, if needed |
| 278 | if(!componentsFile.exists()) |
| 279 | { |
| 280 | if(!migratePreComponentConfig()) |
| 281 | { |
| 282 | // FIXME: the user should be notified... |
| 283 | qCritical() << "Failed to convert old pre-component config for instance" << d->m_instance->name(); |
| 284 | return false; |
| 285 | } |
| 286 | } |
| 287 | |
| 288 | // load the new component list and swap it with the current one... |
| 289 | ComponentContainer newComponents; |
| 290 | if(!loadPackProfile(this, filename, patchesPattern(), newComponents)) |
| 291 | { |
| 292 | qCritical() << "Failed to load the component config for instance" << d->m_instance->name(); |
| 293 | return false; |
| 294 | } |
| 295 | else |
| 296 | { |
| 297 | // FIXME: actually use fine-grained updates, not this... |
| 298 | beginResetModel(); |
| 299 | // disconnect all the old components |
| 300 | for(auto component: d->components) |
| 301 | { |
| 302 | disconnect(component.get(), &Component::dataChanged, this, &PackProfile::componentDataChanged); |
| 303 | } |
| 304 | d->components.clear(); |
| 305 | d->componentIndex.clear(); |
| 306 | for(auto component: newComponents) |
| 307 | { |
| 308 | if(d->componentIndex.contains(component->m_uid)) |
| 309 | { |
| 310 | qWarning() << "Ignoring duplicate component entry" << component->m_uid; |
| 311 | continue; |
| 312 | } |
| 313 | connect(component.get(), &Component::dataChanged, this, &PackProfile::componentDataChanged); |
| 314 | d->components.append(component); |
| 315 | d->componentIndex[component->m_uid] = component; |
| 316 | } |
| 317 | endResetModel(); |
| 318 | d->loaded = true; |
| 319 | return true; |
| 320 | } |
| 321 | } |
| 322 | |
| 323 | void PackProfile::reload(Net::Mode netmode) |
| 324 | { |
no test coverage detected