Commit 29243f35 authored by Alexander Semke's avatar Alexander Semke

Moved the common locale specific code in the filter classes to the base

class.
parent 50141c1b
......@@ -55,7 +55,9 @@ public:
virtual double valueAt(int row) const;
virtual int integerAt(int row) const;
virtual qint64 bigIntAt(int row) const;
virtual void setNumberLocale(const QLocale&) {};
void setNumberLocale(const QLocale& locale) { m_numberLocale = locale; m_useDefaultLocale = false; }
void setNumberLocaleToDefault() { m_useDefaultLocale = true; }
virtual int rowCount() const;
virtual int availableRowCount() const;
......@@ -83,6 +85,8 @@ protected:
void inputRowsRemoved(const AbstractColumn * source, int first, int count) override;
SimpleFilterColumn* m_output_column;
QLocale m_numberLocale;
bool m_useDefaultLocale{true};
};
class SimpleFilterColumn : public AbstractColumn {
......
......@@ -36,8 +36,6 @@ class BigInt2StringFilter : public AbstractSimpleFilter {
public:
explicit BigInt2StringFilter() {}
void setNumberLocale(const QLocale& locale) { m_numberLocale = locale; m_useDefaultLocale = false; }
void setNumberLocaleToDefault() { m_useDefaultLocale = true; }
//! Return the data type of the column
AbstractColumn::ColumnMode columnMode() const override { return AbstractColumn::ColumnMode::Text; }
......@@ -60,10 +58,6 @@ protected:
bool inputAcceptable(int, const AbstractColumn *source) override {
return source->columnMode() == AbstractColumn::ColumnMode::BigInt;
}
private:
QLocale m_numberLocale;
bool m_useDefaultLocale{true};
};
#endif // BIGINT2STRING_FILTER_H
......
......@@ -48,8 +48,6 @@ public:
char numericFormat() const { return m_format; }
//! Get number of displayed digits
int numDigits() const { return m_digits; }
void setNumberLocale(const QLocale& locale) { m_numberLocale = locale; m_useDefaultLocale = false; }
void setNumberLocaleToDefault() { m_useDefaultLocale = true; }
//! Return the data type of the column
AbstractColumn::ColumnMode columnMode() const override { return AbstractColumn::ColumnMode::Text; }
......@@ -61,8 +59,6 @@ private:
char m_format;
//! Display digits or precision as in QString::number
int m_digits;
QLocale m_numberLocale;
bool m_useDefaultLocale{true};
//! \name XML related functions
//@{
......
......@@ -36,8 +36,6 @@ class Integer2StringFilter : public AbstractSimpleFilter {
public:
explicit Integer2StringFilter() {}
void setNumberLocale(const QLocale& locale) { m_numberLocale = locale; m_useDefaultLocale = false; }
void setNumberLocaleToDefault() { m_useDefaultLocale = true; }
//! Return the data type of the column
AbstractColumn::ColumnMode columnMode() const override { return AbstractColumn::ColumnMode::Text; }
......@@ -60,10 +58,6 @@ protected:
bool inputAcceptable(int, const AbstractColumn *source) override {
return source->columnMode() == AbstractColumn::ColumnMode::Integer;
}
private:
QLocale m_numberLocale;
bool m_useDefaultLocale{true};
};
#endif // INTEGER2STRING_FILTER_H
......
......@@ -36,9 +36,7 @@ class String2BigIntFilter : public AbstractSimpleFilter {
Q_OBJECT
public:
String2BigIntFilter() : m_use_default_locale(true) {}
void setNumberLocale(const QLocale& locale) { m_numeric_locale = locale; m_use_default_locale = false; }
void setNumberLocaleToDefault() { m_use_default_locale = true; }
String2BigIntFilter() {}
qint64 bigIntAt(int row) const override {
//DEBUG("String2BigInt::bigIntAt()");
......@@ -48,10 +46,10 @@ public:
bool valid;
QString textValue = m_inputs.value(0)->textAt(row);
//DEBUG(" textValue = " << STDSTRING(textValue));
if (m_use_default_locale) // we need a new QLocale instance here in case the default changed since the last call
if (m_useDefaultLocale) // we need a new QLocale instance here in case the default changed since the last call
result = QLocale().toLongLong(textValue, &valid);
else
result = m_numeric_locale.toLongLong(textValue, &valid);
result = m_numberLocale.toLongLong(textValue, &valid);
//DEBUG(" result = " << result << " valid = " << valid);
if (valid)
......@@ -67,10 +65,6 @@ protected:
bool inputAcceptable(int, const AbstractColumn *source) override {
return source->columnMode() == AbstractColumn::ColumnMode::Text;
}
private:
QLocale m_numeric_locale;
bool m_use_default_locale;
};
#endif // ifndef STRING2BIGINT_FILTER_H
......@@ -39,8 +39,6 @@ class String2DoubleFilter : public AbstractSimpleFilter {
public:
String2DoubleFilter() {}
void setNumberLocale(const QLocale& locale) { m_numberLocale = locale; m_useDefaultLocale = false; }
void setNumberLocaleToDefault() { m_useDefaultLocale = true; }
double valueAt(int row) const override {
//DEBUG("String2Double::valueAt()");
......@@ -68,10 +66,6 @@ protected:
bool inputAcceptable(int, const AbstractColumn *source) override {
return source->columnMode() == AbstractColumn::ColumnMode::Text;
}
private:
QLocale m_numberLocale;
bool m_useDefaultLocale{true};
};
#endif // ifndef STRING2DOUBLE_FILTER_H
......@@ -37,8 +37,6 @@ class String2IntegerFilter : public AbstractSimpleFilter {
public:
explicit String2IntegerFilter() {}
void setNumberLocale(const QLocale& locale) { m_numberLocale = locale; m_useDefaultLocale = false; }
void setNumberLocaleToDefault() { m_useDefaultLocale = true; }
int integerAt(int row) const override {
//DEBUG("String2Integer::integerAt()");
......@@ -67,10 +65,6 @@ protected:
bool inputAcceptable(int, const AbstractColumn *source) override {
return source->columnMode() == AbstractColumn::ColumnMode::Text;
}
private:
QLocale m_numberLocale;
bool m_useDefaultLocale{true};
};
#endif // ifndef STRING2INTEGER_FILTER_H
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment