diff --git a/src/cpp/serviceitemmodel.cpp b/src/cpp/serviceitemmodel.cpp index 800bb67..e773d8d 100644 --- a/src/cpp/serviceitemmodel.cpp +++ b/src/cpp/serviceitemmodel.cpp @@ -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); diff --git a/src/cpp/slidemodel.cpp b/src/cpp/slidemodel.cpp index 44206cd..6099668 100644 --- a/src/cpp/slidemodel.cpp +++ b/src/cpp/slidemodel.cpp @@ -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) { diff --git a/src/cpp/slideobject.cpp b/src/cpp/slideobject.cpp index 15e4f2f..a3692be 100644 --- a/src/cpp/slideobject.cpp +++ b/src/cpp/slideobject.cpp @@ -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(); diff --git a/src/main.cpp b/src/main.cpp index 80372bf..cb06203 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -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 diff --git a/src/qml/presenter/MainWindow.qml b/src/qml/presenter/MainWindow.qml index b912c5c..f81d423 100644 --- a/src/qml/presenter/MainWindow.qml +++ b/src/qml/presenter/MainWindow.qml @@ -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);