| 381 | } |
| 382 | |
| 383 | void WorkingSet::loadToArea(Sublime::Area* area) { |
| 384 | PushValue<bool> enableLoading(m_loading, true); |
| 385 | |
| 386 | /// We cannot disable the updates here, because (probably) due to a bug in Qt, |
| 387 | /// which causes the updates to stay disabled forever after some complex operations |
| 388 | /// on the sub-views. This could be reproduced by creating two working-sets with complex |
| 389 | /// split-view configurations and switching between them. Re-enabling the updates doesn't help. |
| 390 | // DisableMainWindowUpdatesFromArea updatesDisabler(area); |
| 391 | |
| 392 | qCDebug(WORKINGSET) << "loading working-set" << m_id << "into area" << area; |
| 393 | |
| 394 | QMultiMap<QString, Sublime::View*> recycle; |
| 395 | |
| 396 | const auto viewsBefore = area->views(); |
| 397 | for (Sublime::View* view : viewsBefore) { |
| 398 | recycle.insert( view->document()->documentSpecifier(), area->removeView(view) ); |
| 399 | } |
| 400 | |
| 401 | qCDebug(WORKINGSET) << "recycling up to" << recycle.size() << "old views"; |
| 402 | |
| 403 | Q_ASSERT( area->views().empty() ); |
| 404 | |
| 405 | KConfigGroup setConfig(Core::self()->activeSession()->config(), QStringLiteral("Working File Sets")); |
| 406 | KConfigGroup setGroup = setConfig.group(m_id); |
| 407 | |
| 408 | // Migrate from former by-area configs to a shared config |
| 409 | KConfigGroup areaGroup = setConfig.group(m_id + QLatin1Char('|') + area->title()); |
| 410 | if (areaGroup.exists()) { |
| 411 | if (setGroup.readEntry("Active View", QString()).isEmpty()) { |
| 412 | setGroup.writeEntry("Active View", areaGroup.readEntry("Active View", QString())); |
| 413 | } |
| 414 | int viewCount = setGroup.readEntry("View Count", 0); |
| 415 | QMultiMap<QString, KConfigGroup> oldViewConfigs; |
| 416 | for (int i = 0; i < viewCount; ++i) { |
| 417 | KConfigGroup viewGroup(&setGroup, QStringLiteral("View %1 Config").arg(i)); |
| 418 | auto specifier = setGroup.readEntry(QStringLiteral("View %1").arg(i), QString()); |
| 419 | if (viewGroup.exists() || specifier.isEmpty()) { |
| 420 | continue; |
| 421 | } |
| 422 | if (oldViewConfigs.empty()) { // cache all view configs from the old area config |
| 423 | int oldViewCount = areaGroup.readEntry("View Count", 0); |
| 424 | for (int j = 0; j < oldViewCount; ++j) { |
| 425 | auto oldSpecifier = areaGroup.readEntry(QStringLiteral("View %1").arg(j), QString()); |
| 426 | if (!oldSpecifier.isEmpty()) { |
| 427 | oldViewConfigs.insert(oldSpecifier, KConfigGroup(&areaGroup, QStringLiteral("View %1 Config").arg(j))); |
| 428 | } |
| 429 | } |
| 430 | } |
| 431 | auto it = oldViewConfigs.find(specifier); |
| 432 | if (it != oldViewConfigs.end()) { |
| 433 | viewGroup.copyTo(&(*it)); |
| 434 | oldViewConfigs.erase(it); |
| 435 | } |
| 436 | if (oldViewConfigs.empty()) { |
| 437 | break; |
| 438 | } |
| 439 | } |
| 440 | setConfig.deleteGroup(areaGroup.name()); |
no test coverage detected