From 770e2f4593965a82e2b3457f8c8fa84f258d7607 Mon Sep 17 00:00:00 2001 From: Chris Cochrun Date: Sat, 6 Aug 2022 07:23:57 -0500 Subject: [PATCH] added the previous item change --- src/qml/presenter/Presentation.qml | 48 +++++++++++++++++++----------- src/slide.cpp | 21 +++++++++++++ src/slide.h | 1 + 3 files changed, 53 insertions(+), 17 deletions(-) diff --git a/src/qml/presenter/Presentation.qml b/src/qml/presenter/Presentation.qml index 2536580..2fcd177 100644 --- a/src/qml/presenter/Presentation.qml +++ b/src/qml/presenter/Presentation.qml @@ -177,24 +177,38 @@ Item { } function previousSlideAction() { - print(textIndex); - if (itemType === "song") { - if (textIndex === 0) { - clearText(); - nextSlide(); - } else if (textIndex <= root.text.length) { - SlideObject.setText(root.text[textIndex]); - print(root.text[textIndex]); - --textIndex; - } - } else if (itemType === "video") { - /* clearText(); */ - previousSlide(); - } - else if (itemType === "image") { - /* clearText(); */ - previousSlide(); + const prevServiceItemIndex = currentServiceItem - 1; + const prevItem = serviceItemModel.getItem(prevServiceItemIndex); + print("currentServiceItem " + currentServiceItem); + print("prevServiceItem " + prevServiceItemIndex); + print(prevItem.name); + const changed = SlideObject.previous(prevItem); + print(changed); + if (changed) { + currentServiceItem--; + loadVideo(); } + + + + /* print(textIndex); */ + /* if (itemType === "song") { */ + /* if (textIndex === 0) { */ + /* clearText(); */ + /* nextSlide(); */ + /* } else if (textIndex <= root.text.length) { */ + /* SlideObject.setText(root.text[textIndex]); */ + /* print(root.text[textIndex]); */ + /* --textIndex; */ + /* } */ + /* } else if (itemType === "video") { */ + /* /\* clearText(); *\/ */ + /* previousSlide(); */ + /* } */ + /* else if (itemType === "image") { */ + /* /\* clearText(); *\/ */ + /* previousSlide(); */ + /* } */ } function previousSlide() { diff --git a/src/slide.cpp b/src/slide.cpp index e3039d3..f079922 100644 --- a/src/slide.cpp +++ b/src/slide.cpp @@ -210,3 +210,24 @@ bool Slide::next(QVariantMap nextItem) return false; } + +bool Slide::previous(QVariantMap prevItem) +{ + qDebug() << "Starting to go to previous item."; + qDebug() << "Slide Index: " << m_slideIndex << " Slide Size: " << m_slideSize; + QStringList text = m_serviceItem.value("text").toStringList(); + if (m_slideIndex == 1) { + changeSlide(prevItem); + return true; + } + + // since the string list is 0 indexed m_slideIndex actually + // maps to the next item. So the prev text is minus 2 + int prevTextIndex = m_slideIndex - 2; + qDebug() << prevTextIndex; + qDebug() << text[prevTextIndex]; + setText(text[prevTextIndex]); + m_slideIndex--; + + return false; +} diff --git a/src/slide.h b/src/slide.h index 0a6c71e..06661b2 100644 --- a/src/slide.h +++ b/src/slide.h @@ -53,6 +53,7 @@ public: Q_INVOKABLE void changeSlide(QVariantMap item); Q_INVOKABLE bool next(QVariantMap nextItem); + Q_INVOKABLE bool previous(QVariantMap prevItem); signals: Q_INVOKABLE void textChanged(QString text);