From e59f00af34822b466f3788ddd1a5183ed3839453 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Mardelle Date: Sat, 1 Sep 2012 22:50:19 +0200 Subject: [PATCH] Workaround dragging timeline clips on another track not reliable: http://kdenlive.org/mantis/view.php?id=2670 --- src/clipitem.cpp | 4 +++- src/customtrackview.cpp | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/clipitem.cpp b/src/clipitem.cpp index e00b59b4..ba8cb455 100644 --- a/src/clipitem.cpp +++ b/src/clipitem.cpp @@ -1301,7 +1301,9 @@ QVariant ClipItem::itemChange(GraphicsItemChange change, const QVariant &value) int xpos = projectScene()->getSnapPointForPos((int) newPos.x(), KdenliveSettings::snaptopoints()); xpos = qMax(xpos, 0); newPos.setX(xpos); - int newTrack = newPos.y() / KdenliveSettings::trackheight(); + // Warning: newPos gives a position relative to the click event, so hack to get absolute pos + int yOffset = property("y_absolute").toInt() + newPos.y(); + int newTrack = yOffset / KdenliveSettings::trackheight(); newTrack = qMin(newTrack, projectScene()->tracksCount() - 1); newTrack = qMax(newTrack, 0); newPos.setY((int)(newTrack * KdenliveSettings::trackheight() + 1)); diff --git a/src/customtrackview.cpp b/src/customtrackview.cpp index b23108f6..5fb7afc3 100644 --- a/src/customtrackview.cpp +++ b/src/customtrackview.cpp @@ -422,6 +422,7 @@ void CustomTrackView::mouseMoveEvent(QMouseEvent * event) bool move = (event->pos() - m_clickEvent).manhattanLength() >= QApplication::startDragDistance(); if (m_dragItem && m_tool == SELECTTOOL) { if (m_operationMode == MOVE && move) { + //m_dragItem->setProperty("y_absolute", event->pos().y()); QGraphicsView::mouseMoveEvent(event); // If mouse is at a border of the view, scroll if (pos < 5) { @@ -799,6 +800,7 @@ void CustomTrackView::mousePressEvent(QMouseEvent * event) else m_dragItem = collisionClip; found = true; + m_dragItem->setProperty("y_absolute", m_clickEvent.y() - m_dragItem->scenePos().y()); m_dragItemInfo = m_dragItem->info(); if (m_dragItem->parentItem() && m_dragItem->parentItem()->type() == GROUPWIDGET && m_dragItem->parentItem() != m_selectionGroup) { // kDebug()<<"// KLIK FOUND GRP: "<sceneBoundingRect(); -- 2.39.2