Skip to content

Commit

Permalink
Fix decimal point char + locale on QT
Browse files Browse the repository at this point in the history
  • Loading branch information
schaumb committed Sep 12, 2024
1 parent c8ddf53 commit 05d820c
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 7 deletions.
10 changes: 6 additions & 4 deletions src/base/conv/numtostr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,20 +36,22 @@ std::string NumberToString::convert(double number)
("%." + std::to_string(fractionDigitCount) + "f").c_str(),
number));

auto decimalPoint =
std::min(number_view.find('.'), number_view.size());
auto decimalPoint = std::min(number_view.find(decimalPointChar),
number_view.size());
if (decimalPoint != number_view.size()) {
if (!fillFractionWithZero) {
number_view = number_view.substr(0,
number_view.find_last_not_of('0') + 1);
}
if (number_view.ends_with('.')) {
if (number_view.ends_with(decimalPointChar)) {
number_view.remove_suffix(1);
}
}

if (number_view.starts_with('-')
&& number_view.find_last_not_of("0.") == 0) {
&& number_view.find_last_not_of(std::string_view{
std::initializer_list{'0', decimalPointChar, '\0'}})
== 0) {
number_view.remove_prefix(1);
++begin;
--decimalPoint;
Expand Down
1 change: 0 additions & 1 deletion src/chart/options/channel.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
#include <set>
#include <string>

#include "dataframe/old/datatable.h"
#include "dataframe/old/types.h"

#include "autoparam.h"
Expand Down
3 changes: 1 addition & 2 deletions src/dataframe/old/datatable.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@
#ifndef DATAFRAME_OLD2_DATATABLE_H
#define DATAFRAME_OLD2_DATATABLE_H

#include <chart/options/channel.h>

#include "../impl/dataframe.h"
#include "chart/options/channel.h"

#include "types.h"

Expand Down
1 change: 1 addition & 0 deletions test/qtest/window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ Window::Window(QWidget *parent) :
chart.run();
animStep();
installEventFilter(this);
setlocale(LC_NUMERIC, "C");
}

void Window::animStep()
Expand Down

0 comments on commit 05d820c

Please sign in to comment.