| 639 | } |
| 640 | |
| 641 | LayerLoadStatus LayerManager::LoadLayer(const QJsonObject &json_layer_object, const Path &layer_path, LayerType type, |
| 642 | Version file_format_version, LayerDescriptor descriptor) { |
| 643 | Layer layer; |
| 644 | layer.type = type; |
| 645 | layer.manifest_path = layer_path; |
| 646 | layer.file_format_version = file_format_version; |
| 647 | layer.descriptor = descriptor; |
| 648 | |
| 649 | LayerLoadStatus status = layer.Load(json_layer_object); |
| 650 | if (status == LAYER_LOAD_INVALID || status == LAYER_LOAD_IGNORED) { |
| 651 | return status; |
| 652 | } |
| 653 | |
| 654 | Layer *duplicated_layer = this->Find(layer.GetId(), false); |
| 655 | if (duplicated_layer != nullptr) { |
| 656 | if (duplicated_layer->descriptor.removed) { |
| 657 | duplicated_layer->descriptor.removed = false; |
| 658 | duplicated_layer->descriptor.enabled = true; |
| 659 | } else if (duplicated_layer->descriptor.last_modified != layer.descriptor.last_modified) { |
| 660 | // Reload when the manifest was updated |
| 661 | LayerLoadStatus reloaded_status = duplicated_layer->Load(json_layer_object); |
| 662 | status = reloaded_status == LAYER_LOAD_ADDED ? LAYER_LOAD_RELOADED : reloaded_status; |
| 663 | } else { |
| 664 | status = LAYER_LOAD_UNMODIFIED; |
| 665 | } |
| 666 | } else { |
| 667 | this->available_layers.push_back(layer); |
| 668 | } |
| 669 | |
| 670 | return status; |
| 671 | } |
| 672 | |
| 673 | void LayerManager::RemoveLayer(LayerId id) { |
| 674 | Layer *layer = this->Find(id, false); |
no test coverage detected