swift
Public Types | Public Member Functions | List of all members
swift::misc::physical_quantities::CTime Class Reference

Time class, e.g. More...

Inheritance diagram for swift::misc::physical_quantities::CTime:
[legend]

Public Types

enum  Parts { Hours = 0 , Minutes , Seconds }
 Parts.
 
- Public Types inherited from swift::misc::physical_quantities::CPhysicalQuantity< CTimeUnit, CTime >
enum  ColumnIndex
 Index.
 
- Public Types inherited from swift::misc::mixin::Index< Derived >
enum  ColumnIndex { IndexPixmap = 10 , IndexIcon , IndexString }
 Base class enums.
 

Public Member Functions

 CTime ()
 Default constructor.
 
 CTime (double value, const CTimeUnit &unit)
 Init by double value.
 
 CTime (int hours, int minutes, int seconds=0)
 By hours, minutes, seconds.
 
 CTime (QTime time, bool negative=false)
 By Qt time.
 
 CTime (const QString &unitString)
 Constructor by parsed string, e.g. 10m. More...
 
void parseFromString (const QString &time)
 From string hh:mm, or hh:mm:ss, or time units such as s, min.
 
bool parseFromString_hhmm (const QString &hhmm)
 From string like 2211 (hhmm)
 
void parseFromString (const QString &time, swift::misc::physical_quantities::CPqString::SeparatorMode mode)
 From string hh:mm, or hh:mm:ss, or time units such as s, min.
 
QList< int > getHrsMinSecParts () const
 Parts hh, mm, ss. More...
 
QString formattedHrsMinSec () const
 Formatted as hh:mm:ss.
 
int toMs () const
 Convenience functions when used with timers etc.
 
int toSeconds () const
 Convenience functions when used with timers etc.
 
QString formattedHrsMin () const
 Formatted as hh:mm.
 
QDateTime toQDateTime () const
 To Qt date time.
 
QTime toQTime () const
 To Qt time.
 
- Public Member Functions inherited from swift::misc::physical_quantities::CPhysicalQuantity< CTimeUnit, CTime >
int compare (const CTime &other) const
 Compare with other PQ.
 
const CTimeUnitgetUnit () const
 Unit.
 
void setUnit (const CTimeUnit &unit)
 Simply set unit, do no calclulate conversion. More...
 
void setUnitBySymbol (const QString &unitName)
 Set unit by string.
 
QString getUnitSymbol () const
 Unit.
 
CTimeswitchUnit (const CTimeUnit &newUnit)
 Change unit, and convert value to maintain the same quantity.
 
CTime switchedUnit (const CTimeUnit &newUnit) const
 Return copy with switched unit.
 
bool isNull () const
 Is quantity null?
 
void setNull ()
 Set null.
 
double value (CTimeUnit unit) const
 Value in given unit.
 
double value () const
 Value in current unit.
 
void setCurrentUnitValue (double value)
 Set value in current unit.
 
int valueInteger (CTimeUnit unit) const
 As integer value.
 
int valueInteger () const
 As integer value in current unit.
 
QString valueIntegerAsString (CTimeUnit unit) const
 As integer value.
 
QString valueIntegerAsString () const
 As integer value in current unit.
 
bool isInteger () const
 Is value an integer.
 
double valueRounded (CTimeUnit unit, int digits=-1) const
 Rounded value in given unit. More...
 
double valueRounded (int digits=-1) const
 Rounded value in current unit. More...
 
QString valueRoundedAsString (CTimeUnit unit, int digits=-1) const
 Rounded value in given unit. More...
 
QString valueRoundedWithUnit (const CTimeUnit &unit, int digits=-1, bool withGroupSeparator=false, bool i18n=false) const
 Value to QString with the given unit, e.g. "5.00m". More...
 
QString valueRoundedWithUnit (int digits=-1, bool withGroupSeparator=false, bool i18n=false) const
 Value to QString with the current unit, e.g. "5.00m". More...
 
void roundToEpsilon ()
 Round current value in current unit to epsilon. More...
 
void setValueSameUnit (double value)
 Change value without changing unit.
 
void addValueSameUnit (double value)
 Add to the value in the current unit.
 
void substractValueSameUnit (double value)
 Substract from the value in the current unit.
 
CPhysicalQuantityoperator*= (double multiply)
 Multiply operator *=.
 
CPhysicalQuantityoperator/= (double divide)
 Divide operator /=.
 
CTime operator* (double multiply) const
 Operator *.
 
CTime operator/ (double divide) const
 Operator /.
 
CTime operator- () const
 Unary operator -.
 
CPhysicalQuantityoperator+= (const CPhysicalQuantity &other)
 Plus operator +=.
 
CPhysicalQuantityoperator-= (const CPhysicalQuantity &other)
 Minus operator-=.
 
bool isZeroEpsilonConsidered () const
 Quantity value <= epsilon.
 
bool isPositiveWithEpsilonConsidered () const
 Value >= 0 epsilon considered.
 
bool isNegativeWithEpsilonConsidered () const
 Value <= 0 epsilon considered.
 
const CTimemakePositive ()
 Make value always positive.
 
const CTimemakeNegative ()
 Make value always negative.
 
