Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
QMediaTimeRange Class Reference

The QMediaTimeRange class represents a set of zero or more disjoint time intervals. More...

#include <qmediatimerange.h>

+ Collaboration diagram for QMediaTimeRange:

Classes

class  Interval
 The QMediaTimeRange::Interval class represents a time interval with integer precision. More...
 

Public Member Functions

 QMediaTimeRange ()
 Constructs an empty time range.
 
 QMediaTimeRange (qint64 start, qint64 end)
 Constructs a time range that contains an initial interval from start to end inclusive.
 
 QMediaTimeRange (const Interval &)
 Constructs a time range that contains an initial interval, interval.
 
 QMediaTimeRange (const QMediaTimeRange &range) noexcept
 Constructs a time range by copying another time range.
 
 ~QMediaTimeRange ()
 Destructor.
 
QMediaTimeRangeoperator= (const QMediaTimeRange &) noexcept
 Takes a copy of the other time range and returns itself.
 
 QMediaTimeRange (QMediaTimeRange &&other) noexcept=default
 Constructs a time range by moving from other.
 
void swap (QMediaTimeRange &other) noexcept
 Swaps the current instance with the other.
 
void detach ()
 
QMediaTimeRangeoperator= (const Interval &)
 Sets the time range to a single continuous interval, interval.
 
qint64 earliestTime () const
 Returns the earliest time within the time range.
 
qint64 latestTime () const
 Returns the latest time within the time range.
 
QList< QMediaTimeRange::Intervalintervals () const
 Returns the list of intervals covered by this time range.
 
bool isEmpty () const
 Returns true if there are no intervals within the time range.
 
bool isContinuous () const
 Returns true if the time range consists of a continuous interval.
 
bool contains (qint64 time) const
 Returns true if the specified time lies within the time range.
 
void addInterval (qint64 start, qint64 end)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Adds the interval specified by start and end to the time range.
 
void addInterval (const Interval &interval)
 Adds the specified interval to the time range.
 
void addTimeRange (const QMediaTimeRange &)
 Adds each of the intervals in range to this time range.
 
void removeInterval (qint64 start, qint64 end)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Removes the interval specified by start and end from the time range.
 
void removeInterval (const Interval &interval)
 Removes the specified interval from the time range.
 
void removeTimeRange (const QMediaTimeRange &)
 Removes each of the intervals in range from this time range.
 
QMediaTimeRangeoperator+= (const QMediaTimeRange &)
 Adds each interval in other to the time range and returns the result.
 
QMediaTimeRangeoperator+= (const Interval &)
 Adds the specified interval to the time range and returns the result.
 
QMediaTimeRangeoperator-= (const QMediaTimeRange &)
 Removes each interval in other from the time range and returns the result.
 
QMediaTimeRangeoperator-= (const Interval &)
 Removes the specified interval from the time range and returns the result.
 
void clear ()
 Removes all intervals from the time range.
 

Friends

bool operator== (const QMediaTimeRange &lhs, const QMediaTimeRange &rhs)
 Returns true if all intervals in lhs are present in rhs.
 
bool operator!= (const QMediaTimeRange &lhs, const QMediaTimeRange &rhs)
 Returns true if one or more intervals in lhs are not present in rhs.
 

Related Symbols

(Note that these are not member symbols.)

QMediaTimeRange operator+ (const QMediaTimeRange &r1, const QMediaTimeRange &r2)
 Returns a time range containing the union between r1 and r2.
 
QMediaTimeRange operator- (const QMediaTimeRange &r1, const QMediaTimeRange &r2)
 Returns a time range containing r2 subtracted from r1.
 

Detailed Description

The QMediaTimeRange class represents a set of zero or more disjoint time intervals.

\inmodule QtMultimedia

\reentrant

The earliestTime(), latestTime(), intervals() and isEmpty() methods are used to get information about the current time range.

The addInterval(), removeInterval() and clear() methods are used to modify the current time range.

When adding or removing intervals from the time range, existing intervals within the range may be expanded, trimmed, deleted, merged or split to ensure that all intervals within the time range remain distinct and disjoint. As a consequence, all intervals added or removed from a time range must be \l{QMediaTimeRange::Interval::isNormal()}{normal}.

See also
QMediaTimeRange::Interval

Definition at line 19 of file qmediatimerange.h.

Constructor & Destructor Documentation

◆ QMediaTimeRange() [1/5]

QMediaTimeRange::QMediaTimeRange ( )

Constructs an empty time range.

Definition at line 219 of file qmediatimerange.cpp.

◆ QMediaTimeRange() [2/5]

QMediaTimeRange::QMediaTimeRange ( qint64 start,
qint64 end )
explicit

Constructs a time range that contains an initial interval from start to end inclusive.

