20#ifndef LIBREPCB_CORE_LENGTHUNIT_H
21#define LIBREPCB_CORE_LENGTHUNIT_H
132 QString
toStr() const noexcept;
163 QString
format(const
Length& value, const QLocale& locale,
164 const QString& separator = " ") const noexcept;
324 QString& expression)
noexcept;
332 return mUnit == rhs.mUnit;
335 return mUnit != rhs.mUnit;
362 stream << unit.
toStr();
367 stream << QString(
"LengthUnit(%1)").arg(unit.
toStr());
The Length class is used to represent a length (for example 12.75 millimeters)
Definition length.h:82
The LengthUnit class represents a length unit (millimeters, inches,...) and provides some useful meth...
Definition lengthunit.h:62
QString toStringTr() const noexcept
Convert the length unit to a localized string.
Definition lengthunit.cpp:63
QString format(const Length &value, const QLocale &locale, const QString &separator=" ") const noexcept
Get a pretty formatted length value with this unit.
Definition lengthunit.cpp:103
static std::optional< LengthUnit > extractFromExpression(QString &expression) noexcept
Try to extract the unit from a user input string.
Definition lengthunit.cpp:259
LengthUnit_t mUnit
Holds the length unit of the object.
Definition lengthunit.h:354
QString toStr() const noexcept
Serialize this object into a string.
Definition lengthunit.cpp:43
int getIndex() const noexcept
Get the Index of the length unit of this object.
Definition lengthunit.h:125
QString toShortStringTr() const noexcept
Convert the length unit to a localized string (short form)
Definition lengthunit.cpp:83
LengthUnit(LengthUnit_t unit) noexcept
Private Constructor to create a LengthUnit object with a specific unit.
Definition lengthunit.h:347
qreal convertToUnit(const Length &length) const noexcept
Convert a Length to this length unit.
Definition lengthunit.cpp:152
bool operator==(const LengthUnit &rhs) const noexcept
Definition lengthunit.h:331
static LengthUnit fromString(const QString &str)
Get the length unit represented by a string.
Definition lengthunit.cpp:234
static LengthUnit nanometers() noexcept
Definition lengthunit.h:304
static LengthUnit micrometers() noexcept
Definition lengthunit.h:301
static QList< LengthUnit > getAllUnits() noexcept
Get all available length units.
Definition lengthunit.cpp:252
static LengthUnit fromIndex(int index)
Get the length unit of a specific index (to use with getIndex())
Definition lengthunit.cpp:245
static LengthUnit mils() noexcept
Definition lengthunit.h:310
LengthUnit_t
An enum which contains all available length units.
Definition lengthunit.h:79
@ _COUNT
count of units, must be the last entry of the enum
LengthUnit & operator=(const LengthUnit &rhs) noexcept
Definition lengthunit.h:327
static LengthUnit millimeters() noexcept
Definition lengthunit.h:298
Length convertFromUnit(qreal length) const
Convert a floating point number with this unit to a Length object.
Definition lengthunit.cpp:192
bool operator!=(const LengthUnit &rhs) const noexcept
Definition lengthunit.h:334
LengthUnit(const LengthUnit &other) noexcept
Copy constructor.
Definition lengthunit.h:101
LengthUnit() noexcept
Default constructor which uses millimeters as unit.
Definition lengthunit.h:94
int getReasonableNumberOfDecimals() const noexcept
Get a reasonable number of decimals to be shown.
Definition lengthunit.cpp:110
~LengthUnit() noexcept
Destructor.
Definition lengthunit.h:106
static LengthUnit inches() noexcept
Definition lengthunit.h:307
QStringList getUserInputSuffixes() const noexcept
Get user input suffixes.
Definition lengthunit.cpp:131
The Point class is used to represent a point/coordinate/vector, for example (1.2mm; 5....
Definition point.h:78
Definition occmodel.cpp:77
QDataStream & operator<<(QDataStream &stream, const AttributeKey &obj)
Definition attributekey.h:108