fixing empty files not loading the application

This commit is contained in:
Chris Cochrun 2023-02-20 11:21:04 -06:00
parent d97467ee63
commit 0086ed3d5a
5 changed files with 20 additions and 19 deletions

View file

@ -27,16 +27,6 @@
ServiceItemModel::ServiceItemModel(QObject *parent)
: QAbstractListModel(parent) {
addItem(new ServiceItem("10,000 Reasons", "song",
"file:/home/chris/nextcloud/tfc/openlp/CMG - Nature King 21.jpg",
"image", QStringList("Yip Yip"),
"file:/home/chris/nextcloud/tfc/openlp/music/Eden-Phil Wickham [lyrics].mp3"));
addItem(new ServiceItem("Marvelous Light", "song",
"file:/home/chris/nextcloud/tfc/openlp/Fire Embers_Loop.mp4",
"video", QStringList("Hallelujah!")));
addItem(new ServiceItem("BP Text", "video",
"file:/home/chris/nextcloud/tfc/openlp/videos/test.mp4",
"video", QStringList()));
}
int ServiceItemModel::rowCount(const QModelIndex &parent) const {
@ -718,7 +708,8 @@ bool ServiceItemModel::load(QUrl file) {
qDebug() << "File path is: " << file.toString();
qDebug() << "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@";
if (file.isEmpty() || !file.isValid())
QFileInfo loadInfo = QFileInfo(file.toLocalFile());
if (!loadInfo.exists())
return false;
QString fileUrl = file.toString().right(file.toString().size() - 7);

View file

@ -493,10 +493,12 @@ bool SlideModel::select(int id) {
bool SlideModel::activate(int id) {
QModelIndex idx = index(id);
Slide *item = m_items[idx.row()];
qDebug() << item->type();
for (int i = 0; i < m_items.length(); i++) {
QModelIndex idx = index(i);
Slide *itm = m_items[idx.row()];
qDebug() << i << m_items.length() << item->active() << itm->active();
if (itm->active()) {
itm->setActive(false);
qDebug() << "################";
@ -539,7 +541,7 @@ int SlideModel::findSlideIdFromServItm(int index) {
return i;
}
}
return -1;
return 0;
}
void SlideModel::addItemFromService(const int &index, const ServiceItem &item) {

View file

@ -146,6 +146,8 @@ void SlideObject::changeSlide(QVariantMap item, int index)
setImageCount(item.value("imageCount").toInt());
setSlideIndex(item.value("slideIndex").toInt());
qDebug() << "THIS IS THE INDEX OF THE SLIDE!";
qDebug() << index;
emit slideChanged(index);
// m_slideSize = serviceItem.value("slideNumber").toInt();

View file

@ -147,10 +147,6 @@ int main(int argc, char *argv[])
SIGNAL(itemAdded(const int&, const ServiceItem&)),
slideModel.get(),
SLOT(addItemFromService(const int&, const ServiceItem&)));
QObject::connect(slideobject.get(),
SIGNAL(slideChanged(int)),
slideModel.get(),
SLOT(activate(int)));
QObject::connect(serviceItemModel.get(),
SIGNAL(rowMoved(const int&, const int&, const ServiceItem&)),
slideModel.get(),
@ -163,8 +159,18 @@ int main(int argc, char *argv[])
SIGNAL(allRemoved()),
slideModel.get(),
SLOT(clearAll()));
QObject::connect(slideobject.get(),
SIGNAL(slideChanged(int)),
slideModel.get(),
SLOT(activate(int)));
bool loading = serviceItemModel.get()->loadLastSaved();
if (!serviceItemModel.get()->loadLastSaved()) {
qDebug() << "Last saved file is missing or there isn't a last saved file.";
serviceItemModel.get()->addItem("Black", "image",
"qrc:/assets/black.jpg",
"image", QStringList(""),
"", "", 0, 1);
}
// apparently mpv needs this class set
// let's register mpv as well

View file

@ -146,12 +146,12 @@ Controls.Page {
currentSlide = slideId;
const slide = SlideModel.getItem(slideId);
console.log("index grabbed: " + index);
console.log(item);
console.log(slideId);
console.log("Time to start changing");
/* presentation.stopVideo(); */
/* pWindow.stopVideo(); */
/* presentation.itemType = item.type; */
console.log("Time to start changing");
ServiceItemModel.activate(index);
SlideObject.changeSlide(slide, slideId);