]> git.sesse.net Git - kdenlive/commitdiff
first small implement of transitionscommand
authorMarco Gittler <marco@gitma.de>
Tue, 18 Mar 2008 12:42:07 +0000 (12:42 +0000)
committerMarco Gittler <marco@gitma.de>
Tue, 18 Mar 2008 12:42:07 +0000 (12:42 +0000)
svn path=/branches/KDE4/; revision=2074

src/addtransitioncommand.cpp [new file with mode: 0644]
src/addtransitioncommand.h [new file with mode: 0644]
src/clipitem.cpp
src/customtrackview.cpp
src/customtrackview.h

diff --git a/src/addtransitioncommand.cpp b/src/addtransitioncommand.cpp
new file mode 100644 (file)
index 0000000..3363487
--- /dev/null
@@ -0,0 +1,39 @@
+/***************************************************************************
+                          addtransitioncommand.cpp  -  description
+                             -------------------
+    begin                : 2008
+    copyright            : (C) 2008 by Marco Gittler
+    email                : g.marco@freenet.de
+ ***************************************************************************/
+
+/***************************************************************************
+ *                                                                         *
+ *   This program is free software; you can redistribute it and/or modify  *
+ *   it under the terms of the GNU General Public License as published by  *
+ *   the Free Software Foundation; either version 2 of the License, or     *
+ *   (at your option) any later version.                                   *
+ *                                                                         *
+ ***************************************************************************/
+#include <KLocale>
+
+#include "addtransitioncommand.h"
+
+AddTransitionCommand::AddTransitionCommand(CustomTrackView *view, int track, QDomElement xml, GenTime pos, bool doIt) : m_view(view), m_track(track), m_xml(xml), m_pos(pos), m_doIt(doIt) {
+    if (m_doIt) setText(i18n("Add transition to clip"));
+    else setText(i18n("Delete transition from clip"));
+}
+
+
+// virtual
+void AddTransitionCommand::undo() {
+    if (!m_doIt) m_view->deleteTransition(m_track, m_pos, m_xml);
+    else m_view->addTransition(m_track , m_pos, m_xml);
+}
+// virtual
+void AddTransitionCommand::redo() {
+    if (m_doIt) m_view->addTransition(m_track , m_pos, m_xml);
+    else m_view->deleteTransition(m_track, m_pos, m_xml);
+    m_doIt = true;
+}
+
+#include "addtimelineclipcommand.moc"
diff --git a/src/addtransitioncommand.h b/src/addtransitioncommand.h
new file mode 100644 (file)
index 0000000..eb01870
--- /dev/null
@@ -0,0 +1,46 @@
+/***************************************************************************
+                          addtransitioncommand.h  -  description
+                             -------------------
+    begin                : 2008
+    copyright            : (C) 2008 by Marco Gittler
+    email                : g.marco@freenet.de
+ ***************************************************************************/
+
+/***************************************************************************
+ *                                                                         *
+ *   This program is free software; you can redistribute it and/or modify  *
+ *   it under the terms of the GNU General Public License as published by  *
+ *   the Free Software Foundation; either version 2 of the License, or     *
+ *   (at your option) any later version.                                   *
+ *                                                                         *
+ ***************************************************************************/
+
+#ifndef TIMELINETRANSITIONCOMMAND_H
+#define TIMELINETRANSITIONCOMMAND_H
+
+#include <QUndoCommand>
+#include <QGraphicsView>
+#include <QPointF>
+
+#include <KDebug>
+
+#include "gentime.h"
+#include "projectlist.h"
+#include "customtrackview.h"
+
+class AddTransitionCommand : public QUndoCommand {
+public:
+    AddTransitionCommand(CustomTrackView *view, int track, QDomElement xml , GenTime pos, bool doIt);
+    virtual void undo();
+    virtual void redo();
+
+private:
+    CustomTrackView *m_view;
+    GenTime m_pos;
+    QDomElement m_xml;
+    int m_track;
+    bool m_doIt;
+};
+
+#endif
+
index 75a18cb32cb3eef2cca415987f4c457763d1548b..82d29928c838b6deaadedd191d032d278625d547 100644 (file)
@@ -650,6 +650,10 @@ void ClipItem::dragLeaveEvent(QGraphicsSceneDragDropEvent *event) {
 }
 void ClipItem::addTransition(Transition* t) {
     m_transitionsList.append(t);
+    CustomTrackView *view = (CustomTrackView *) scene()->views()[0];
+    QDomDocument doc;
+    QDomElement e = doc.documentElement();
+    if (view) view->slotAddTransition(this, QDomElement() , t->startPos(), m_track);
 }
 // virtual
 /*
index cd4001360275a8ac76cf89ff68263051ea7982e7..f8d7d6e4e0f75918d7f818a3d019719cd2b0c852 100644 (file)
@@ -36,6 +36,7 @@
 #include "addtimelineclipcommand.h"
 #include "addeffectcommand.h"
 #include "editeffectcommand.h"
+#include "addtransitioncommand.h"
 #include "kdenlivesettings.h"
 #include "transition.h"
 
@@ -507,6 +508,25 @@ void CustomTrackView::slotUpdateClipEffect(ClipItem *clip, QDomElement oldeffect
     m_commandStack->push(command);
 }
 
+void CustomTrackView::slotAddTransition(ClipItem* clip , QDomElement transition, GenTime startTime , int startTrack) {
+    AddTransitionCommand* command = new AddTransitionCommand(this, startTrack, transition, startTime, true);
+    m_commandStack->push(command);
+}
+
+void CustomTrackView::addTransition(int startTrack, GenTime startPos , QDomElement) {
+    QMap < QString, QString> map;
+    map["combine"] = "1";
+    map["valign"] = "1";
+    map["progressive"] = "1";
+    map["fill"] = "1";
+    map["halign"] = "1";
+    m_document->renderer()->mltAddTransition("composite", startTrack, startTrack + 1 , startPos, startPos + GenTime(2.5), map);
+    m_document->setModified(true);
+}
+
+void CustomTrackView::deleteTransition(int, GenTime, QDomElement) {
+
+}
 
 void CustomTrackView::addItem(DocClipBase *clip, QPoint pos) {
     int in = 0;
index ca16c36d29d56bfb96452df36f49d904366a5ecd..fa77a67ceb5f7111d3b54d8695e5a9087ad0e9a8 100644 (file)
@@ -53,6 +53,8 @@ public:
     void addEffect(int track, GenTime pos, QDomElement effect);
     void deleteEffect(int track, GenTime pos, QDomElement effect);
     void updateEffect(int track, GenTime pos, QDomElement effect);
+    void addTransition(int track, GenTime pos, QDomElement transition);
+    void deleteTransition(int track, GenTime pos, QDomElement transition);
     void activateMonitor();
     int duration() const;
     void deleteSelectedClips();
@@ -66,6 +68,7 @@ public slots:
     void slotUpdateClipEffect(ClipItem *clip, QDomElement oldeffect, QDomElement effect);
     void slotRefreshEffects(ClipItem *clip);
     void setDuration(int duration);
+    void slotAddTransition(ClipItem* clip , QDomElement transition, GenTime startTime , int startTrack);
 
 protected:
     virtual void drawBackground(QPainter * painter, const QRectF & rect);
@@ -123,3 +126,4 @@ signals:
 };
 
 #endif
+