]> git.sesse.net Git - kdenlive/commitdiff
Try to fix rebuild of group during resize not cared of in undo history (does not...
authorTill Theato <root@ttill.de>
Sat, 17 Jul 2010 20:24:31 +0000 (20:24 +0000)
committerTill Theato <root@ttill.de>
Sat, 17 Jul 2010 20:24:31 +0000 (20:24 +0000)
svn path=/trunk/kdenlive/; revision=4590

src/CMakeLists.txt
src/configtrackscommand.cpp
src/configtrackscommand.h
src/customtrackview.cpp
src/customtrackview.h
src/rebuildgroupcommand.cpp [new file with mode: 0644]
src/rebuildgroupcommand.h [new file with mode: 0644]

index 5ecaabfa9396524593ec490ee72a9b99197de690..7319b63c509e979f912fe586ca6b3400e0831329 100644 (file)
@@ -195,6 +195,7 @@ set(kdenlive_SRCS
   vectorscope.cpp
   colorplaneexport.cpp
   colortools.cpp
+  rebuildgroupcommand.cpp
 )
 
 add_definitions( ${KDE4_DEFINITIONS} )
index 4904f619d3031fc68c7a7b2c55f8a48d582b24ac..f034eddedc5a8edca8c457487a9df6defd92b15d 100644 (file)
@@ -21,7 +21,6 @@
 #include "configtrackscommand.h"
 #include "customtrackview.h"
 
-#include <KLocale>
 
 ConfigTracksCommand::ConfigTracksCommand(CustomTrackView* view, QList< TrackInfo > oldInfos, QList< TrackInfo > newInfos, QUndoCommand* parent) :
         QUndoCommand(parent),
index 27f88b7e919ea36f91934e6f3a7cd08baf025c4c..9c13c3e012875ee66addb8c09ee3a729bc1bcbb2 100644 (file)
@@ -24,7 +24,6 @@
 #include <QGraphicsView>
 #include <QPointF>
 
-#include <KDebug>
 #include "definitions.h"
 
 class CustomTrackView;
index d58c1612f1182f0d9e3fbcc6fcbd32ca6eafdb87..c86ff067d288ce729f3024c82512640b7a1897a7 100644 (file)
@@ -58,6 +58,7 @@
 #include "trackdialog.h"
 #include "tracksconfigdialog.h"
 #include "configtrackscommand.h"
+#include "rebuildgroupcommand.h"
 
 #include <KDebug>
 #include <KLocale>
@@ -1009,8 +1010,18 @@ void CustomTrackView::mousePressEvent(QMouseEvent * event)
     QGraphicsView::mousePressEvent(event);
 }
 
-void CustomTrackView::rebuildGroup(AbstractGroupItem* group)
+void CustomTrackView::rebuildGroup(int childTrack, GenTime childPos)
 {
+    const QPointF p((int)childPos.frames(m_document->fps()), childTrack * m_tracksHeight + m_tracksHeight / 2);
+    QList<QGraphicsItem *> list = scene()->items(p);
+    AbstractGroupItem *group = NULL;
+    for (int i = 0; i < list.size(); i++) {
+        if (!list.at(i)->isEnabled()) continue;
+        if (list.at(i)->type() == GROUPWIDGET) {
+            group = static_cast <AbstractGroupItem *>(list.at(i));
+            break;
+        }
+    }
     if (group) {
         QList <QGraphicsItem *> children = group->childItems();
         m_document->clipManager()->removeGroup(group);
@@ -4121,7 +4132,7 @@ void CustomTrackView::prepareResizeClipStart(AbstractClipItem* item, ItemInfo ol
 
     }
     if (item->parentItem() && item->parentItem() != m_selectionGroup)
-        rebuildGroup(static_cast <AbstractGroupItem *>(item->parentItem()));
+        new RebuildGroupCommand(this, item->info().track, item->info().startPos, command);
 }
 
 void CustomTrackView::prepareResizeClipEnd(AbstractClipItem* item, ItemInfo oldInfo, int pos, bool check, QUndoCommand *command)
@@ -4233,7 +4244,7 @@ void CustomTrackView::prepareResizeClipEnd(AbstractClipItem* item, ItemInfo oldI
         }
     }
     if (item->parentItem() && item->parentItem() != m_selectionGroup)
