Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Education
LabPlot
Commits
0b831830
Commit
0b831830
authored
Jul 09, 2020
by
Stefan Gerlach
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[locale] Number locale fixes
parent
1d3e2d42
Changes
13
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
64 additions
and
43 deletions
+64
-43
src/backend/matrix/Matrix.cpp
src/backend/matrix/Matrix.cpp
+5
-4
src/backend/matrix/MatrixModel.cpp
src/backend/matrix/MatrixModel.cpp
+4
-1
src/commonfrontend/matrix/MatrixView.cpp
src/commonfrontend/matrix/MatrixView.cpp
+5
-2
src/commonfrontend/spreadsheet/SpreadsheetView.cpp
src/commonfrontend/spreadsheet/SpreadsheetView.cpp
+34
-31
src/kdefrontend/SettingsGeneralPage.cpp
src/kdefrontend/SettingsGeneralPage.cpp
+0
-1
src/kdefrontend/datasources/AsciiOptionsWidget.cpp
src/kdefrontend/datasources/AsciiOptionsWidget.cpp
+2
-0
src/kdefrontend/datasources/DatasetMetadataManagerWidget.cpp
src/kdefrontend/datasources/DatasetMetadataManagerWidget.cpp
+1
-0
src/kdefrontend/datasources/ImportSQLDatabaseWidget.cpp
src/kdefrontend/datasources/ImportSQLDatabaseWidget.cpp
+3
-1
src/kdefrontend/datasources/JsonOptionsWidget.cpp
src/kdefrontend/datasources/JsonOptionsWidget.cpp
+2
-0
src/kdefrontend/dockwidgets/XYFitCurveDock.cpp
src/kdefrontend/dockwidgets/XYFitCurveDock.cpp
+4
-2
src/kdefrontend/spreadsheet/ExportSpreadsheetDialog.cpp
src/kdefrontend/spreadsheet/ExportSpreadsheetDialog.cpp
+1
-0
src/kdefrontend/widgets/LabelWidget.cpp
src/kdefrontend/widgets/LabelWidget.cpp
+1
-0
src/tools/EquationHighlighter.cpp
src/tools/EquationHighlighter.cpp
+2
-1
No files found.
src/backend/matrix/Matrix.cpp
View file @
0b831830
...
...
@@ -39,15 +39,16 @@
#include "commonfrontend/matrix/MatrixView.h"
#include "kdefrontend/spreadsheet/ExportSpreadsheetDialog.h"
#include <KLocalizedString>
#include <KConfig>
#include <KConfigGroup>
#include <KSharedConfig>
#include <QHeaderView>
#include <QPrinter>
#include <QPrintDialog>
#include <QPrintPreviewDialog>
#include <KConfig>
#include <KConfigGroup>
#include <KLocalizedString>
/*!
This class manages matrix based data (i.e., mathematically
a MxN matrix with M rows, N columns). This data is typically
...
...
src/backend/matrix/MatrixModel.cpp
View file @
0b831830
...
...
@@ -30,8 +30,11 @@
#include "backend/matrix/MatrixModel.h"
#include "backend/matrix/Matrix.h"
#include <KConfigGroup>
#include <KSharedConfig>
#include <QBrush>
#include <QLocale>
/*!
\class MatrixModel
...
...
src/commonfrontend/matrix/MatrixView.cpp
View file @
0b831830
...
...
@@ -41,6 +41,10 @@
#include "kdefrontend/matrix/MatrixFunctionDialog.h"
#include "kdefrontend/spreadsheet/StatisticsDialog.h"
#include <KLocalizedString>
#include <KConfigGroup>
#include <KSharedConfig>
#include <QAction>
#include <QStackedWidget>
#include <QTableView>
...
...
@@ -57,8 +61,6 @@
#include <QMutex>
#include <QProcess>
#include <QHeaderView>
#include <KLocalizedString>
#include <QIcon>
#include <cfloat>
...
...
@@ -1123,6 +1125,7 @@ void MatrixView::exportToFile(const QString& path, const QString& separator, QLo
const
int
cols
=
m_matrix
->
columnCount
();
const
int
rows
=
m_matrix
->
rowCount
();
const
QVector
<
QVector
<
double
>
>*
data
=
static_cast
<
QVector
<
QVector
<
double
>>*>
(
m_matrix
->
data
());
//TODO: use general setting for number locale?
QLocale
locale
(
language
);
for
(
int
row
=
0
;
row
<
rows
;
++
row
)
{
for
(
int
col
=
0
;
col
<
cols
;
++
col
)
{
...
...
src/commonfrontend/spreadsheet/SpreadsheetView.cpp
View file @
0b831830
...
...
@@ -45,6 +45,28 @@
#include "backend/core/datatypes/DateTime2StringFilter.h"
#include "backend/core/datatypes/String2DateTimeFilter.h"
#include "kdefrontend/spreadsheet/ExportSpreadsheetDialog.h"
#include "kdefrontend/spreadsheet/PlotDataDialog.h"
#include "kdefrontend/spreadsheet/AddSubtractValueDialog.h"
#include "kdefrontend/spreadsheet/DropValuesDialog.h"
#include "kdefrontend/spreadsheet/GoToDialog.h"
#include "kdefrontend/spreadsheet/RescaleDialog.h"
#include "kdefrontend/spreadsheet/SortDialog.h"
#include "kdefrontend/spreadsheet/RandomValuesDialog.h"
#include "kdefrontend/spreadsheet/EquidistantValuesDialog.h"
#include "kdefrontend/spreadsheet/FunctionValuesDialog.h"
#include "kdefrontend/spreadsheet/StatisticsDialog.h"
#ifdef Q_OS_MAC
#include "3rdparty/kdmactouchbar/src/kdmactouchbar.h"
#endif
#include <KConfigGroup>
#include <KLocalizedString>
#include <KMessageBox>
#include <KConfigGroup>
#include <KSharedConfig>
#include <QKeyEvent>
#include <QClipboard>
#include <QInputDialog>
...
...
@@ -69,30 +91,11 @@
#include <QRandomGenerator>
#endif
#include <KConfigGroup>
#include <KLocalizedString>
#include <KMessageBox>
#include <KSharedConfig>
#include "kdefrontend/spreadsheet/ExportSpreadsheetDialog.h"
#include "kdefrontend/spreadsheet/PlotDataDialog.h"
#include "kdefrontend/spreadsheet/AddSubtractValueDialog.h"
#include "kdefrontend/spreadsheet/DropValuesDialog.h"
#include "kdefrontend/spreadsheet/GoToDialog.h"
#include "kdefrontend/spreadsheet/RescaleDialog.h"
#include "kdefrontend/spreadsheet/SortDialog.h"
#include "kdefrontend/spreadsheet/RandomValuesDialog.h"
#include "kdefrontend/spreadsheet/EquidistantValuesDialog.h"
#include "kdefrontend/spreadsheet/FunctionValuesDialog.h"
#include "kdefrontend/spreadsheet/StatisticsDialog.h"
#include <algorithm> //for std::reverse
extern
"C"
{
#include <gsl/gsl_math.h>
#ifdef Q_OS_MAC
#include "3rdparty/kdmactouchbar/src/kdmactouchbar.h"
#endif
}
enum
NormalizationMethod
{
DivideBySum
,
DivideByMin
,
DivideByMax
,
DivideByCount
,
DivideByMean
,
DivideByMedian
,
DivideByMode
,
DivideByRange
,
...
...
@@ -1423,7 +1426,7 @@ void SpreadsheetView::copySelection() {
formats
<<
out_fltr
->
numericFormat
();
}
QLocale
locale
;
SET_NUMBER_LOCALE
for
(
int
r
=
0
;
r
<
rows
;
r
++
)
{
for
(
int
c
=
0
;
c
<
cols
;
c
++
)
{
const
Column
*
col_ptr
=
columns
.
at
(
c
);
...
...
@@ -1432,9 +1435,9 @@ void SpreadsheetView::copySelection() {
// output_str += col_ptr->formula(first_row + r);
// else
if
(
col_ptr
->
columnMode
()
==
AbstractColumn
::
ColumnMode
::
Numeric
)
output_str
+=
l
ocale
.
toString
(
col_ptr
->
valueAt
(
first_row
+
r
),
formats
.
at
(
c
),
16
);
// copy with max. precision
output_str
+=
numberL
ocale
.
toString
(
col_ptr
->
valueAt
(
first_row
+
r
),
formats
.
at
(
c
),
16
);
// copy with max. precision
else
if
(
col_ptr
->
columnMode
()
==
AbstractColumn
::
ColumnMode
::
Integer
||
col_ptr
->
columnMode
()
==
AbstractColumn
::
ColumnMode
::
BigInt
)
output_str
+=
QString
::
number
(
col_ptr
->
valueAt
(
first_row
+
r
));
output_str
+=
numberLocale
.
toString
(
col_ptr
->
valueAt
(
first_row
+
r
));
else
output_str
+=
col_ptr
->
asStringColumn
()
->
textAt
(
first_row
+
r
);
}
...
...
@@ -1501,7 +1504,7 @@ void SpreadsheetView::pasteIntoSelection() {
input_col_count
=
cellTexts
.
at
(
i
).
count
();
}
QLocale
locale
;
SET_NUMBER_LOCALE
// bool localeDetermined = false;
if
(
(
first_col
==
-
1
||
first_row
==
-
1
)
||
(
last_row
==
first_row
&&
last_col
==
first_col
)
)
{
...
...
@@ -1583,14 +1586,14 @@ void SpreadsheetView::pasteIntoSelection() {
QVector
<
double
>
new_data
(
rows
);
for
(
int
r
=
0
;
r
<
rows
;
++
r
)
{
if
(
c
<
cellTexts
.
at
(
r
).
count
())
new_data
[
r
]
=
l
ocale
.
toDouble
(
cellTexts
.
at
(
r
).
at
(
c
));
new_data
[
r
]
=
numberL
ocale
.
toDouble
(
cellTexts
.
at
(
r
).
at
(
c
));
}
col
->
replaceValues
(
0
,
new_data
);
}
else
{
for
(
int
r
=
0
;
r
<
rows
&&
r
<
input_row_count
;
r
++
)
{
if
(
isCellSelected
(
first_row
+
r
,
first_col
+
c
)
&&
(
c
<
cellTexts
.
at
(
r
).
count
())
)
{
if
(
!
cellTexts
.
at
(
r
).
at
(
c
).
isEmpty
())
col
->
setValueAt
(
first_row
+
r
,
l
ocale
.
toDouble
(
cellTexts
.
at
(
r
).
at
(
c
)));
col
->
setValueAt
(
first_row
+
r
,
numberL
ocale
.
toDouble
(
cellTexts
.
at
(
r
).
at
(
c
)));
else
col
->
setValueAt
(
first_row
+
r
,
std
::
numeric_limits
<
double
>::
quiet_NaN
());
}
...
...
@@ -1601,14 +1604,14 @@ void SpreadsheetView::pasteIntoSelection() {
QVector
<
int
>
new_data
(
rows
);
for
(
int
r
=
0
;
r
<
rows
;
++
r
)
{
if
(
c
<
cellTexts
.
at
(
r
).
count
())
new_data
[
r
]
=
l
ocale
.
toInt
(
cellTexts
.
at
(
r
).
at
(
c
));
new_data
[
r
]
=
numberL
ocale
.
toInt
(
cellTexts
.
at
(
r
).
at
(
c
));
}
col
->
replaceInteger
(
0
,
new_data
);
}
else
{
for
(
int
r
=
0
;
r
<
rows
&&
r
<
input_row_count
;
r
++
)
{
if
(
isCellSelected
(
first_row
+
r
,
first_col
+
c
)
&&
(
c
<
cellTexts
.
at
(
r
).
count
())
)
{
if
(
!
cellTexts
.
at
(
r
).
at
(
c
).
isEmpty
())
col
->
setIntegerAt
(
first_row
+
r
,
l
ocale
.
toInt
(
cellTexts
.
at
(
r
).
at
(
c
)));
col
->
setIntegerAt
(
first_row
+
r
,
numberL
ocale
.
toInt
(
cellTexts
.
at
(
r
).
at
(
c
)));
else
col
->
setIntegerAt
(
first_row
+
r
,
0
);
}
...
...
@@ -1618,13 +1621,13 @@ void SpreadsheetView::pasteIntoSelection() {
if
(
rows
==
m_spreadsheet
->
rowCount
()
&&
rows
<=
cellTexts
.
size
())
{
QVector
<
qint64
>
new_data
(
rows
);
for
(
int
r
=
0
;
r
<
rows
;
++
r
)
new_data
[
r
]
=
l
ocale
.
toLongLong
(
cellTexts
.
at
(
r
).
at
(
c
));
new_data
[
r
]
=
numberL
ocale
.
toLongLong
(
cellTexts
.
at
(
r
).
at
(
c
));
col
->
replaceBigInt
(
0
,
new_data
);
}
else
{
for
(
int
r
=
0
;
r
<
rows
&&
r
<
input_row_count
;
r
++
)
{
if
(
isCellSelected
(
first_row
+
r
,
first_col
+
c
)
&&
(
c
<
cellTexts
.
at
(
r
).
count
())
)
{
if
(
!
cellTexts
.
at
(
r
).
at
(
c
).
isEmpty
())
col
->
setBigIntAt
(
first_row
+
r
,
l
ocale
.
toLongLong
(
cellTexts
.
at
(
r
).
at
(
c
)));
col
->
setBigIntAt
(
first_row
+
r
,
numberL
ocale
.
toLongLong
(
cellTexts
.
at
(
r
).
at
(
c
)));
else
col
->
setBigIntAt
(
first_row
+
r
,
0
);
}
...
...
src/kdefrontend/SettingsGeneralPage.cpp
View file @
0b831830
...
...
@@ -73,7 +73,6 @@ QLocale::Language SettingsGeneralPage::decimalSeparatorLocale() const {
return
QLocale
().
language
();
QChar
groupSeparator
{
QLocale
().
groupSeparator
()};
QChar
decimalPoint
{
QLocale
().
decimalPoint
()};
if
(
currentIndex
==
static_cast
<
int
>
(
DecimalSeparator
::
Dot
))
{
if
(
groupSeparator
==
QLocale
(
QLocale
::
Language
::
Zarma
).
groupSeparator
())
// \u00a0
return
QLocale
::
Language
::
Zarma
;
// . \u00a0
...
...
src/kdefrontend/datasources/AsciiOptionsWidget.cpp
View file @
0b831830
...
...
@@ -148,6 +148,7 @@ void AsciiOptionsWidget::applyFilterSettings(AsciiFilter* filter) const {
filter
->
setCommentCharacter
(
ui
.
cbCommentCharacter
->
currentText
()
);
filter
->
setSeparatingCharacter
(
ui
.
cbSeparatingCharacter
->
currentText
()
);
//TODO: use general setting for decimal separator?
QLocale
::
Language
lang
;
if
(
ui
.
cbDecimalSeparator
->
currentIndex
()
==
0
)
lang
=
QLocale
::
Language
::
C
;
...
...
@@ -175,6 +176,7 @@ void AsciiOptionsWidget::loadSettings() const {
ui
.
cbCommentCharacter
->
setCurrentText
(
conf
.
readEntry
(
"CommentCharacter"
,
"#"
));
ui
.
cbSeparatingCharacter
->
setCurrentItem
(
conf
.
readEntry
(
"SeparatingCharacter"
,
"auto"
));
//TODO: use general setting for decimal separator?
const
QChar
decimalSeparator
=
QLocale
().
decimalPoint
();
int
index
=
(
decimalSeparator
==
'.'
)
?
0
:
1
;
ui
.
cbDecimalSeparator
->
setCurrentIndex
(
conf
.
readEntry
(
"DecimalSeparator"
,
index
));
...
...
src/kdefrontend/datasources/DatasetMetadataManagerWidget.cpp
View file @
0b831830
...
...
@@ -118,6 +118,7 @@ void DatasetMetadataManagerWidget::loadSettings() {
KConfigGroup
conf
(
KSharedConfig
::
openConfig
(),
"DatasetMetadataManagerWidget"
);
ui
.
cbCommentCharacter
->
setCurrentItem
(
conf
.
readEntry
(
"commentChar"
,
"#"
));
ui
.
cbSeparatingCharacter
->
setCurrentItem
(
conf
.
readEntry
(
"separator"
,
"auto"
));
//TODO: use general setting for decimal separator?
ui
.
cbNumberFormat
->
setCurrentIndex
(
conf
.
readEntry
(
"numberFormat"
,
static_cast
<
int
>
(
QLocale
::
AnyLanguage
)));
ui
.
cbDateTimeFormat
->
setCurrentItem
(
conf
.
readEntry
(
"dateTimeFormat"
,
"yyyy-MM-dd hh:mm:ss.zzz"
));
ui
.
chbCreateIndex
->
setChecked
(
conf
.
readEntry
(
"createIndexColumn"
,
false
));
...
...
src/kdefrontend/datasources/ImportSQLDatabaseWidget.cpp
View file @
0b831830
...
...
@@ -159,7 +159,7 @@ void ImportSQLDatabaseWidget::loadSettings() {
ui
.
cbImportFrom
->
setCurrentIndex
(
config
.
readEntry
(
"ImportFrom"
,
0
));
importFromChanged
(
ui
.
cbImportFrom
->
currentIndex
());
//TODO
//TODO
: use general setting for decimal separator?
const
QChar
decimalSeparator
=
QLocale
().
decimalPoint
();
int
index
=
(
decimalSeparator
==
'.'
)
?
0
:
1
;
ui
.
cbDecimalSeparator
->
setCurrentIndex
(
config
.
readEntry
(
"DecimalSeparator"
,
index
));
...
...
@@ -342,6 +342,7 @@ void ImportSQLDatabaseWidget::refreshPreview() {
m_columnNames
.
clear
();
m_columnModes
.
clear
();
bool
numeric
=
true
;
//TODO: use general setting for decimal separator?
QLocale
::
Language
lang
;
if
(
ui
.
cbDecimalSeparator
->
currentIndex
()
==
0
)
lang
=
QLocale
::
Language
::
C
;
...
...
@@ -443,6 +444,7 @@ void ImportSQLDatabaseWidget::read(AbstractDataSource* dataSource, AbstractFileF
//number and DateTime formatting
const
QString
&
dateTimeFormat
=
ui
.
cbDateTimeFormat
->
currentText
();
//TODO: use general setting for decimal separator?
QLocale
::
Language
lang
;
if
(
ui
.
cbDecimalSeparator
->
currentIndex
()
==
0
)
lang
=
QLocale
::
Language
::
C
;
...
...
src/kdefrontend/datasources/JsonOptionsWidget.cpp
View file @
0b831830
...
...
@@ -60,6 +60,7 @@ void JsonOptionsWidget::applyFilterSettings(JsonFilter* filter, const QModelInde
Q_ASSERT
(
filter
);
filter
->
setModelRows
(
getIndexRows
(
index
));
//TODO: use general setting for decimal separator?
filter
->
setNumberFormat
(
QLocale
::
Language
(
ui
.
cbNumberFormat
->
currentIndex
()));
filter
->
setDateTimeFormat
(
ui
.
cbDateTimeFormat
->
currentText
());
filter
->
setCreateIndexEnabled
(
ui
.
chbCreateIndex
->
isChecked
());
...
...
@@ -82,6 +83,7 @@ void JsonOptionsWidget::clearModel() {
void
JsonOptionsWidget
::
loadSettings
()
const
{
KConfigGroup
conf
(
KSharedConfig
::
openConfig
(),
"ImportJson"
);
//TODO: use general setting for decimal separator?
ui
.
cbNumberFormat
->
setCurrentIndex
(
conf
.
readEntry
(
"NumberFormat"
,
(
int
)
QLocale
::
AnyLanguage
));
ui
.
cbDateTimeFormat
->
setCurrentItem
(
conf
.
readEntry
(
"DateTimeFormat"
,
"yyyy-MM-dd hh:mm:ss.zzz"
));
ui
.
chbCreateIndex
->
setChecked
(
conf
.
readEntry
(
"CreateIndex"
,
false
));
...
...
src/kdefrontend/dockwidgets/XYFitCurveDock.cpp
View file @
0b831830
...
...
@@ -39,14 +39,16 @@
#include "kdefrontend/widgets/FitOptionsWidget.h"
#include "kdefrontend/widgets/FitParametersWidget.h"
#include <KMessageWidget>
#include <KConfigGroup>
#include <KSharedConfig>
#include <QMenu>
#include <QWidgetAction>
#include <QStandardItemModel>
#include <QStandardPaths>
#include <QClipboard>
#include <KMessageWidget>
extern
"C"
{
#include "backend/nsl/nsl_sf_stats.h"
}
...
...
src/kdefrontend/spreadsheet/ExportSpreadsheetDialog.cpp
View file @
0b831830
...
...
@@ -112,6 +112,7 @@ ExportSpreadsheetDialog::ExportSpreadsheetDialog(QWidget* parent) : QDialog(pare
ui
->
chkExportHeader
->
setChecked
(
conf
.
readEntry
(
"Header"
,
true
));
ui
->
cbSeparator
->
setCurrentItem
(
conf
.
readEntry
(
"Separator"
,
"TAB"
));
//TODO: use general setting for decimal separator?
const
QChar
decimalSeparator
=
QLocale
().
decimalPoint
();
int
index
=
(
decimalSeparator
==
'.'
)
?
0
:
1
;
ui
->
cbDecimalSeparator
->
setCurrentIndex
(
conf
.
readEntry
(
"DecimalSeparator"
,
index
));
...
...
src/kdefrontend/widgets/LabelWidget.cpp
View file @
0b831830
...
...
@@ -758,6 +758,7 @@ void LabelWidget::dateTimeMenu() {
//application language was changed:
//determine the currently used language and use QLocale::toString()
//to get the strings translated into the currently used language
//TODO: why not use QLocale() ?
QSettings
settings
(
configFile
,
QSettings
::
IniFormat
);
settings
.
beginGroup
(
QLatin1String
(
"Language"
));
QByteArray
languageCode
;
...
...
src/tools/EquationHighlighter.cpp
View file @
0b831830
...
...
@@ -128,7 +128,8 @@ void EquationHighlighter::highlightBlock(const QString& text) {
bool isFraction = (u >= 0xbc && u <= 0xbe) || (u >= 0x2153 && u <= 0x215e);
bool isPower = (u >= 0xb2 && u <= 0xb3) || (u == 0x2070) || (u >= 0x2074 && u <= 0x2079);
bool isDigit = text[i].isDigit();
bool isDecimalPoint = text[i] == QLocale().decimalPoint();
SET_NUMBER_LOCALE
bool isDecimalPoint = text[i] == numberLocale.decimalPoint();
if (isFraction || isPower || isDigit || isDecimalPoint)
setFormat(i, 1, number);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment