From d9535b846b2e247b8a02ea629b498ca15c3f72fa Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Mardelle Date: Sun, 1 Feb 2009 13:42:54 +0000 Subject: [PATCH] Fix spacer and group move sometimes moving clips to wrong place: http://www.kdenlive.org:80/mantis/view.php?id=604 svn path=/branches/KDE4/; revision=3024 --- src/abstractgroupitem.cpp | 2 +- src/customtrackview.cpp | 27 ++++++++++++++++++--------- 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/src/abstractgroupitem.cpp b/src/abstractgroupitem.cpp index b032526b..b4f8c1eb 100644 --- a/src/abstractgroupitem.cpp +++ b/src/abstractgroupitem.cpp @@ -176,6 +176,6 @@ QVariant AbstractGroupItem::itemChange(GraphicsItemChange change, const QVariant return newPos; } } - return QGraphicsItem::itemChange(change, value); + return QGraphicsItemGroup::itemChange(change, value); } diff --git a/src/customtrackview.cpp b/src/customtrackview.cpp index 13bc8bff..69d903dd 100644 --- a/src/customtrackview.cpp +++ b/src/customtrackview.cpp @@ -611,10 +611,8 @@ void CustomTrackView::mousePressEvent(QMouseEvent * event) { if (event->modifiers() == Qt::ControlModifier) { // Ctrl + click, select all items on track after click position int track = (int)(mapToScene(m_clickEvent).y() / m_tracksHeight); - selection = items(m_clickEvent.x(), track * m_tracksHeight + 1, mapFromScene(sceneRect().width(), 0).x() - m_clickEvent.x(), m_tracksHeight - 2); - // for (int count = 0; count < selection.size(); count++) { - // selection.at(count); - // } + selection = items(m_clickEvent.x(), track * m_tracksHeight + m_tracksHeight / 2, mapFromScene(sceneRect().width(), 0).x() - m_clickEvent.x(), m_tracksHeight / 2 - 2); + kDebug() << "SPACER TOOL + CTRL, SELECTING ALL CLIPS ON TRACK " << track << " WITH SELECTION RECT " << m_clickEvent.x() << "/" << track * m_tracksHeight + 1 << "; " << mapFromScene(sceneRect().width(), 0).x() - m_clickEvent.x() << "/" << m_tracksHeight - 2; } else { // Select all items on all tracks after click position @@ -778,11 +776,11 @@ void CustomTrackView::resetSelectionGroup(bool selectItems) { bool snap = KdenliveSettings::snaptopoints(); KdenliveSettings::setSnaptopoints(false); QList children = m_selectionGroup->childItems(); + scene()->destroyItemGroup(m_selectionGroup); for (int i = 0; i < children.count(); i++) { children.at(i)->setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable); children.at(i)->setSelected(selectItems); } - scene()->destroyItemGroup(m_selectionGroup); m_selectionGroup = NULL; KdenliveSettings::setSnaptopoints(snap); } @@ -794,8 +792,16 @@ void CustomTrackView::groupSelectedItems(bool force) { return; } QList selection = m_scene->selectedItems(); + QGraphicsItemGroup *group = m_scene->createItemGroup(selection); + scene()->addItem(group); + QPointF top = group->sceneBoundingRect().topLeft(); + m_scene->destroyItemGroup(group); if (force || selection.count() > 1) { + bool snap = KdenliveSettings::snaptopoints(); + KdenliveSettings::setSnaptopoints(false); m_selectionGroup = new AbstractGroupItem(m_document->fps()); + m_selectionGroup->translate(-top.x(), -top.y() + 1); + m_selectionGroup->setPos(top.x(), top.y() - 1); scene()->addItem(m_selectionGroup); for (int i = 0; i < selection.count(); i++) { if (selection.at(i)->type() == AVWIDGET || selection.at(i)->type() == TRANSITIONWIDGET) { @@ -803,16 +809,19 @@ void CustomTrackView::groupSelectedItems(bool force) { selection.at(i)->setFlags(QGraphicsItem::ItemIsSelectable); } } + KdenliveSettings::setSnaptopoints(snap); if (m_selectionGroup) { - bool snap = KdenliveSettings::snaptopoints(); + /*bool snap = KdenliveSettings::snaptopoints(); KdenliveSettings::setSnaptopoints(false); QPointF top = m_selectionGroup->sceneBoundingRect().topLeft(); - m_selectionGroup->translate(-top.x(), -top.y() + 1); - m_selectionGroup->setPos(top); + // kDebug()<<"SEL GRP TOP: "<translate(-top.x(), -top.y()); + m_selectionGroup->setPos(top);*/ m_selectionGroupInfo.startPos = GenTime(m_selectionGroup->scenePos().x(), m_document->fps()); m_selectionGroupInfo.track = m_selectionGroup->track(); - KdenliveSettings::setSnaptopoints(snap); + //KdenliveSettings::setSnaptopoints(snap); } } else resetSelectionGroup(); } -- 2.39.2