diff --git a/TODO.org b/TODO.org index a665d11..0329f88 100644 --- a/TODO.org +++ b/TODO.org @@ -3,7 +3,7 @@ :CATEGORY: dev :END: -* Tasks [61%] [26/42] +* Tasks [65%] [27/41] ** TODO Start planning out what a 1.0 release would look like and decide how to get there A 1.0 release may be achievable soon as long as I can figure out what is good have in and what isn't. Then figure out what outstanding bugs and odd workflows exist and fix them. Then figure out deploying the package to various distros, windows, and mac. @@ -12,7 +12,6 @@ A 1.0 release may be achievable soon as long as I can figure out what is good ha *** TODO What is In *** TODO Major Bugs *** TODO Deployment -** TODO ServiceItemModel load needs to first look for on disk path and then the archive path ** TODO give images an aspect ratio option ** TODO Fix ImageEditor to make more sense for images ** TODO Add image slideshow with looping @@ -77,6 +76,8 @@ This thread helped a lot ** DONE Make serviceItemModel aware of being selected and active Being selected means that those items can be dragged or deleted or moved together. Being active, means that the singular item is the currently displayed item. +** DONE ServiceItemModel load needs to first look for on disk path and then the archive path +Check audio and background first, if they don't exist, grab the file in the archive and put it in the local folder and use that path to create the serviceitem ** DONE Unload video when switching to something with just image :core:bug: ** DONE Create a nextslide function to be used after the end of the list of slides :slide: [[file:~/dev/church-presenter/src/qml/presenter/Presentation.qml::function nextSlide() {]] diff --git a/src/serviceitemmodel.cpp b/src/serviceitemmodel.cpp index c62dc2d..690d0ae 100644 --- a/src/serviceitemmodel.cpp +++ b/src/serviceitemmodel.cpp @@ -20,7 +20,8 @@ #include #include #include - +#include +#include ServiceItemModel::ServiceItemModel(QObject *parent) @@ -602,10 +603,72 @@ bool ServiceItemModel::load(QUrl file) { QMap item = serviceList[i].toMap(); + QString backgroundString = item.value("background").toString(); + QFileInfo backgroundFile = backgroundString.right(backgroundString.size() - 7); + + QString audioString = item.value("audio").toString(); + QFileInfo audioFile = audioString.right(audioString.size() - 7); + + qDebug() << "POOPPOPOPOPOPOPOPOPOPOPOPOPO"; + qDebug() << backgroundFile; + qDebug() << backgroundFile.exists(); + qDebug() << audioFile; + qDebug() << audioFile.exists(); + qDebug() << "POOPPOPOPOPOPOPOPOPOPOPOPOPO"; + + QString realBackground; + QString realAudio; + + QFileInfo serviceFile = file.toString().right(file.toString().size() - 7); + QString serviceName = serviceFile.baseName(); + QDir localDir = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation); + localDir.mkdir(serviceName); + QDir serviceDir = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + + "/" + serviceName; + qDebug() << serviceDir.path(); + + realBackground = backgroundString; + realAudio = audioString; + // If the background file is on disk use that, else use the one in archive + if (!backgroundFile.exists() && backgroundString.length() > 0) { + const KArchiveEntry *e = dir->entry(backgroundFile.fileName()); + if (!e) { + qDebug() << "Background File not found!"; + continue; + } + const KArchiveFile *f = static_cast(e); + if (!f->copyTo(serviceDir.path())) + qDebug() << "FILE COULDN'T BE CREATED!"; + + QFileInfo bgFile = serviceDir.path() + "/" + backgroundFile.fileName(); + + qDebug() << bgFile.filePath(); + + realBackground = bgFile.filePath(); + } + + // If the audio file is on disk use that, else use the one in archive + if (!audioFile.exists() && audioString.length() > 0) { + const KArchiveEntry *e = dir->entry(audioFile.fileName()); + if (!e) { + qDebug() << "Audio File not found!"; + continue; + } + const KArchiveFile *f = static_cast(e); + if (!f->copyTo(serviceDir.path())) + qDebug() << "FILE COULDN'T BE CREATED!"; + + QFileInfo audFile = serviceDir.path() + "/" + audioFile.fileName(); + + qDebug() << audFile.filePath(); + + realAudio = audFile.filePath(); + } + insertItem(i, item.value("name").toString(), item.value("type").toString(), - item.value("background").toString(), + realBackground, item.value("backgroundType").toString(), - item.value("text").toStringList(), item.value("audio").toString(), + item.value("text").toStringList(), realAudio, item.value("font").toString(), item.value("fontSize").toInt()); }