|
KanoopCommonQt 2.1.1
Kanoop foundational Qt utility library
|
|
An interval of time defined by a start TimeSpan offset and an end TimeSpan offset. More...
#include <timespanrange.h>
Classes | |
| class | List |
| A QList of TimeSpanRange objects with a consolidated() helper. More... | |
Public Member Functions | |
| TimeSpanRange () | |
| Default constructor — creates an invalid (default-constructed) range. | |
| TimeSpanRange (const TimeSpan &startOffset, const TimeSpan &endOffset) | |
| Construct a range from explicit start and end offsets. | |
| TimeSpanRange (const QDateTime &startTime, const TimeSpan &duration) | |
| Construct a range from an absolute QDateTime start and a duration. | |
| TimeSpanRange (const TimeSpanRange &other) | |
| Copy constructor. | |
| TimeSpanRange & | operator= (const TimeSpanRange &other) |
| Copy assignment. | |
| TimeSpanRange | operator+ (const TimeSpan &other) const |
| Shift both endpoints forward by a TimeSpan delta. | |
| TimeSpanRange | operator- (const TimeSpan &other) const |
| Shift both endpoints backward by a TimeSpan delta. | |
| void | operator+= (const TimeSpan &other) |
| Add-assign a TimeSpan delta to both endpoints. | |
| void | operator-= (const TimeSpan &other) |
| Subtract-assign a TimeSpan delta from both endpoints. | |
| bool | operator== (const TimeSpanRange &other) const |
| Equality comparison. | |
| bool | operator!= (const TimeSpanRange &other) const |
| Inequality comparison. | |
| TimeSpan | startOffset () const |
| Return the start offset. | |
| void | setStartOffset (const TimeSpan &value) |
| Set the start offset. | |
| TimeSpan | endOffset () const |
| Return the end offset. | |
| void | setEndOffset (const TimeSpan &value) |
| Set the end offset. | |
| TimeSpan | duration () const |
| Return the duration of this range (end − start). | |
| TimeSpan | midpoint () const |
| Return the midpoint of this range. | |
| bool | contains (const TimeSpan &time) const |
| Test whether a time offset falls within this range (inclusive). | |
| bool | contains (const TimeSpanRange &other) const |
| Test whether another range is entirely contained within this one. | |
| TimeSpanRange | subRange (const TimeSpanRange &other) const |
| Return the portion of another range that overlaps this range. | |
| TimeSpanRange | merged (const TimeSpanRange &other) const |
| Return the union of this range and another, spanning both. | |
| QString | toString () const |
| Format this range as a human-readable string. | |
| bool | isValid () const |
| Return true if both endpoints are valid TimeSpan values. | |
Static Public Member Functions | |
| static TimeSpanRange | fromMidpoint (const TimeSpan &midpoint, const TimeSpan &duration) |
| Construct a range centred on a midpoint with a given total duration. | |
| static TimeSpanRange | fromDateRange (const DateRange &dateRange) |
| Construct a TimeSpanRange from a DateRange. | |
| static TimeSpanRange | fromStartAndDuration (const TimeSpan &startOffset, const TimeSpan &duration) |
| Construct a range from a start offset and a duration. | |
| static TimeSpanRange | merged (const TimeSpanRange &a, const TimeSpanRange &b) |
| Return the union of two ranges, spanning both. | |
An interval of time defined by a start TimeSpan offset and an end TimeSpan offset.
Useful for windowing or slicing time-series data. All arithmetic operators shift both endpoints by the same delta. The inner List class provides consolidated() to merge overlapping or adjacent ranges into a minimal non-overlapping set.
Definition at line 18 of file timespanrange.h.
|
inline |
Default constructor — creates an invalid (default-constructed) range.
Definition at line 22 of file timespanrange.h.
Construct a range from explicit start and end offsets.
| startOffset | Start of the range |
| endOffset | End of the range |
Definition at line 29 of file timespanrange.h.
|
inline |
Construct a range from an absolute QDateTime start and a duration.
| startTime | Start time (converted to a millisecond-epoch offset) |
| duration | Length of the range |
Definition at line 37 of file timespanrange.h.
| TimeSpanRange::TimeSpanRange | ( | const TimeSpanRange & | other | ) |
Copy constructor.
| other | Range to copy |
|
inline |
Test whether a time offset falls within this range (inclusive).
| time | TimeSpan offset to test |
Definition at line 156 of file timespanrange.h.
|
inline |
Test whether another range is entirely contained within this one.
| other | Range to test |
Definition at line 163 of file timespanrange.h.
References contains(), endOffset(), and startOffset().
Referenced by contains().
|
inline |
Return the duration of this range (end − start).
Definition at line 143 of file timespanrange.h.
|
inline |
Return the end offset.
Definition at line 131 of file timespanrange.h.
Referenced by TimeSpanRange::List::consolidated(), and contains().
|
static |
Construct a TimeSpanRange from a DateRange.
| dateRange | Source date range |
|
static |
Construct a range centred on a midpoint with a given total duration.
| midpoint | Centre of the range |
| duration | Total length of the range |
|
static |
Construct a range from a start offset and a duration.
| startOffset | Start of the range |
| duration | Length of the range |
|
inline |
Return true if both endpoints are valid TimeSpan values.
Definition at line 197 of file timespanrange.h.
|
inlinestatic |
Return the union of two ranges, spanning both.
| a | First range |
| b | Second range |
Definition at line 185 of file timespanrange.h.
References merged().
| TimeSpanRange TimeSpanRange::merged | ( | const TimeSpanRange & | other | ) | const |
Return the union of this range and another, spanning both.
| other | Range to merge with |
Referenced by merged().
|
inline |
Return the midpoint of this range.
Definition at line 149 of file timespanrange.h.
| bool TimeSpanRange::operator!= | ( | const TimeSpanRange & | other | ) | const |
Inequality comparison.
| other | Range to compare with |
| TimeSpanRange TimeSpanRange::operator+ | ( | const TimeSpan & | other | ) | const |
Shift both endpoints forward by a TimeSpan delta.
| other | Amount to add to both endpoints |
| void TimeSpanRange::operator+= | ( | const TimeSpan & | other | ) |
Add-assign a TimeSpan delta to both endpoints.
| other | Amount to add |
| TimeSpanRange TimeSpanRange::operator- | ( | const TimeSpan & | other | ) | const |
Shift both endpoints backward by a TimeSpan delta.
| other | Amount to subtract from both endpoints |
| void TimeSpanRange::operator-= | ( | const TimeSpan & | other | ) |
Subtract-assign a TimeSpan delta from both endpoints.
| other | Amount to subtract |
| TimeSpanRange & TimeSpanRange::operator= | ( | const TimeSpanRange & | other | ) |
Copy assignment.
| other | Range to copy |
| bool TimeSpanRange::operator== | ( | const TimeSpanRange & | other | ) | const |
Equality comparison.
| other | Range to compare with |
|
inline |
Set the end offset.
| value | New end TimeSpan |
Definition at line 137 of file timespanrange.h.
|
inline |
Set the start offset.
| value | New start TimeSpan |
Definition at line 125 of file timespanrange.h.
|
inline |
Return the start offset.
Definition at line 119 of file timespanrange.h.
Referenced by TimeSpanRange::List::consolidated(), and contains().
| TimeSpanRange TimeSpanRange::subRange | ( | const TimeSpanRange & | other | ) | const |
Return the portion of another range that overlaps this range.
| other | Range to intersect with |
| QString TimeSpanRange::toString | ( | ) | const |
Format this range as a human-readable string.