! * \brief NumberSpinBox::createStringNumber * Create a string with integer, fraction and exponent part but with the constraint to match * the properties of \p p * \param integerFraction integer and fraction part of the numeric value * \param exponent exponent part of the numeric value * \param p value properties * \return */
| 202 | * \return |
| 203 | */ |
| 204 | QString NumberSpinBox::createStringNumber(double integerFraction, int exponent, const NumberProperties& p) const { |
| 205 | QString number; |
| 206 | if (p.fraction) { |
| 207 | number = locale().toString(integerFraction, 'f', p.fractionDigits); |
| 208 | if (p.fractionDigits == 0) |
| 209 | number.append(locale().decimalPoint()); |
| 210 | } else { |
| 211 | if (p.groupSeparators) |
| 212 | number = locale().toString(int(integerFraction)); |
| 213 | else |
| 214 | number = QStringLiteral("%1").arg(int(integerFraction)); |
| 215 | } |
| 216 | |
| 217 | if (p.exponentLetter != QChar::Null) { |
| 218 | const auto e = QStringLiteral("%L1").arg(exponent, p.exponentDigits + (p.exponentSign == QLatin1Char('-')), 10, QLatin1Char('0')); |
| 219 | QString sign; |
| 220 | if (exponent >= 0 && !p.exponentSign.isNull()) |
| 221 | sign = QLatin1Char('+'); |
| 222 | number += p.exponentLetter + sign + e; |
| 223 | } |
| 224 | |
| 225 | if (p.integerSign == QLatin1Char('+')) |
| 226 | number.prepend(QLatin1Char('+')); |
| 227 | |
| 228 | return number; |
| 229 | } |
| 230 | |
| 231 | QString NumberSpinBox::strip(const QString& t) const { |
| 232 | // Copied from QAbstractSpinBox.cpp |