]> git.sesse.net Git - kdenlive/blobdiff - src/kdenlivedoc.cpp
folders in project view
[kdenlive] / src / kdenlivedoc.cpp
index e01e86f18cabf0d2e1b3721439001c18a97e9630..06f6ff229424f0861af1332e3051ff0087c73710 100644 (file)
 #include "docclipbase.h"
 #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);
@@ -67,6 +71,7 @@ KdenliveDoc::KdenliveDoc(const KUrl &url, MltVideoProfile profile, QUndoGroup *u
 
 
         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");
@@ -104,11 +109,19 @@ KdenliveDoc::KdenliveDoc(const KUrl &url, MltVideoProfile profile, QUndoGroup *u
             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);
 }
@@ -119,11 +132,12 @@ KdenliveDoc::~KdenliveDoc() {
 }
 
 QDomElement KdenliveDoc::documentInfoXml() {
-    QDomDocument doc;
-    QDomElement addedXml = doc.createElement("kdenlive");
+    //QDomDocument doc;
+    QDomElement addedXml = m_document.createElement("kdenlive");
     addedXml.setAttribute("version", "0.7");
     addedXml.setAttribute("profile", profilePath());
-    return addedXml;
+    kDebug() << m_document.toString();
+    return m_document.documentElement();
 }
 
 
@@ -259,7 +273,12 @@ KUrl KdenliveDoc::url() const {
 
 void KdenliveDoc::setUrl(KUrl url) {
     m_url = url;
-    m_modified = false;
+}
+
+void KdenliveDoc::setModified(bool mod) {
+    if (mod == m_modified) return;
+    m_modified = mod;
+    emit docModified(m_modified);
 }
 
 QString KdenliveDoc::description() const {
@@ -270,15 +289,35 @@ QString KdenliveDoc::description() const {
 }
 
 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) {
@@ -286,17 +325,41 @@ 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"