| 149 | LayerManager::LayerManager() {} |
| 150 | |
| 151 | bool LayerManager::Load(const QJsonObject &json_root_object, ConfiguratorMode configurator_mode) { |
| 152 | this->available_layers.clear(); |
| 153 | |
| 154 | // LAYERS_PATHS_GUI |
| 155 | if (json_root_object.value("layers") != QJsonValue::Undefined) { |
| 156 | const QJsonObject &json_layers_object = json_root_object.value("layers").toObject(); |
| 157 | |
| 158 | if (json_layers_object.value("last_layers_dir") != QJsonValue::Undefined) { |
| 159 | this->last_layers_dir = json_layers_object.value("last_layers_dir").toString().toStdString(); |
| 160 | } |
| 161 | |
| 162 | if (json_layers_object.value("validate_manifests") != QJsonValue::Undefined) { |
| 163 | this->validate_manifests = json_layers_object.value("validate_manifests").toBool(); |
| 164 | } |
| 165 | |
| 166 | if (json_layers_object.value("found") != QJsonValue::Undefined) { |
| 167 | const QJsonObject &json_layers_found_object = json_layers_object.value("found").toObject(); |
| 168 | const QStringList &json_layers_found_keys = json_layers_found_object.keys(); |
| 169 | |
| 170 | for (int i = 0, n = json_layers_found_keys.length(); i < n; ++i) { |
| 171 | const QJsonObject &json_status_object = json_layers_found_object.value(json_layers_found_keys[i]).toObject(); |
| 172 | |
| 173 | LayerDisplay layer; |
| 174 | layer.id.manifest_path = json_layers_found_keys[i].toStdString(); |
| 175 | layer.descriptor.enabled = !json_status_object.value("disabled").toBool(); |
| 176 | layer.descriptor.validated = LAYER_VALIDATE_NONE; |
| 177 | |
| 178 | std::vector<LayerDisplay> layers; |
| 179 | layers.push_back(layer); |
| 180 | this->AppendInit(layer.id.manifest_path, layers); |
| 181 | } |
| 182 | } |
| 183 | } |
| 184 | |
| 185 | this->LoadAllInstalledLayers(configurator_mode); |
| 186 | |
| 187 | return true; |
| 188 | } |
| 189 | |
| 190 | bool LayerManager::Save(QJsonObject &json_root_object) const { |
| 191 | QJsonObject json_layers_object; |
no test coverage detected