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

Method createStringNumber

src/frontend/widgets/NumberSpinBox.cpp:204–229  ·  view source on GitHub ↗

! * \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 */

Source from the content-addressed store, hash-verified

202 * \return
203 */
204QString 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
231QString NumberSpinBox::strip(const QString& t) const {
232 // Copied from QAbstractSpinBox.cpp

Callers 1

Calls 4

appendMethod · 0.80
argMethod · 0.80
isNullMethod · 0.80
toStringMethod · 0.45

Tested by 1