summaryrefslogtreecommitdiffstats
path: root/desktop-widgets/divelogexportdialog.cpp
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2018-02-25 13:51:41 +0100
committerGravatar Lubomir I. Ivanov <neolit123@gmail.com>2018-03-14 13:55:36 +0200
commitb72cc1f31784346884c8552c22f1e4c3c6d5ed1d (patch)
tree00a04967dc56ccdc69ee998058c13911292ecef7 /desktop-widgets/divelogexportdialog.cpp
parent4e44fe7598430f9879736ec2d00b99b15dc05451 (diff)
downloadsubsurface-b72cc1f31784346884c8552c22f1e4c3c6d5ed1d.tar.gz
Cleanup: consistently use qPrintable()
Replace constructs of the kind s.toUtf8().data(), s.toUtf8().constData(), s.toLocal8Bit().data(), s.toLocal8Bit.constData() or qUtf8Printable(s) by qPrintable(s). This is concise, consistent and - in principle - more performant than the .data() versions. Sadly, owing to a suboptimal implementation, qPrintable(s) currently is a pessimization compared to s.toUtf8().data(). A fix is scheduled for new Qt versions: https://codereview.qt-project.org/#/c/221331/ Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'desktop-widgets/divelogexportdialog.cpp')
-rw-r--r--desktop-widgets/divelogexportdialog.cpp16
1 files changed, 8 insertions, 8 deletions
diff --git a/desktop-widgets/divelogexportdialog.cpp b/desktop-widgets/divelogexportdialog.cpp
index 2af8d1b80..078e5d0d1 100644
--- a/desktop-widgets/divelogexportdialog.cpp
+++ b/desktop-widgets/divelogexportdialog.cpp
@@ -154,7 +154,7 @@ void DiveLogExportDialog::on_buttonBox_accepted()
filename = QFileDialog::getSaveFileName(this, tr("Export world map"), lastDir,
tr("HTML files") + " (*.html)");
if (!filename.isNull() && !filename.isEmpty())
- export_worldmap_HTML(filename.toUtf8().data(), ui->exportSelected->isChecked());
+ export_worldmap_HTML(qPrintable(filename), ui->exportSelected->isChecked());
} else if (ui->exportSubsurfaceXML->isChecked()) {
filename = QFileDialog::getSaveFileName(this, tr("Export Subsurface XML"), lastDir,
tr("Subsurface files") + " (*.ssrf *.xml)");
@@ -167,11 +167,11 @@ void DiveLogExportDialog::on_buttonBox_accepted()
} else if (ui->exportImageDepths->isChecked()) {
filename = QFileDialog::getSaveFileName(this, tr("Save image depths"), lastDir);
if (!filename.isNull() && !filename.isEmpty())
- export_depths(filename.toUtf8().data(), ui->exportSelected->isChecked());
+ export_depths(qPrintable(filename), ui->exportSelected->isChecked());
} else if (ui->exportTeX->isChecked()) {
filename = QFileDialog::getSaveFileName(this, tr("Export to TeX file"), lastDir, tr("TeX files") + " (*.tex)");
if (!filename.isNull() && !filename.isEmpty())
- export_TeX(filename.toUtf8().data(), ui->exportSelected->isChecked());
+ export_TeX(qPrintable(filename), ui->exportSelected->isChecked());
}
break;
case 1:
@@ -226,7 +226,7 @@ void DiveLogExportDialog::export_depths(const char *filename, const bool selecte
f = subsurface_fopen(filename, "w+");
if (!f) {
- report_error(tr("Can't open file %s").toUtf8().data(), filename);
+ report_error(qPrintable(tr("Can't open file %s")), filename);
} else {
flush_buffer(&buf, f); /*check for writing errors? */
fclose(f);
@@ -325,7 +325,7 @@ void DiveLogExportDialog::export_TeX(const char *filename, const bool selected_o
site ? put_format(&buf, "\\def\\gpslat{%f}\n", site->latitude.udeg / 1000000.0) : put_format(&buf, "\\def\\gpslat{}\n");
site ? put_format(&buf, "\\def\\gpslon{%f}\n", site->longitude.udeg / 1000000.0) : put_format(&buf, "\\def\\gpslon{}\n");
put_format(&buf, "\\def\\computer{%s}\n", dive->dc.model);
- put_format(&buf, "\\def\\country{%s}\n", country.toUtf8().data());
+ put_format(&buf, "\\def\\country{%s}\n", qPrintable(country));
put_format(&buf, "\\def\\time{%u:%02u}\n", FRACTION(dive->duration.seconds, 60));
put_format(&buf, "\n%% Dive Profile Details:\n");
@@ -337,8 +337,8 @@ void DiveLogExportDialog::export_TeX(const char *filename, const bool selected_o
dive->meandepth.mm ? put_format(&buf, "\\def\\meandepth{%.1f\\depthunit}\n", get_depth_units(dive->meandepth.mm, NULL, &unit)) : put_format(&buf, "\\def\\meandepth{}\n");
put_format(&buf, "\\def\\type{%s}\n", dive->tag_list ? dive->tag_list->tag->name : "");
- put_format(&buf, "\\def\\viz{%s}\n", viz.toUtf8().data());
- put_format(&buf, "\\def\\rating{%s}\n", rating.toUtf8().data());
+ put_format(&buf, "\\def\\viz{%s}\n", qPrintable(viz));
+ put_format(&buf, "\\def\\rating{%s}\n", qPrintable(rating));
put_format(&buf, "\\def\\plot{\\includegraphics[width=9cm,height=4cm]{profile%d}}\n", dive->number);
put_format(&buf, "\\def\\comment{%s}\n", dive->notes ? dive->notes : "");
put_format(&buf, "\\def\\buddy{%s}\n", dive->buddy ? dive->buddy : "");
@@ -408,7 +408,7 @@ void DiveLogExportDialog::export_TeX(const char *filename, const bool selected_o
f = subsurface_fopen(filename, "w+");
if (!f) {
- report_error(tr("Can't open file %s").toUtf8().data(), filename);
+ report_error(qPrintable(tr("Can't open file %s")), filename);
} else {
flush_buffer(&buf, f); /*check for writing errors? */
fclose(f);