| 124 | } |
| 125 | |
| 126 | void Project::loadJSON(const QJsonObject& obj, const QFileInfo& fi, ConfigWindow* configWindow, QStringList& warnings) |
| 127 | { |
| 128 | int version = obj["version"].toInt(); |
| 129 | |
| 130 | QString basePath = fi.absolutePath() + "/"; |
| 131 | |
| 132 | auto of = obj["openFiles"].toArray(); |
| 133 | for (auto file : of) { |
| 134 | auto path = basePath + file.toString(); |
| 135 | if (QFileInfo(path).exists()) { |
| 136 | openTabs << path; |
| 137 | } else { |
| 138 | warnings << "The file " + file.toString() + " could not be found"; |
| 139 | } |
| 140 | } |
| 141 | |
| 142 | openTabIndex = obj["openTab"].toInt(); |
| 143 | |
| 144 | QList<SolverConfiguration*> configs; |
| 145 | if (obj["builtinSolverConfigs"].isArray()) { |
| 146 | for (auto config : obj["builtinSolverConfigs"].toArray()) { |
| 147 | if (!config.isObject()) { |
| 148 | warnings << "Failed to read solver builtin solver config"; |
| 149 | continue; |
| 150 | } |
| 151 | try { |
| 152 | SolverConfiguration* loaded; |
| 153 | if (version >= 106) { |
| 154 | loaded = new (SolverConfiguration) (SolverConfiguration::loadJSON(QJsonDocument(config.toObject()), warnings)); |
| 155 | } else { |
| 156 | loaded = new (SolverConfiguration) (SolverConfiguration::loadLegacy(QJsonDocument(config.toObject()), warnings)); |
| 157 | } |
| 158 | loaded->isBuiltin = true; |
| 159 | configs << loaded; |
| 160 | } catch (Exception& e) { |
| 161 | warnings << e.message(); |
| 162 | } |
| 163 | } |
| 164 | } |
| 165 | |
| 166 | if (obj["projectSolverConfigs"].isArray()) { |
| 167 | for (auto config : obj["projectSolverConfigs"].toArray()) { |
| 168 | if (!config.isObject()) { |
| 169 | warnings << "Failed to read solver project solver config"; |
| 170 | continue; |
| 171 | } |
| 172 | try { |
| 173 | auto loaded = new (SolverConfiguration) (SolverConfiguration::loadLegacy(QJsonDocument(config.toObject()), warnings)); |
| 174 | loaded->modified = true; |
| 175 | configs << loaded; |
| 176 | } catch (Exception& e) { |
| 177 | warnings << e.message(); |
| 178 | } |
| 179 | } |
| 180 | } |
| 181 | |
| 182 | configWindow->mergeConfigs(configs); |
| 183 |
nothing calls this directly
no test coverage detected