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.h
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QMEDIATIMERANGE_H
5#define QMEDIATIMERANGE_H
6
7#include <QtMultimedia/qtmultimediaglobal.h>
8#include <QtCore/qshareddata.h>
9#include <QtCore/qlist.h>
10#include <QtCore/qmetatype.h>
11
13
14
16
18
19class Q_MULTIMEDIA_EXPORT QMediaTimeRange
20{
21public:
22 struct Interval
23 {
24 constexpr Interval() noexcept = default;
25 explicit constexpr Interval(qint64 start, qint64 end) noexcept
26 : s(start), e(end)
27 {}
28
29 constexpr qint64 start() const noexcept { return s; }
30 constexpr qint64 end() const noexcept { return e; }
31
32 constexpr bool contains(qint64 time) const noexcept
33 {
34 return isNormal() ? (s <= time && time <= e)
35 : (e <= time && time <= s);
36 }
37
38 constexpr bool isNormal() const noexcept { return s <= e; }
39 constexpr Interval normalized() const
40 {
41 return s > e ? Interval(e, s) : *this;
42 }
44 {
45 return Interval(s + offset, e + offset);
46 }
47
48 friend constexpr bool operator==(Interval lhs, Interval rhs) noexcept
49 {
50 return lhs.start() == rhs.start() && lhs.end() == rhs.end();
51 }
52 friend constexpr bool operator!=(Interval lhs, Interval rhs) noexcept
53 {
54 return lhs.start() != rhs.start() || lhs.end() != rhs.end();
55 }
56
57 private:
59 qint64 s = 0;
60 qint64 e = 0;
61 };
62
68
70
71 QMediaTimeRange(QMediaTimeRange &&other) noexcept = default;
72 QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_PURE_SWAP(QMediaTimeRange)
74 { d.swap(other.d); }
75 void detach();
76
78
79 qint64 earliestTime() const;
80 qint64 latestTime() const;
81
82 QList<QMediaTimeRange::Interval> intervals() const;
83 bool isEmpty() const;
84 bool isContinuous() const;
85
86 bool contains(qint64 time) const;
87
89 void addInterval(const Interval &interval);
90 void addTimeRange(const QMediaTimeRange&);
91
93 void removeInterval(const Interval &interval);
94 void removeTimeRange(const QMediaTimeRange&);
95
98 QMediaTimeRange& operator-=(const QMediaTimeRange&);
99 QMediaTimeRange& operator-=(const Interval&);
100
101 void clear();
102
103 friend inline bool operator==(const QMediaTimeRange &lhs, const QMediaTimeRange &rhs)
104 { return lhs.intervals() == rhs.intervals(); }
105 friend inline bool operator!=(const QMediaTimeRange &lhs, const QMediaTimeRange &rhs)
106 { return lhs.intervals() != rhs.intervals(); }
107
108private:
109 QExplicitlySharedDataPointer<QMediaTimeRangePrivate> d;
110};
111
112#ifndef QT_NO_DEBUG_STREAM
113Q_MULTIMEDIA_EXPORT QDebug operator<<(QDebug, const QMediaTimeRange::Interval &);
114Q_MULTIMEDIA_EXPORT QDebug operator<<(QDebug, const QMediaTimeRange &);
115#endif
116
121
122Q_DECLARE_SHARED(QMediaTimeRange)
123
125
128
129#endif // QMEDIATIMERANGE_H
\inmodule QtCore
QList< QMediaTimeRange::Interval > intervals
void removeInterval(const QMediaTimeRange::Interval &interval)
void addInterval(const QMediaTimeRange::Interval &interval)
The QMediaTimeRange class represents a set of zero or more disjoint time intervals.
friend bool operator==(const QMediaTimeRange &lhs, const QMediaTimeRange &rhs)
Returns true if all intervals in lhs are present in rhs.
QMediaTimeRange(QMediaTimeRange &&other) noexcept=default
Constructs a time range by moving from other.
QMediaTimeRange & operator=(const QMediaTimeRange &) noexcept
Takes a copy of the other time range and returns itself.
QMediaTimeRange(const QMediaTimeRange &range) noexcept
Constructs a time range by copying another time range.
friend bool operator!=(const QMediaTimeRange &lhs, const QMediaTimeRange &rhs)
Returns true if one or more intervals in lhs are not present in rhs.
~QMediaTimeRange()
Destructor.
QList< QMediaTimeRange::Interval > intervals() const
Returns the list of intervals covered by this time range.
QSharedData & operator=(const QSharedData &)=delete
b clear()
Combined button and popup list for selecting options.
constexpr timespec & operator+=(timespec &t1, const timespec &t2)
DBusConnection const char DBusError DBusBusType DBusError return DBusConnection DBusHandleMessageFunction void DBusFreeFunction return DBusConnection return DBusConnection return const char DBusError return DBusConnection DBusMessage dbus_uint32_t return DBusConnection dbus_bool_t DBusConnection DBusAddWatchFunction DBusRemoveWatchFunction DBusWatchToggledFunction void DBusFreeFunction return DBusConnection DBusDispatchStatusFunction void DBusFreeFunction DBusTimeout return DBusTimeout return DBusWatch return DBusWatch unsigned int return DBusError const DBusError return const DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessageIter int const void return DBusMessageIter DBusMessageIter return DBusMessageIter void DBusMessageIter void int return DBusMessage DBusMessageIter return DBusMessageIter return DBusMessageIter DBusMessageIter const char const char const char const char return DBusMessage return DBusMessage const char return DBusMessage dbus_bool_t return DBusMessage dbus_uint32_t return DBusMessage void
QMediaTimeRange operator+(const QMediaTimeRange &r1, const QMediaTimeRange &r2)
QMediaTimeRange operator-(const QMediaTimeRange &r1, const QMediaTimeRange &r2)
Q_MULTIMEDIA_EXPORT QDebug operator<<(QDebug, const QMediaTimeRange::Interval &)
#define Q_DECLARE_METATYPE(TYPE)
Definition qmetatype.h:1525
static bool contains(const QJsonArray &haystack, unsigned needle)
Definition qopengl.cpp:116
GLuint GLuint end
GLsizei range
GLuint start
GLenum GLuint GLintptr offset
GLdouble s
[6]
Definition qopenglext.h:235
static const int Interval
#define QT_DECLARE_QESDP_SPECIALIZATION_DTOR_WITH_EXPORT(Class, ExportMacro)
long long qint64
Definition qtypes.h:60
#define explicit
QRect r1(100, 200, 11, 16)
[0]
QRect r2(QPoint(100, 200), QSize(11, 16))
QSharedPointer< T > other(t)
[5]
this swap(other)
The QMediaTimeRange::Interval class represents a time interval with integer precision.
constexpr bool contains(qint64 time) const noexcept
Returns true if the time interval contains the specified time.
friend constexpr bool operator==(Interval lhs, Interval rhs) noexcept
Returns true if lhs is exactly equal to rhs.
constexpr qint64 end() const noexcept
Returns the end time of the interval.
constexpr bool isNormal() const noexcept
Returns true if this time interval is normal.
constexpr qint64 start() const noexcept
Returns the start time of the interval.
constexpr Interval normalized() const
Returns a normalized version of this interval.
constexpr Interval() noexcept=default
constexpr Interval translated(qint64 offset) const
Returns a copy of this time interval, translated by a value of offset.
friend constexpr bool operator!=(Interval lhs, Interval rhs) noexcept
Returns true if lhs is not exactly equal to rhs.