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)
 
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 )
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

Definition at line 452 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 446 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 652 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 436 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 525 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 Tue Mar 26 2024 11:21:23 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.