diff options
author | Christian Strømme <christian.stromme@qt.io> | 2018-02-28 17:33:43 +0100 |
---|---|---|
committer | Christian Stromme <christian.stromme@qt.io> | 2018-03-07 10:32:22 +0000 |
commit | e61d954e332c65fe5087d7a91e049e0fa9571a4b (patch) | |
tree | affdfd40f3c1e5202462e4451bb8f22373eabe37 /src/runtime/q3dsslideplayer_p.h | |
parent | ebe9e782b18b57cc5282deb01044390c2b080283 (diff) |
Make PlayThroughTo work when explicitly setting a slide
Previously we would assume PlayThroughTo would either be "next" or
"previous". With this change it's also possible to set a value, which
should either be an index, or an id to the slide to be played next.
Task-number: QT3DS-405
Change-Id: I6a6aa2b4dd7a0592be818af0f3c15f24bb296a3d
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
Diffstat (limited to 'src/runtime/q3dsslideplayer_p.h')
-rw-r--r-- | src/runtime/q3dsslideplayer_p.h | 39 |
1 files changed, 36 insertions, 3 deletions
diff --git a/src/runtime/q3dsslideplayer_p.h b/src/runtime/q3dsslideplayer_p.h index b601c4f..eca3d20 100644 --- a/src/runtime/q3dsslideplayer_p.h +++ b/src/runtime/q3dsslideplayer_p.h @@ -221,6 +221,21 @@ public: m_player->reload(); } + Q3DSSlide *setCurrentIndex(int index) + { + Q_ASSERT(m_masterSlide); + const int count = m_masterSlide->childCount(); + if ((index < 0) || (index > count - 1)) { + qWarning("Invalid index!"); + return nullptr; + } + + if (index != m_index) + m_index = index; + + return static_cast<Q3DSSlide *>(m_masterSlide->childAtIndex(m_index)); + } + Q3DSSlide *nextSlide() { if (!m_masterSlide) @@ -230,7 +245,7 @@ public: return nullptr; if (m_index < slideCount() - 1) { - return (m_lastSlide = static_cast<Q3DSSlide *>(m_masterSlide->childAtIndex(++m_index))); + return static_cast<Q3DSSlide *>(m_masterSlide->childAtIndex(++m_index)); } else { return nullptr; } @@ -245,7 +260,7 @@ public: return nullptr; if ((m_index > 0) && (m_index < slideCount())) { - return (m_lastSlide = static_cast<Q3DSSlide *>(m_masterSlide->childAtIndex(--m_index))); + return static_cast<Q3DSSlide *>(m_masterSlide->childAtIndex(--m_index)); } else { return nullptr; } @@ -270,6 +285,25 @@ public: return found ? index : -1; } + int indexOfSlide(const QByteArray &slideId) + { + Q_ASSERT(m_masterSlide); + + Q3DSSlide *ns = static_cast<Q3DSSlide *>(m_masterSlide->firstChild()); + int index = 0; + bool found = false; + while (ns) { + if (ns->id() == slideId) { + found = true; + break; + } + ns = static_cast<Q3DSSlide *>(ns->nextSibling()); + ++index; + } + + return found ? index : -1; + } + private: void bind(Q3DSSlidePlayer *player) { @@ -285,7 +319,6 @@ private: friend class Q3DSSlidePlayer; Q3DSSlidePlayer *m_player = nullptr; Q3DSSlide *m_masterSlide = nullptr; - Q3DSSlide *m_lastSlide = nullptr; int m_index = -1; }; |