adding of items now adds slides as well through signal/slot
This commit is contained in:
parent
d1e0cc2fc0
commit
b40d9e11a6
6 changed files with 107 additions and 104 deletions
|
@ -277,7 +277,7 @@ 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, SlideModel &slideModel) {
|
const int &slideNumber) {
|
||||||
qDebug() << "*************************";
|
qDebug() << "*************************";
|
||||||
qDebug() << "Plain adding item: " << name;
|
qDebug() << "Plain adding item: " << name;
|
||||||
qDebug() << "*************************";
|
qDebug() << "*************************";
|
||||||
|
@ -285,36 +285,9 @@ void ServiceItemModel::addItem(const QString &name, const QString &type,
|
||||||
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);
|
|
||||||
}
|
|
||||||
} else if (type == "video") {
|
|
||||||
slideModel.addItem("", type, "", background,
|
|
||||||
audio, font, fontSize,
|
|
||||||
"center", "center",
|
|
||||||
rowCount(), 0, 1);
|
|
||||||
} else {
|
|
||||||
slideModel.addItem("", type, background, "",
|
|
||||||
audio, font, fontSize,
|
|
||||||
"center", "center",
|
|
||||||
rowCount(), 0, 1);
|
|
||||||
}
|
|
||||||
addItem(item);
|
addItem(item);
|
||||||
|
emit itemAdded(rowCount() - 1, *item);
|
||||||
|
qDebug() << "EMITTED ITEM ADDED" << rowCount();
|
||||||
qDebug() << "#################################";
|
qDebug() << "#################################";
|
||||||
qDebug() << name << type << font << fontSize << slideNumber;
|
qDebug() << name << type << font << fontSize << slideNumber;
|
||||||
qDebug() << "#################################";
|
qDebug() << "#################################";
|
||||||
|
@ -376,8 +349,7 @@ 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) {
|
|
||||||
qDebug() << "*************************";
|
qDebug() << "*************************";
|
||||||
qDebug() << "Inserting serviceItem: " << name << " and index is " << index;
|
qDebug() << "Inserting serviceItem: " << name << " and index is " << index;
|
||||||
qDebug() << "*************************";
|
qDebug() << "*************************";
|
||||||
|
@ -385,43 +357,12 @@ void ServiceItemModel::insertItem(const int &index, const QString &name,
|
||||||
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(), 0, 1);
|
|
||||||
} else {
|
|
||||||
slideModel.insertItem(slideModelIdx, type, background, "", "",
|
|
||||||
audio, font, fontSize,
|
|
||||||
"center", "center",
|
|
||||||
rowCount(), 0, 1);
|
|
||||||
}
|
|
||||||
insertItem(index, item);
|
insertItem(index, item);
|
||||||
|
emit itemInserted(index, *item);
|
||||||
|
qDebug() << "EMITTED ITEM INSERTED";
|
||||||
qDebug() << "#################################";
|
qDebug() << "#################################";
|
||||||
qDebug() << "INSERTING SERVICE ITEM!";
|
qDebug() << "INSERTING SERVICE ITEM!";
|
||||||
qDebug() << name << type << font << fontSize << slideNumber << index << slideModelIdx;
|
qDebug() << name << type << font << fontSize << slideNumber << index;
|
||||||
qDebug() << "#################################";
|
qDebug() << "#################################";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -721,7 +662,7 @@ bool ServiceItemModel::save(QUrl file) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ServiceItemModel::load(QUrl file, SlideModel &slideModel) {
|
bool ServiceItemModel::load(QUrl file) {
|
||||||
qDebug() << "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@";
|
qDebug() << "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@";
|
||||||
qDebug() << "Loading...";
|
qDebug() << "Loading...";
|
||||||
qDebug() << "File path is: " << file.toString();
|
qDebug() << "File path is: " << file.toString();
|
||||||
|
@ -827,7 +768,7 @@ bool ServiceItemModel::load(QUrl file, SlideModel &slideModel) {
|
||||||
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(), slideModel);
|
item.value("slideNumber").toInt());
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -843,7 +784,7 @@ void ServiceItemModel::clearAll() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ServiceItemModel::loadLastSaved(SlideModel &slideModel) {
|
bool ServiceItemModel::loadLastSaved() {
|
||||||
QSettings settings;
|
QSettings settings;
|
||||||
return load(settings.value("lastSaveFile").toUrl(), slideModel);
|
return load(settings.value("lastSaveFile").toUrl());
|
||||||
}
|
}
|
||||||
|
|
|
@ -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, SlideModel &slideModel);
|
const int &slideNumber);
|
||||||
// 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,8 +93,7 @@ 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);
|
||||||
|
@ -107,19 +106,12 @@ 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, SlideModel &slideModel);
|
Q_INVOKABLE bool load(QUrl file);
|
||||||
Q_INVOKABLE bool loadLastSaved(SlideModel &slideModel);
|
Q_INVOKABLE bool loadLastSaved();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void itemAdded(const int &index, const QString &type,
|
void itemAdded(const int &, const ServiceItem &);
|
||||||
const QString &background, const QString &backgroundType,
|
void itemInserted(const int &, const ServiceItem &);
|
||||||
const QStringList &text, const QString &audio,
|
|
||||||
const QString &font, const int &fontSize, const int &slideNumber);
|
|
||||||
|
|
||||||
void itemInserted(const int &index, const QString &type,
|
|
||||||
const QString &background, const QString &backgroundType,
|
|
||||||
const QStringList &text, const QString &audio,
|
|
||||||
const QString &font, const int &fontSize, const int &slideNumber);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
#include "slidemodel.h"
|
#include "slidemodel.h"
|
||||||
|
#include "serviceitem.h"
|
||||||
#include "slide.h"
|
#include "slide.h"
|
||||||
#include <qabstractitemmodel.h>
|
#include <qabstractitemmodel.h>
|
||||||
#include <qglobal.h>
|
#include <qglobal.h>
|
||||||
|
@ -476,3 +477,74 @@ int SlideModel::findSlideIdFromServItm(int index) {
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SlideModel::addItemFromService(const int &index, const ServiceItem &item) {
|
||||||
|
qDebug() << "***INSERTING SLIDE FROM SERVICEITEM***";
|
||||||
|
if (item.type() == "song") {
|
||||||
|
for (int i = 0; i < item.text().size(); i++) {
|
||||||
|
if (item.backgroundType() == "image") {
|
||||||
|
addItem(item.text()[i], item.type(), item.background(), "",
|
||||||
|
item.audio(), item.font(), item.fontSize(), "center", "center",
|
||||||
|
index, i, item.text().size());
|
||||||
|
} else {
|
||||||
|
addItem(item.text()[i], item.type(), "", item.background(),
|
||||||
|
item.audio(), item.font(), item.fontSize(), "center", "center",
|
||||||
|
index, i, item.text().size());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (item.type() == "presentation") {
|
||||||
|
for (int i = 0; i < item.slideNumber(); i++) {
|
||||||
|
addItem("", item.type(), item.background(), "",
|
||||||
|
item.audio(), item.font(), item.fontSize(),
|
||||||
|
"center", "center",
|
||||||
|
index, i, item.slideNumber());
|
||||||
|
}
|
||||||
|
} else if (item.type() == "video") {
|
||||||
|
addItem("", item.type(), "", item.background(),
|
||||||
|
item.audio(), item.font(), item.fontSize(),
|
||||||
|
"center", "center",
|
||||||
|
index, 0, 1);
|
||||||
|
} else {
|
||||||
|
addItem("", item.type(), item.background(), "",
|
||||||
|
item.audio(), item.font(), item.fontSize(),
|
||||||
|
"center", "center",
|
||||||
|
index, 0, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void SlideModel::insertItemFromService(const int &index, const ServiceItem &item) {
|
||||||
|
qDebug() << "***INSERTING SLIDE FROM SERVICEITEM***";
|
||||||
|
int slideId = findSlideIdFromServItm(index);
|
||||||
|
if (item.type() == "song") {
|
||||||
|
for (int i = 0; i < item.text().size(); i++) {
|
||||||
|
if (item.backgroundType() == "image") {
|
||||||
|
insertItem(slideId + i, item.type(), item.background(), "", item.text()[i],
|
||||||
|
item.audio(), item.font(), item.fontSize(), "center", "center",
|
||||||
|
index, i, item.text().size());
|
||||||
|
} else {
|
||||||
|
insertItem(slideId + i, item.type(), "", item.background(), item.text()[i],
|
||||||
|
item.audio(), item.font(), item.fontSize(), "center", "center",
|
||||||
|
index, i, item.text().size());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (item.type() == "presentation") {
|
||||||
|
for (int i = 0; i < item.slideNumber(); i++) {
|
||||||
|
insertItem(slideId + i, item.type(), item.background(), "",
|
||||||
|
"", item.audio(), item.font(), item.fontSize(),
|
||||||
|
"center", "center",
|
||||||
|
index, i, item.slideNumber());
|
||||||
|
}
|
||||||
|
} else if (item.type() == "video") {
|
||||||
|
insertItem(slideId, item.type(), "", item.background(), "",
|
||||||
|
item.audio(), item.font(), item.fontSize(),
|
||||||
|
"center", "center",
|
||||||
|
index, 0, 1);
|
||||||
|
} else {
|
||||||
|
insertItem(slideId, item.type(), item.background(), "", "",
|
||||||
|
item.audio(), item.font(), item.fontSize(),
|
||||||
|
"center", "center",
|
||||||
|
index, 0, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#ifndef SLIDEMODEL_H
|
#ifndef SLIDEMODEL_H
|
||||||
#define SLIDEMODEL_H
|
#define SLIDEMODEL_H
|
||||||
|
|
||||||
|
#include "serviceitem.h"
|
||||||
#include "slide.h"
|
#include "slide.h"
|
||||||
#include <QAbstractListModel>
|
#include <QAbstractListModel>
|
||||||
#include <qabstractitemmodel.h>
|
#include <qabstractitemmodel.h>
|
||||||
|
@ -83,15 +84,8 @@ public:
|
||||||
Q_INVOKABLE int findSlideIdFromServItm(int index);
|
Q_INVOKABLE int findSlideIdFromServItm(int index);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void addItemFromService(const int &index, const QString &type,
|
void addItemFromService(const int &index, const ServiceItem &item);
|
||||||
const QString &background, const QString &backgroundType,
|
void insertItemFromService(const int &index, const ServiceItem &item);
|
||||||
const QStringList &text, const QString &audio,
|
|
||||||
const QString &font, const int &fontSize, const int &slideNumber);
|
|
||||||
|
|
||||||
void insertItemFromService(const int &index, const QString &type,
|
|
||||||
const QString &background, const QString &backgroundType,
|
|
||||||
const QStringList &text, const QString &audio,
|
|
||||||
const QString &font, const int &fontSize, const int &slideNumber);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QList<Slide *> m_items;
|
QList<Slide *> m_items;
|
||||||
|
|
12
src/main.cpp
12
src/main.cpp
|
@ -139,10 +139,16 @@ int main(int argc, char *argv[])
|
||||||
QScopedPointer<SlideObject> slideobject(new SlideObject);
|
QScopedPointer<SlideObject> slideobject(new SlideObject);
|
||||||
preswin->setSource(QUrl(QStringLiteral("qrc:qml/presenter/PresentationWindow.qml")));
|
preswin->setSource(QUrl(QStringLiteral("qrc:qml/presenter/PresentationWindow.qml")));
|
||||||
|
|
||||||
QObject::connect(serviceItemModel.get(), &ServiceItemModel::itemAdded,
|
QObject::connect(serviceItemModel.get(),
|
||||||
slideModel.get(), &SlideModel::addItem())
|
SIGNAL(itemInserted(const int&, const ServiceItem&)),
|
||||||
|
slideModel.get(),
|
||||||
|
SLOT(insertItemFromService(const int&, const ServiceItem&)));
|
||||||
|
QObject::connect(serviceItemModel.get(),
|
||||||
|
SIGNAL(itemAdded(const int&, const ServiceItem&)),
|
||||||
|
slideModel.get(),
|
||||||
|
SLOT(addItemFromService(const int&, const ServiceItem&)));
|
||||||
|
|
||||||
bool loading = serviceItemModel.get()->loadLastSaved(*slideModel.get());
|
bool loading = serviceItemModel.get()->loadLastSaved();
|
||||||
|
|
||||||
// apparently mpv needs this class set
|
// apparently mpv needs this class set
|
||||||
// let's register mpv as well
|
// let's register mpv as well
|
||||||
|
|
|
@ -520,7 +520,7 @@ Item {
|
||||||
ServiceItemModel.insertItem(index, name,
|
ServiceItemModel.insertItem(index, name,
|
||||||
type, background,
|
type, background,
|
||||||
backgroundType, newtext,
|
backgroundType, newtext,
|
||||||
audio, font, fontSize, newtext.length, SlideModel);
|
audio, font, fontSize, newtext.length);
|
||||||
/* totalServiceItems++; */
|
/* totalServiceItems++; */
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -529,7 +529,7 @@ Item {
|
||||||
ServiceItemModel.insertItem(index, name,
|
ServiceItemModel.insertItem(index, name,
|
||||||
type, background,
|
type, background,
|
||||||
backgroundType, "",
|
backgroundType, "",
|
||||||
"", "", 0, dragItemSlideNumber, SlideModel);
|
"", "", 0, dragItemSlideNumber);
|
||||||
/* totalServiceItems++; */
|
/* totalServiceItems++; */
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -537,7 +537,7 @@ Item {
|
||||||
ServiceItemModel.insertItem(index, name,
|
ServiceItemModel.insertItem(index, name,
|
||||||
type, background,
|
type, background,
|
||||||
backgroundType, "", "",
|
backgroundType, "", "",
|
||||||
"", 0, 0, SlideModel);
|
"", 0, 0);
|
||||||
/* totalServiceItems++; */
|
/* totalServiceItems++; */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -552,8 +552,7 @@ Item {
|
||||||
console.log(lyrics);
|
console.log(lyrics);
|
||||||
ServiceItemModel.addItem(name, type, background,
|
ServiceItemModel.addItem(name, type, background,
|
||||||
backgroundType, lyrics,
|
backgroundType, lyrics,
|
||||||
audio, font, fontSize, lyrics.length(),
|
audio, font, fontSize, lyrics.length());
|
||||||
SlideModel);
|
|
||||||
/* totalServiceItems++; */
|
/* totalServiceItems++; */
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
@ -565,8 +564,7 @@ Item {
|
||||||
ServiceItemModel.addItem(name, type, background,
|
ServiceItemModel.addItem(name, type, background,
|
||||||
backgroundType, "",
|
backgroundType, "",
|
||||||
audio, font, fontSize,
|
audio, font, fontSize,
|
||||||
dragSlideItemNumber,
|
dragSlideItemNumber);
|
||||||
SlideModel);
|
|
||||||
/* totalServiceItems++; */
|
/* totalServiceItems++; */
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
@ -575,7 +573,7 @@ Item {
|
||||||
|
|
||||||
ServiceItemModel.addItem(name, type, background,
|
ServiceItemModel.addItem(name, type, background,
|
||||||
backgroundType, [""], "",
|
backgroundType, [""], "",
|
||||||
"", 0, 0, SlideModel);
|
"", 0, 0);
|
||||||
/* totalServiceItems++; */
|
/* totalServiceItems++; */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue