diff options
author | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2021-05-01 21:21:50 +0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2021-05-06 08:21:04 -0700 |
commit | 38d0fac2d1a074ac7de23ebb61ea06adc32cd30f (patch) | |
tree | c7208bc0d0d56b8f294efdf4958bdc1a4db74895 /backend-shared | |
parent | 9ee8807af7276ee8a910561f671a8cd1936babf9 (diff) | |
download | subsurface-38d0fac2d1a074ac7de23ebb61ea06adc32cd30f.tar.gz |
export: show progress dialog for profile exports
Simply reuse QProgressDialog interface for the TeX exports.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'backend-shared')
-rw-r--r-- | backend-shared/exportfuncs.cpp | 7 | ||||
-rw-r--r-- | backend-shared/exportfuncs.h | 2 |
2 files changed, 7 insertions, 2 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); |