diff --git a/src/TrajectoriesTreeModel.cpp b/src/TrajectoriesTreeModel.cpp index 656fb61..28550fe 100644 --- a/src/TrajectoriesTreeModel.cpp +++ b/src/TrajectoriesTreeModel.cpp @@ -307,10 +307,11 @@ QString TrajectoriesTreeModel::dumpTabSeparatedData() const QProgressDialog progress("Generating the table...", "Cancel", 0, indexes.size()); progress.setWindowModality(Qt::ApplicationModal); - progress.setWindowTitle("Saving results..."); + progress.setWindowTitle("Generating the table..."); progress.setValue(0); for (const auto &idx : indexes) { if (progress.wasCanceled()) { + result.clear(); break; } TrajectoriesTreeItem *parentItem; diff --git a/src/gui/mainwindow.cpp b/src/gui/mainwindow.cpp index 8279853..11e7bb8 100644 --- a/src/gui/mainwindow.cpp +++ b/src/gui/mainwindow.cpp @@ -410,6 +410,12 @@ bool MainWindow::exportData(const QString &fileName) return false; } QString s = trajectoriesModel.dumpTabSeparatedData(); + if (s.isEmpty()) { + file.remove(); + statusBar()->showMessage(tr("Export cancelled").arg(fileName), + 5000); + return false; + } QStringList lines = s.split('\n'); QProgressDialog dlg; dlg.setLabelText("Saving the file..."); @@ -417,9 +423,13 @@ bool MainWindow::exportData(const QString &fileName) dlg.setRange(0, lines.size()); dlg.setWindowModality(Qt::WindowModal); dlg.show(); - dlg.setCancelButton(0); QTextStream out(&file); for (int i = 0; i < lines.size(); ++i) { + if (dlg.wasCanceled()) { + statusBar()->showMessage( + tr("Export cancelled").arg(fileName), 5000); + return false; + } out << lines[i] << "\n"; dlg.setValue(i); }