adding of items now adds slides as well through signal/slot

This commit is contained in:
Chris Cochrun 2023-01-21 07:23:33 -06:00
parent d1e0cc2fc0
commit b40d9e11a6
6 changed files with 107 additions and 104 deletions

View file

@ -1,4 +1,5 @@
#include "slidemodel.h"
#include "serviceitem.h"
#include "slide.h"
#include <qabstractitemmodel.h>
#include <qglobal.h>
@ -476,3 +477,74 @@ int SlideModel::findSlideIdFromServItm(int index) {
}
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);
}
}