* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
***************************************************************************/
-#include <QCryptographicHash>
-#include <QFile>
+
+#include "kdenlivedoc.h"
+#include "docclipbase.h"
+#include "profilesdialog.h"
+#include "kdenlivesettings.h"
+#include "renderer.h"
+#include "clipmanager.h"
+#include "titlewidget.h"
+#include "mainwindow.h"
#include <KDebug>
#include <KStandardDirs>
#include <KIO/CopyJob>
#include <KApplication>
+#include <QCryptographicHash>
+#include <QFile>
#include <mlt++/Mlt.h>
-#include "kdenlivedoc.h"
-#include "docclipbase.h"
-#include "profilesdialog.h"
-#include "kdenlivesettings.h"
-#include "renderer.h"
-#include "clipmanager.h"
-#include "titlewidget.h"
-#include "mainwindow.h"
KdenliveDoc::KdenliveDoc(const KUrl &url, const KUrl &projectFolder, QUndoGroup *undoGroup, const QString &profileName, const QPoint tracks, Render *render, MainWindow *parent): QObject(parent), m_render(render), m_url(url), m_projectFolder(projectFolder), m_commandStack(new QUndoStack(undoGroup)), m_modified(false), m_documentLoadingProgress(0), m_documentLoadingStep(0.0), m_startPos(0), m_zoom(7), m_autosave(NULL), m_zoneStart(0), m_zoneEnd(100), m_abortLoading(false) {
m_clipManager = new ClipManager(this);
// Upgrade old Kdenlive documents to current version
if (!convertDocument(version)) {
- KMessageBox::sorry(parent, i18n("This project type is unsupported and can't be loaded."), i18n("Unable to open project"));
+ m_url.clear();
m_document = createEmptyDocument(tracks.x(), tracks.y());
setProfilePath(profileName);
} else {
}
m_startPos = infoXml.attribute("position").toInt();
m_zoom = infoXml.attribute("zoom", "7").toInt();
-
-
-
-
m_zoneEnd = infoXml.attribute("zoneout", "100").toInt();
setProfilePath(profilePath);
westley.removeChild(tracksinfo);
}
- QDomElement orig;
QDomNodeList producers = m_document.elementsByTagName("producer");
QDomNodeList infoproducers = m_document.elementsByTagName("kdenlive_producer");
const int max = producers.count();
if (!e.isNull() && prodId != "black" && !prodId.startsWith("slowmotion") && !m_abortLoading) {
e.setTagName("producer");
// Get MLT's original producer properties
-
+ QDomElement orig;
for (int j = 0; j < max; j++) {
QDomElement o = producers.item(j).cloneNode().toElement();
QString origId = o.attribute("id").section('_', 0, 0);
bool KdenliveDoc::convertDocument(double version) {
kDebug() << "Opening a document with version " << version;
+ const double current_version = 0.82;
- if (version == 0.82) return true;
+ if (version == current_version) return true;
+
+ if (version > current_version) {
+ kDebug() << "Unable to open document with version " << version;
+ KMessageBox::sorry(kapp->activeWindow(), i18n("This project type is unsupported (version %1) and can't be loaded.\nPlease consider upgrading you Kdenlive version.", version), i18n("Unable to open project"));
+ return false;
+ }
+
+ // Opening a old Kdenlive document
+ if (version == 0.5 || version == 0.7) {
+ KMessageBox::sorry(kapp->activeWindow(), i18n("This project type is unsupported (version %1) and can't be loaded.", version), i18n("Unable to open project"));
+ kDebug() << "Unable to open document with version " << version;
+ // TODO: convert 0.7 (0.5?) files to the new document format.
+ return false;
+ }
+
+ setModified(true);
if (version == 0.81) {
// Add correct tracks info
QDomNode kdenlivedoc = m_document.elementsByTagName("kdenlivedoc").at(0);
QDomElement infoXml = kdenlivedoc.toElement();
+ infoXml.setAttribute("version", current_version);
QString currentTrackOrder = infoXml.attribute("tracks");
QDomElement tracksinfo = m_document.createElement("tracksinfo");
for (int i = 0; i < currentTrackOrder.size(); i++) {
return true;
}
- // Opening a old Kdenlive document
- if (version == 0.5 || version == 0.7 || version > 0.81) {
- kDebug() << "Unable to open document with version " << version;
- // TODO: convert 0.7 (0.5?) files to the new document format.
- return false;
- }
-
if (version == 0.8) {
// Add the tracks information
QDomNodeList tracks = m_document.elementsByTagName("track");
QDomNode kdenlivedoc = m_document.elementsByTagName("kdenlivedoc").at(0);
QDomElement infoXml = kdenlivedoc.toElement();
+ infoXml.setAttribute("version", current_version);
QDomElement tracksinfo = m_document.createElement("tracksinfo");
for (int i = 0; i < max; i++) {
QDomNode tractor = m_document.elementsByTagName("tractor").at(0);
QDomNode kdenlivedoc = m_document.elementsByTagName("kdenlivedoc").at(0);
QDomElement kdenlivedoc_old = kdenlivedoc.cloneNode(true).toElement(); // Needed for folders
+ QDomElement infoXml = kdenlivedoc.toElement();
+ infoXml.setAttribute("version", current_version);
QDomNode multitrack = m_document.elementsByTagName("multitrack").at(0);
QDomNodeList playlists = m_document.elementsByTagName("playlist");
else m_timecode.setFormat((int) m_fps);
}
-const double KdenliveDoc::dar() {
+double KdenliveDoc::dar() {
return (double) m_profile.display_aspect_num / m_profile.display_aspect_den;
}
}
double KdenliveDoc::projectDuration() const {
- if (m_render) return GenTime(m_render->getLength(), m_fps).ms() / 1000;
+ if (m_render)
+ return GenTime(m_render->getLength(), m_fps).ms() / 1000;
+ else
+ return 0;
}
double KdenliveDoc::fps() const {
void KdenliveDoc::addClip(QDomElement elem, QString clipId, bool createClipItem) {
const QString producerId = clipId.section('_', 0, 0);
- int subtrack = clipId.section('_', 1, 1).toInt();
DocClipBase *clip = m_clipManager->getClipById(producerId);
if (clip == NULL) {
- /*kDebug()<<"// CLIP "<<clipId<<" NOT OFUND in LIST, CREATING";
- QDomDocument doc;
- doc.appendChild(doc.importNode(elem, true));
- kDebug() << "IMPORTED CLIP: \n" << doc.toString()<<"\n";*/
elem.setAttribute("id", producerId);
QString path = elem.attribute("resource");
QString extension;
extension = KUrl(path).fileName();
path = KUrl(path).directory();
}
- if (!QFile::exists(path) && elem.attribute("type").toInt() == TEXT) {
+ if (elem.attribute("type").toInt() == TEXT && !QFile::exists(path)) {
kDebug() << "// TITLE: " << elem.attribute("titlename") << " Preview file: " << elem.attribute("resource") << " DOES NOT EXIST";
QString titlename = elem.attribute("titlename");
QString titleresource;
clip = new DocClipBase(m_clipManager, elem, producerId);
m_clipManager->addClip(clip);
}
+
if (createClipItem) {
emit addProjectClip(clip);
qApp->processEvents();
m = m.nextSibling();
}
if (!meta.isEmpty()) {
- clip = m_clipManager->getClipById(clipId);
+ if (clip == NULL) clip = m_clipManager->getClipById(clipId);
if (clip) clip->setMetadata(meta);
}
}
void KdenliveDoc::slotAddClipFile(const KUrl url, const QString group, const QString &groupId) {
- kDebug() << "///////// DOCUM, ADD CLP: " << url;
+ //kDebug() << "///////// DOCUM, ADD CLP: " << url;
m_clipManager->slotAddClipFile(url, group, groupId);
emit selectLastAddedClip(QString::number(m_clipManager->lastClipId()));
setModified(true);
}
-const QString&KdenliveDoc::getFreeClipId() {
+const QString KdenliveDoc::getFreeClipId() {
return QString::number(m_clipManager->getFreeClipId());
}
return m_clipManager->getClipById(clipId);
}
-void KdenliveDoc::slotAddColorClipFile(const QString name, const QString color, QString duration, const QString group, const QString &groupId) {
- m_clipManager->slotAddColorClipFile(name, color, duration, group, groupId);
- setModified(true);
-}
-
-void KdenliveDoc::slotAddSlideshowClipFile(const QString name, const QString path, int count, const QString duration, const bool loop, const bool fade, const QString &luma_duration, const QString &luma_file, const int softness, const QString group, const QString &groupId) {
- m_clipManager->slotAddSlideshowClipFile(name, path, count, duration, loop, fade, luma_duration, luma_file, softness, group, groupId);
- setModified(true);
-}
-
void KdenliveDoc::slotCreateTextClip(QString group, const QString &groupId) {
QString titlesFolder = projectFolder().path() + "/titles/";
KStandardDirs::makeDir(titlesFolder);