src/documentmanager.cpp

changeset 329
6d75fa09cc0c
parent 328
3ea38fd469ca
child 333
07e65a4c6611
equal deleted inserted replaced
328:3ea38fd469ca 329:6d75fa09cc0c
333 } 333 }
334 }; 334 };
335 QObject::connect(model, &Model::dataChanged, modelModified); 335 QObject::connect(model, &Model::dataChanged, modelModified);
336 QObject::connect(model, &Model::rowsInserted, modelModified); 336 QObject::connect(model, &Model::rowsInserted, modelModified);
337 QObject::connect(model, &Model::rowsRemoved, modelModified); 337 QObject::connect(model, &Model::rowsRemoved, modelModified);
338 QObject::connect(model, &Model::modelReset, modelModified);
338 } 339 }
339 } 340 }
340 341
341 static QString findFile( 342 static QString findFile(
342 QString referenceName, 343 QString referenceName,
401 DocumentManager* documents, 402 DocumentManager* documents,
402 const LibrariesModel* libraries, 403 const LibrariesModel* libraries,
403 std::map<QString, QString>& missing) 404 std::map<QString, QString>& missing)
404 { 405 {
405 bool repeat = true; 406 bool repeat = true;
407 const auto olddeps = info->dependencies;
406 info->dependencies.clear(); 408 info->dependencies.clear();
407 while (repeat) { 409 while (repeat) {
408 repeat = false; 410 repeat = false;
409 const std::set<Dependency> dependencies = resolveReferencePaths(info, libraries); 411 const std::set<Dependency> dependencies = resolveReferencePaths(info, libraries);
410 for (const Dependency& dep : dependencies) { 412 for (const Dependency& dep : dependencies) {
411 if (not info->dependencies.contains(dep.name) and not missing.contains(dep.path)) { 413 const ModelId* const idp = findInMap(olddeps, dep.name);
414 if (idp != nullptr) {
415 info->dependencies[dep.name] = *idp;
416 }
417 else if (not info->dependencies.contains(dep.name) and not missing.contains(dep.path)) {
412 QString loadErrorString; 418 QString loadErrorString;
413 QTextStream localErrorStream{&loadErrorString}; 419 QTextStream localErrorStream{&loadErrorString};
414 const std::optional<ModelId> modelIdOpt = documents->openModel( 420 const std::optional<ModelId> modelIdOpt = documents->openModel(
415 dep.path, 421 dep.path,
416 localErrorStream, 422 localErrorStream,
417 OpenType::AutomaticallyOpened); 423 OpenType::AutomaticallyOpened);
418 if (not modelIdOpt.has_value()) { 424 if (not modelIdOpt.has_value()) {
419 const QString& errorMessage = QObject::tr("could not load '%1': %2") 425 const QString& errorMessage = QObject::tr("could not load '%1': %2")
420 .arg(dep.path, loadErrorString); 426 .arg(dep.path, loadErrorString);
421 missing[dep.path] = errorMessage; 427 missing[dep.path] = errorMessage;
422 } 428 }
423 else { 429 else {
424 info->dependencies[dep.name] = modelIdOpt.value(); 430 info->dependencies[dep.name] = modelIdOpt.value();
425 repeat = true; 431 repeat = true;

mercurial