cleanup: remove use of QRegExp in TeX export

Qt 6 will drop support for QRegExp.

When looking at replacing this use of a QRegExp it seemed like a much
better idea to simply switch to utilizing the taxonomy data instead.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Dirk Hohndel 2021-10-25 16:04:54 -07:00
parent ba1564fddb
commit b2d5350bb1

View file

@ -16,6 +16,7 @@
#include "core/pref.h" #include "core/pref.h"
#include "core/sample.h" #include "core/sample.h"
#include "core/selection.h" #include "core/selection.h"
#include "core/taxonomy.h"
#include "exportfuncs.h" #include "exportfuncs.h"
// Default implementation of the export callback: do nothing / never cancel // Default implementation of the export callback: do nothing / never cancel
@ -119,14 +120,10 @@ void export_TeX(const char *filename, bool selected_only, bool plain, ExportCall
struct tm tm; struct tm tm;
utc_mkdate(dive->when, &tm); utc_mkdate(dive->when, &tm);
const char *country = NULL;
dive_site *site = dive->dive_site; dive_site *site = dive->dive_site;
QRegExp ct("countrytag: (\\w+)"); if (site)
QString country; country = taxonomy_get_country(&site->taxonomy);
if (site && ct.indexIn(site->notes) >= 0)
country = ct.cap(1);
else
country = "";
pressure_t delta_p = {.mbar = 0}; pressure_t delta_p = {.mbar = 0};
QString star = "*"; QString star = "*";
@ -158,7 +155,7 @@ void export_TeX(const char *filename, bool selected_only, bool plain, ExportCall
site ? put_format(&buf, "\\def\\%sgpslat{%f}\n", ssrf, site->location.lat.udeg / 1000000.0) : put_format(&buf, "\\def\\%sgpslat{}\n", ssrf); site ? put_format(&buf, "\\def\\%sgpslat{%f}\n", ssrf, site->location.lat.udeg / 1000000.0) : put_format(&buf, "\\def\\%sgpslat{}\n", ssrf);
site ? put_format(&buf, "\\def\\%sgpslon{%f}\n", ssrf, site->location.lon.udeg / 1000000.0) : put_format(&buf, "\\def\\gpslon{}\n"); site ? put_format(&buf, "\\def\\%sgpslon{%f}\n", ssrf, site->location.lon.udeg / 1000000.0) : put_format(&buf, "\\def\\gpslon{}\n");
put_format(&buf, "\\def\\%scomputer{%s}\n", ssrf, dive->dc.model); put_format(&buf, "\\def\\%scomputer{%s}\n", ssrf, dive->dc.model);
put_format(&buf, "\\def\\%scountry{%s}\n", ssrf, qPrintable(country)); put_format(&buf, "\\def\\%scountry{%s}\n", ssrf, country ?: "");
put_format(&buf, "\\def\\%stime{%u:%02u}\n", ssrf, FRACTION(dive->duration.seconds, 60)); put_format(&buf, "\\def\\%stime{%u:%02u}\n", ssrf, FRACTION(dive->duration.seconds, 60));
put_format(&buf, "\n%% Dive Profile Details:\n"); put_format(&buf, "\n%% Dive Profile Details:\n");