| 211 | } |
| 212 | |
| 213 | void Project::saveProject() |
| 214 | { |
| 215 | QJsonObject confObject; |
| 216 | confObject["version"] = 106; |
| 217 | |
| 218 | // Save the currently open tabs |
| 219 | QStringList of; |
| 220 | for (auto& f: openTabs) { |
| 221 | of << relativeToProject(f); |
| 222 | } |
| 223 | confObject["openFiles"] = QJsonArray::fromStringList(of); |
| 224 | confObject["openTab"] = openTabIndex; |
| 225 | |
| 226 | // Save paths of all project files |
| 227 | QStringList relativeFilePaths; |
| 228 | for (auto& file : files()) { |
| 229 | relativeFilePaths << relativeToProject(file); |
| 230 | } |
| 231 | confObject["projectFiles"] = QJsonArray::fromStringList(relativeFilePaths); |
| 232 | |
| 233 | // Save which config is currently selected |
| 234 | if (!selectedBuiltinConfigId.isEmpty() && !selectedBuiltinConfigVersion.isEmpty()) { |
| 235 | confObject["selectedBuiltinConfigId"] = selectedBuiltinConfigId; |
| 236 | confObject["selectedBuiltinConfigVersion"] = selectedBuiltinConfigVersion; |
| 237 | } else if (!selectedSolverConfigFile.isEmpty()){ |
| 238 | confObject["selectedSolverConfigFile"] = selectedSolverConfigFile; |
| 239 | } |
| 240 | |
| 241 | // Write project file |
| 242 | QJsonDocument doc(confObject); |
| 243 | QFile file(projectFile()); |
| 244 | if (!file.open(QFile::WriteOnly)) { |
| 245 | throw FileError("Failed to write file"); |
| 246 | } |
| 247 | file.write(doc.toJson()); |
| 248 | file.close(); |
| 249 | |
| 250 | setModified(false); |
| 251 | } |
| 252 | |
| 253 | void Project::add(const QString& fileName) |
| 254 | { |