MCPcopy Create free account
hub / github.com/LUX-Core/lux / setNumberFormat

Method setNumberFormat

src/qt/qcustomplot.cpp:8003–8056  ·  view source on GitHub ↗

! Sets the number format for the numbers in tick labels. This \a formatCode is an extended version of the format code used e.g. by QString::number() and QLocale::toString(). For reference about that, see the "Argument Formats" section in the detailed description of the QString class. \a formatCode is a string of one, two or three characters. The first character is identical to the nor

Source from the content-addressed store, hash-verified

8001 code will not be changed.
8002*/
8003void QCPAxis::setNumberFormat(const QString &formatCode)
8004{
8005 if (formatCode.isEmpty())
8006 {
8007 qDebug() << Q_FUNC_INFO << "Passed formatCode is empty";
8008 return;
8009 }
8010 mCachedMarginValid = false;
8011
8012 // interpret first char as number format char:
8013 QString allowedFormatChars(QLatin1String("eEfgG"));
8014 if (allowedFormatChars.contains(formatCode.at(0)))
8015 {
8016 mNumberFormatChar = QLatin1Char(formatCode.at(0).toLatin1());
8017 } else
8018 {
8019 qDebug() << Q_FUNC_INFO << "Invalid number format code (first char not in 'eEfgG'):" << formatCode;
8020 return;
8021 }
8022 if (formatCode.length() < 2)
8023 {
8024 mNumberBeautifulPowers = false;
8025 mAxisPainter->numberMultiplyCross = false;
8026 return;
8027 }
8028
8029 // interpret second char as indicator for beautiful decimal powers:
8030 if (formatCode.at(1) == QLatin1Char('b') && (mNumberFormatChar == QLatin1Char('e') || mNumberFormatChar == QLatin1Char('g')))
8031 {
8032 mNumberBeautifulPowers = true;
8033 } else
8034 {
8035 qDebug() << Q_FUNC_INFO << "Invalid number format code (second char not 'b' or first char neither 'e' nor 'g'):" << formatCode;
8036 return;
8037 }
8038 if (formatCode.length() < 3)
8039 {
8040 mAxisPainter->numberMultiplyCross = false;
8041 return;
8042 }
8043
8044 // interpret third char as indicator for dot or cross multiplication symbol:
8045 if (formatCode.at(2) == QLatin1Char('c'))
8046 {
8047 mAxisPainter->numberMultiplyCross = true;
8048 } else if (formatCode.at(2) == QLatin1Char('d'))
8049 {
8050 mAxisPainter->numberMultiplyCross = false;
8051 } else
8052 {
8053 qDebug() << Q_FUNC_INFO << "Invalid number format code (third char neither 'c' nor 'd'):" << formatCode;
8054 return;
8055 }
8056}
8057
8058/*!
8059 Sets the precision of the tick label numbers. See QLocale::toString(double i, char f, int prec)

Callers 1

setupFullAxesBoxMethod · 0.80

Calls 4

isEmptyMethod · 0.45
containsMethod · 0.45
atMethod · 0.45
lengthMethod · 0.45

Tested by

no test coverage detected