cleanup: replace membuffer by qasprintf_loc()

There is a function to format QString with C-format strings. Let's
use it instead of doing a detour via membuffer.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2021-07-20 07:52:54 +02:00 committed by Dirk Hohndel
parent 16b31985c3
commit 69914964f6

View file

@ -4,11 +4,11 @@
#include "profile-widget/divecartesianaxis.h" #include "profile-widget/divecartesianaxis.h"
#include "profile-widget/animationfunctions.h" #include "profile-widget/animationfunctions.h"
#include "core/event.h" #include "core/event.h"
#include "core/format.h"
#include "core/libdivecomputer.h" #include "core/libdivecomputer.h"
#include "core/profile.h" #include "core/profile.h"
#include "core/gettextfromc.h" #include "core/gettextfromc.h"
#include "core/metrics.h" #include "core/metrics.h"
#include "core/membuffer.h"
#include "core/sample.h" #include "core/sample.h"
#include "core/subsurface-string.h" #include "core/subsurface-string.h"
#include <QDebug> #include <QDebug>
@ -165,7 +165,6 @@ void DiveEventItem::setupToolTipString(struct gasmix lastgasmix)
if (event_is_gaschange(ev)) { if (event_is_gaschange(ev)) {
struct icd_data icd_data; struct icd_data icd_data;
struct gasmix mix = get_gasmix_from_event(dive, ev); struct gasmix mix = get_gasmix_from_event(dive, ev);
struct membuffer mb = {};
name += ": "; name += ": ";
name += gasname(mix); name += gasname(mix);
@ -174,13 +173,11 @@ void DiveEventItem::setupToolTipString(struct gasmix lastgasmix)
name += tr(" (cyl. %1)").arg(ev->gas.index + 1); name += tr(" (cyl. %1)").arg(ev->gas.index + 1);
bool icd = isobaric_counterdiffusion(lastgasmix, mix, &icd_data); bool icd = isobaric_counterdiffusion(lastgasmix, mix, &icd_data);
if (icd_data.dHe < 0) { if (icd_data.dHe < 0) {
put_format(&mb, "\n%s %s:%+.3g%% %s:%+.3g%%%s%+.3g%%", name += qasprintf_loc("\n%s %s:%+.3g%% %s:%+.3g%%%s%+.3g%%",
qPrintable(tr("ICD")), qPrintable(tr("ICD")),
qPrintable(tr("ΔHe")), icd_data.dHe / 10.0, qPrintable(tr("ΔHe")), icd_data.dHe / 10.0,
qPrintable(tr("ΔN₂")), icd_data.dN2 / 10.0, qPrintable(tr("ΔN₂")), icd_data.dN2 / 10.0,
icd ? ">" : "<", lrint(-icd_data.dHe / 5.0) / 10.0); icd ? ">" : "<", lrint(-icd_data.dHe / 5.0) / 10.0);
name += QString::fromUtf8(mb.buffer, mb.len);
free_buffer(&mb);
} }
} else if (same_string(ev->name, "modechange")) { } else if (same_string(ev->name, "modechange")) {
name += QString(": %1").arg(gettextFromC::tr(divemode_text_ui[ev->value])); name += QString(": %1").arg(gettextFromC::tr(divemode_text_ui[ev->value]));