diff options
author | Yoann Lopes <yoann.lopes@theqtcompany.com> | 2015-10-08 18:26:39 +0200 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@theqtcompany.com> | 2015-12-11 14:53:16 +0000 |
commit | 82e135167a5d24f600f006480b78a59511ae5cb3 (patch) | |
tree | 0e27d0b2520e42d4b7bfb1db32dd5446df49502f /tests/auto/unit/qmultimedia_common/mockmediaplaylistcontrol.h | |
parent | 94c33684fe3ba3c08af91d5d465c35f5dc706721 (diff) |
Change the way a playlist is bound to a media object.v5.6.0-beta1
The previous behavior was to simply switch from the internal
control to the service's control, discarding anything that was
added to the playlist before binding.
We now carry over the changes made to the playlist when switching
controls. This means the switch is now transparent to the user.
When the service's control is read-only, we cannot transfer the
items, which means the user must be notified of the items that
might have been "lost" during the switch.
Auto-test modified to reflect this change.
Change-Id: Ibf80b650b06425ddbaeb320b72ac5d3082a25960
Reviewed-by: Jim Hodapp <jim.hodapp@canonical.com>
Reviewed-by: Yoann Lopes <yoann.lopes@theqtcompany.com>
Diffstat (limited to 'tests/auto/unit/qmultimedia_common/mockmediaplaylistcontrol.h')
-rw-r--r-- | tests/auto/unit/qmultimedia_common/mockmediaplaylistcontrol.h | 46 |
1 files changed, 41 insertions, 5 deletions
diff --git a/tests/auto/unit/qmultimedia_common/mockmediaplaylistcontrol.h b/tests/auto/unit/qmultimedia_common/mockmediaplaylistcontrol.h index 6620aa763..9f4eabf38 100644 --- a/tests/auto/unit/qmultimedia_common/mockmediaplaylistcontrol.h +++ b/tests/auto/unit/qmultimedia_common/mockmediaplaylistcontrol.h @@ -36,24 +36,52 @@ #include <private/qmediaplaylistcontrol_p.h> #include <private/qmediaplaylistnavigator_p.h> +#include <private/qmedianetworkplaylistprovider_p.h> #include "mockreadonlyplaylistprovider.h" -// Hmm, read only. class MockMediaPlaylistControl : public QMediaPlaylistControl { - Q_OBJECT public: - MockMediaPlaylistControl(QObject *parent) : QMediaPlaylistControl(parent) + MockMediaPlaylistControl(bool readonly = false, QObject *parent = 0) + : QMediaPlaylistControl(parent) + , m_navigator(0) + , m_playlist(0) + , m_ownsProvider(false) + , m_readOnly(readonly) { - m_navigator = new QMediaPlaylistNavigator(new MockReadOnlyPlaylistProvider(this), this); + reset(); } ~MockMediaPlaylistControl() { } - QMediaPlaylistProvider* playlistProvider() const { return m_navigator->playlist(); } + void reset() + { + delete m_navigator; + if (m_ownsProvider) + delete m_playlist; + + if (m_readOnly) + m_playlist = new MockReadOnlyPlaylistProvider(this); + else + m_playlist = new QMediaNetworkPlaylistProvider(this); + + m_ownsProvider = true; + m_navigator = new QMediaPlaylistNavigator(m_playlist, this); + } + + void setReadOnly(bool ro) + { + if (m_readOnly == ro) + return; + + m_readOnly = ro; + reset(); + } + + QMediaPlaylistProvider* playlistProvider() const { return m_playlist; } bool setPlaylistProvider(QMediaPlaylistProvider *newProvider) { bool bMediaContentChanged = false; @@ -70,6 +98,11 @@ public: emit currentMediaChanged(newProvider->media(i)); } + if (m_ownsProvider) + delete m_playlist; + m_playlist = newProvider; + m_ownsProvider = false; + m_navigator->setPlaylist(newProvider); return true; } @@ -99,6 +132,9 @@ public: private: QMediaPlaylistNavigator *m_navigator; + QMediaPlaylistProvider *m_playlist; + bool m_ownsProvider; + bool m_readOnly; }; #endif // MOCKMEDIAPLAYLISTCONTROL_H |