]> git.sesse.net Git - kdenlive/commitdiff
Fix moving of grouped clips in tracks:http://kdenlive.org/mantis/view.php?id=2670
authorJean-Baptiste Mardelle <jb@kdenlive.org>
Fri, 26 Oct 2012 10:27:05 +0000 (12:27 +0200)
committerJean-Baptiste Mardelle <jb@kdenlive.org>
Fri, 26 Oct 2012 10:27:05 +0000 (12:27 +0200)
src/abstractclipitem.h
src/abstractgroupitem.cpp
src/customtrackview.cpp

index 8703c919bcff6fbff4d96b2cdb265679963a49d0..1cdcf0cbbfb048a5028957b988615b91a1192648 100644 (file)
@@ -94,7 +94,6 @@ public:
 
 protected:
     ItemInfo m_info;
-//    int m_track;
     /** The position of the current keyframe when it has moved */
     int m_editedKeyframe;
     /** The position of the current keyframe before it was moved */
index 2db8874eadb9929a966d56d056a3534439e13a6c..f2a475f6b2bbc5ef02bac47889a9bad9b5a9515d 100644 (file)
@@ -32,6 +32,7 @@
 #include <QMimeData>
 #include <QGraphicsSceneMouseEvent>
 
+
 AbstractGroupItem::AbstractGroupItem(double /* fps */) :
         QObject(),
         QGraphicsItemGroup()
@@ -168,22 +169,18 @@ QVariant AbstractGroupItem::itemChange(GraphicsItemChange change, const QVariant
         //kDebug()<<"GRP XPOS:"<<xpos<<", START:"<<start.x()<<",NEW:"<<newPos.x()<<"; SCENE:"<<scenePos().x()<<",POS:"<<pos().x();
         newPos.setX((int)(pos().x() + xpos - (int) start.x()));
 
-        //int startTrack = (start.y() + trackHeight / 2) / trackHeight;
-
-        int realTrack = (start.y() + newPos.y() - pos().y()) / trackHeight;
-        int proposedTrack = newPos.y() / trackHeight;
-
-        int correctedTrack = qMin(realTrack, projectScene()->tracksCount() - (int)(boundingRect().height() + 5) / trackHeight);
-        correctedTrack = qMax(correctedTrack, 0);
-
-        proposedTrack += (correctedTrack - realTrack);
+       int yOffset = property("y_absolute").toInt() + newPos.y();
+        int proposedTrack = yOffset / trackHeight;
 
         // Check if top item is a clip or a transition
         int offset = 0;
         int topTrack = -1;
         QList<QGraphicsItem *> children = childItems();
         for (int i = 0; i < children.count(); i++) {
-            int currentTrack = (int)(children.at(i)->scenePos().y() / trackHeight);
+            int currentTrack = 0;
+           if (children.at(i)->type() == AVWIDGET || children.at(i)->type() == TRANSITIONWIDGET) currentTrack = static_cast <AbstractClipItem*> (children.at(i))->track();
+           else if (children.at(i)->type() == GROUPWIDGET) currentTrack = static_cast <AbstractGroupItem*> (children.at(i))->track();
+           else continue;
             if (children.at(i)->type() == AVWIDGET) {
                 if (topTrack == -1 || currentTrack <= topTrack) {
                     offset = 0;
index f4aa85ff4ca61a02c7ec70ed17ead5807e5afe4d..d78def43d8ab6502d3cc783a0fdc60e9691cc7de 100644 (file)
@@ -810,6 +810,7 @@ void CustomTrackView::mousePressEvent(QMouseEvent * event)
             found = true;
            m_dragItem->setProperty("y_absolute", mapToScene(m_clickEvent).y() - m_dragItem->scenePos().y());
             m_dragItemInfo = m_dragItem->info();
+           if (m_selectionGroup) m_selectionGroup->setProperty("y_absolute", mapToScene(m_clickEvent).y() - m_dragItem->scenePos().y());
             if (m_dragItem->parentItem() && m_dragItem->parentItem()->type() == GROUPWIDGET && m_dragItem->parentItem() != m_selectionGroup) {
                 // kDebug()<<"// KLIK FOUND GRP: "<<m_dragItem->sceneBoundingRect();
                 dragGroup = static_cast <AbstractGroupItem *>(m_dragItem->parentItem());