From 2ec570098b61d0ca9685420c82724633928192dc Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Thu, 6 Feb 2020 22:38:29 +0100 Subject: Cleanup: remove exportFunc class exportFunc was a collections of functions for exporting dive data. It had no state, therefore there is no reason for it to ever be instantiated. Simply remove the class. Rename the saveProfile function to exportProfile so that all export functions start with "export". Signed-off-by: Berthold Stoeger --- backend-shared/exportfuncs.cpp | 28 +++++++++++--------------- backend-shared/exportfuncs.h | 45 ++++++++++++++++-------------------------- 2 files changed, 28 insertions(+), 45 deletions(-) (limited to 'backend-shared') diff --git a/backend-shared/exportfuncs.cpp b/backend-shared/exportfuncs.cpp index eea20ef5b..54ec08139 100644 --- a/backend-shared/exportfuncs.cpp +++ b/backend-shared/exportfuncs.cpp @@ -4,6 +4,7 @@ #include #include "core/membuffer.h" #include "core/divesite.h" +#include "core/gettextfromc.h" #include "core/tag.h" #include "core/file.h" #include "core/errorhelper.h" @@ -11,14 +12,7 @@ #include "core/divesite.h" #include "exportfuncs.h" - -exportFuncs *exportFuncs::instance() -{ - static exportFuncs *self = new exportFuncs; - return self; -} - -void exportFuncs::exportProfile(QString filename, const bool selected_only) +void exportProfile(QString filename, const bool selected_only) { struct dive *dive; int i; @@ -31,15 +25,15 @@ void exportFuncs::exportProfile(QString filename, const bool selected_only) if (selected_only && !dive->selected) continue; if (count) - saveProfile(dive, fi.path() + QDir::separator() + fi.completeBaseName().append(QString("-%1.").arg(count)) + fi.suffix()); + exportProfile(dive, fi.path() + QDir::separator() + fi.completeBaseName().append(QString("-%1.").arg(count)) + fi.suffix()); else - saveProfile(dive, filename); + exportProfile(dive, filename); ++count; } } -void exportFuncs::export_TeX(const char *filename, const bool selected_only, bool plain) +void export_TeX(const char *filename, const bool selected_only, bool plain) { FILE *f; QDir texdir = QFileInfo(filename).dir(); @@ -96,7 +90,7 @@ void exportFuncs::export_TeX(const char *filename, const bool selected_only, boo if (selected_only && !dive->selected) continue; - saveProfile(dive, texdir.filePath(QString("profile%1.png").arg(dive->number))); + exportProfile(dive, texdir.filePath(QString("profile%1.png").arg(dive->number))); struct tm tm; utc_mkdate(dive->when, &tm); @@ -230,7 +224,7 @@ void exportFuncs::export_TeX(const char *filename, const bool selected_only, boo f = subsurface_fopen(filename, "w+"); if (!f) { - report_error(qPrintable(tr("Can't open file %s")), filename); + report_error(qPrintable(gettextFromC::tr("Can't open file %s")), filename); } else { flush_buffer(&buf, f); /*check for writing errors? */ fclose(f); @@ -239,7 +233,7 @@ void exportFuncs::export_TeX(const char *filename, const bool selected_only, boo } -void exportFuncs::export_depths(const char *filename, const bool selected_only) +void export_depths(const char *filename, const bool selected_only) { FILE *f; struct dive *dive; @@ -268,7 +262,7 @@ void exportFuncs::export_depths(const char *filename, const bool selected_only) f = subsurface_fopen(filename, "w+"); if (!f) { - report_error(qPrintable(tr("Can't open file %s")), filename); + report_error(qPrintable(gettextFromC::tr("Can't open file %s")), filename); } else { flush_buffer(&buf, f); /*check for writing errors? */ fclose(f); @@ -276,7 +270,7 @@ void exportFuncs::export_depths(const char *filename, const bool selected_only) free_buffer(&buf); } -std::vector exportFuncs::getDiveSitesToExport(bool selectedOnly) +std::vector getDiveSitesToExport(bool selectedOnly) { std::vector res; #ifndef SUBSURFACE_MOBILE @@ -311,7 +305,7 @@ std::vector exportFuncs::getDiveSitesToExport(bool selectedOn return res; } -QFuture exportFuncs::exportUsingStyleSheet(QString filename, bool doExport, int units, +QFuture exportUsingStyleSheet(QString filename, bool doExport, int units, QString stylesheet, bool anonymize) { return QtConcurrent::run(export_dives_xslt, filename.toUtf8(), doExport, units, stylesheet.toUtf8(), anonymize); diff --git a/backend-shared/exportfuncs.h b/backend-shared/exportfuncs.h index 530cde7e0..1b888b19f 100644 --- a/backend-shared/exportfuncs.h +++ b/backend-shared/exportfuncs.h @@ -6,33 +6,22 @@ #include #include "core/dive.h" -class exportFuncs: public QObject { - Q_OBJECT - -public: - static exportFuncs *instance(); - - void exportProfile(QString filename, const bool selected_only); - void export_TeX(const char *filename, const bool selected_only, bool plain); - void export_depths(const char *filename, const bool selected_only); - std::vector getDiveSitesToExport(bool selectedOnly); - QFuture exportUsingStyleSheet(QString filename, bool doExport, int units, - QString stylesheet, bool anonymize); - - // prepareDivesForUploadDiveLog - // prepareDivesForUploadDiveShare - -private: - exportFuncs() {} - - // WARNING - // saveProfile uses the UI and are therefore different between - // Desktop (UI) and Mobile (QML) - // In order to solve this difference, the actual implementations - // are done in - // desktop-widgets/divelogexportdialog.cpp and - // mobile-widgets/qmlmanager.cpp - void saveProfile(const struct dive *dive, const QString filename); -}; +void exportProfile(QString filename, const bool selected_only); +void export_TeX(const char *filename, const bool selected_only, bool plain); +void export_depths(const char *filename, const bool selected_only); +std::vector getDiveSitesToExport(bool selectedOnly); +QFuture exportUsingStyleSheet(QString filename, bool doExport, int units, QString stylesheet, bool anonymize); + +// prepareDivesForUploadDiveLog +// prepareDivesForUploadDiveShare + +// WARNING +// exportProfile uses the UI and are therefore different between +// Desktop (UI) and Mobile (QML) +// In order to solve this difference, the actual implementations +// are done in +// desktop-widgets/divelogexportdialog.cpp and +// mobile-widgets/qmlmanager.cpp +void exportProfile(const struct dive *dive, const QString filename); #endif // EXPORT_FUNCS_H -- cgit v1.2.3-70-g09d2