If the interval is not \l{QMediaTimeRange::Interval::isNormal()}{normal}, the resulting time range will be empty.

See also
addInterval()

Definition at line 234 of file qmediatimerange.cpp.

◆ QMediaTimeRange() [3/5]

QMediaTimeRange::QMediaTimeRange ( const Interval & interval)

Constructs a time range that contains an initial interval, interval.

If interval is not \l{QMediaTimeRange::Interval::isNormal()}{normal}, the resulting time range will be empty.

See also
addInterval()

Definition at line 247 of file qmediatimerange.cpp.

◆ QMediaTimeRange() [4/5]

QMediaTimeRange::QMediaTimeRange ( const QMediaTimeRange & range)
defaultnoexcept

Constructs a time range by copying another time range.

◆ ~QMediaTimeRange()

QMediaTimeRange::~QMediaTimeRange ( )
default

Destructor.

◆ QMediaTimeRange() [5/5]

QMediaTimeRange::QMediaTimeRange ( QMediaTimeRange && other)
defaultnoexcept

Constructs a time range by moving from other.

Member Function Documentation

◆ addInterval() [1/2]

void QMediaTimeRange::addInterval ( const Interval & interval)

Adds the specified interval to the time range.

Adding intervals which are not \l{QMediaTimeRange::Interval::isNormal()}{normal} is invalid, and will be ignored.

If the specified interval is adjacent to, or overlaps existing intervals within the time range, these intervals will be merged.

This operation takes linear time.

See also
removeInterval()

Definition at line 352 of file qmediatimerange.cpp.

References QMediaTimeRangePrivate::addInterval(), and detach().

+ Here is the call graph for this function:

◆ addInterval() [2/2]

void QMediaTimeRange::addInterval ( qint64 start,
qint64 end )

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Adds the interval specified by start and end to the time range.

See also
addInterval()

Definition at line 333 of file qmediatimerange.cpp.

References QMediaTimeRangePrivate::addInterval(), detach(), and Interval.

Referenced by operator+=().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ addTimeRange()

void QMediaTimeRange::addTimeRange ( const QMediaTimeRange & range)

Adds each of the intervals in range to this time range.

Equivalent to calling addInterval() for each interval in range.

Definition at line 363 of file qmediatimerange.cpp.

References QMediaTimeRangePrivate::addInterval(), detach(), i, and intervals().

Referenced by operator+=().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ clear()

void QMediaTimeRange::clear ( )

Removes all intervals from the time range.

See also
removeInterval()

Definition at line 465 of file qmediatimerange.cpp.

References QList< T >::clear(), detach(), and QMediaTimeRangePrivate::intervals.

+ Here is the call graph for this function:

◆ contains()

bool QMediaTimeRange::contains ( qint64 time) const

Returns true if the specified time lies within the time range.

Definition at line 517 of file qmediatimerange.cpp.

References QListSpecialMethodsBase< T >::contains(), i, QMediaTimeRangePrivate::intervals, intervals(), QList< T >::size(), and time.

+ Here is the call graph for this function:

◆ detach()

void QMediaTimeRange::detach ( )

Definition at line 474 of file qmediatimerange.cpp.

References QExplicitlySharedDataPointer< T >::detach().

Referenced by addInterval(), addInterval(), addTimeRange(), clear(), removeInterval(), removeInterval(), and removeTimeRange().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ earliestTime()

qint64 QMediaTimeRange::earliestTime ( ) const

Returns the earliest time within the time range.

For empty time ranges, this value is equal to zero.

See also
latestTime()

Definition at line 302 of file qmediatimerange.cpp.

References QMediaTimeRangePrivate::intervals, and QList< T >::isEmpty().

+ Here is the call graph for this function:

◆ intervals()

QList< QMediaTimeRange::Interval > QMediaTimeRange::intervals ( ) const

Returns the list of intervals covered by this time range.

Definition at line 484 of file qmediatimerange.cpp.

References QMediaTimeRangePrivate::intervals.

Referenced by addTimeRange(), contains(), and removeTimeRange().

+ Here is the caller graph for this function:

◆ isContinuous()

bool QMediaTimeRange::isContinuous ( ) const

Returns true if the time range consists of a continuous interval.

That is, there is one or fewer disjoint intervals within the time range.

Definition at line 507 of file qmediatimerange.cpp.

References QMediaTimeRangePrivate::intervals, and QList< T >::size().

+ Here is the call graph for this function:

◆ isEmpty()

bool QMediaTimeRange::isEmpty ( ) const

Returns true if there are no intervals within the time range.

See also
intervals()

Definition at line 496 of file qmediatimerange.cpp.

References QMediaTimeRangePrivate::intervals, and QList< T >::isEmpty().

