Commit 50141c1b authored by Alexander Semke's avatar Alexander Semke

[spreadsheet] update the locale on locale setting changes.

parent 3ace91b6
......@@ -55,6 +55,7 @@ public:
virtual double valueAt(int row) const;
virtual int integerAt(int row) const;
virtual qint64 bigIntAt(int row) const;
virtual void setNumberLocale(const QLocale&) {};
virtual int rowCount() const;
virtual int availableRowCount() const;
......
......@@ -199,6 +199,12 @@ QMenu* Column::createContextMenu() {
return menu;
}
void Column::updateLocale() {
SET_NUMBER_LOCALE;
d->inputFilter()->setNumberLocale(numberLocale);
d->outputFilter()->setNumberLocale(numberLocale);
}
void Column::navigateTo(QAction* action) {
project()->navigateTo(action->data().toString());
}
......
......@@ -56,6 +56,8 @@ public:
QIcon icon() const override;
QMenu* createContextMenu() override;
void updateLocale();
AbstractColumn::ColumnMode columnMode() const override;
void setColumnMode(AbstractColumn::ColumnMode) override;
void setColumnModeFast(AbstractColumn::ColumnMode);
......
......@@ -127,6 +127,11 @@ void Spreadsheet::updateHorizontalHeader() {
m_model->updateHorizontalHeader();
}
void Spreadsheet::updateLocale() {
for (auto* col : children<Column>())
col->updateLocale();
}
/*!
Returns the maximum number of rows in the spreadsheet.
*/
......
......@@ -55,6 +55,7 @@ public:
SpreadsheetModel* model();
void updateHorizontalHeader();
void updateLocale();
int columnCount() const;
int columnCount(AbstractColumn::PlotDesignation) const;
......
......@@ -2257,31 +2257,15 @@ void MainWin::handleSettingsChanges() {
}
}
//update the locale
if (!stackedWidget)
return;
auto* widget = stackedWidget->currentWidget();
BaseDock* dock = dynamic_cast<BaseDock*>(widget);
qDebug() << "dock " << dock;
if (dock)
dock->updateLocale();
else {
auto* labelWidget = dynamic_cast<LabelWidget*>(widget);
if (labelWidget)
labelWidget->updateUnits();
}
//update the units
//TODO: implement similar to the update of the locale above:
//update for the current dock widget only,
//for others the settings will be updated once the user selects them
//update the locale and the units in the dock widgets
if (stackedWidget) {
for (int i = 0; i < stackedWidget->count(); ++i) {
auto* widget = stackedWidget->widget(i);
BaseDock* dock = dynamic_cast<BaseDock*>(widget);
if (dock)
if (dock) {
dock->updateLocale();
dock->updateUnits();
else {
} else {
auto* labelWidget = dynamic_cast<LabelWidget*>(widget);
if (labelWidget)
labelWidget->updateUnits();
......@@ -2291,8 +2275,10 @@ void MainWin::handleSettingsChanges() {
//update spreadsheet header
auto spreadsheets = m_project->children<Spreadsheet>(AbstractAspect::ChildIndexFlag::Recursive);
for (auto* spreadsheet : spreadsheets)
for (auto* spreadsheet : spreadsheets) {
spreadsheet->updateHorizontalHeader();
spreadsheet->updateLocale();
}
bool showWelcomeScreen = group.readEntry<bool>(QLatin1String("ShowWelcomeScreen"), true);
if(m_showWelcomeScreen != showWelcomeScreen)
......
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