-        rebuildGroup(static_cast <AbstractGroupItem *>(item->parentItem()));
+        new RebuildGroupCommand(this, item->info().track, item->info().startPos, command);
 }
 
 void CustomTrackView::updatePositionEffects(ClipItem * item, ItemInfo info)
index 50ad4932e73bfc160228a80092fc79e075278384..3220a1132b6dc0d1b783a2a7da72e85ff1f4869c 100644 (file)
@@ -219,6 +219,11 @@ public slots:
     void slotSelectTrack(int ix);
     void insertZoneOverwrite(QStringList data, int in);
 
+    /** @brief Rebuilds a group to fit changes to it's childen.
+    * @param childTrack the track of one of the groups children
+    * @param childPos The position of the same child */
+    void rebuildGroup(int childTrack, GenTime childPos);
+
 protected:
     virtual void drawBackground(QPainter * painter, const QRectF & rect);
     //virtual void drawForeground ( QPainter * painter, const QRectF & rect );
@@ -307,8 +312,6 @@ private:
     bool canBeMoved(QList<AbstractClipItem *> items, GenTime offset, int trackOffset) const;
     ClipItem *getClipUnderCursor() const;
     AbstractClipItem *getMainActiveClip() const;
-    /** @brief Rebuilds @param group to fit changes to it's childen. */
-    void rebuildGroup(AbstractGroupItem *group);
     void resetSelectionGroup(bool selectItems = true);
     void groupSelectedItems(bool force = false, bool createNewGroup = false);
     /** Get available space for clip move (min and max free positions) */
diff --git a/src/rebuildgroupcommand.cpp b/src/rebuildgroupcommand.cpp
new file mode 100644 (file)
index 0000000..69a276c
--- /dev/null
@@ -0,0 +1,43 @@
+/***************************************************************************
+ *   Copyright (C) 2010 by Till Theato (root@ttill.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.                                   *
+ *                                                                         *
+ *   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 "rebuildgroupcommand.h"
+#include "customtrackview.h"
+
+RebuildGroupCommand::RebuildGroupCommand(CustomTrackView* view, int childTrack, GenTime childPos, QUndoCommand* parent) :
+        QUndoCommand(parent),
+        m_view(view),
+        m_childTrack(childTrack),
+        m_childPos(childPos)
+{
+    setText(i18n("Rebuild Group"));
+}
+
+// virtual
+void RebuildGroupCommand::undo()
+{
+    m_view->rebuildGroup(m_childTrack, m_childPos);
+}
+
+// virtual
+void RebuildGroupCommand::redo()
+{
+    m_view->rebuildGroup(m_childTrack, m_childPos);
+}
diff --git a/src/rebuildgroupcommand.h b/src/rebuildgroupcommand.h
new file mode 100644 (file)
index 0000000..bc3354f
--- /dev/null
@@ -0,0 +1,42 @@
+/***************************************************************************
+ *   Copyright (C) 2010 by Till Theato (root@ttill.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.                                   *
+ *                                                                         *
+ *   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 REBUILDGROUPCOMMAND_H
+#define REBUILDGROUPCOMMAND_H
+
+#include <QUndoCommand>
+
+#include "abstractgroupitem.h"
+
+class CustomTrackView;
+
+class RebuildGroupCommand : public QUndoCommand
+{
+public:
+    RebuildGroupCommand(CustomTrackView *view, int childTrack, GenTime childPos, QUndoCommand* parent = 0);
+    virtual void undo();
+    virtual void redo();
+
+private:
+    CustomTrackView *m_view;
+    int m_childTrack;
+    GenTime m_childPos;
+};
+
+#endif