]> git.sesse.net Git - kdenlive/blobdiff - src/customtrackview.cpp
Prepare for clip extra data (reusable analysis data)
[kdenlive] / src / customtrackview.cpp
index 396625b5deb4101770251f36944502611001d9c1..5ab409b5d8a571f874db423849c42a9f71c591a7 100644 (file)
@@ -26,6 +26,7 @@
 #include "commands/movetransitioncommand.h"
 #include "commands/resizeclipcommand.h"
 #include "commands/editguidecommand.h"
+#include "commands/addextradatacommand.h"
 #include "commands/addtimelineclipcommand.h"
 #include "commands/addeffectcommand.h"
 #include "commands/editeffectcommand.h"
@@ -5251,6 +5252,16 @@ void CustomTrackView::clipEnd()
     }
 }
 
+void CustomTrackView::slotAddClipExtraData(const QString &id, const QString &key, const QString &data, QUndoCommand *groupCommand)
+{
+    DocClipBase *base = m_document->clipManager()->getClipById(id);
+    if (!base) return;
+    QMap <QString, QString> extraData = base->analysisData();
+    QString oldData = extraData.value(key);
+    AddExtraDataCommand *command = new AddExtraDataCommand(this, id, key, oldData, data, groupCommand);
+    if (!groupCommand) m_commandStack->push(command);
+}
+
 void CustomTrackView::slotAddClipMarker(const QString &id, CommentedTime newMarker, QUndoCommand *groupCommand)
 {
     CommentedTime oldMarker = m_document->clipManager()->getClipById(id)->markerAt(newMarker.time());
@@ -5414,6 +5425,7 @@ void CustomTrackView::slotLoadClipMarkers(const QString &id)
 void CustomTrackView::addMarker(const QString &id, const CommentedTime marker)
 {
     DocClipBase *base = m_document->clipManager()->getClipById(id);
+    if (base == NULL) return;
     if (marker.markerType() < 0) base->deleteSnapMarker(marker.time());
     else base->addSnapMarker(marker);
     emit updateClipMarkers(base);
@@ -5421,6 +5433,16 @@ void CustomTrackView::addMarker(const QString &id, const CommentedTime marker)
     viewport()->update();
 }
 
+void CustomTrackView::addData(const QString &id, const QString &key, const QString &data)
+{
+    DocClipBase *base = m_document->clipManager()->getClipById(id);
+    if (base == NULL) return;
+    base->setAnalysisData(key, data);
+    emit updateClipExtraData(base);
+    setDocumentModified();
+    viewport()->update();
+}
+
 int CustomTrackView::hasGuide(int pos, int offset)
 {
     for (int i = 0; i < m_guides.count(); i++) {