adding a pdfindex to slideobject and moving through index

This commit is contained in:
Chris Cochrun 2022-09-24 07:17:52 -05:00
parent 52e08f2a4d
commit d52bbda181
2 changed files with 60 additions and 20 deletions

View file

@ -15,12 +15,13 @@ Slide::Slide(QObject *parent)
Slide::Slide(const QString &text, const QString &audio, const QString &imageBackground, Slide::Slide(const QString &text, const QString &audio, const QString &imageBackground,
const QString &videoBackground, const QString &horizontalTextAlignment, const QString &videoBackground, const QString &horizontalTextAlignment,
const QString &verticalTextAlignment, const QString &font, const QString &verticalTextAlignment, const QString &font,
const int &fontSize, const int &imageCount, const bool &isPlaying, const int &fontSize, const int &imageCount, const int &pdfIndex,
const QString &type, QObject *parent) const bool &isPlaying, const QString &type, QObject *parent)
: QObject(parent),m_text(text),m_audio(audio),m_imageBackground(imageBackground), : QObject(parent),m_text(text),m_audio(audio),m_imageBackground(imageBackground),
m_videoBackground(videoBackground),m_verticalTextAlignment(verticalTextAlignment), m_videoBackground(videoBackground),m_verticalTextAlignment(verticalTextAlignment),
m_horizontalTextAlignment(horizontalTextAlignment),m_font(font), m_horizontalTextAlignment(horizontalTextAlignment),m_font(font),
m_fontSize(fontSize),m_imageCount(imageCount),m_isPlaying(isPlaying),m_type(type) m_fontSize(fontSize),m_imageCount(imageCount),m_pdfIndex(pdfIndex),
m_isPlaying(isPlaying),m_type(type)
{ {
qDebug() << "Initializing slide with defaults"; qDebug() << "Initializing slide with defaults";
} }
@ -76,6 +77,11 @@ int Slide::imageCount() const
return m_imageCount; return m_imageCount;
} }
int Slide::pdfIndex() const
{
return m_pdfIndex;
}
bool Slide::isPlaying() const bool Slide::isPlaying() const
{ {
return m_isPlaying; return m_isPlaying;
@ -185,6 +191,15 @@ void Slide::setImageCount(int imageCount)
emit imageCountChanged(m_imageCount); emit imageCountChanged(m_imageCount);
} }
void Slide::setPdfIndex(int pdfIndex)
{
if (m_pdfIndex == pdfIndex)
return;
m_pdfIndex = pdfIndex;
emit pdfIndexChanged(m_pdfIndex);
}
void Slide::changeSlide(QVariantMap item) void Slide::changeSlide(QVariantMap item)
{ {
setServiceItem(item); setServiceItem(item);
@ -198,6 +213,10 @@ void Slide::changeSlide(QVariantMap item)
setImageBackground(""); setImageBackground("");
} }
setText("");
m_slideSize = 1;
m_slideIndex = 1;
if (type() == "pres") { if (type() == "pres") {
qDebug() << "#$#$#$#$ THIS PDF $#$#$#$#"; qDebug() << "#$#$#$#$ THIS PDF $#$#$#$#";
int pageCount; int pageCount;
@ -217,15 +236,13 @@ void Slide::changeSlide(QVariantMap item)
} }
setImageCount(pageCount); setImageCount(pageCount);
qDebug() << m_imageCount; qDebug() << m_imageCount;
m_slideSize = m_imageCount;
m_slideIndex = 1;
setPdfIndex(1);
} }
QStringList text = m_serviceItem.value("text").toStringList(); QStringList text = m_serviceItem.value("text").toStringList();
if (text.isEmpty()) { if (type() == "song") {
setText("");
m_slideSize = 1;
m_slideIndex = 1;
}
else {
qDebug() << "TEXT LENGTH: " << text.length(); qDebug() << "TEXT LENGTH: " << text.length();
m_slideSize = text.length(); m_slideSize = text.length();
m_slideIndex = 1; m_slideIndex = 1;
@ -245,13 +262,23 @@ bool Slide::next(QVariantMap nextItem)
return true; return true;
} }
qDebug() << m_type;
// since the string list is 0 indexed m_slideIndex actually // since the string list is 0 indexed m_slideIndex actually
// maps to the next item. // maps to the next item.
int nextTextIndex = m_slideIndex; if (m_type == "song") {
qDebug() << nextTextIndex; int nextTextIndex = m_slideIndex;
qDebug() << text[nextTextIndex]; qDebug() << nextTextIndex;
setText(text[nextTextIndex]); qDebug() << text[nextTextIndex];
m_slideIndex++; setText(text[nextTextIndex]);
m_slideIndex++;
}
if (m_type == "pres") {
qDebug() << "prev slide index: " << m_pdfIndex;
setPdfIndex(m_pdfIndex + 1);
qDebug() << "new slide index: " << m_pdfIndex;
m_slideIndex++;
}
return false; return false;
} }
@ -268,11 +295,17 @@ bool Slide::previous(QVariantMap prevItem)
// since the string list is 0 indexed m_slideIndex actually // since the string list is 0 indexed m_slideIndex actually
// maps to the next item. So the prev text is minus 2 // maps to the next item. So the prev text is minus 2
int prevTextIndex = m_slideIndex - 2; if (m_type == "song") {
qDebug() << prevTextIndex; int prevTextIndex = m_slideIndex - 2;
qDebug() << text[prevTextIndex]; qDebug() << prevTextIndex;
setText(text[prevTextIndex]); qDebug() << text[prevTextIndex];
m_slideIndex--; setText(text[prevTextIndex]);
m_slideIndex--;
}
if (m_type == "presentation") {
m_slideIndex--;
}
return false; return false;
} }

View file

@ -22,6 +22,7 @@ class Slide : public QObject
Q_PROPERTY(QString font READ font WRITE setFont NOTIFY fontChanged) Q_PROPERTY(QString font READ font WRITE setFont NOTIFY fontChanged)
Q_PROPERTY(int fontSize READ fontSize WRITE setFontSize NOTIFY fontSizeChanged) Q_PROPERTY(int fontSize READ fontSize WRITE setFontSize NOTIFY fontSizeChanged)
Q_PROPERTY(int imageCount READ imageCount WRITE setImageCount NOTIFY imageCountChanged) Q_PROPERTY(int imageCount READ imageCount WRITE setImageCount NOTIFY imageCountChanged)
Q_PROPERTY(int pdfIndex READ pdfIndex WRITE setPdfIndex NOTIFY pdfIndexChanged)
Q_PROPERTY(bool isPlaying READ isPlaying NOTIFY isPlayingChanged) Q_PROPERTY(bool isPlaying READ isPlaying NOTIFY isPlayingChanged)
// QML_ELEMENT // QML_ELEMENT
@ -29,7 +30,9 @@ public:
explicit Slide(QObject *parent = nullptr); explicit Slide(QObject *parent = nullptr);
Slide(const QString &text, const QString &audio, const QString &imageBackground, const QString &videoBackground, Slide(const QString &text, const QString &audio, const QString &imageBackground, const QString &videoBackground,
const QString &horizontalTextAlignment, const QString &verticalTextAlignment, const QString &horizontalTextAlignment, const QString &verticalTextAlignment,
const QString &font, const int &fontSize, const int &imageCount, const bool &isPlaying, const QString &type, QObject * parent = nullptr); const QString &font, const int &fontSize, const int &imageCount,
const int &pdfIndex, const bool &isPlaying, const QString &type,
QObject * parent = nullptr);
QString text() const; QString text() const;
QString type() const; QString type() const;
@ -42,6 +45,7 @@ public:
QString font() const; QString font() const;
int fontSize() const; int fontSize() const;
int imageCount() const; int imageCount() const;
int pdfIndex() const;
bool isPlaying() const; bool isPlaying() const;
Q_INVOKABLE void setText(QString text); Q_INVOKABLE void setText(QString text);
@ -55,6 +59,7 @@ public:
Q_INVOKABLE void setFont(QString font); Q_INVOKABLE void setFont(QString font);
Q_INVOKABLE void setFontSize(int fontSize); Q_INVOKABLE void setFontSize(int fontSize);
Q_INVOKABLE void setImageCount(int imageCount); Q_INVOKABLE void setImageCount(int imageCount);
Q_INVOKABLE void setPdfIndex(int pdfIndex);
Q_INVOKABLE void changeSlide(QVariantMap item); Q_INVOKABLE void changeSlide(QVariantMap item);
Q_INVOKABLE void play(); Q_INVOKABLE void play();
@ -75,6 +80,7 @@ signals:
Q_INVOKABLE void fontChanged(QString font); Q_INVOKABLE void fontChanged(QString font);
Q_INVOKABLE void fontSizeChanged(int fontSize); Q_INVOKABLE void fontSizeChanged(int fontSize);
Q_INVOKABLE void imageCountChanged(int imageCount); Q_INVOKABLE void imageCountChanged(int imageCount);
Q_INVOKABLE void pdfIndexChanged(int pdfIndex);
Q_INVOKABLE void isPlayingChanged(bool isPlaying); Q_INVOKABLE void isPlayingChanged(bool isPlaying);
private: private:
@ -90,6 +96,7 @@ private:
QString m_font; QString m_font;
int m_fontSize; int m_fontSize;
int m_imageCount; int m_imageCount;
int m_pdfIndex;
bool m_isPlaying; bool m_isPlaying;
int m_slideIndex; int m_slideIndex;