| 598 | |
| 599 | |
| 600 | bool MapEditorController::exportTo(const QString& path, const FileFormat& format) |
| 601 | { |
| 602 | if (!map || editing_in_progress) |
| 603 | return false; |
| 604 | |
| 605 | auto exporter = format.makeExporter(path, map, main_view); |
| 606 | if (!exporter) |
| 607 | { |
| 608 | auto message = |
| 609 | tr("Cannot export the map as\n" |
| 610 | "\"%1\"\n" |
| 611 | "because saving as %2 (.%3) is not supported."). |
| 612 | arg(path, |
| 613 | format.description(), |
| 614 | format.fileExtensions().join(QLatin1String(", ")) ); |
| 615 | QMessageBox::warning(nullptr, tr("Error"), message); |
| 616 | return false; |
| 617 | } |
| 618 | |
| 619 | if (!exporter->doExport()) |
| 620 | { |
| 621 | auto message = tr("Cannot save file\n%1:\n%2") |
| 622 | .arg(path, exporter->warnings().back()); |
| 623 | QMessageBox::warning(nullptr, tr("Error"), message); |
| 624 | return false; |
| 625 | } |
| 626 | |
| 627 | if (!exporter->warnings().empty()) |
| 628 | { |
| 629 | MainWindow::showMessageBox(nullptr, |
| 630 | tr("Warning"), |
| 631 | tr("The map export generated warnings."), |
| 632 | exporter->warnings() ); |
| 633 | } |
| 634 | |
| 635 | return true; |
| 636 | } |
| 637 | |
| 638 | |
| 639 | bool MapEditorController::loadFrom(const QString& path, const FileFormat& format, QWidget* dialog_parent) |
no test coverage detected