Changeset View
Changeset View
Standalone View
Standalone View
src/unit.h
Show All 21 Lines | |||||
22 | #define KUNITCONVERSION_UNIT_H | 22 | #define KUNITCONVERSION_UNIT_H | ||
23 | 23 | | |||
24 | #include "kunitconversion/kunitconversion_export.h" | 24 | #include "kunitconversion/kunitconversion_export.h" | ||
25 | 25 | | |||
26 | #include <QString> | 26 | #include <QString> | ||
27 | #include <QExplicitlySharedDataPointer> | 27 | #include <QExplicitlySharedDataPointer> | ||
28 | 28 | | |||
29 | class KLocalizedString; | 29 | class KLocalizedString; | ||
30 | class QLocale; | ||||
30 | 31 | | |||
31 | namespace KUnitConversion | 32 | namespace KUnitConversion | ||
32 | { | 33 | { | ||
33 | 34 | | |||
34 | enum CategoryId { | 35 | enum CategoryId { | ||
35 | InvalidCategory = -1, | 36 | InvalidCategory = -1, | ||
36 | LengthCategory, | 37 | LengthCategory, | ||
37 | AreaCategory, | 38 | AreaCategory, | ||
▲ Show 20 Lines • Show All 382 Lines • ▼ Show 20 Line(s) | 376 | #endif | |||
420 | QString description() const; | 421 | QString description() const; | ||
421 | 422 | | |||
422 | /** | 423 | /** | ||
423 | * @return symbol for the unit. | 424 | * @return symbol for the unit. | ||
424 | **/ | 425 | **/ | ||
425 | QString symbol() const; | 426 | QString symbol() const; | ||
426 | 427 | | |||
427 | /** | 428 | /** | ||
429 | * Convert value to a string with the unit. | ||||
430 | * | ||||
431 | * @note Due to historic reasons the number in the string is generated using the C locale. | ||||
432 | * For a localized representation of the value number use the overload method with | ||||
433 | * a QLocale argument. | ||||
434 | * | ||||
428 | * @param value number value | 435 | * @param value number value | ||
429 | * @param fieldWidth width of the formatted field, padded by spaces. | 436 | * @param fieldWidth width of the formatted field, padded by spaces. | ||
430 | * Positive value aligns right, negative aligns left | 437 | * Positive value aligns right, negative aligns left | ||
431 | * @param format type of floating point formating, like in QString::arg | 438 | * @param format type of floating point formating, like in QString::arg | ||
432 | * @param precision number of digits after the decimal separator | 439 | * @param precision number of digits after the decimal separator | ||
433 | * @param fillChar the character used to fill up the empty places when | 440 | * @param fillChar the character used to fill up the empty places when | ||
434 | * field width is greater than argument width | 441 | * field width is greater than argument width | ||
435 | * @return value + unit string | 442 | * @return value + unit string | ||
436 | **/ | 443 | **/ | ||
437 | QString toString(qreal value, int fieldWidth = 0, char format = 'g', int precision = -1, | 444 | QString toString(qreal value, int fieldWidth = 0, char format = 'g', int precision = -1, | ||
438 | const QChar &fillChar = QLatin1Char(' ')) const; | 445 | const QChar &fillChar = QLatin1Char(' ')) const; | ||
439 | 446 | | |||
440 | /** | 447 | /** | ||
448 | * Convert value to a string with the unit. | ||||
449 | * | ||||
450 | * @param value number value | ||||
451 | * @param locale locale object to use for creating the number string from the value | ||||
452 | * @param format type of floating point formating, like in QString::arg | ||||
453 | * @param precision number of digits after the decimal separator | ||||
454 | * @return value + unit string | ||||
455 | * | ||||
456 | * @since 5.46 | ||||
457 | **/ | ||||
458 | QString toString(qreal value, const QLocale &locale, | ||||
459 | char format = 'g', int precision = -1) const; | ||||
460 | | ||||
461 | /** | ||||
462 | * Convert value to a string with the symbol. | ||||
463 | * | ||||
464 | * @note Due to historic reasons the number in the string is generated using the C locale. | ||||
465 | * For a localized representation of the value number use the overload method with | ||||
466 | * a QLocale argument. | ||||
467 | * | ||||
441 | * @param value number value | 468 | * @param value number value | ||
442 | * @param fieldWidth width of the formatted field, padded by spaces. | 469 | * @param fieldWidth width of the formatted field, padded by spaces. | ||
443 | * Positive value aligns right, negative aligns left | 470 | * Positive value aligns right, negative aligns left | ||
444 | * @param format type of floating point formating, like in QString::arg | 471 | * @param format type of floating point formating, like in QString::arg | ||
445 | * @param precision number of digits after the decimal separator | 472 | * @param precision number of digits after the decimal separator | ||
446 | * @param fillChar the character used to fill up the empty places when | 473 | * @param fillChar the character used to fill up the empty places when | ||
447 | * field width is greater than argument width | 474 | * field width is greater than argument width | ||
448 | * @return value + unit string | 475 | * @return value + unit string | ||
449 | **/ | 476 | **/ | ||
450 | QString toSymbolString(qreal value, int fieldWidth = 0, char format = 'g', int precision = -1, | 477 | QString toSymbolString(qreal value, int fieldWidth = 0, char format = 'g', int precision = -1, | ||
451 | const QChar &fillChar = QLatin1Char(' ')) const; | 478 | const QChar &fillChar = QLatin1Char(' ')) const; | ||
452 | 479 | | |||
480 | /** | ||||
481 | * Convert value to a string with the symbol. | ||||
482 | * | ||||
483 | * @param value number value | ||||
484 | * @param locale locale object to use for creating the number string from the value | ||||
485 | * @param format type of floating point formating, like in QString::arg | ||||
486 | * @param precision number of digits after the decimal separator | ||||
487 | * @return value + unit string | ||||
488 | * | ||||
489 | * @since 5.46 | ||||
490 | **/ | ||||
491 | QString toSymbolString(qreal value, const QLocale &locale, | ||||
492 | char format = 'g', int precision = -1) const; | ||||
493 | | ||||
453 | 494 | | |||
454 | protected: | 495 | protected: | ||
455 | qreal toDefault(qreal value) const; | 496 | qreal toDefault(qreal value) const; | ||
456 | qreal fromDefault(qreal value) const; | 497 | qreal fromDefault(qreal value) const; | ||
457 | 498 | | |||
458 | private: | 499 | private: | ||
459 | friend class CustomUnit; | 500 | friend class CustomUnit; | ||
460 | friend class UnitCategory; | 501 | friend class UnitCategory; | ||
Show All 12 Lines |