+ Here is the call graph for this function:

◆ latestTime()

qint64 QMediaTimeRange::latestTime ( ) const

Returns the latest time within the time range.

For empty time ranges, this value is equal to zero.

See also
earliestTime()

Definition at line 317 of file qmediatimerange.cpp.

References QList< T >::end(), QMediaTimeRangePrivate::intervals, QList< T >::isEmpty(), and QList< T >::size().

+ Here is the call graph for this function:

◆ operator+=() [1/2]

QMediaTimeRange & QMediaTimeRange::operator+= ( const Interval & interval)

Adds the specified interval to the time range and returns the result.

Definition at line 434 of file qmediatimerange.cpp.

References addInterval().

+ Here is the call graph for this function:

◆ operator+=() [2/2]

QMediaTimeRange & QMediaTimeRange::operator+= ( const QMediaTimeRange & other)

Adds each interval in other to the time range and returns the result.

Definition at line 425 of file qmediatimerange.cpp.

References addTimeRange(), and other().

+ Here is the call graph for this function:

◆ operator-=() [1/2]

QMediaTimeRange & QMediaTimeRange::operator-= ( const Interval & interval)

Removes the specified interval from the time range and returns the result.

Definition at line 452 of file qmediatimerange.cpp.

References removeInterval().

+ Here is the call graph for this function:

◆ operator-=() [2/2]

QMediaTimeRange & QMediaTimeRange::operator-= ( const QMediaTimeRange & other)

Removes each interval in other from the time range and returns the result.

Definition at line 443 of file qmediatimerange.cpp.

References other(), and removeTimeRange().

+ Here is the call graph for this function:

◆ operator=() [1/2]

QMediaTimeRange & QMediaTimeRange::operator= ( const Interval & interval)

Sets the time range to a single continuous interval, interval.

Definition at line 289 of file qmediatimerange.cpp.

◆ operator=() [2/2]

QMediaTimeRange & QMediaTimeRange::operator= ( const QMediaTimeRange & )
defaultnoexcept

Takes a copy of the other time range and returns itself.

◆ removeInterval() [1/2]

void QMediaTimeRange::removeInterval ( const Interval & interval)

Removes the specified interval from the time range.

Removing intervals which are not \l{QMediaTimeRange::Interval::isNormal()}{normal} is invalid, and will be ignored.

Intervals within the time range will be trimmed, split or deleted such that no intervals within the time range include any part of the target interval.

This operation takes linear time.

See also
addInterval()

Definition at line 402 of file qmediatimerange.cpp.

References detach(), and QMediaTimeRangePrivate::removeInterval().

+ Here is the call graph for this function:

◆ removeInterval() [2/2]

void QMediaTimeRange::removeInterval ( qint64 start,
qint64 end )

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Removes the interval specified by start and end from the time range.

See also
removeInterval()

Definition at line 380 of file qmediatimerange.cpp.

References detach(), Interval, and QMediaTimeRangePrivate::removeInterval().

Referenced by operator-=().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ removeTimeRange()

void QMediaTimeRange::removeTimeRange ( const QMediaTimeRange & range)

Removes each of the intervals in range from this time range.

Equivalent to calling removeInterval() for each interval in range.

Definition at line 413 of file qmediatimerange.cpp.

References detach(), i, intervals(), and QMediaTimeRangePrivate::removeInterval().

Referenced by operator-=().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ swap()

void QMediaTimeRange::swap ( QMediaTimeRange & other)
inlinenoexcept

Swaps the current instance with the other.

Definition at line 73 of file qmediatimerange.h.

References d, and other().

+ Here is the call graph for this function:

Friends And Related Symbol Documentation

◆ operator!=

bool QMediaTimeRange::operator!= ( const QMediaTimeRange & lhs,
const QMediaTimeRange & rhs )
friend

Returns true if one or more intervals in lhs are not present in rhs.

Definition at line 105 of file qmediatimerange.h.

◆ operator+()

QMediaTimeRange operator+ ( const QMediaTimeRange & r1,
const QMediaTimeRange & r2 )
related

Returns a time range containing the union between r1 and r2.

Definition at line 117 of file qmediatimerange.h.

References r1, and r2.

◆ operator-()

QMediaTimeRange operator- ( const QMediaTimeRange & r1,
const QMediaTimeRange & r2 )
related

Returns a time range containing r2 subtracted from r1.

Definition at line 119 of file qmediatimerange.h.

References r1, and r2.

◆ operator==

bool QMediaTimeRange::operator== ( const QMediaTimeRange & lhs,
const QMediaTimeRange & rhs )
friend

Returns true if all intervals in lhs are present in rhs.

Definition at line 103 of file qmediatimerange.h.


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