#include "kdenlivedoc.h"
#include "docclipbase.h"
-
-KdenliveDoc::KdenliveDoc(const KUrl &url, MltVideoProfile profile, QUndoGroup *undoGroup, QWidget *parent): QObject(parent), m_render(NULL), m_url(url), m_profile(profile), m_fps((double)profile.frame_rate_num / profile.frame_rate_den), m_width(profile.width), m_height(profile.height), m_commandStack(new KUndoStack(undoGroup)) {
+#include "profilesdialog.h"
+#include "kdenlivesettings.h"
+#include "renderer.h"
+#include "clipmanager.h"
+#include "addfoldercommand.h"
+#include "editfoldercommand.h"
+
+KdenliveDoc::KdenliveDoc(const KUrl &url, MltVideoProfile profile, QUndoGroup *undoGroup, QWidget *parent): QObject(parent), m_render(NULL), m_url(url), m_profile(profile), m_fps((double)profile.frame_rate_num / profile.frame_rate_den), m_width(profile.width), m_height(profile.height), m_commandStack(new KUndoStack(undoGroup)), m_modified(false) {
m_clipManager = new ClipManager(this);
if (!url.isEmpty()) {
QString tmpFile;
QFile file(tmpFile);
m_document.setContent(&file, false);
file.close();
+ QDomNode infoXmlNode = m_document.elementsByTagName("kdenlive").at(0);
+ if (!infoXmlNode.isNull()) {
+ QDomElement infoXml = infoXmlNode.toElement();
+ QString profilePath = infoXml.attribute("profile");
+ if (!profilePath.isEmpty()) setProfilePath(profilePath);
+ }
KIO::NetAccess::removeTempFile(tmpFile);
} else {
KMessageBox::error(parent, KIO::NetAccess::lastErrorString());
QDomElement tractor = m_document.createElement("tractor");
+ tractor.setAttribute("id", "maintractor");
QDomElement multitrack = m_document.createElement("multitrack");
QDomElement playlist = m_document.createElement("playlist");
QDomElement producer = m_document.createElement("producer");
transition.setAttribute("combine", "1");
tractor.appendChild(transition);
}
-
+ QDomElement playlistmain = m_document.createElement("playlist");
+ playlistmain.setAttribute("id", "playlistmain");
+ QDomElement playentry = m_document.createElement("entry");
+ playentry.setAttribute("producer", "maintractor");
+ playentry.setAttribute("in", "0");
+ playentry.setAttribute("out", "15000");
+ playlistmain.appendChild(playentry);
doc.appendChild(tractor);
+ doc.appendChild(playlistmain);
}
m_scenelist = m_document.toString();
+ kDebug() << "scenelist" << m_scenelist;
if (m_fps == 30000.0 / 1001.0) m_timecode.setFormat(30, true);
else m_timecode.setFormat((int) m_fps);
}
delete m_clipManager;
}
+QDomElement KdenliveDoc::documentInfoXml() {
+ //QDomDocument doc;
+ QDomElement addedXml = m_document.createElement("kdenlive");
+ addedXml.setAttribute("version", "0.7");
+ addedXml.setAttribute("profile", profilePath());
+ kDebug() << m_document.toString();
+ return m_document.documentElement();
+}
+
+
ClipManager *KdenliveDoc::clipManager() {
return m_clipManager;
}
return m_profile.path;
}
+void KdenliveDoc::setProfilePath(QString path) {
+ KdenliveSettings::setCurrent_profile(path);
+ m_profile = ProfilesDialog::getVideoProfile(path);
+ m_fps = (double) m_profile.frame_rate_num / m_profile.frame_rate_den;
+ m_width = m_profile.width;
+ m_height = m_profile.height;
+ if (m_fps == 30000.0 / 1001.0) m_timecode.setFormat(30, true);
+ else m_timecode.setFormat((int) m_fps);
+}
+
void KdenliveDoc::setThumbsProgress(KUrl url, int progress) {
emit thumbsProgress(url, progress);
}
return m_url;
}
+void KdenliveDoc::setUrl(KUrl url) {
+ m_url = url;
+}
+
+void KdenliveDoc::setModified(bool mod) {
+ if (mod == m_modified) return;
+ m_modified = mod;
+ emit docModified(m_modified);
+}
+
QString KdenliveDoc::description() const {
if (m_url.isEmpty())
return i18n("Untitled") + " / " + m_profile.description;
}
void KdenliveDoc::addClip(const QDomElement &elem, const int clipId) {
- kDebug() << "///////// DOCUM, CREATING NEW CLIP, ID:" << clipId;
DocClipBase *clip = new DocClipBase(m_clipManager, elem, clipId);
+ kDebug() << "///////// DOCUM, CREATING NEW CLIP, ID:" << clipId << ", PAR ID:" << elem.attribute("groupid");
m_clipManager->addClip(clip);
emit addProjectClip(clip);
}
-void KdenliveDoc::deleteProjectClip(const uint clipId) {
- emit deletTimelineClip(clipId);
- m_clipManager->slotDeleteClip(clipId);
+void KdenliveDoc::addFolder(const QString foldername, int clipId, bool edit) {
+ emit addProjectFolder(foldername, clipId, false, edit);
+}
+
+void KdenliveDoc::deleteFolder(const QString foldername, int clipId) {
+ emit addProjectFolder(foldername, clipId, true);
+}
+
+void KdenliveDoc::deleteProjectClip(QList <int> ids) {
+ for (int i = 0; i < ids.size(); ++i) {
+ emit deletTimelineClip(ids.at(i));
+ m_clipManager->slotDeleteClip(ids.at(i));
+ }
+ setModified(true);
+}
+
+void KdenliveDoc::deleteProjectFolder(QMap <QString, int> map) {
+ QMapIterator<QString, int> i(map);
+ while (i.hasNext()) {
+ i.next();
+ slotDeleteFolder(i.key(), i.value());
+ }
+ setModified(true);
}
void KdenliveDoc::deleteClip(const uint clipId) {
m_clipManager->deleteClip(clipId);
}
-void KdenliveDoc::slotAddClipFile(const KUrl url, const QString group) {
+void KdenliveDoc::slotAddClipFile(const KUrl url, const QString group, const int groupId) {
kDebug() << "///////// DOCUM, ADD CLP: " << url;
- m_clipManager->slotAddClipFile(url, group);
+ m_clipManager->slotAddClipFile(url, group, groupId);
+ setModified(true);
+}
+
+void KdenliveDoc::slotAddFolder(const QString folderName) {
+ AddFolderCommand *command = new AddFolderCommand(this, folderName, m_clipManager->getFreeClipId(), true);
+ commandStack()->push(command);
+ setModified(true);
+}
+
+void KdenliveDoc::slotDeleteFolder(const QString folderName, const int id) {
+ AddFolderCommand *command = new AddFolderCommand(this, folderName, id, false);
+ commandStack()->push(command);
+ setModified(true);
+}
+
+void KdenliveDoc::slotEditFolder(const QString newfolderName, const QString oldfolderName, int clipId) {
+ EditFolderCommand *command = new EditFolderCommand(this, newfolderName, oldfolderName, clipId, false);
+ commandStack()->push(command);
+ setModified(true);
+}
+
+int KdenliveDoc::getFreeClipId() {
+ return m_clipManager->getFreeClipId();
}
DocClipBase *KdenliveDoc::getBaseClip(int clipId) {
return m_clipManager->getClipById(clipId);
}
-void KdenliveDoc::slotAddColorClipFile(const QString name, const QString color, QString duration, const QString group) {
- m_clipManager->slotAddColorClipFile(name, color, duration, group);
+void KdenliveDoc::slotAddColorClipFile(const QString name, const QString color, QString duration, const QString group, const int groupId) {
+ m_clipManager->slotAddColorClipFile(name, color, duration, group, groupId);
+ setModified(true);
}
#include "kdenlivedoc.moc"