KSysGuard::Formatter

Search for usage in LXR

KSysGuard::Formatter Class Reference

#include <Formatter.h>

Static Public Member Functions

static QString formatValue (const QVariant &value, Unit unit, MetricPrefix targetPrefix=MetricPrefixAutoAdjust, FormatOptions options=FormatOptionNone, int precision=-1)
 
static KLocalizedString localizedString (const QVariant &value, Unit unit, MetricPrefix targetPrefix=MetricPrefixAutoAdjust)
 
static qreal maximumLength (Unit unit, const QFont &font)
 
static qreal scaleDownFactor (const QVariant &value, Unit unit, MetricPrefix targetPrefix=MetricPrefixAutoAdjust)
 
static QString symbol (Unit unit)
 

Detailed Description

A class for formatting sensor values.

See also
FormatterWrapper, for using it from Qml

Definition at line 35 of file Formatter.h.

Member Function Documentation

◆ formatValue()

QString KSysGuard::Formatter::formatValue ( const QVariant & value,
Unit unit,
MetricPrefix targetPrefix = MetricPrefixAutoAdjust,
FormatOptions options = FormatOptionNone,
int precision = -1 )
static

Converts value to the appropriate displayable string.

The returned string is localized.

Parameters
valueThe value to be converted.
unitThe unit of the value.
targetPrefixPreferred metric prefix.
options
precisionThe precision to use. If < 0, use a default value.

Definition at line 517 of file Formatter.cpp.

◆ localizedString()

KLocalizedString KSysGuard::Formatter::localizedString ( const QVariant & value,
Unit unit,
MetricPrefix targetPrefix = MetricPrefixAutoAdjust )
static

Returns localized string that is suitable for display.

Parameters
valueThe maximum output value.
unitThe unit of the value.
targetPrefixPreferred metric prefix.

Definition at line 511 of file Formatter.cpp.

◆ maximumLength()

qreal KSysGuard::Formatter::maximumLength ( Unit unit,
const QFont & font )
static

Return the maximum length of a formatted string for the specified unit and font.

Parameters
unitThe unit to use.
fontThe font to use.

Definition at line 717 of file Formatter.cpp.

◆ scaleDownFactor()

qreal KSysGuard::Formatter::scaleDownFactor ( const QVariant & value,
Unit unit,
MetricPrefix targetPrefix = MetricPrefixAutoAdjust )
static

Returns the scale factor suitable for display.

Parameters
valueThe maximum output value.
unitThe unit of the value.
targetPrefixPreferred metric prefix.

Definition at line 501 of file Formatter.cpp.

◆ symbol()

QString KSysGuard::Formatter::symbol ( Unit unit)
static

Returns a symbol that corresponds to the given unit.

The returned unit symbol is localized.

Definition at line 590 of file Formatter.cpp.


The documentation for this class was generated from the following files:
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:19:45 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.