diff options
-rw-r--r-- | backend-shared/exportfuncs.cpp | 7 | ||||
-rw-r--r-- | backend-shared/exportfuncs.h | 2 | ||||
-rw-r--r-- | desktop-widgets/divelogexportdialog.cpp | 6 |
3 files changed, 11 insertions, 4 deletions
diff --git a/backend-shared/exportfuncs.cpp b/backend-shared/exportfuncs.cpp index af6379001..7f15886db 100644 --- a/backend-shared/exportfuncs.cpp +++ b/backend-shared/exportfuncs.cpp @@ -29,7 +29,7 @@ bool ExportCallback::canceled() const } #if !defined(SUBSURFACE_MOBILE) -void exportProfile(QString filename, bool selected_only) +void exportProfile(QString filename, bool selected_only, ExportCallback &cb) { struct dive *dive; int i; @@ -38,9 +38,14 @@ void exportProfile(QString filename, bool selected_only) filename = filename.append(".png"); QFileInfo fi(filename); + int todo = selected_only ? amount_selected : dive_table.nr; + int done = 0; for_each_dive (i, dive) { + if (cb.canceled()) + return; if (selected_only && !dive->selected) continue; + cb.setProgress(done++ * 1000 / todo); if (count) exportProfile(dive, fi.path() + QDir::separator() + fi.completeBaseName().append(QString("-%1.").arg(count)) + fi.suffix()); else diff --git a/backend-shared/exportfuncs.h b/backend-shared/exportfuncs.h index 3eb83c9b1..ed483f90d 100644 --- a/backend-shared/exportfuncs.h +++ b/backend-shared/exportfuncs.h @@ -13,7 +13,7 @@ struct ExportCallback { virtual bool canceled() const; }; -void exportProfile(QString filename, bool selected_only); +void exportProfile(QString filename, bool selected_only, ExportCallback &cb); void export_TeX(const char *filename, bool selected_only, bool plain, ExportCallback &cb); void export_depths(const char *filename, bool selected_only); std::vector<const dive_site *> getDiveSitesToExport(bool selectedOnly); diff --git a/desktop-widgets/divelogexportdialog.cpp b/desktop-widgets/divelogexportdialog.cpp index 7d9a6d6ca..164ae0434 100644 --- a/desktop-widgets/divelogexportdialog.cpp +++ b/desktop-widgets/divelogexportdialog.cpp @@ -222,8 +222,10 @@ void DiveLogExportDialog::on_buttonBox_accepted() } } else if (ui->exportProfile->isChecked()) { filename = QFileDialog::getSaveFileName(this, tr("Save profile image"), lastDir); - if (!filename.isEmpty()) - exportProfile(qPrintable(filename), ui->exportSelected->isChecked()); + if (!filename.isEmpty()) { + ProgressDialogCallback cb; + exportProfile(qPrintable(filename), ui->exportSelected->isChecked(), cb); + } } else if (ui->exportProfileData->isChecked()) { filename = QFileDialog::getSaveFileName(this, tr("Save profile data"), lastDir); if (!filename.isEmpty()) |