| 2175 | } |
| 2176 | |
| 2177 | void MainWindow::saveProject(const QString& f) |
| 2178 | { |
| 2179 | QString filepath = f; |
| 2180 | if (filepath.isEmpty()) { |
| 2181 | filepath = QFileDialog::getSaveFileName(this, "Save project", getLastPath(), "MiniZinc projects (*.mzp)"); |
| 2182 | if (!filepath.isNull()) { |
| 2183 | setLastPath(QFileInfo(filepath).absolutePath() + fileDialogSuffix); |
| 2184 | } |
| 2185 | } |
| 2186 | if (filepath.isEmpty()) { |
| 2187 | return; |
| 2188 | } |
| 2189 | |
| 2190 | auto& p = getProject(); |
| 2191 | if (p.projectFile() != filepath && IDE::instance()->projects.contains(filepath)) { |
| 2192 | QMessageBox::warning(this,"MiniZinc IDE","Cannot overwrite existing open project.", |
| 2193 | QMessageBox::Ok); |
| 2194 | return; |
| 2195 | } |
| 2196 | |
| 2197 | if (p.projectFile() != filepath) { |
| 2198 | IDE::instance()->projects.remove(p.projectFile()); |
| 2199 | IDE::instance()->projects.insert(filepath, this); |
| 2200 | p.projectFile(filepath); |
| 2201 | } |
| 2202 | p.openTabsChanged(getOpenFiles(), ui->tabWidget->currentIndex()); |
| 2203 | p.activeSolverConfigChanged(getCurrentSolverConfig()); |
| 2204 | try { |
| 2205 | p.saveProject(); |
| 2206 | } catch (FileError& f) { |
| 2207 | QMessageBox::critical(this, "MiniZinc IDE", f.message(), QMessageBox::Ok); |
| 2208 | } |
| 2209 | |
| 2210 | updateRecentProjects(p.projectFile()); |
| 2211 | } |
| 2212 | |
| 2213 | void MainWindow::loadProject(const QString& filepath) |
| 2214 | { |
nothing calls this directly
no test coverage detected