]> git.sesse.net Git - kdenlive/commitdiff
Edit effect parameter can be undone / redone
authorJean-Baptiste Mardelle <jb@kdenlive.org>
Wed, 27 Feb 2008 22:50:27 +0000 (22:50 +0000)
committerJean-Baptiste Mardelle <jb@kdenlive.org>
Wed, 27 Feb 2008 22:50:27 +0000 (22:50 +0000)
svn path=/branches/KDE4/; revision=1954

src/CMakeLists.txt
src/customtrackview.cpp
src/customtrackview.h
src/editeffectcommand.cpp [new file with mode: 0644]
src/editeffectcommand.h [new file with mode: 0644]
src/effectstackedit.cpp
src/effectstackedit.h
src/effectstackview.cpp
src/effectstackview.h
src/mainwindow.cpp

index d12fd8695ea4975156d26b5245d7cd671448830c..81b50c2560ba543a76c38dc5639c9207bb0bc438 100644 (file)
@@ -74,6 +74,7 @@ set(kdenlive_SRCS
   initeffects.cpp
   effectslistview.cpp
   addeffectcommand.cpp
+  editeffectcommand.cpp
   effectstackview.cpp
   effectstackedit.cpp
   parameterplotter.cpp
index 86cf16b610918b44c9b4709bd38905b0d20063a5..1c216d530000ced52539fe4e8ce9fe9d89efa811 100644 (file)
@@ -34,6 +34,7 @@
 #include "resizeclipcommand.h"
 #include "addtimelineclipcommand.h"
 #include "addeffectcommand.h"
+#include "editeffectcommand.h"
 
 CustomTrackView::CustomTrackView(KdenliveDoc *doc, QGraphicsScene * projectscene, QWidget *parent)
     : QGraphicsView(projectscene, parent), m_tracksCount(0), m_cursorPos(0), m_dropItem(NULL), m_cursorLine(NULL), m_operationMode(NONE), m_startPos(QPointF()), m_dragItem(NULL), m_visualTip(NULL), m_moveOpMode(NONE), m_animation(NULL), m_projectDuration(0), m_scale(1.0), m_clickPoint(0), m_document(doc)
@@ -388,11 +389,20 @@ void CustomTrackView::slotDeleteEffect(ClipItem *clip, QDomElement effect)
   m_commandStack->push(command);
 }
 
-
-void CustomTrackView::slotUpdateClipEffect(ClipItem *clip, QDomElement effect)
+void CustomTrackView::updateEffect(int track, GenTime pos, QDomElement effect)
 {
+  ClipItem *clip = getClipItemAt(pos.frames(m_document->fps()) + 1, m_tracksCount - track);
+  if (clip){
     QMap <QString, QString> effectParams = clip->getEffectArgs(effect);
     m_document->renderer()->mltEditEffect(m_tracksCount - clip->track(), GenTime(clip->startPos(), m_document->fps()), effectParams);
+  }
+}
+
+
+void CustomTrackView::slotUpdateClipEffect(ClipItem *clip, QDomElement oldeffect, QDomElement effect)
+{
+  EditEffectCommand *command = new EditEffectCommand(this, m_tracksCount - clip->track(), GenTime(clip->startPos(), m_document->fps()), oldeffect, effect, true);
+  m_commandStack->push(command);
 }
 
 
index 5cfd988b9753d3bcc22e0a02e2b5b82c8b87e693..be95cbb2cb616dee5ab982b5c30623b810bd70d6 100644 (file)
@@ -52,11 +52,12 @@ class CustomTrackView : public QGraphicsView
     void slotAddEffect(QDomElement effect);
     void addEffect(int track, GenTime pos, QDomElement effect);
     void deleteEffect(int track, GenTime pos, QDomElement effect);
+    void updateEffect(int track, GenTime pos, QDomElement effect);
 
   public slots:
     void setCursorPos(int pos, bool seek = true);
     void slotDeleteEffect(ClipItem *clip, QDomElement effect);
-    void slotUpdateClipEffect(ClipItem *clip, QDomElement effect);
+    void slotUpdateClipEffect(ClipItem *clip, QDomElement oldeffect, QDomElement effect);
     void slotRefreshEffects(ClipItem *clip);
     void setDuration(int duration);
 
