Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Move documentRoot property to kdenlivedoc

parent 4a687921
......@@ -503,8 +503,3 @@ std::shared_ptr<ProjectItemModel> Core::projectItemModel()
return m_projectItemModel;
}
QString Core::getDocumentRoot() const
{
// TODO refac: the root should probably be stored elsewhere
return m_binController->documentRoot();
}
......@@ -115,9 +115,6 @@ public:
/** @brief Returns frame rate of current profile */
double getCurrentFps() const;
/** @brief Returns the root of the document */
QString getDocumentRoot() const;
/** @brief Returns the frame size (width x height) of current profile */
QSize getCurrentFrameSize() const;
/** @brief Returns the frame display size (width x height) of current profile */
......
......@@ -877,7 +877,7 @@ QMap<QString, QString> KdenliveDoc::getRenderProperties() const
// Check that we have a full path
QString value = i.value();
if (QFileInfo(value).isRelative()) {
value.prepend(pCore->binController()->documentRoot());
value.prepend(m_documentRoot);
}
renderProperties.insert(i.key(), value);
} else {
......@@ -1283,9 +1283,9 @@ void KdenliveDoc::loadDocumentProperties()
{
QDomNodeList list = m_document.elementsByTagName(QStringLiteral("playlist"));
QDomElement baseElement = m_document.documentElement();
QString root = baseElement.attribute(QStringLiteral("root"));
if (!root.isEmpty()) {
root = QDir::cleanPath(root) + QDir::separator();
m_documentRoot = baseElement.attribute(QStringLiteral("root"));
if (!m_documentRoot.isEmpty()) {
m_documentRoot = QDir::cleanPath(m_documentRoot) + QDir::separator();
}
if (!list.isEmpty()) {
QDomElement pl = list.at(0).toElement();
......@@ -1304,7 +1304,7 @@ void KdenliveDoc::loadDocumentProperties()
// Make sure we have an absolute path
QString value = e.firstChild().nodeValue();
if (QFileInfo(value).isRelative()) {
value.prepend(root);
value.prepend(m_documentRoot);
}
m_documentProperties.insert(name, value);
} else if (name == QStringLiteral("guides")) {
......@@ -1715,3 +1715,8 @@ void KdenliveDoc::guidesChanged()
{
m_documentProperties[QStringLiteral("guides")] = m_guideModel->toJson();
}
const QString KdenliveDoc::documentRoot() const
{
return m_documentRoot;
}
......@@ -173,10 +173,14 @@ public:
// TODO REFAC: delete */
Render *renderer();
/** @brief Returns MLT's root (base path) */
const QString documentRoot() const;
private:
QUrl m_url;
QDomDocument m_document;
/** @brief MLT's root (base path) that is stripped from urls in saved xml */
QString m_documentRoot;
KDirWatch m_fileWatcher;
/** Timer used to reload clips when they have been externally modified */
QTimer m_modifiedTimer;
......
......@@ -3459,7 +3459,7 @@ void MainWindow::slotPrepareRendering(bool scriptExport, bool zoneOnly, const QS
// replace proxy clips with originals
// TODO
QMap<QString, QString> proxies = pCore->binController()->getProxies();
QMap<QString, QString> proxies = pCore->binController()->getProxies(pCore->currentDoc()->documentRoot());
QDomNodeList producers = doc.elementsByTagName(QStringLiteral("producer"));
QString producerResource;
......
......@@ -54,23 +54,6 @@ void BinController::destroyBin()
m_clipList.clear();
}
void BinController::setDocumentRoot(const QString &root)
{
if (root.isEmpty()) {
m_documentRoot.clear();
} else {
m_documentRoot = root;
if (!m_documentRoot.endsWith(QLatin1Char('/'))) {
m_documentRoot.append(QLatin1Char('/'));
}
}
}
const QString BinController::documentRoot() const
{
return m_documentRoot;
}
void BinController::loadExtraProducer(const QString &id, Mlt::Producer *prod)
{
if (m_extraClipList.contains(id)) {
......@@ -558,7 +541,7 @@ const QString BinController::getProperty(const QString &name)
return QString(m_binPlaylist->get(name.toUtf8().constData()));
}
QMap<QString, QString> BinController::getProxies()
QMap<QString, QString> BinController::getProxies(const QString &root)
{
QMap<QString, QString> proxies;
int size = m_binPlaylist->count();
......@@ -570,11 +553,11 @@ QMap<QString, QString> BinController::getProxies()
QString proxy = prod->parent().get("kdenlive:proxy");
if (proxy.length() > 2) {
if (QFileInfo(proxy).isRelative()) {
proxy.prepend(m_documentRoot);
proxy.prepend(root);
}
QString sourceUrl(prod->parent().get("kdenlive:originalurl"));
if (QFileInfo(sourceUrl).isRelative()) {
sourceUrl.prepend(m_documentRoot);
sourceUrl.prepend(root);
}
proxies.insert(proxy, sourceUrl);
}
......
......@@ -157,13 +157,7 @@ public:
const QString getProperty(const QString &name);
/** @brief Return a list of proxy / original url */
QMap<QString, QString> getProxies();
/** @brief Loads the MLT's XML document root */
void setDocumentRoot(const QString &);
/** @brief Returns the MLT's XML document root */
const QString documentRoot() const;
QMap<QString, QString> getProxies(const QString &root);
/** @brief Returns a list of all clips hashes. */
QStringList getProjectHashes();
......@@ -189,9 +183,6 @@ private:
/** @brief This list holds all extra controllers (slowmotion, video only, ... that are in timeline, indexed by id */
QMap<QString, Mlt::Producer *> m_extraClipList;
/** @brief Stores MLT's xml playlist document root, useful to recover full urls */
QString m_documentRoot;
/** @brief Remove a clip from MLT's special bin playlist */
void removeBinPlaylistClip(const QString &id);
......
......@@ -30,6 +30,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "profiles/profilemodel.hpp"
#include "timeline/effectmanager.h"
#include "timeline/timeline.h"
#include "doc/kdenlivedoc.h"
#include "core.h"
#include "kdenlive_debug.h"
......@@ -67,11 +68,11 @@ ClipController::ClipController(const QString clipId, std::shared_ptr<BinControll
// This is a proxy producer, read original url from kdenlive property
path = m_properties->get("kdenlive:originalurl");
if (QFileInfo(path).isRelative()) {
path.prepend(pCore->getDocumentRoot());
path.prepend(pCore->currentDoc()->documentRoot());
}
m_usesProxy = true;
} else if (m_service != QLatin1String("color") && m_service != QLatin1String("colour") && QFileInfo(path).isRelative()) {
path.prepend(pCore->getDocumentRoot());
path.prepend(pCore->currentDoc()->documentRoot());
}
m_path = QFileInfo(path).absoluteFilePath();
getInfoForProducer();
......@@ -100,7 +101,7 @@ AudioStreamInfo *ClipController::audioInfo() const
void ClipController::addMasterProducer(const std::shared_ptr<Mlt::Producer> &producer)
{
QString documentRoot = pCore->getDocumentRoot();
QString documentRoot = pCore->currentDoc()->documentRoot();
m_masterProducer = producer;
m_properties = new Mlt::Properties(m_masterProducer->get_properties());
int id = m_properties->get_int("kdenlive:id");
......
......@@ -23,6 +23,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "bin/projectclip.h"
#include "bincontroller.h"
#include "clipcontroller.h"
#include "doc/kdenlivedoc.h"
#include "core.h"
#include "dialogs/profilesdialog.h"
#include "doc/kthumb.h"
......@@ -188,7 +189,7 @@ void ProducerQueue::processFileProperties()
if (proxy == QLatin1String("-")) {
path = ProjectClip::getXmlProperty(info.xml, QStringLiteral("kdenlive:originalurl"));
if (QFileInfo(path).isRelative()) {
path.prepend(m_binController->documentRoot());
path.prepend(pCore->currentDoc()->documentRoot());
}
proxyProducer = false;
} else {
......
......@@ -483,7 +483,7 @@ int Render::setSceneList(QString playlist, int position)
}
// init MLT's document root, useful to find full urls
m_binController->setDocumentRoot(doc.documentElement().attribute(QStringLiteral("root")));
//m_binController->setDocumentRoot(doc.documentElement().attribute(QStringLiteral("root")));
// Fill Bin's playlist
Mlt::Service service(m_mltProducer->parent().get_service());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment