diff options
author | Stefan Fuchs <sfuchs@gmx.de> | 2018-02-19 21:55:18 +0100 |
---|---|---|
committer | Robert C. Helling <helling@atdotde.de> | 2018-03-05 16:28:18 +0100 |
commit | aacc6886705e720809d253d22e0f6f49444993e0 (patch) | |
tree | 4d8026cae13f8706d2bb904f7115089d60a7d603 /profile-widget | |
parent | 18c034ea37f830880e4cbf3636819c6be43d0464 (diff) | |
download | subsurface-aacc6886705e720809d253d22e0f6f49444993e0.tar.gz |
Use correct numeric format based on selected locale (Qt domain part)
This changes the numeric format of many values printed to the UI to
reflect the correct numeric format of the selected locale:
- dot or comma as decimal separator
- comma or dot as thousands separator
In the Qt domain the `L` flag is used case specific mostly
in qthelper.cpp.
Then the helper functions get_xxx_string() are used more consistently.
Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
Diffstat (limited to 'profile-widget')
-rw-r--r-- | profile-widget/divecartesianaxis.cpp | 2 | ||||
-rw-r--r-- | profile-widget/diveprofileitem.cpp | 9 |
2 files changed, 3 insertions, 8 deletions
diff --git a/profile-widget/divecartesianaxis.cpp b/profile-widget/divecartesianaxis.cpp index 3ca87dd10..4d7d9eaa3 100644 --- a/profile-widget/divecartesianaxis.cpp +++ b/profile-widget/divecartesianaxis.cpp @@ -271,7 +271,7 @@ void DiveCartesianAxis::animateChangeLine(const QLineF &newLine) QString DiveCartesianAxis::textForValue(double value) { - return QString::number(value); + return QString("%L1").arg(value, 0, 'g', 4); } void DiveCartesianAxis::setTickSize(qreal size) diff --git a/profile-widget/diveprofileitem.cpp b/profile-widget/diveprofileitem.cpp index 24edba4db..529024c11 100644 --- a/profile-widget/diveprofileitem.cpp +++ b/profile-widget/diveprofileitem.cpp @@ -260,11 +260,9 @@ void DiveProfileItem::settingsChanged() void DiveProfileItem::plot_depth_sample(struct plot_data *entry, QFlags<Qt::AlignmentFlag> flags, const QColor &color) { - int decimals; - double d = get_depth_units(entry->depth, &decimals, NULL); DiveTextItem *item = new DiveTextItem(this); item->setPos(hAxis->posAtValue(entry->sec), vAxis->posAtValue(entry->depth)); - item->setText(QString("%1").arg(d, 0, 'f', 1)); + item->setText(get_depth_string(entry->depth, true)); item->setAlignment(flags); item->setBrush(color); texts.append(item); @@ -670,15 +668,12 @@ void DiveMeanDepthItem::createTextItem() { int sec = entry[dataModel->rowCount()-1].sec; qDeleteAll(texts); texts.clear(); - int decimals; - const char *unitText; - double d = get_depth_units(lrint(lastRunningSum), &decimals, &unitText); DiveTextItem *text = new DiveTextItem(this); text->setAlignment(Qt::AlignRight | Qt::AlignTop); text->setBrush(getColor(TEMP_TEXT)); text->setPos(QPointF(hAxis->posAtValue(sec) + 1, vAxis->posAtValue(lastRunningSum))); text->setScale(0.8); // need to call this BEFORE setText() - text->setText(QString("%1%2").arg(d, 0, 'f', 1).arg(unitText)); + text->setText(get_depth_string(lrint(lastRunningSum), true)); texts.append(text); } |