MCPcopy Create free account
hub / github.com/KDE/labplot / updateLocale

Method updateLocale

src/frontend/dockwidgets/CartesianPlotDock.cpp:459–540  ·  view source on GitHub ↗

* updates the locale in the widgets. called when the application settings are changed. */

Source from the content-addressed store, hash-verified

457 * updates the locale in the widgets. called when the application settings are changed.
458 */
459void CartesianPlotDock::updateLocale() {
460 DEBUG(Q_FUNC_INFO)
461 const auto numberLocale = QLocale();
462
463 // update the QSpinBoxes
464 ui.sbLeft->setLocale(numberLocale);
465 ui.sbTop->setLocale(numberLocale);
466 ui.sbWidth->setLocale(numberLocale);
467 ui.sbHeight->setLocale(numberLocale);
468 ui.sbBorderCornerRadius->setLocale(numberLocale);
469 ui.sbPaddingHorizontal->setLocale(numberLocale);
470 ui.sbPaddingVertical->setLocale(numberLocale);
471 ui.sbPaddingRight->setLocale(numberLocale);
472 ui.sbPaddingBottom->setLocale(numberLocale);
473
474 // update the QLineEdits, avoid the change events
475 if (m_plot) {
476 if (m_plot->rangeType() == CartesianPlot::RangeType::First)
477 ui.leRangePoints->setText(numberLocale.toString(m_plot->rangeFirstValues()));
478 else if (m_plot->rangeType() == CartesianPlot::RangeType::Last)
479 ui.leRangePoints->setText(numberLocale.toString(m_plot->rangeLastValues()));
480
481 // x ranges
482 bool isDateTime = false;
483 for (int row = 0; row < std::min(ui.twXRanges->rowCount(), m_plot->rangeCount(Dimension::X)); row++) {
484 const auto& xRange = m_plot->range(Dimension::X, row);
485 DEBUG(Q_FUNC_INFO << ", x range " << row << " auto scale = " << xRange.autoScale())
486 if (m_plot->xRangeFormat(row) == RangeT::Format::Numeric) {
487 // const int relPrec = xRange.relativePrecision();
488 auto* sb = qobject_cast<NumberSpinBox*>(ui.twXRanges->cellWidget(row, TwRangesColumn::Min));
489 sb->setLocale(numberLocale);
490 sb = qobject_cast<NumberSpinBox*>(ui.twXRanges->cellWidget(row, TwRangesColumn::Max));
491 sb->setLocale(numberLocale);
492
493 } else {
494 CELLWIDGET(Dimension::X, row, TwRangesColumn::Min, UTCDateTimeEdit, setMSecsSinceEpochUTC(xRange.start()));
495 CELLWIDGET(Dimension::X, row, TwRangesColumn::Max, UTCDateTimeEdit, setMSecsSinceEpochUTC(xRange.end()));
496 auto* dte = qobject_cast<UTCDateTimeEdit*>(ui.twXRanges->cellWidget(row, TwRangesColumn::Min));
497 if (dte)
498 isDateTime = true;
499 }
500 }
501
502 // TODO
503 if (isDateTime) {
504 ui.twXRanges->resizeColumnToContents(2);
505 ui.twXRanges->resizeColumnToContents(3);
506 }
507
508 // y ranges
509 isDateTime = false;
510 for (int row = 0; row < std::min(ui.twYRanges->rowCount(), m_plot->rangeCount(Dimension::Y)); row++) {
511 const auto& yRange = m_plot->range(Dimension::Y, row);
512 DEBUG(Q_FUNC_INFO << ", y range " << row << " auto scale = " << yRange.autoScale())
513 if (m_plot->yRangeFormat(row) == RangeT::Format::Numeric) {
514 // const int relPrec = yRange.relativePrecision();
515 auto* sb = qobject_cast<NumberSpinBox*>(ui.twYRanges->cellWidget(row, TwRangesColumn::Min));
516 sb->setLocale(numberLocale);

Callers

nothing calls this directly

Calls 11

setLocaleMethod · 0.80
rangeMethod · 0.80
xRangeFormatMethod · 0.80
yRangeFormatMethod · 0.80
setTextMethod · 0.45
toStringMethod · 0.45
rowCountMethod · 0.45
rangeCountMethod · 0.45
autoScaleMethod · 0.45
startMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected