backend now uses the new classes and compiles some functions

might still need reworking
This commit is contained in:
Chris Cochrun 2023-01-20 07:05:51 -06:00
parent 9bee92a9e4
commit f503622287
9 changed files with 401 additions and 363 deletions

View file

@ -25,9 +25,8 @@
#include <QImage> #include <QImage>
ServiceItemModel::ServiceItemModel(QObject *parent, SlideModel *slideModel) ServiceItemModel::ServiceItemModel(QObject *parent)
: QAbstractListModel(parent) { : QAbstractListModel(parent) {
if (!loadLastSaved()) {
addItem(new ServiceItem("10,000 Reasons", "song", addItem(new ServiceItem("10,000 Reasons", "song",
"file:/home/chris/nextcloud/tfc/openlp/CMG - Nature King 21.jpg", "file:/home/chris/nextcloud/tfc/openlp/CMG - Nature King 21.jpg",
"image", QStringList("Yip Yip"), "image", QStringList("Yip Yip"),
@ -38,7 +37,6 @@ ServiceItemModel::ServiceItemModel(QObject *parent, SlideModel *slideModel)
addItem(new ServiceItem("BP Text", "video", addItem(new ServiceItem("BP Text", "video",
"file:/home/chris/nextcloud/tfc/openlp/videos/test.mp4", "file:/home/chris/nextcloud/tfc/openlp/videos/test.mp4",
"video", QStringList())); "video", QStringList()));
}
} }
int ServiceItemModel::rowCount(const QModelIndex &parent) const { int ServiceItemModel::rowCount(const QModelIndex &parent) const {
@ -279,11 +277,30 @@ void ServiceItemModel::addItem(const QString &name, const QString &type,
const QString &background, const QString &backgroundType, const QString &background, const QString &backgroundType,
const QStringList &text, const QString &audio, const QStringList &text, const QString &audio,
const QString &font, const int &fontSize, const QString &font, const int &fontSize,
const int &slideNumber) { const int &slideNumber, SlideModel &slideModel) {
ServiceItem *item = new ServiceItem(name, type, background, backgroundType, ServiceItem *item = new ServiceItem(name, type, background, backgroundType,
text, audio, font, fontSize, slideNumber); text, audio, font, fontSize, slideNumber);
item->setSelected(false); item->setSelected(false);
item->setActive(false); item->setActive(false);
if (type == "song") {
for (int i = 0; i < text.size(); i++) {
if (backgroundType == "image") {
slideModel.addItem(text[i], type, background, "", audio, font, fontSize,
"horizontalTextAlignment", "verticalTextAlignment",
rowCount(), i, 0);
} else {
slideModel.addItem(text[i], type, "", background, audio, font, fontSize,
"horizontalTextAlignment", "verticalTextAlignment",
rowCount(), i, 0);
}
}
} else if (type == "presentation") {
for (int i = 0; i < slideNumber; i++) {
slideModel.addItem("", type, background, "", audio, font, fontSize,
"horizontalTextAlignment", "verticalTextAlignment",
rowCount(), i, slideNumber);
}
}
addItem(item); addItem(item);
qDebug() << "#################################"; qDebug() << "#################################";
qDebug() << name << type << font << fontSize << slideNumber; qDebug() << name << type << font << fontSize << slideNumber;
@ -345,11 +362,45 @@ void ServiceItemModel::insertItem(const int &index, const QString &name,
const QString &type,const QString &background, const QString &type,const QString &background,
const QString &backgroundType,const QStringList &text, const QString &backgroundType,const QStringList &text,
const QString &audio, const QString &font, const QString &audio, const QString &font,
const int &fontSize, const int &slideNumber) { const int &fontSize, const int &slideNumber,
SlideModel &slideModel) {
ServiceItem *item = new ServiceItem(name, type, background, backgroundType, ServiceItem *item = new ServiceItem(name, type, background, backgroundType,
text, audio, font, fontSize, slideNumber); text, audio, font, fontSize, slideNumber);
item->setSelected(false); item->setSelected(false);
item->setActive(false); item->setActive(false);
int slideModelIdx = slideModel.findSlideIdFromServItm(index);
if (type == "song") {
for (int i = 0; i < text.size(); i++) {
if (backgroundType == "image") {
slideModel.insertItem(slideModelIdx, type, background, "",
text[i], audio, font, fontSize,
"center", "center",
rowCount(), i, 0);
} else {
slideModel.insertItem(slideModelIdx, type, "", background,
text[i], audio, font, fontSize,
"center", "center",
rowCount(), i, 0);
}
}
} else if (type == "presentation") {
for (int i = 0; i < slideNumber; i++) {
slideModel.insertItem(slideModelIdx, type, background, "",
"", audio, font, fontSize,
"center", "center",
rowCount(), i, slideNumber);
}
} else if (type == "video") {
slideModel.insertItem(slideModelIdx, type, "", background, "",
audio, font, fontSize,
"center", "center",
rowCount(), 1, 1);
} else {
slideModel.insertItem(slideModelIdx, type, background, "", "",
audio, font, fontSize,
"center", "center",
rowCount(), 1, 1);
}
insertItem(index, item); insertItem(index, item);
qDebug() << "#################################"; qDebug() << "#################################";
qDebug() << name << type << font << fontSize << slideNumber; qDebug() << name << type << font << fontSize << slideNumber;
@ -652,7 +703,7 @@ bool ServiceItemModel::save(QUrl file) {
return false; return false;
} }
bool ServiceItemModel::load(QUrl file) { bool ServiceItemModel::load(QUrl file, SlideModel &slideModel) {
qDebug() << "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"; qDebug() << "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@";
qDebug() << "Loading..."; qDebug() << "Loading...";
qDebug() << "File path is: " << file.toString(); qDebug() << "File path is: " << file.toString();
@ -758,7 +809,7 @@ bool ServiceItemModel::load(QUrl file) {
item.value("backgroundType").toString(), item.value("backgroundType").toString(),
item.value("text").toStringList(), realAudio, item.value("text").toStringList(), realAudio,
item.value("font").toString(), item.value("fontSize").toInt(), item.value("font").toString(), item.value("fontSize").toInt(),
item.value("slideNumber").toInt()); item.value("slideNumber").toInt(), slideModel);
} }
return true; return true;
@ -774,7 +825,7 @@ void ServiceItemModel::clearAll() {
} }
} }
bool ServiceItemModel::loadLastSaved() { bool ServiceItemModel::loadLastSaved(SlideModel &slideModel) {
QSettings settings; QSettings settings;
return load(settings.value("lastSaveFile").toUrl()); return load(settings.value("lastSaveFile").toUrl(), slideModel);
} }

View file

@ -13,7 +13,7 @@ class ServiceItemModel : public QAbstractListModel {
Q_OBJECT Q_OBJECT
public: public:
explicit ServiceItemModel(QObject *parent = nullptr, SlideModel *slideModel = nullptr); explicit ServiceItemModel(QObject *parent = nullptr);
enum Roles { enum Roles {
NameRole = Qt::UserRole, NameRole = Qt::UserRole,
@ -72,7 +72,7 @@ public:
const QString &backgroundType, const QString &backgroundType,
const QStringList &text, const QString &audio, const QStringList &text, const QString &audio,
const QString &font, const int &fontSize, const QString &font, const int &fontSize,
const int &slideNumber); const int &slideNumber, SlideModel &slideModel);
Q_INVOKABLE void insertItem(const int &index, const QString &name, Q_INVOKABLE void insertItem(const int &index, const QString &name,
const QString &type); const QString &type);
Q_INVOKABLE void insertItem(const int &index, const QString &name, Q_INVOKABLE void insertItem(const int &index, const QString &name,
@ -93,7 +93,8 @@ public:
const QString &type, const QString &background, const QString &type, const QString &background,
const QString &backgroundType, const QStringList &text, const QString &backgroundType, const QStringList &text,
const QString &audio, const QString &font, const QString &audio, const QString &font,
const int &fontSize, const int &slideNumber); const int &fontSize, const int &slideNumber,
SlideModel &slideModel);
Q_INVOKABLE void removeItem(int index); Q_INVOKABLE void removeItem(int index);
Q_INVOKABLE bool moveRows(int sourceIndex, int destIndex, int count); Q_INVOKABLE bool moveRows(int sourceIndex, int destIndex, int count);
Q_INVOKABLE bool moveDown(int index); Q_INVOKABLE bool moveDown(int index);
@ -106,10 +107,11 @@ public:
Q_INVOKABLE void clearAll(); Q_INVOKABLE void clearAll();
Q_INVOKABLE bool save(QUrl file); Q_INVOKABLE bool save(QUrl file);
Q_INVOKABLE bool load(QUrl file); Q_INVOKABLE bool load(QUrl file, SlideModel &slideModel);
Q_INVOKABLE bool loadLastSaved(); Q_INVOKABLE bool loadLastSaved(SlideModel &slideModel);
private: private:
QList<ServiceItem *> m_items; QList<ServiceItem *> m_items;
}; };

View file

@ -13,11 +13,12 @@ Slide::Slide(const QString &text, const QString &audio, const QString &imageBack
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 int &fontSize, const int &imageCount,
const QString &type, QObject *parent) const QString &type, const int &slideIndex, 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_type(type) m_fontSize(fontSize),m_imageCount(imageCount),m_type(type),
m_slideIndex(slideIndex),m_active(false),m_selected(false)
{ {
qDebug() << "Initializing slide with defaults"; qDebug() << "Initializing slide with defaults";
} }
@ -73,6 +74,19 @@ int Slide::imageCount() const
return m_imageCount; return m_imageCount;
} }
int Slide::slideIndex() const
{
return m_slideIndex;
}
bool Slide::active() const {
return m_active;
}
bool Slide::selected() const {
return m_selected;
}
void Slide::setText(QString text) void Slide::setText(QString text)
{ {
if (m_text == text) if (m_text == text)
@ -178,3 +192,33 @@ void Slide::setImageCount(int imageCount)
m_imageCount = imageCount; m_imageCount = imageCount;
emit imageCountChanged(m_imageCount); emit imageCountChanged(m_imageCount);
} }
void Slide::setSlideIndex(int slideIndex)
{
if (m_slideIndex == slideIndex)
return;
qDebug() << "####changing slideIndex to: " << slideIndex;
m_slideIndex = slideIndex;
emit slideIndexChanged(m_slideIndex);
}
void Slide::setActive(bool active)
{
qDebug() << "::::::::::::::::::::";
qDebug() << "CHANGE ME!";
if (m_active == active)
return;
m_active = active;
emit activeChanged(m_active);
}
void Slide::setSelected(bool selected)
{
if (m_selected == selected)
return;
m_selected = selected;
emit selectedChanged(m_selected);
}

View file

@ -11,7 +11,7 @@ class Slide : public QObject
Q_OBJECT Q_OBJECT
Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged) Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged)
Q_PROPERTY(QString type READ type WRITE setType NOTIFY typeChanged) Q_PROPERTY(QString type READ type WRITE setType NOTIFY typeChanged)
Q_PROPERTY(QVariantMap serviceItemId READ serviceItemId WRITE setServiceItemId Q_PROPERTY(int serviceItemId READ serviceItemId WRITE setServiceItemId
NOTIFY serviceItemIdChanged) NOTIFY serviceItemIdChanged)
Q_PROPERTY(QString audio READ audio WRITE setAudio NOTIFY audioChanged) Q_PROPERTY(QString audio READ audio WRITE setAudio NOTIFY audioChanged)
Q_PROPERTY(QString imageBackground READ imageBackground WRITE setImageBackground Q_PROPERTY(QString imageBackground READ imageBackground WRITE setImageBackground
@ -25,6 +25,9 @@ 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 slideIndex READ slideIndex WRITE setSlideIndex NOTIFY slideIndexChanged)
Q_PROPERTY(bool active READ active WRITE setActive NOTIFY activeChanged)
Q_PROPERTY(bool selected READ selected WRITE setSelected NOTIFY selectedChanged)
// QML_ELEMENT // QML_ELEMENT
public: public:
@ -33,7 +36,7 @@ public:
const QString &imageBackground, const QString &videoBackground, 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 QString &font, const int &fontSize, const int &imageCount,
const QString &type, const QString &type, const int &slideIndex,
QObject * parent = nullptr); QObject * parent = nullptr);
QString text() const; QString text() const;
@ -46,7 +49,10 @@ public:
QString font() const; QString font() const;
int fontSize() const; int fontSize() const;
int imageCount() const; int imageCount() const;
int slideIndex() const;
int serviceItemId() const; int serviceItemId() const;
bool active() const;
bool selected() const;
Q_INVOKABLE void setText(QString text); Q_INVOKABLE void setText(QString text);
Q_INVOKABLE void setType(QString type); Q_INVOKABLE void setType(QString type);
@ -59,33 +65,42 @@ 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 setSlideIndex(int slideIndex);
Q_INVOKABLE void setActive(bool active);
Q_INVOKABLE void setSelected(bool selected);
signals: signals:
Q_INVOKABLE void textChanged(QString text); Q_INVOKABLE void textChanged(QString text);
Q_INVOKABLE void typeChanged(QString type); Q_INVOKABLE void typeChanged(QString type);
Q_INVOKABLE void serviceItemIdChanged(int serviceItemId); Q_INVOKABLE void serviceItemIdChanged(int serviceItemId);
Q_INVOKABLE void audioChanged(QString audio); Q_INVOKABLE void audioChanged(QString audio);
Q_INVOKABLE void imageBackgroundChanged(QString imageBackground); Q_INVOKABLE void imageBackgroundChanged(QString imageBackground);
Q_INVOKABLE void videoBackgroundChanged(QString videoBackground); Q_INVOKABLE void videoBackgroundChanged(QString videoBackground);
Q_INVOKABLE void horizontalTextAlignmentChanged(QString horizontalTextAlignment); Q_INVOKABLE void horizontalTextAlignmentChanged(QString horizontalTextAlignment);
Q_INVOKABLE void verticalTextAlignmentChanged(QString verticalTextAlignment); Q_INVOKABLE void verticalTextAlignmentChanged(QString verticalTextAlignment);
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 slideIndexChanged(int slideIndex);
Q_INVOKABLE void activeChanged(bool active);
Q_INVOKABLE void selectedChanged(bool selected);
private: private:
int m_id; int m_id;
QString m_text; QString m_text;
QString m_type; QString m_type;
int m_serviceItemId; int m_serviceItemId;
QString m_audio; QString m_audio;
QString m_imageBackground; QString m_imageBackground;
QString m_videoBackground; QString m_videoBackground;
QString m_horizontalTextAlignment; QString m_horizontalTextAlignment;
QString m_verticalTextAlignment; QString m_verticalTextAlignment;
QString m_font; QString m_font;
int m_fontSize; int m_fontSize;
int m_imageCount; int m_imageCount;
int m_slideIndex;
bool m_active;
bool m_selected;
}; };
#endif //SLIDE_H #endif //SLIDE_H

View file

@ -20,18 +20,18 @@
SlideModel::SlideModel(QObject *parent) SlideModel::SlideModel(QObject *parent)
: QAbstractListModel(parent) { : QAbstractListModel(parent) {
if (!loadLastSaved()) { // if () {
addItem(new Slide("10,000 Reasons", "song", // addItem(new Slide("10,000 Reasons", "song",
"file:/home/chris/nextcloud/tfc/openlp/CMG - Nature King 21.jpg", // "file:/home/chris/nextcloud/tfc/openlp/CMG - Nature King 21.jpg",
"image", QStringList("Yip Yip"), // "image", QString("Yip Yip"),
"file:/home/chris/nextcloud/tfc/openlp/music/Eden-Phil Wickham [lyrics].mp3")); // "file:/home/chris/nextcloud/tfc/openlp/music/Eden-Phil Wickham [lyrics].mp3"));
addItem(new Slide("Marvelous Light", "song", // addItem(new Slide("Marvelous Light", "song",
"file:/home/chris/nextcloud/tfc/openlp/Fire Embers_Loop.mp4", // "file:/home/chris/nextcloud/tfc/openlp/Fire Embers_Loop.mp4",
"video", QStringList("Hallelujah!"))); // "video", QString("Hallelujah!")));
addItem(new Slide("BP Text", "video", // addItem(new Slide("BP Text", "video",
"file:/home/chris/nextcloud/tfc/openlp/videos/test.mp4", // "file:/home/chris/nextcloud/tfc/openlp/videos/test.mp4",
"video", QStringList())); // "video", QString()));
} // }
} }
int SlideModel::rowCount(const QModelIndex &parent) const { int SlideModel::rowCount(const QModelIndex &parent) const {
@ -51,16 +51,14 @@ QVariant SlideModel::data(const QModelIndex &index, int role) const {
Slide *item = m_items[index.row()]; Slide *item = m_items[index.row()];
switch (role) { switch (role) {
case NameRole:
return item->name();
case TypeRole:
return item->type();
case BackgroundRole:
return item->background();
case BackgroundTypeRole:
return item->backgroundType();
case TextRole: case TextRole:
return item->text(); return item->text();
case TypeRole:
return item->type();
case ImageBackgroundRole:
return item->imageBackground();
case VideoBackgroundRole:
return item->videoBackground();
case AudioRole: case AudioRole:
return item->audio(); return item->audio();
case FontRole: case FontRole:
@ -69,6 +67,8 @@ QVariant SlideModel::data(const QModelIndex &index, int role) const {
return item->fontSize(); return item->fontSize();
case ServiceItemIdRole: case ServiceItemIdRole:
return item->serviceItemId(); return item->serviceItemId();
case SlideIndexRole:
return item->slideIndex();
case HorizontalTextAlignmentRole: case HorizontalTextAlignmentRole:
return item->horizontalTextAlignment(); return item->horizontalTextAlignment();
case VerticalTextAlignmentRole: case VerticalTextAlignmentRole:
@ -83,18 +83,18 @@ QVariant SlideModel::data(const QModelIndex &index, int role) const {
} }
QHash<int, QByteArray> SlideModel::roleNames() const { QHash<int, QByteArray> SlideModel::roleNames() const {
static QHash<int, QByteArray> mapping{ static QHash<int, QByteArray> mapping {
{NameRole, "name"},
{TypeRole, "type"},
{BackgroundRole, "background"},
{BackgroundTypeRole, "backgroundType"},
{TextRole, "text"}, {TextRole, "text"},
{TypeRole, "type"},
{ImageBackgroundRole, "imageBackground"},
{VideoBackgroundRole, "videoBackground"},
{AudioRole, "audio"}, {AudioRole, "audio"},
{FontRole, "font"}, {FontRole, "font"},
{FontSizeRole, "fontSize"}, {FontSizeRole, "fontSize"},
{ServiceItemIdRole, "serviceItemId"}, {ServiceItemIdRole, "serviceItemId"},
{HorizontalTextAlignmentRole, "horizontalTextAlignment"}, {HorizontalTextAlignmentRole, "horizontalTextAlignment"},
{VerticalTextAlignmentRole, "verticalTextAlignment"}, {VerticalTextAlignmentRole, "verticalTextAlignment"},
{SlideIndexRole, "slideIndex"},
{ActiveRole, "active"}, {ActiveRole, "active"},
{SelectedRole, "selected"} {SelectedRole, "selected"}
}; };
@ -115,15 +115,15 @@ bool SlideModel::setData(const QModelIndex &index, const QVariant &value,
somethingChanged = true; somethingChanged = true;
} }
break; break;
case BackgroundRole: case ImageBackgroundRole:
if (item->background() != value.toString()) { if (item->imageBackground() != value.toString()) {
item->setBackground(value.toString()); item->setImageBackground(value.toString());
somethingChanged = true; somethingChanged = true;
} }
break; break;
case BackgroundTypeRole: case VideoBackgroundRole:
if (item->backgroundType() != value.toString()) { if (item->videoBackground() != value.toString()) {
item->setBackgroundType(value.toString()); item->setVideoBackground(value.toString());
somethingChanged = true; somethingChanged = true;
} }
break; break;
@ -157,6 +157,12 @@ bool SlideModel::setData(const QModelIndex &index, const QVariant &value,
somethingChanged = true; somethingChanged = true;
} }
break; break;
case SlideIndexRole:
if (item->slideIndex() != value.toInt()) {
item->setSlideIndex(value.toInt());
somethingChanged = true;
}
break;
case HorizontalTextAlignmentRole: case HorizontalTextAlignmentRole:
if (item->horizontalTextAlignment() != value.toString()) { if (item->horizontalTextAlignment() != value.toString()) {
item->setHorizontalTextAlignment(value.toString()); item->setHorizontalTextAlignment(value.toString());
@ -232,156 +238,44 @@ void SlideModel::insertItem(const int &index, Slide *item) {
qDebug() << "Success"; qDebug() << "Success";
} }
void SlideModel::addItem(const QString &text, const QString &type) { void SlideModel::addItem(const QString &text, const QString &type,
Slide *item = new Slide(name, type);
item->setSelected(false);
item->setActive(false);
addItem(item);
}
void SlideModel::addItem(const QString &name, const QString &type,
const QString &imageBackground, const QString &videoBackground) {
Slide *item = new Slide(name, type, imageBackground, videoBackground);
item->setSelected(false);
item->setActive(false);
addItem(item);
}
void SlideModel::addItem(const QString &name, const QString &type,
const QString &imageBackground, const QString &videoBackground, const QString &imageBackground, const QString &videoBackground,
const QStringList &text) { const QString &audio,
Slide *item = new Slide(name, type, imageBackground, videoBackground, text);
item->setSelected(false);
item->setActive(false);
addItem(item);
qDebug() << name << type << imageBackground;
}
void SlideModel::addItem(const QString &name, const QString &type,
const QString &imageBackground, const QString &videoBackground,
const QStringList &text, const QString &audio) {
Slide *item = new Slide(name, type, imageBackground, videoBackground,
text, audio);
item->setSelected(false);
item->setActive(false);
addItem(item);
qDebug() << name << type << imageBackground;
}
void SlideModel::addItem(const QString &name, const QString &type,
const QString &imageBackground, const QString &videoBackground,
const QStringList &text, const QString &audio,
const QString &font, const int &fontSize) {
Slide *item = new Slide(name, type, imageBackground, videoBackground,
text, audio, font, fontSize);
item->setSelected(false);
item->setActive(false);
addItem(item);
qDebug() << "#################################";
qDebug() << name << type << font << fontSize;
qDebug() << "#################################";
}
void SlideModel::addItem(const QString &name, const QString &type,
const QString &imageBackground, const QString &videoBackground,
const QStringList &text, const QString &audio,
const QString &font, const int &fontSize,
const QString &horizontalTextAlignment,
const QString &verticalTextAlignment) {
Slide *item = new Slide(name, type, imageBackground, videoBackground,
text, audio, font, fontSize, horizontalTextAlignment,
verticalTextAlignment);
item->setSelected(false);
item->setActive(false);
addItem(item);
qDebug() << "#################################";
qDebug() << name << type << font << fontSize;
qDebug() << "#################################";
}
void SlideModel::addItem(const QString &name, const QString &type,
const QString &imageBackground, const QString &videoBackground,
const QStringList &text, const QString &audio,
const QString &font, const int &fontSize, const QString &font, const int &fontSize,
const QString &horizontalTextAlignment, const QString &horizontalTextAlignment,
const QString &verticalTextAlignment, const QString &verticalTextAlignment,
const int &serviceItemId) { const int &serviceItemId, const int &slideIndex,
Slide *item = new Slide(name, type, imageBackground, videoBackground, const int &imageCount) {
text, audio, font, fontSize, horizontalTextAlignment, Slide *item = new Slide(text, audio, imageBackground, videoBackground,
verticalTextAlignment); horizontalTextAlignment,
verticalTextAlignment,
font, fontSize, imageCount, type, slideIndex );
item->setSelected(false); item->setSelected(false);
item->setActive(false); item->setActive(false);
item->setServiceItemId(serviceItemId); item->setServiceItemId(serviceItemId);
addItem(item); addItem(item);
qDebug() << "#################################"; qDebug() << "#################################";
qDebug() << name << type << font << fontSize << serviceItemId; qDebug() << type << font << fontSize << serviceItemId;
qDebug() << "#################################"; qDebug() << "#################################";
} }
void SlideModel::insertItem(const int &index, const QString &name, const QString &type) { void SlideModel::insertItem(const int &index,
Slide *item = new Slide(name, type); const QString &type, const QString &imageBackground,
item->setSelected(false); const QString &videoBackground, const QString &text,
item->setActive(false);
insertItem(index, item);
qDebug() << name << type;
}
void SlideModel::insertItem(const int &index, const QString &name, const QString &type,
const QString &imageBackground, const QString &videoBackground) {
Slide *item = new Slide(name, type, imageBackground, videoBackground);
item->setSelected(false);
item->setActive(false);
insertItem(index, item);
qDebug() << name << type << imageBackground;
}
void SlideModel::insertItem(const int &index, const QString &name, const QString &type,
const QString &imageBackground, const QString &videoBackground,
const QStringList &text) {
Slide *item = new Slide(name, type, imageBackground, videoBackground, text);
insertItem(index, item);
qDebug() << name << type << imageBackground << text;
}
void SlideModel::insertItem(const int &index, const QString &name,
const QString &type,const QString &imageBackground,
const QString &videoBackground,const QStringList &text,
const QString &audio) {
Slide *item = new Slide(name, type, imageBackground, videoBackground,
text, audio);
item->setSelected(false);
item->setActive(false);
insertItem(index, item);
qDebug() << name << type << imageBackground << text;
}
void SlideModel::insertItem(const int &index, const QString &name,
const QString &type,const QString &imageBackground,
const QString &videoBackground,const QStringList &text,
const QString &audio, const QString &font, const QString &audio, const QString &font,
const int &fontSize) { const int &fontSize, const QString &horizontalTextAlignment,
Slide *item = new Slide(name, type, imageBackground, videoBackground, const QString &verticalTextAlignment,
text, audio, font, fontSize); const int &serviceItemId, const int &slideIndex,
const int &imageCount) {
Slide *item = new Slide(text, audio, imageBackground, videoBackground,
horizontalTextAlignment, verticalTextAlignment, font, fontSize,
imageCount, type, slideIndex);
item->setSelected(false); item->setSelected(false);
item->setActive(false); item->setActive(false);
item->setServiceItemId(serviceItemId);
insertItem(index, item); insertItem(index, item);
qDebug() << "#################################"; qDebug() << "#################################";
qDebug() << name << type << font << fontSize; qDebug() << type << font << fontSize << slideIndex;
qDebug() << "#################################";
}
void SlideModel::insertItem(const int &index, const QString &name,
const QString &type,const QString &imageBackground,
const QString &videoBackground,const QStringList &text,
const QString &audio, const QString &font,
const int &fontSize, const int &slideNumber) {
Slide *item = new Slide(name, type, imageBackground, videoBackground,
text, audio, font, fontSize, slideNumber);
item->setSelected(false);
item->setActive(false);
insertItem(index, item);
qDebug() << "#################################";
qDebug() << name << type << font << fontSize << slideNumber;
qDebug() << "#################################"; qDebug() << "#################################";
} }
@ -497,7 +391,7 @@ QVariantList SlideModel::getItems() {
itm["fontSize"] = item->fontSize(); itm["fontSize"] = item->fontSize();
itm["horizontalTextAlignment"] = item->horizontalTextAlignment(); itm["horizontalTextAlignment"] = item->horizontalTextAlignment();
itm["verticalTextAlignment"] = item->verticalTextAlignment(); itm["verticalTextAlignment"] = item->verticalTextAlignment();
itm["serviceItemId"] = item->seviceItemId(); itm["serviceItemId"] = item->serviceItemId();
itm["selected"] = item->selected(); itm["selected"] = item->selected();
itm["active"] = item->active(); itm["active"] = item->active();
data.append(itm); data.append(itm);
@ -515,7 +409,7 @@ bool SlideModel::select(int id) {
if (item->selected()) { if (item->selected()) {
item->setSelected(false); item->setSelected(false);
qDebug() << "################"; qDebug() << "################";
qDebug() << "deselected" << item->name(); qDebug() << "deselected" << item->slideIndex();
qDebug() << "################"; qDebug() << "################";
emit dataChanged(idx, idx, QVector<int>() << SelectedRole); emit dataChanged(idx, idx, QVector<int>() << SelectedRole);
} }
@ -524,7 +418,7 @@ bool SlideModel::select(int id) {
Slide *item = m_items[idx.row()]; Slide *item = m_items[idx.row()];
item->setSelected(true); item->setSelected(true);
qDebug() << "################"; qDebug() << "################";
qDebug() << "selected" << item->name(); qDebug() << "selected" << item->slideIndex();
qDebug() << "################"; qDebug() << "################";
emit dataChanged(idx, idx, QVector<int>() << SelectedRole); emit dataChanged(idx, idx, QVector<int>() << SelectedRole);
return true; return true;
@ -540,7 +434,7 @@ bool SlideModel::activate(int id) {
if (itm->active()) { if (itm->active()) {
itm->setActive(false); itm->setActive(false);
qDebug() << "################"; qDebug() << "################";
qDebug() << "deactivated" << itm->name(); qDebug() << "deactivated" << itm->slideIndex();
qDebug() << "################"; qDebug() << "################";
emit dataChanged(idx, idx, QVector<int>() << ActiveRole); emit dataChanged(idx, idx, QVector<int>() << ActiveRole);
} }
@ -548,7 +442,7 @@ bool SlideModel::activate(int id) {
item->setActive(true); item->setActive(true);
qDebug() << "################"; qDebug() << "################";
qDebug() << "activated" << item->name(); qDebug() << "activated" << item->slideIndex();
qDebug() << "################"; qDebug() << "################";
emit dataChanged(idx, idx, QVector<int>() << ActiveRole); emit dataChanged(idx, idx, QVector<int>() << ActiveRole);
return true; return true;
@ -560,7 +454,7 @@ bool SlideModel::deactivate(int id) {
item->setActive(false); item->setActive(false);
qDebug() << "################"; qDebug() << "################";
qDebug() << "deactivated" << item->name(); qDebug() << "deactivated" << item->slideIndex();
qDebug() << "################"; qDebug() << "################";
emit dataChanged(idx, idx, QVector<int>() << ActiveRole); emit dataChanged(idx, idx, QVector<int>() << ActiveRole);
return true; return true;
@ -571,3 +465,13 @@ void SlideModel::clearAll() {
removeItem(i); removeItem(i);
} }
} }
int SlideModel::findSlideIdFromServItm(int index) {
for (int i = 0; i < m_items.size(); i++) {
Slide *itm = m_items[i];
if (itm->serviceItemId() == index) {
return i;
}
}
return -1;
}

View file

@ -25,6 +25,8 @@ public:
FontRole, FontRole,
FontSizeRole, FontSizeRole,
ServiceItemIdRole, ServiceItemIdRole,
SlideIndexRole,
ImageCountRole,
ActiveRole, ActiveRole,
SelectedRole SelectedRole
}; };
@ -48,26 +50,6 @@ public:
// Helper methods // Helper methods
void addItem(Slide *item); void addItem(Slide *item);
void insertItem(const int &index, Slide *item); void insertItem(const int &index, Slide *item);
Q_INVOKABLE void addItem(const QString &name, const QString &type);
Q_INVOKABLE void addItem(const QString &text, const QString &type,
const QString &imageBackground,
const QString &videoBackground);
Q_INVOKABLE void addItem(const QString &text, const QString &type,
const QString &imageBackground,
const QString &videoBackground,
const QString &audio);
Q_INVOKABLE void addItem(const QString &text, const QString &type,
const QString &imageBackground,
const QString &videoBackground,
const QString &audio,
const QString &font, const int &fontSize);
Q_INVOKABLE void addItem(const QString &text, const QString &type,
const QString &imageBackground,
const QString &videoBackground,
const QString &audio,
const QString &font, const int &fontSize,
const QString &horizontalTextAlignment,
const QString &verticalTextAlignment);
Q_INVOKABLE void addItem(const QString &text, const QString &type, Q_INVOKABLE void addItem(const QString &text, const QString &type,
const QString &imageBackground, const QString &imageBackground,
const QString &videoBackground, const QString &videoBackground,
@ -75,28 +57,9 @@ public:
const QString &font, const int &fontSize, const QString &font, const int &fontSize,
const QString &horizontalTextAlignment, const QString &horizontalTextAlignment,
const QString &verticalTextAlignment, const QString &verticalTextAlignment,
const int &serviceItemId); const int &serviceItemId,
Q_INVOKABLE void insertItem(const int &index, const QString &text, const int &slideIndex,
const QString &type); const int &imageCount);
Q_INVOKABLE void insertItem(const int &index, const QString &text,
const QString &type, const QString &imageBackground,
const QString &videoBackground);
Q_INVOKABLE void insertItem(const int &index, const QString &text,
const QString &type, const QString &imageBackground,
const QString &videoBackground,
const QString &audio);
Q_INVOKABLE void insertItem(const int &index, const QString &text,
const QString &type, const QString &imageBackground,
const QString &videoBackground,
const QString &audio, const QString &font,
const int &fontSize);
Q_INVOKABLE void insertItem(const int &index, const QString &text,
const QString &type, const QString &imageBackground,
const QString &videoBackground,
const QString &audio, const QString &font,
const int &fontSize,
const QString &horizontalTextAlignment,
const QString &verticalTextAlignment);
Q_INVOKABLE void insertItem(const int &index, const QString &text, Q_INVOKABLE void insertItem(const int &index, const QString &text,
const QString &type, const QString &imageBackground, const QString &type, const QString &imageBackground,
const QString &videoBackground, const QString &videoBackground,
@ -104,7 +67,9 @@ public:
const int &fontSize, const int &fontSize,
const QString &horizontalTextAlignment, const QString &horizontalTextAlignment,
const QString &verticalTextAlignment, const QString &verticalTextAlignment,
const int &serviceItemId); const int &serviceItemId,
const int &slideIndex,
const int &imageCount);
Q_INVOKABLE void removeItem(int index); Q_INVOKABLE void removeItem(int index);
Q_INVOKABLE bool moveRows(int sourceIndex, int destIndex, int count); Q_INVOKABLE bool moveRows(int sourceIndex, int destIndex, int count);
Q_INVOKABLE bool moveDown(int index); Q_INVOKABLE bool moveDown(int index);
@ -115,6 +80,7 @@ public:
Q_INVOKABLE QVariantMap getItem(int index) const; Q_INVOKABLE QVariantMap getItem(int index) const;
Q_INVOKABLE QVariantList getItems(); Q_INVOKABLE QVariantList getItems();
Q_INVOKABLE void clearAll(); Q_INVOKABLE void clearAll();
Q_INVOKABLE int findSlideIdFromServItm(int index);
private: private:
QList<Slide *> m_items; QList<Slide *> m_items;

View file

@ -1,5 +1,6 @@
#include "slideobject.h" #include "slideobject.h"
#include "serviceitemmodel.h" #include "serviceitemmodel.h"
#include "slidemodel.h"
#include <podofo/podofo.h> #include <podofo/podofo.h>
#include <QDebug> #include <QDebug>
@ -54,128 +55,178 @@ int SlideObject::slideSize() const
return m_slideSize; return m_slideSize;
} }
void SlideObject::changeSlide(QVariantMap item) void SlideObject::changeSlide(QVariantMap item, ServiceItemModel *serviceItemModel)
{ {
setServiceItem(item); // setServiceItem(item);
setType(serviceItemId().value("type").toString()); // setType(serviceItemId().value("type").toString());
qDebug() << "#$% SLIDE TYPE: " << type() << " %$#"; // qDebug() << "#$% SLIDE TYPE: " << type() << " %$#";
// First let's clear the text and then set // // First let's clear the text and then set
// the size and index of a basic slide // // the size and index of a basic slide
// then we'll build the rest // // then we'll build the rest
setText(""); // setText("");
m_slideSize = 1; // m_slideSize = 1;
m_slideIndex = 1; // m_slideIndex = 1;
qDebug() << serviceItemId().value("backgroundType").toString(); // qDebug() << serviceItemId().value("backgroundType").toString();
if (serviceItemId().value("backgroundType") == "image") { // if (serviceItemId().value("backgroundType") == "image") {
setImageBackground(serviceItemId().value("background").toString()); // setImageBackground(serviceItemId().value("background").toString());
setVideoBackground(""); // setVideoBackground("");
} else { // } else {
setVideoBackground(serviceItemId().value("background").toString()); // setVideoBackground(serviceItemId().value("background").toString());
setImageBackground(""); // setImageBackground("");
} // }
setFont(serviceItemId().value("font").toString()); // setFont(serviceItemId().value("font").toString());
setFontSize(serviceItemId().value("fontSize").toInt()); // setFontSize(serviceItemId().value("fontSize").toInt());
setAudio(""); // setAudio("");
if (type() == "presentation") { // if (type() == "presentation") {
qDebug() << "#$#$#$#$ THIS PDF $#$#$#$#"; // qDebug() << "#$#$#$#$ THIS PDF $#$#$#$#";
int pageCount; // int pageCount;
QString str = imageBackground().remove(0,6); // QString str = imageBackground().remove(0,6);
qDebug() << str; // qDebug() << str;
std::string file = str.toStdString(); // std::string file = str.toStdString();
// qDebug() << file; // // qDebug() << file;
const char * doc = file.c_str(); // const char * doc = file.c_str();
qDebug() << doc; // qDebug() << doc;
try { // try {
PdfMemDocument pdf = PdfMemDocument(doc); // PdfMemDocument pdf = PdfMemDocument(doc);
pageCount = pdf.GetPageCount(); // pageCount = pdf.GetPageCount();
} catch ( const PdfError & eCode ) { // } catch ( const PdfError & eCode ) {
eCode.PrintErrorMsg(); // eCode.PrintErrorMsg();
eCode.GetError(); // eCode.GetError();
return; // return;
} // }
setImageCount(pageCount); // setImageCount(pageCount);
qDebug() << imageCount(); // qDebug() << imageCount();
m_slideSize = imageCount(); // m_slideSize = imageCount();
} // }
QStringList text = serviceItemId().value("text").toStringList(); // QStringList text = serviceItemId().value("text").toStringList();
if (type() == "song") { // if (type() == "song") {
qDebug() << "TEXT LENGTH: " << text.length(); // qDebug() << "TEXT LENGTH: " << text.length();
m_slideSize = text.length(); // m_slideSize = text.length();
m_slideIndex = 1; // m_slideIndex = 1;
setText(text[0]); // setText(text[0]);
setAudio(serviceItemId().value("audio").toString()); // setAudio(serviceItemId().value("audio").toString());
} // }
// qDebug() << "MAP: " << serviceItemId().value("text");
//New implementation
QVariantMap serviceItem = serviceItemModel->getItem(item.value("serviceItemId").toInt());
setText(item.value("text").toString());
setType(item.value("type").toString());
setAudio(item.value("audio").toString());
setImageBackground(item.value("imageBackground").toString());
setVideoBackground(item.value("videoBackground").toString());
setVerticalTextAlignment(item.value("verticalTextAlignment").toString());
setHorizontalTextAlignment(item.value("horizontalTextAlignment").toString());
setFont(item.value("font").toString());
setFontSize(item.value("fontSize").toInt());
setImageCount(item.value("imageCount").toInt());
setSlideIndex(item.value("slideIndex").toInt());
m_slideSize = serviceItem.value("slideNumber").toInt();
qDebug() << "MAP: " << serviceItemId().value("text");
emit slideIndexChanged(m_slideIndex);
emit slideSizeChanged(m_slideSize); emit slideSizeChanged(m_slideSize);
} }
bool SlideObject::next(QVariantMap nextItem) bool SlideObject::next(QVariantMap nextItem, ServiceItemModel *serviceItemModel)
{ {
qDebug() << "Starting to go to next item."; // qDebug() << "Starting to go to next item.";
qDebug() << "SlideObject Index: " << slideIndex() << " SlideObject Size: " << slideSize(); // qDebug() << "SlideObject Index: " << slideIndex() << " SlideObject Size: " << slideSize();
QStringList text = serviceItemId().value("text").toStringList(); // QStringList text = serviceItemId().value("text").toStringList();
if (slideIndex() == slideSize()) { // if (slideIndex() == slideSize()) {
// changeSlideObject(nextItem); // // changeSlideObject(nextItem);
return true; // return true;
} // }
qDebug() << type(); // qDebug() << 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.
if (type() == "song") { // if (type() == "song") {
int nextTextIndex = slideIndex(); // int nextTextIndex = slideIndex();
qDebug() << nextTextIndex; // qDebug() << nextTextIndex;
qDebug() << text[nextTextIndex]; // qDebug() << text[nextTextIndex];
setText(text[nextTextIndex]); // setText(text[nextTextIndex]);
m_slideSize++; // m_slideSize++;
emit slideIndexChanged(m_slideIndex); // emit slideIndexChanged(m_slideIndex);
} // }
if (type() == "presentation") { // if (type() == "presentation") {
qDebug() << "prev slide index: " << slideIndex(); // qDebug() << "prev slide index: " << slideIndex();
m_slideIndex++; // m_slideIndex++;
emit slideIndexChanged(m_slideIndex); // emit slideIndexChanged(m_slideIndex);
qDebug() << "new slide index: " << slideIndex(); // qDebug() << "new slide index: " << slideIndex();
} // }
//new implementation
QVariantMap serviceItem = serviceItemModel->getItem(nextItem.value("serviceItemId").toInt());
setText(nextItem.value("text").toString());
setType(nextItem.value("type").toString());
setAudio(nextItem.value("audio").toString());
setImageBackground(nextItem.value("imageBackground").toString());
setVideoBackground(nextItem.value("videoBackground").toString());
setVerticalTextAlignment(nextItem.value("verticalTextAlignment").toString());
setHorizontalTextAlignment(nextItem.value("horizontalTextAlignment").toString());
setFont(nextItem.value("font").toString());
setFontSize(nextItem.value("fontSize").toInt());
setImageCount(nextItem.value("imageCount").toInt());
setSlideIndex(nextItem.value("slideIndex").toInt());
m_slideSize = serviceItem.value("slideNumber").toInt();
emit slideSizeChanged(m_slideSize);
return false; return false;
} }
bool SlideObject::previous(QVariantMap prevItem) bool SlideObject::previous(QVariantMap prevItem, ServiceItemModel *serviceItemModel)
{ {
qDebug() << "Starting to go to previous item."; // qDebug() << "Starting to go to previous item.";
qDebug() << "SlideObject Index: " << slideIndex() << " SlideObject Size: " << slideSize(); // qDebug() << "SlideObject Index: " << slideIndex() << " SlideObject Size: " << slideSize();
QStringList text = serviceItemId().value("text").toStringList(); // QStringList text = serviceItemId().value("text").toStringList();
if (slideIndex() == 1) { // if (slideIndex() == 1) {
// changeSlideObject(prevItem); // // changeSlideObject(prevItem);
return true; // return true;
} // }
// 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
if (type() == "song") { // if (type() == "song") {
int prevTextIndex = slideIndex() - 2; // int prevTextIndex = slideIndex() - 2;
qDebug() << prevTextIndex; // qDebug() << prevTextIndex;
qDebug() << text[prevTextIndex]; // qDebug() << text[prevTextIndex];
setText(text[prevTextIndex]); // setText(text[prevTextIndex]);
m_slideIndex--; // m_slideIndex--;
emit slideIndexChanged(m_slideIndex); // emit slideIndexChanged(m_slideIndex);
} // }
if (type() == "presentation") { // if (type() == "presentation") {
qDebug() << "prev slide index: " << slideIndex(); // qDebug() << "prev slide index: " << slideIndex();
m_slideIndex--; // m_slideIndex--;
emit slideIndexChanged(m_slideIndex); // emit slideIndexChanged(m_slideIndex);
qDebug() << "new slide index: " << slideIndex(); // qDebug() << "new slide index: " << slideIndex();
} // }
//new implementation
QVariantMap serviceItem = serviceItemModel->getItem(prevItem.value("serviceItemId").toInt());
setText(prevItem.value("text").toString());
setType(prevItem.value("type").toString());
setAudio(prevItem.value("audio").toString());
setImageBackground(prevItem.value("imageBackground").toString());
setVideoBackground(prevItem.value("videoBackground").toString());
setVerticalTextAlignment(prevItem.value("verticalTextAlignment").toString());
setHorizontalTextAlignment(prevItem.value("horizontalTextAlignment").toString());
setFont(prevItem.value("font").toString());
setFontSize(prevItem.value("fontSize").toInt());
setImageCount(prevItem.value("imageCount").toInt());
setSlideIndex(prevItem.value("slideIndex").toInt());
m_slideSize = serviceItem.value("slideNumber").toInt();
emit slideSizeChanged(m_slideSize);
return false; return false;
} }
@ -183,7 +234,7 @@ bool SlideObject::changeSlideIndex(int index)
{ {
qDebug() << "Starting to change slide index."; qDebug() << "Starting to change slide index.";
qDebug() << "SlideObject Index: " << slideIndex() << " SlideObject Size: " << slideSize(); qDebug() << "SlideObject Index: " << slideIndex() << " SlideObject Size: " << slideSize();
QStringList text = serviceItemId().value("text").toStringList(); // QStringList text = serviceItemId().value("text").toStringList();
if (index > slideSize() - 1 || index < 0) { if (index > slideSize() - 1 || index < 0) {
qDebug() << "index is invalid: " << index; qDebug() << "index is invalid: " << index;
return false; return false;
@ -194,8 +245,8 @@ bool SlideObject::changeSlideIndex(int index)
if (type() == "song") { if (type() == "song") {
int textIndex = index; int textIndex = index;
qDebug() << textIndex; qDebug() << textIndex;
qDebug() << text[textIndex]; // qDebug() << text[textIndex];
setText(text[textIndex]); // setText(text[textIndex]);
m_slideIndex = index; m_slideIndex = index;
emit slideIndexChanged(m_slideIndex); emit slideIndexChanged(m_slideIndex);
return true; return true;

View file

@ -1,7 +1,9 @@
#ifndef SLIDEOBJECT_H #ifndef SLIDEOBJECT_H
#define SLIDEOBJECT_H #define SLIDEOBJECT_H
#include "serviceitemmodel.h"
#include "slide.h" #include "slide.h"
#include "slidemodel.h"
#include <qobjectdefs.h> #include <qobjectdefs.h>
#include <qqml.h> #include <qqml.h>
#include <QObject> #include <QObject>
@ -28,12 +30,12 @@ public:
int slideIndex() const; int slideIndex() const;
int slideSize() const; int slideSize() const;
Q_INVOKABLE void changeSlide(QVariantMap item); Q_INVOKABLE void changeSlide(QVariantMap item, ServiceItemModel *serviceItemModel);
Q_INVOKABLE void play(); Q_INVOKABLE void play();
Q_INVOKABLE void pause(); Q_INVOKABLE void pause();
Q_INVOKABLE void playPause(); Q_INVOKABLE void playPause();
Q_INVOKABLE bool next(QVariantMap nextItem); Q_INVOKABLE bool next(QVariantMap nextItem, ServiceItemModel *serviceItemModel);
Q_INVOKABLE bool previous(QVariantMap prevItem); Q_INVOKABLE bool previous(QVariantMap prevItem, ServiceItemModel *serviceItemModel);
Q_INVOKABLE bool changeSlideIndex(int index); Q_INVOKABLE bool changeSlideIndex(int index);
signals: signals:

View file

@ -133,12 +133,14 @@ int main(int argc, char *argv[])
//Need to instantiate our slide //Need to instantiate our slide
QScopedPointer<SlideModel> slideModel(new SlideModel); QScopedPointer<SlideModel> slideModel(new SlideModel);
QScopedPointer<SlideObject> slideobject(new SlideObject);
QScopedPointer<File> filemanager(new File); QScopedPointer<File> filemanager(new File);
QScopedPointer<QQuickView> preswin(new QQuickView); QScopedPointer<QQuickView> preswin(new QQuickView);
QScopedPointer<ServiceItemModel> serviceItemModel(new ServiceItemModel(slideModel.get())); QScopedPointer<ServiceItemModel> serviceItemModel(new ServiceItemModel);
QScopedPointer<SlideObject> slideobject(new SlideObject);
preswin->setSource(QUrl(QStringLiteral("qrc:qml/presenter/PresentationWindow.qml"))); preswin->setSource(QUrl(QStringLiteral("qrc:qml/presenter/PresentationWindow.qml")));
bool loading = serviceItemModel.get()->loadLastSaved(*slideModel.get());
// apparently mpv needs this class set // apparently mpv needs this class set
// let's register mpv as well // let's register mpv as well
std::setlocale(LC_NUMERIC, "C"); std::setlocale(LC_NUMERIC, "C");
@ -153,6 +155,7 @@ int main(int argc, char *argv[])
qmlRegisterType<ServiceThing>("org.presenter", 1, 0, "ServiceThing"); qmlRegisterType<ServiceThing>("org.presenter", 1, 0, "ServiceThing");
qmlRegisterSingletonInstance("org.presenter", 1, 0, qmlRegisterSingletonInstance("org.presenter", 1, 0,
"ServiceItemModel", serviceItemModel.get()); "ServiceItemModel", serviceItemModel.get());
qmlRegisterSingletonInstance("org.presenter", 1, 0, "SlideModel", slideModel.get());
qmlRegisterSingletonInstance("org.presenter", 1, 0, "SlideObject", slideobject.get()); qmlRegisterSingletonInstance("org.presenter", 1, 0, "SlideObject", slideobject.get());
qmlRegisterSingletonInstance("org.presenter", 1, 0, "FileManager", filemanager.get()); qmlRegisterSingletonInstance("org.presenter", 1, 0, "FileManager", filemanager.get());
qmlRegisterSingletonInstance("org.presenter", 1, 0, "PresWindow", preswin.get()); qmlRegisterSingletonInstance("org.presenter", 1, 0, "PresWindow", preswin.get());