diff --git a/src/editeffectcommand.cpp b/src/editeffectcommand.cpp
new file mode 100644 (file)
index 0000000..8e36523
--- /dev/null
@@ -0,0 +1,44 @@
+/***************************************************************************
+ *   Copyright (C) 2007 by Jean-Baptiste Mardelle (jb@kdenlive.org)        *
+ *                                                                         *
+ *   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.                                   *
+ *                                                                         *
+ *   This program is distributed in the hope that it will be useful,       *
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+ *   GNU General Public License for more details.                          *
+ *                                                                         *
+ *   You should have received a copy of the GNU General Public License     *
+ *   along with this program; if not, write to the                         *
+ *   Free Software Foundation, Inc.,                                       *
+ *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA          *
+ ***************************************************************************/
+
+#include <KLocale>
+
+#include "editeffectcommand.h"
+
+EditEffectCommand::EditEffectCommand(CustomTrackView *view, const int track, GenTime pos, QDomElement oldeffect, QDomElement effect, bool doIt)
+         : m_view(view), m_track(track), m_pos(pos), m_oldeffect(oldeffect), m_doIt(doIt) {
+           m_effect = effect.cloneNode().toElement();
+           setText(i18n("Edit effect"));
+        }
+
+
+// virtual 
+void EditEffectCommand::undo()
+{
+kDebug()<<"----  undoing action";
+  m_view->updateEffect(m_track, m_pos, m_oldeffect);
+}
+// virtual 
+void EditEffectCommand::redo()
+{
+kDebug()<<"----  redoing action";
+  m_view->updateEffect(m_track, m_pos, m_effect);
+}
+
+#include "editeffectcommand.moc"
diff --git a/src/editeffectcommand.h b/src/editeffectcommand.h
new file mode 100644 (file)
index 0000000..9f871e1
--- /dev/null
@@ -0,0 +1,47 @@
+/***************************************************************************
+ *   Copyright (C) 2007 by Jean-Baptiste Mardelle (jb@kdenlive.org)        *
+ *                                                                         *
+ *   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.                                   *
+ *                                                                         *
+ *   This program is distributed in the hope that it will be useful,       *
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+ *   GNU General Public License for more details.                          *
+ *                                                                         *
+ *   You should have received a copy of the GNU General Public License     *
+ *   along with this program; if not, write to the                         *
+ *   Free Software Foundation, Inc.,                                       *
+ *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA          *
+ ***************************************************************************/
+
+
+#ifndef EDITEFFECTCOMMAND_H
+#define EDITEFFECTCOMMAND_H
+
+#include <QUndoCommand>
+#include <KDebug>
+
+#include "customtrackview.h"
+
+class EditEffectCommand : public QUndoCommand
+ {
+ public:
+     EditEffectCommand(CustomTrackView *view, const int track, GenTime pos, QDomElement oldeffect, QDomElement effect, bool doIt);
+
+    virtual void undo();
+    virtual void redo();
+
+ private:
+     CustomTrackView *m_view;
+     int m_track;
+     QDomElement m_effect;
+     QDomElement m_oldeffect;
+     GenTime m_pos;
+     bool m_doIt;
+ };
+
+#endif
+
index 5fd69f75fef0630c059632eb1d1006147aacf7b6..36973d06928caacfe5a629fc8c23eea19ca7650a 100644 (file)
@@ -151,7 +151,7 @@ void EffectStackEdit::transferParamDesc(const QDomElement& d,int ,int){
        }
 }
 void EffectStackEdit::collectAllParameters(){
-       
+       QDomElement oldparam = params.cloneNode().toElement();
        QDomNodeList namenode = params.elementsByTagName("parameter");
 
        for (int i=0;i< namenode.count() ;i++){
@@ -183,7 +183,7 @@ void EffectStackEdit::collectAllParameters(){
                        pa.attributes().namedItem("value").setNodeValue(setValue);
                }
        }
-       emit parameterChanged(params);
+       emit parameterChanged(oldparam, params);
 }
 
 void EffectStackEdit::createSliderItem(const QString& name, int val ,int min, int max){
index 859947d4523baf546c7bb89c7dda39bc1c5423ff..a96770ebd8910129fd9d9b63baf4c1a75b6b44bb 100644 (file)
@@ -44,7 +44,7 @@ public slots:
        void slotSliderMoved(int);
        void collectAllParameters();
 signals:
-       void parameterChanged(const QDomElement& );
+       void parameterChanged(const QDomElement&, const QDomElement& );
 };
        
 #endif
index 2419c571f3dbdf604c5ca13d6bfbc750a0c8eb34..be3c2235d1e994dfb927a97ccde039b8e87780cb 100644 (file)
@@ -52,7 +52,7 @@ EffectStackView::EffectStackView(EffectsList *audioEffectList, EffectsList *vide
        connect (ui.buttonDown, SIGNAL (clicked()), this, SLOT (slotItemDown()) );
        connect (ui.buttonDel, SIGNAL (clicked()), this, SLOT (slotItemDel()) );
        connect( this, SIGNAL (transferParamDesc(const QDomElement&,int ,int) ), effectedit , SLOT(transferParamDesc(const QDomElement&,int ,int)));
-       connect(effectedit, SIGNAL (parameterChanged(const QDomElement&  ) ), this , SLOT (slotUpdateEffectParams(const QDomElement&)));
+       connect(effectedit, SIGNAL (parameterChanged( const QDomElement&, const QDomElement& ) ), this , SLOT (slotUpdateEffectParams( const QDomElement&, const QDomElement& )));
        effectLists["audio"]=audioEffectList;
        effectLists["video"]=videoEffectList;
        effectLists["custom"]=customEffectList;
@@ -63,9 +63,9 @@ EffectStackView::EffectStackView(EffectsList *audioEffectList, EffectsList *vide
        
 }
 
-void EffectStackView::slotUpdateEffectParams(const QDomElement& e){
+void EffectStackView::slotUpdateEffectParams(const QDomElement& old, const QDomElement& e){
        if (clipref)
-               emit updateClipEffect(clipref, e);
+               emit updateClipEffect(clipref, old, e);
 }
 
 void EffectStackView::slotClipItemSelected(ClipItem* c)
index 94429d8b41b932ba3dfa440a46edebfb4a073390..6cb29ba415587197d798de72c97806b7990b4489 100644 (file)
@@ -47,13 +47,13 @@ public slots:
        void slotItemDel();
        void slotNewEffect();
        void itemSelectionChanged();
-       void slotUpdateEffectParams(const QDomElement&);
+       void slotUpdateEffectParams(const QDomElement&, const QDomElement&);
 
 signals:
        void transferParamDesc(const QDomElement&,int ,int);
        void removeEffect(ClipItem*, QDomElement);
        /**  Parameters for an effect changed, update the filter in playlist */
-       void updateClipEffect(ClipItem*, QDomElement);
+       void updateClipEffect(ClipItem*, QDomElement, QDomElement);
        /** An effect in stack was moved, we need to regenerate 
            all effects for this clip in the playlist */
        void refreshEffectStack(ClipItem *);
index 167e6e29702079c10ac0c76f5f6e0c11031e11bf..1455498e9728081856ed676c00b4d44476cccc24 100644 (file)
@@ -464,7 +464,7 @@ void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc) //chang
   connect(doc, SIGNAL(updateClipDisplay(int)), m_projectList, SLOT(slotUpdateClip(int)));
   connect(doc, SIGNAL(deletTimelineClip(int)), trackView, SLOT(slotDeleteClip(int)));
   connect(trackView, SIGNAL(clipItemSelected(ClipItem*)), effectStack, SLOT(slotClipItemSelected(ClipItem*)));
-  connect(effectStack, SIGNAL(updateClipEffect(ClipItem*, QDomElement)), trackView->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, QDomElement)));
+  connect(effectStack, SIGNAL(updateClipEffect(ClipItem*, QDomElement, QDomElement)), trackView->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, QDomElement, QDomElement)));
   connect(effectStack, SIGNAL(removeEffect(ClipItem*, QDomElement)), trackView->projectView(), SLOT(slotDeleteEffect(ClipItem*, QDomElement)));
   connect(effectStack, SIGNAL(refreshEffectStack(ClipItem*)), trackView->projectView(), SLOT(slotRefreshEffects(ClipItem*)));