diff options
author | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2021-07-20 07:52:54 +0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2021-07-23 11:22:43 -0700 |
commit | 69914964f66f53c4ce413c780b97e52d015538e2 (patch) | |
tree | 37d6bb7bb1253367ae7fd922a3c90b52b16ce206 /profile-widget | |
parent | 16b31985c3245d5cb3be26f3cc0aa06bc6acb139 (diff) | |
download | subsurface-69914964f66f53c4ce413c780b97e52d015538e2.tar.gz |
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>
Diffstat (limited to 'profile-widget')
-rw-r--r-- | profile-widget/diveeventitem.cpp | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/profile-widget/diveeventitem.cpp b/profile-widget/diveeventitem.cpp index e61182051..911aba8a7 100644 --- a/profile-widget/diveeventitem.cpp +++ b/profile-widget/diveeventitem.cpp @@ -4,11 +4,11 @@ #include "profile-widget/divecartesianaxis.h" #include "profile-widget/animationfunctions.h" #include "core/event.h" +#include "core/format.h" #include "core/libdivecomputer.h" #include "core/profile.h" #include "core/gettextfromc.h" #include "core/metrics.h" -#include "core/membuffer.h" #include "core/sample.h" #include "core/subsurface-string.h" #include <QDebug> @@ -165,7 +165,6 @@ void DiveEventItem::setupToolTipString(struct gasmix lastgasmix) if (event_is_gaschange(ev)) { struct icd_data icd_data; struct gasmix mix = get_gasmix_from_event(dive, ev); - struct membuffer mb = {}; name += ": "; name += gasname(mix); @@ -174,13 +173,11 @@ void DiveEventItem::setupToolTipString(struct gasmix lastgasmix) name += tr(" (cyl. %1)").arg(ev->gas.index + 1); bool icd = isobaric_counterdiffusion(lastgasmix, mix, &icd_data); if (icd_data.dHe < 0) { - put_format(&mb, "\n%s %s:%+.3g%% %s:%+.3g%%%s%+.3g%%", - qPrintable(tr("ICD")), - qPrintable(tr("ΔHe")), icd_data.dHe / 10.0, - qPrintable(tr("ΔN₂")), icd_data.dN2 / 10.0, - icd ? ">" : "<", lrint(-icd_data.dHe / 5.0) / 10.0); - name += QString::fromUtf8(mb.buffer, mb.len); - free_buffer(&mb); + name += qasprintf_loc("\n%s %s:%+.3g%% %s:%+.3g%%%s%+.3g%%", + qPrintable(tr("ICD")), + qPrintable(tr("ΔHe")), icd_data.dHe / 10.0, + qPrintable(tr("ΔN₂")), icd_data.dN2 / 10.0, + icd ? ">" : "<", lrint(-icd_data.dHe / 5.0) / 10.0); } } else if (same_string(ev->name, "modechange")) { name += QString(": %1").arg(gettextFromC::tr(divemode_text_ui[ev->value])); |