diff options
author | Jim Hodapp <jim.hodapp@canonical.com> | 2015-10-26 13:17:02 -0400 |
---|---|---|
committer | Yoann Lopes <yoann.lopes@theqtcompany.com> | 2015-12-18 16:33:21 +0000 |
commit | 7228e7c8b79cd4ae74c6abd12317b43a7b1e6334 (patch) | |
tree | 23639701a44cdb4a299cb12cb9e652c222ad4a51 /src/imports/multimedia | |
parent | dd467ecc7723f6d190024d6aeb3466f3461d8b5a (diff) | |
download | qtmultimedia-7228e7c8b79cd4ae74c6abd12317b43a7b1e6334.tar.gz |
Added addItems to QML Playlist for batch adding of tracks.
Change-Id: Ieb7df35ad9dd50bbc68e5305e0de9fb26c64b540
Reviewed-by: Yoann Lopes <yoann.lopes@theqtcompany.com>
Diffstat (limited to 'src/imports/multimedia')
-rw-r--r-- | src/imports/multimedia/qdeclarativeplaylist.cpp | 23 | ||||
-rw-r--r-- | src/imports/multimedia/qdeclarativeplaylist_p.h | 1 |
2 files changed, 24 insertions, 0 deletions
diff --git a/src/imports/multimedia/qdeclarativeplaylist.cpp b/src/imports/multimedia/qdeclarativeplaylist.cpp index bb785aa98..c6ea1bd31 100644 --- a/src/imports/multimedia/qdeclarativeplaylist.cpp +++ b/src/imports/multimedia/qdeclarativeplaylist.cpp @@ -421,6 +421,29 @@ bool QDeclarativePlaylist::addItem(const QUrl &source) } /*! + \qmlmethod bool QtMultimedia::Playlist::addItems(sources) + + Appends the list of URLs in \a sources to the playlist. + + Returns true if the \a sources are added successfully. + + \since 5.7 +*/ +bool QDeclarativePlaylist::addItems(const QList<QUrl> &sources) +{ + if (sources.isEmpty()) + return false; + + QList<QMediaContent> contents; + QList<QUrl>::const_iterator it = sources.constBegin(); + while (it != sources.constEnd()) { + contents.push_back(QMediaContent(*it)); + ++it; + } + return m_playlist->addMedia(contents); +} + +/*! \qmlmethod bool QtMultimedia::Playlist::insertItem(index, source) Inserts the \a source URL to the playlist at the given \a index. diff --git a/src/imports/multimedia/qdeclarativeplaylist_p.h b/src/imports/multimedia/qdeclarativeplaylist_p.h index fd94135e6..2c6d01585 100644 --- a/src/imports/multimedia/qdeclarativeplaylist_p.h +++ b/src/imports/multimedia/qdeclarativeplaylist_p.h @@ -152,6 +152,7 @@ public Q_SLOTS: void load(const QUrl &location, const QString &format = QString()); bool save(const QUrl &location, const QString &format = QString()); bool addItem(const QUrl &source); + bool addItems(const QList<QUrl> &sources); bool insertItem(int index, const QUrl &source); bool removeItem(int index); bool clear(); |