CTime abs () const
 Absolute value (always >=0)
 
void marshallToDbus (QDBusArgument &argument) const
 Marshall without begin/endStructure, for when composed within another object. More...
 
void marshallToDbus (QDBusArgument &argument, LosslessTag) const
 Marshal to DBus, preserving the measurement unit.
 
void unmarshallFromDbus (const QDBusArgument &argument)
 Unmarshall without begin/endStructure, for when composed within another object. More...
 
void unmarshallFromDbus (const QDBusArgument &argument, LosslessTag)
 Unmarshal from DBus, with preserved measurement unit.
 
void marshalToDataStream (QDataStream &stream) const
 Marshal a value to a QDataStream. More...
 
void unmarshalFromDataStream (QDataStream &stream)
 Unmarshal a value from a QDataStream. More...
 
size_t getValueHash () const
 qHash overload, needed for storing value in a QSet. More...
 
QJsonObject toJson () const
 Cast to JSON object. More...
 
void convertFromJson (const QJsonObject &json)
 Assign from JSON object. More...
 
QVariant propertyByIndex (CPropertyIndexRef index) const
 Property by index. More...
 
void setPropertyByIndex (CPropertyIndexRef index, const QVariant &variant)
 Set property by index. More...
 
int comparePropertyByIndex (CPropertyIndexRef index, const CTime &pq) const
 Compare for index. More...
 
QString convertToQString (bool i18n=false) const
 Cast as QString. More...
 
void parseFromString (const QString &value)
 Parse value from string.
 
void parseFromString (const QString &value, CPqString::SeparatorMode mode)
 Parse to string, with specified separator.
 
void parseFromString (const QString &value, CPqString::SeparatorMode mode, const CTimeUnit &defaultUnitIfMissing)
 Parse to string, with specified separator.
 
- Public Member Functions inherited from swift::misc::mixin::Index< Derived >
CPropertyIndexList apply (const CPropertyIndexVariantMap &indexMap, bool skipEqualValues=false)
 Update by variant map. More...
 
void setPropertyByIndex (CPropertyIndexRef index, const QVariant &variant)
 Set property by index.
 
QVariant propertyByIndex (CPropertyIndexRef index) const
 Property by index.
 
int comparePropertyByIndex (CPropertyIndexRef index, const Derived &compareValue) const
 Compare for index.
 
bool equalsPropertyByIndex (const QVariant &compareValue, CPropertyIndexRef index) const
 Is given variant equal to value of property index?
 
- Public Member Functions inherited from swift::misc::mixin::MetaType< Derived >
int getMetaTypeId () const
 Returns the Qt meta type ID of this object. More...
 
QString getClassName () const
 Class name.
 
bool isA (int metaTypeId) const
 Returns true if this object is an instance of the class with the given meta type ID, or one of its subclasses.
 
- Public Member Functions inherited from swift::misc::mixin::String< Derived >
QString toQString (bool i18n=false) const
 Cast as QString.
 
std::string toStdString (bool i18n=false) const
 To std string.
 
QString stringForStreaming () const
 String for streaming operators.
 
- Public Member Functions inherited from swift::misc::mixin::Icon< Derived, IconIndex >
CIcons::IconIndex toIcon () const
 As icon, not implemented by all classes.
 

Additional Inherited Members

- Static Public Member Functions inherited from swift::misc::physical_quantities::CPhysicalQuantity< CTimeUnit, CTime >
static int compare (const CTime &a, const CTime &b)
 Implementation of compare.
 
static const CTimemaxValue (const CTime &pq1, const CTime &pq2)
 Maximum of 2 quantities.
 
static const CTimeminValue (const CTime &pq1, const CTime &pq2)
 Minimum of 2 quantities.
 
static const CTimenull ()
 NULL PQ.
 
static CTime parsedFromString (const QString &value, CPqString::SeparatorMode mode=CPqString::SeparatorBestGuess)
 Parsed from given string.
 
static CTime parsedFromString (const QString &value, CPqString::SeparatorMode mode, const CTimeUnit &defaultUnitIfMissing)
 Parsed from given string.
 
- Static Public Member Functions inherited from swift::misc::mixin::MetaType< Derived >
static void registerMetadata ()
 Register metadata.
 
- Protected Member Functions inherited from swift::misc::physical_quantities::CPhysicalQuantity< CTimeUnit, CTime >
 CPhysicalQuantity (double value, CTimeUnit unit)
 Constructor with double.
 
 CPhysicalQuantity (const QString &unitString)
 Constructor by parsed string, e.g. 10m.
 

Detailed Description

Time class, e.g.

"ms", "hour", "s", "day"

Definition at line 25 of file time.h.

Constructor & Destructor Documentation

◆ CTime()

swift::misc::physical_quantities::CTime::CTime ( const QString &  unitString)
inline

Constructor by parsed string, e.g. 10m.

Definition at line 49 of file time.h.

Member Function Documentation

◆ getHrsMinSecParts()

QList< int > swift::misc::physical_quantities::CTime::getHrsMinSecParts ( ) const

Parts hh, mm, ss.

Warning
sign not considered

Definition at line 89 of file time.cpp.


The documentation for this class was generated from the following files: