qtmobility/src/multimedia/qmediatimerange.cpp
changeset 1 2b40d63a9c3d
child 5 453da2cfceef
equal deleted inserted replaced
0:cfcbf08528c4 1:2b40d63a9c3d
       
     1 /****************************************************************************
       
     2 **
       
     3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     4 ** All rights reserved.
       
     5 ** Contact: Nokia Corporation (qt-info@nokia.com)
       
     6 **
       
     7 ** This file is part of the Qt Mobility Components.
       
     8 **
       
     9 ** $QT_BEGIN_LICENSE:LGPL$
       
    10 ** No Commercial Usage
       
    11 ** This file contains pre-release code and may not be distributed.
       
    12 ** You may use this file in accordance with the terms and conditions
       
    13 ** contained in the Technology Preview License Agreement accompanying
       
    14 ** this package.
       
    15 **
       
    16 ** GNU Lesser General Public License Usage
       
    17 ** Alternatively, this file may be used under the terms of the GNU Lesser
       
    18 ** General Public License version 2.1 as published by the Free Software
       
    19 ** Foundation and appearing in the file LICENSE.LGPL included in the
       
    20 ** packaging of this file.  Please review the following information to
       
    21 ** ensure the GNU Lesser General Public License version 2.1 requirements
       
    22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
       
    23 **
       
    24 ** In addition, as a special exception, Nokia gives you certain additional
       
    25 ** rights.  These rights are described in the Nokia Qt LGPL Exception
       
    26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
       
    27 **
       
    28 ** If you have questions regarding the use of this file, please contact
       
    29 ** Nokia at qt-info@nokia.com.
       
    30 **
       
    31 **
       
    32 **
       
    33 **
       
    34 **
       
    35 **
       
    36 **
       
    37 **
       
    38 ** $QT_END_LICENSE$
       
    39 **
       
    40 ****************************************************************************/
       
    41 
       
    42 #include "qmediatimerange.h"
       
    43 
       
    44 QTM_BEGIN_NAMESPACE
       
    45 
       
    46 /*!
       
    47     \class QMediaTimeInterval
       
    48     \brief The QMediaTimeInterval class represents a time interval with integer precision.
       
    49     \ingroup multimedia
       
    50 
       
    51     An interval is specified by an inclusive start() and end() time.
       
    52     These must be set in the constructor, as this is an immutable class.
       
    53     The specific units of time represented by the class have not been defined -
       
    54     it is suitable for any times which can be represented by a signed 64 bit integer.
       
    55 
       
    56     The isNormal() method determines if a time interval is normal
       
    57     (a normal time interval has start() <= end()). An abnormal interval can be converted
       
    58     in to a normal interval by calling the normalized() method.
       
    59 
       
    60     The contains() method determines if a specified time lies within
       
    61     the time interval.
       
    62 
       
    63     The translated() method returns a time interval which has been translated
       
    64     forwards or backwards through time by a specified offset.
       
    65 
       
    66     \sa QMediaTimeRange
       
    67 */
       
    68 
       
    69 /*!
       
    70     \fn QMediaTimeInterval::QMediaTimeInterval()
       
    71 
       
    72     Constructs an empty interval.
       
    73 */
       
    74 QMediaTimeInterval::QMediaTimeInterval()
       
    75     : s(0)
       
    76     , e(0)
       
    77 {
       
    78 
       
    79 }
       
    80 
       
    81 /*!
       
    82     \fn QMediaTimeInterval::QMediaTimeInterval(qint64 start, qint64 end)
       
    83 
       
    84     Constructs an interval with the specified \a start and \a end times.
       
    85 */
       
    86 QMediaTimeInterval::QMediaTimeInterval(qint64 start, qint64 end)
       
    87     : s(start)
       
    88     , e(end)
       
    89 {
       
    90 
       
    91 }
       
    92 
       
    93 /*!
       
    94     \fn QMediaTimeInterval::QMediaTimeInterval(const QMediaTimeInterval &other)
       
    95 
       
    96     Constructs an interval by taking a copy of \a other.
       
    97 */
       
    98 QMediaTimeInterval::QMediaTimeInterval(const QMediaTimeInterval &other)
       
    99     : s(other.s)
       
   100     , e(other.e)
       
   101 {
       
   102 
       
   103 }
       
   104 
       
   105 /*!
       
   106     \fn QMediaTimeInterval::start() const
       
   107 
       
   108     Returns the start time of the interval.
       
   109 
       
   110     \sa end()
       
   111 */
       
   112 qint64 QMediaTimeInterval::start() const
       
   113 {
       
   114     return s;
       
   115 }
       
   116 
       
   117 /*!
       
   118     \fn QMediaTimeInterval::end() const
       
   119 
       
   120     Returns the end time of the interval.
       
   121 
       
   122     \sa start()
       
   123 */
       
   124 qint64 QMediaTimeInterval::end() const
       
   125 {
       
   126     return e;
       
   127 }
       
   128 
       
   129 /*!
       
   130     \fn QMediaTimeInterval::contains(qint64 time) const
       
   131 
       
   132     Returns true if the time interval contains the specified \a time.
       
   133     That is, start() <= time <= end().
       
   134 */
       
   135 bool QMediaTimeInterval::contains(qint64 time) const
       
   136 {
       
   137     return isNormal() ? (s <= time && time <= e)
       
   138         : (e <= time && time <= s);
       
   139 }
       
   140 
       
   141 /*!
       
   142     \fn QMediaTimeInterval::isNormal() const
       
   143 
       
   144     Returns true if this time interval is normal.
       
   145     A normal time interval has start() <= end().
       
   146 
       
   147     \sa normalized()
       
   148 */
       
   149 bool QMediaTimeInterval::isNormal() const
       
   150 {
       
   151     return s <= e;
       
   152 }
       
   153 
       
   154 /*!
       
   155     \fn QMediaTimeInterval::normalized() const
       
   156 
       
   157     Returns a normalized version of this interval.
       
   158 
       
   159     If the start() time of the interval is greater than the end() time,
       
   160     then the returned interval has the start and end times swapped.
       
   161 */
       
   162 QMediaTimeInterval QMediaTimeInterval::normalized() const
       
   163 {
       
   164     if(s > e)
       
   165         return QMediaTimeInterval(e, s);
       
   166 
       
   167     return *this;
       
   168 }
       
   169 
       
   170 /*!
       
   171     \fn QMediaTimeInterval::translated(qint64 offset) const
       
   172 
       
   173     Returns a copy of this time interval, translated by a value of \a offset.
       
   174     An interval can be moved forward through time with a positive offset, or backward
       
   175     through time with a negative offset.
       
   176 */
       
   177 QMediaTimeInterval QMediaTimeInterval::translated(qint64 offset) const
       
   178 {
       
   179     return QMediaTimeInterval(s + offset, e + offset);
       
   180 }
       
   181 
       
   182 /*!
       
   183     \fn operator==(const QMediaTimeInterval &a, const QMediaTimeInterval &b)
       
   184     \relates QMediaTimeRange
       
   185 
       
   186     Returns true if \a a is exactly equal to \a b.
       
   187 */
       
   188 bool operator==(const QMediaTimeInterval &a, const QMediaTimeInterval &b)
       
   189 {
       
   190     return a.start() == b.start() && a.end() == b.end();
       
   191 }
       
   192 
       
   193 /*!
       
   194     \fn operator!=(const QMediaTimeInterval &a, const QMediaTimeInterval &b)
       
   195     \relates QMediaTimeRange
       
   196 
       
   197     Returns true if \a a is not exactly equal to \a b.
       
   198 */
       
   199 bool operator!=(const QMediaTimeInterval &a, const QMediaTimeInterval &b)
       
   200 {
       
   201     return a.start() != b.start() || a.end() != b.end();
       
   202 }
       
   203 
       
   204 class QMediaTimeRangePrivate : public QSharedData
       
   205 {
       
   206 public:
       
   207 
       
   208     QMediaTimeRangePrivate();
       
   209     QMediaTimeRangePrivate(const QMediaTimeRangePrivate &other);
       
   210     QMediaTimeRangePrivate(const QMediaTimeInterval &interval);
       
   211 
       
   212     QList<QMediaTimeInterval> intervals;
       
   213 
       
   214     void addInterval(const QMediaTimeInterval &interval);
       
   215     void removeInterval(const QMediaTimeInterval &interval);
       
   216 };
       
   217 
       
   218 QMediaTimeRangePrivate::QMediaTimeRangePrivate()
       
   219     : QSharedData()
       
   220 {
       
   221 
       
   222 }
       
   223 
       
   224 QMediaTimeRangePrivate::QMediaTimeRangePrivate(const QMediaTimeRangePrivate &other)
       
   225     : QSharedData()
       
   226     , intervals(other.intervals)
       
   227 {
       
   228 
       
   229 }
       
   230 
       
   231 QMediaTimeRangePrivate::QMediaTimeRangePrivate(const QMediaTimeInterval &interval)
       
   232     : QSharedData()
       
   233 {
       
   234     if(interval.isNormal())
       
   235         intervals << interval;
       
   236 }
       
   237 
       
   238 void QMediaTimeRangePrivate::addInterval(const QMediaTimeInterval &interval)
       
   239 {    
       
   240     // Handle normalized intervals only
       
   241     if(!interval.isNormal())
       
   242         return;
       
   243 
       
   244     // Find a place to insert the interval
       
   245     int i;
       
   246     for (i = 0; i < intervals.count(); i++) {
       
   247         // Insert before this element
       
   248         if(interval.s < intervals[i].s) {
       
   249             intervals.insert(i, interval);
       
   250             break;
       
   251         }
       
   252     }
       
   253 
       
   254     // Interval needs to be added to the end of the list
       
   255     if (i == intervals.count())
       
   256         intervals.append(interval);
       
   257 
       
   258     // Do we need to correct the element before us?
       
   259     if(i > 0 && intervals[i - 1].e >= interval.s - 1)
       
   260         i--;
       
   261 
       
   262     // Merge trailing ranges
       
   263     while (i < intervals.count() - 1
       
   264           && intervals[i].e >= intervals[i + 1].s - 1) {
       
   265         intervals[i].e = qMax(intervals[i].e, intervals[i + 1].e);
       
   266         intervals.removeAt(i + 1);
       
   267     }
       
   268 }
       
   269 
       
   270 void QMediaTimeRangePrivate::removeInterval(const QMediaTimeInterval &interval)
       
   271 {
       
   272     // Handle normalized intervals only
       
   273     if(!interval.isNormal())
       
   274         return;
       
   275 
       
   276     for (int i = 0; i < intervals.count(); i++) {
       
   277         QMediaTimeInterval r = intervals[i];
       
   278 
       
   279         if (r.e < interval.s) {
       
   280             // Before the removal interval
       
   281             continue;
       
   282         } else if (interval.e < r.s) {
       
   283             // After the removal interval - stop here
       
   284             break;
       
   285         } else if (r.s < interval.s && interval.e < r.e) {
       
   286             // Split case - a single range has a chunk removed
       
   287             intervals[i].e = interval.s -1;
       
   288             addInterval(QMediaTimeInterval(interval.e + 1, r.e));
       
   289             break;
       
   290         } else if (r.s < interval.s) {
       
   291             // Trimming Tail Case
       
   292             intervals[i].e = interval.s - 1;
       
   293         } else if (interval.e < r.e) {
       
   294             // Trimming Head Case - we can stop after this
       
   295             intervals[i].s = interval.e + 1;
       
   296             break;
       
   297         } else {
       
   298             // Complete coverage case
       
   299             intervals.removeAt(i);
       
   300             --i;
       
   301         }
       
   302     }
       
   303 }
       
   304 
       
   305 /*!
       
   306     \class QMediaTimeRange
       
   307     \brief The QMediaTimeRange class represents a set of zero or more disjoint
       
   308     time intervals.
       
   309     \ingroup multimedia
       
   310 
       
   311     \reentrant
       
   312 
       
   313     The earliestTime(), latestTime(), intervals() and isEmpty()
       
   314     methods are used to get information about the current time range.
       
   315 
       
   316     The addInterval(), removeInterval() and clear() methods are used to modify
       
   317     the current time range.
       
   318 
       
   319     When adding or removing intervals from the time range, existing intervals
       
   320     within the range may be expanded, trimmed, deleted, merged or split to ensure
       
   321     that all intervals within the time range remain distinct and disjoint. As a
       
   322     consequence, all intervals added or removed from a time range must be
       
   323     \l{QMediaTimeInterval::isNormal()}{normal}.
       
   324 
       
   325     \sa QMediaTimeInterval
       
   326 */
       
   327 
       
   328 /*!
       
   329     \fn QMediaTimeRange::QMediaTimeRange()
       
   330 
       
   331     Constructs an empty time range.
       
   332 */
       
   333 QMediaTimeRange::QMediaTimeRange()
       
   334     : d(new QMediaTimeRangePrivate)
       
   335 {
       
   336 
       
   337 }
       
   338 
       
   339 /*!
       
   340     \fn QMediaTimeRange::QMediaTimeRange(qint64 start, qint64 end)
       
   341 
       
   342     Constructs a time range that contains an initial interval from
       
   343     \a start to \a end inclusive.
       
   344 
       
   345     If the interval is not \l{QMediaTimeInterval::isNormal()}{normal},
       
   346     the resulting time range will be empty.
       
   347 
       
   348     \sa addInterval()
       
   349 */
       
   350 QMediaTimeRange::QMediaTimeRange(qint64 start, qint64 end)
       
   351     : d(new QMediaTimeRangePrivate(QMediaTimeInterval(start, end)))
       
   352 {
       
   353 
       
   354 }
       
   355 
       
   356 /*!
       
   357     \fn QMediaTimeRange::QMediaTimeRange(const QMediaTimeInterval &interval)
       
   358 
       
   359     Constructs a time range that contains an intitial interval, \a interval.
       
   360 
       
   361     If \a interval is not \l{QMediaTimeInterval::isNormal()}{normal},
       
   362     the resulting time range will be empty.
       
   363 
       
   364     \sa addInterval()
       
   365 */
       
   366 QMediaTimeRange::QMediaTimeRange(const QMediaTimeInterval &interval)
       
   367     : d(new QMediaTimeRangePrivate(interval))
       
   368 {
       
   369 
       
   370 }
       
   371 
       
   372 /*!
       
   373     \fn QMediaTimeRange::QMediaTimeRange(const QMediaTimeRange &range)
       
   374 
       
   375     Constructs a time range by copying another time \a range.
       
   376 */
       
   377 QMediaTimeRange::QMediaTimeRange(const QMediaTimeRange &range)
       
   378     : d(range.d)
       
   379 {
       
   380 
       
   381 }
       
   382 
       
   383 /*!
       
   384     \fn QMediaTimeRange::~QMediaTimeRange()
       
   385 
       
   386     Destructor.
       
   387 */
       
   388 QMediaTimeRange::~QMediaTimeRange()
       
   389 {
       
   390 
       
   391 }
       
   392 
       
   393 /*!
       
   394     \fn QMediaTimeRange::operator=(const QMediaTimeRange &other)
       
   395 
       
   396     Takes a copy of the \a other time range and returns itself.
       
   397 */
       
   398 QMediaTimeRange &QMediaTimeRange::operator=(const QMediaTimeRange &other)
       
   399 {
       
   400     d = other.d;
       
   401     return *this;
       
   402 }
       
   403 
       
   404 /*!
       
   405     \fn QMediaTimeRange::operator=(const QMediaTimeInterval &interval)
       
   406 
       
   407     Sets the time range to a single continuous interval, \a interval.
       
   408 */
       
   409 QMediaTimeRange &QMediaTimeRange::operator=(const QMediaTimeInterval &interval)
       
   410 {
       
   411     d = new QMediaTimeRangePrivate(interval);
       
   412     return *this;
       
   413 }
       
   414 
       
   415 /*!
       
   416     \fn QMediaTimeRange::earliestTime() const
       
   417 
       
   418     Returns the earliest time within the time range.
       
   419 
       
   420     For empty time ranges, this value is equal to zero.
       
   421 
       
   422     \sa latestTime()
       
   423 */
       
   424 qint64 QMediaTimeRange::earliestTime() const
       
   425 {
       
   426     if (!d->intervals.isEmpty())
       
   427         return d->intervals[0].s;
       
   428 
       
   429     return 0;
       
   430 }
       
   431 
       
   432 /*!
       
   433     \fn QMediaTimeRange::latestTime() const
       
   434 
       
   435     Returns the latest time within the time range.
       
   436 
       
   437     For empty time ranges, this value is equal to zero.
       
   438 
       
   439     \sa earliestTime()
       
   440 */
       
   441 qint64 QMediaTimeRange::latestTime() const
       
   442 {
       
   443     if (!d->intervals.isEmpty())
       
   444         return d->intervals[d->intervals.count() - 1].e;
       
   445 
       
   446     return 0;
       
   447 }
       
   448 
       
   449 /*!
       
   450     \fn QMediaTimeRange::addInterval(qint64 start, qint64 end)
       
   451     \overload
       
   452 
       
   453     Adds the interval specified by \a start and \a end
       
   454     to the time range.
       
   455 
       
   456     \sa addInterval()
       
   457 */
       
   458 void QMediaTimeRange::addInterval(qint64 start, qint64 end)
       
   459 {
       
   460     d->addInterval(QMediaTimeInterval(start, end));
       
   461 }
       
   462 
       
   463 /*!
       
   464     \fn QMediaTimeRange::addInterval(const QMediaTimeInterval &interval)
       
   465 
       
   466     Adds the specified \a interval to the time range.
       
   467 
       
   468     Adding intervals which are not \l{QMediaTimeInterval::isNormal()}{normal}
       
   469     is invalid, and will be ignored.
       
   470 
       
   471     If the specified interval is adjacent to, or overlaps existing
       
   472     intervals within the time range, these intervals will be merged.
       
   473 
       
   474     This operation takes \l{linear time}
       
   475 
       
   476     \sa removeInterval()
       
   477 */
       
   478 void QMediaTimeRange::addInterval(const QMediaTimeInterval &interval)
       
   479 {
       
   480     d->addInterval(interval);
       
   481 }
       
   482 
       
   483 /*!
       
   484     \fn QMediaTimeRange::addTimeRange(const QMediaTimeRange &range)
       
   485 
       
   486     Adds each of the intervals in \a range to this time range.
       
   487 
       
   488     Equivalent to calling addInterval() for each interval in \a range.
       
   489 */
       
   490 void QMediaTimeRange::addTimeRange(const QMediaTimeRange &range)
       
   491 {
       
   492     foreach(const QMediaTimeInterval &i, range.intervals()) {
       
   493         d->addInterval(i);
       
   494     }
       
   495 }
       
   496 
       
   497 /*!
       
   498     \fn QMediaTimeRange::removeInterval(qint64 start, qint64 end)
       
   499     \overload
       
   500 
       
   501     Removes the interval specified by \a start and \a end
       
   502     from the time range.
       
   503 
       
   504     \sa removeInterval()
       
   505 */
       
   506 void QMediaTimeRange::removeInterval(qint64 start, qint64 end)
       
   507 {
       
   508     d->removeInterval(QMediaTimeInterval(start, end));
       
   509 }
       
   510 
       
   511 /*!
       
   512     \fn QMediaTimeRange::removeInterval(const QMediaTimeInterval &interval)
       
   513 
       
   514     Removes the specified \a interval from the time range.
       
   515 
       
   516     Removing intervals which are not \l{QMediaTimeInterval::isNormal()}{normal}
       
   517     is invalid, and will be ignored.
       
   518 
       
   519     Intervals within the time range will be trimmed, split or deleted
       
   520     such that no intervals within the time range include any part of the
       
   521     target interval.
       
   522 
       
   523     This operation takes \l{linear time}
       
   524 
       
   525     \sa addInterval()
       
   526 */
       
   527 void QMediaTimeRange::removeInterval(const QMediaTimeInterval &interval)
       
   528 {
       
   529     d->removeInterval(interval);
       
   530 }
       
   531 
       
   532 /*!
       
   533     \fn QMediaTimeRange::removeTimeRange(const QMediaTimeRange &range)
       
   534 
       
   535     Removes each of the intervals in \a range from this time range.
       
   536 
       
   537     Equivalent to calling removeInterval() for each interval in \a range.
       
   538 */
       
   539 void QMediaTimeRange::removeTimeRange(const QMediaTimeRange &range)
       
   540 {
       
   541     foreach(const QMediaTimeInterval &i, range.intervals()) {
       
   542         d->removeInterval(i);
       
   543     }
       
   544 }
       
   545 
       
   546 /*!
       
   547     \fn QMediaTimeRange::operator+=(const QMediaTimeRange &other)
       
   548 
       
   549     Adds each interval in \a other to the time range and returns the result.
       
   550 */
       
   551 QMediaTimeRange& QMediaTimeRange::operator+=(const QMediaTimeRange &other)
       
   552 {
       
   553     addTimeRange(other);
       
   554     return *this;
       
   555 }
       
   556 
       
   557 /*!
       
   558     \fn QMediaTimeRange::operator+=(const QMediaTimeInterval &interval)
       
   559 
       
   560     Adds the specified \a interval to the time range and returns the result.
       
   561 */
       
   562 QMediaTimeRange& QMediaTimeRange::operator+=(const QMediaTimeInterval &interval)
       
   563 {
       
   564     addInterval(interval);
       
   565     return *this;
       
   566 }
       
   567 
       
   568 /*!
       
   569     \fn QMediaTimeRange::operator-=(const QMediaTimeRange &other)
       
   570 
       
   571     Removes each interval in \a other from the time range and returns the result.
       
   572 */
       
   573 QMediaTimeRange& QMediaTimeRange::operator-=(const QMediaTimeRange &other)
       
   574 {
       
   575     removeTimeRange(other);
       
   576     return *this;
       
   577 }
       
   578 
       
   579 /*!
       
   580     \fn QMediaTimeRange::operator-=(const QMediaTimeInterval &interval)
       
   581 
       
   582     Removes the specified \a interval from the time range and returns the result.
       
   583 */
       
   584 QMediaTimeRange& QMediaTimeRange::operator-=(const QMediaTimeInterval &interval)
       
   585 {
       
   586     removeInterval(interval);
       
   587     return *this;
       
   588 }
       
   589 
       
   590 /*!
       
   591     \fn QMediaTimeRange::clear()
       
   592 
       
   593     Removes all intervals from the time range.
       
   594 
       
   595     \sa removeInterval()
       
   596 */
       
   597 void QMediaTimeRange::clear()
       
   598 {
       
   599     d->intervals.clear();
       
   600 }
       
   601 
       
   602 /*!
       
   603     \fn QMediaTimeRange::intervals() const
       
   604 
       
   605     Returns the list of intervals covered by this time range.
       
   606 */
       
   607 QList<QMediaTimeInterval> QMediaTimeRange::intervals() const
       
   608 {
       
   609     return d->intervals;
       
   610 }
       
   611 
       
   612 /*!
       
   613     \fn QMediaTimeRange::isEmpty() const
       
   614 
       
   615     Returns true if there are no intervals within the time range.
       
   616 
       
   617     \sa intervals()
       
   618 */
       
   619 bool QMediaTimeRange::isEmpty() const
       
   620 {
       
   621     return d->intervals.isEmpty();
       
   622 }
       
   623 
       
   624 /*!
       
   625     \fn QMediaTimeRange::isContinuous() const
       
   626 
       
   627     Returns true if the time range consists of a continuous interval.
       
   628     That is, there is one or fewer disjoint intervals within the time range.
       
   629 */
       
   630 bool QMediaTimeRange::isContinuous() const
       
   631 {
       
   632     return (d->intervals.count() <= 1);
       
   633 }
       
   634 
       
   635 /*!
       
   636     \fn QMediaTimeRange::contains(qint64 time) const
       
   637 
       
   638     Returns true if the specified \a time lies within the time range.
       
   639 */
       
   640 bool QMediaTimeRange::contains(qint64 time) const
       
   641 {
       
   642     for (int i = 0; i < d->intervals.count(); i++) {
       
   643         if (d->intervals[i].contains(time))
       
   644             return true;
       
   645 
       
   646         if (time < d->intervals[i].s)
       
   647             break;
       
   648     }
       
   649 
       
   650     return false;
       
   651 }
       
   652 
       
   653 /*!
       
   654     \fn operator==(const QMediaTimeRange &a, const QMediaTimeRange &b)
       
   655     \relates QMediaTimeRange
       
   656 
       
   657     Returns true if all intervals in \a a are present in \a b.
       
   658 */
       
   659 bool operator==(const QMediaTimeRange &a, const QMediaTimeRange &b)
       
   660 {
       
   661     if (a.intervals().count() != b.intervals().count())
       
   662         return false;
       
   663 
       
   664     for (int i = 0; i < a.intervals().count(); i++)
       
   665     {
       
   666         if(a.intervals()[i] != b.intervals()[i])
       
   667             return false;
       
   668     }
       
   669 
       
   670     return true;
       
   671 }
       
   672 
       
   673 /*!
       
   674     \fn operator!=(const QMediaTimeRange &a, const QMediaTimeRange &b)
       
   675     \relates QMediaTimeRange
       
   676 
       
   677     Returns true if one or more intervals in \a a are not present in \a b.
       
   678 */
       
   679 bool operator!=(const QMediaTimeRange &a, const QMediaTimeRange &b)
       
   680 {
       
   681     return !(a == b);
       
   682 }
       
   683 
       
   684 /*!
       
   685     \fn operator+(const QMediaTimeRange &r1, const QMediaTimeRange &r2)
       
   686 
       
   687     Returns a time range containing the union between \a r1 and \a r2.
       
   688  */
       
   689 QMediaTimeRange operator+(const QMediaTimeRange &r1, const QMediaTimeRange &r2)
       
   690 {
       
   691     return (QMediaTimeRange(r1) += r2);
       
   692 }
       
   693 
       
   694 /*!
       
   695     \fn operator-(const QMediaTimeRange &r1, const QMediaTimeRange &r2)
       
   696 
       
   697     Returns a time range containing \a r2 subtracted from \a r1.
       
   698  */
       
   699 QMediaTimeRange operator-(const QMediaTimeRange &r1, const QMediaTimeRange &r2)
       
   700 {
       
   701     return (QMediaTimeRange(r1) -= r2);
       
   702 }
       
   703 
       
   704 QTM_END_NAMESPACE
       
   705