From: Jean-Baptiste Mardelle Date: Mon, 1 Apr 2013 12:54:48 +0000 (+0200) Subject: Spacer tool should never allow to move clips before another clip, fixes timeline... X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=0d59a0487e34d72a58cde6f58b7499d8f6ef404b;p=kdenlive Spacer tool should never allow to move clips before another clip, fixes timeline corruption --- diff --git a/src/abstractgroupitem.cpp b/src/abstractgroupitem.cpp index ff66ac00..83f5e59f 100644 --- a/src/abstractgroupitem.cpp +++ b/src/abstractgroupitem.cpp @@ -92,6 +92,11 @@ CustomTrackScene* AbstractGroupItem::projectScene() return NULL; } +QPainterPath AbstractGroupItem::clipGroupSpacerShape(QPointF offset) const +{ + return spacerGroupShape(AVWIDGET, offset); +} + QPainterPath AbstractGroupItem::clipGroupShape(QPointF offset) const { return groupShape(AVWIDGET, offset); @@ -125,6 +130,31 @@ QPainterPath AbstractGroupItem::groupShape(GRAPHICSRECTITEM type, QPointF offset return path; } +QPainterPath AbstractGroupItem::spacerGroupShape(GRAPHICSRECTITEM type, QPointF offset) const +{ + QPainterPath path; + QList children = childItems(); + for (int i = 0; i < children.count(); i++) { + if (children.at(i)->type() == (int)type) { + QRectF r(children.at(i)->sceneBoundingRect()); + r.translate(offset); + r.setRight(scene()->width()); + path.addRect(r); + } else if (children.at(i)->type() == GROUPWIDGET) { + QList subchildren = children.at(i)->childItems(); + for (int j = 0; j < subchildren.count(); j++) { + if (subchildren.at(j)->type() == (int)type) { + QRectF r(subchildren.at(j)->sceneBoundingRect()); + r.translate(offset); + r.setRight(scene()->width()); + path.addRect(r); + } + } + } + } + return path; +} + void AbstractGroupItem::addItem(QGraphicsItem * item) { addToGroup(item); diff --git a/src/abstractgroupitem.h b/src/abstractgroupitem.h index c68d2237..0f16f32e 100644 --- a/src/abstractgroupitem.h +++ b/src/abstractgroupitem.h @@ -41,6 +41,7 @@ public: void removeItem(QGraphicsItem * item); int track() const; QPainterPath clipGroupShape(QPointF offset) const; + QPainterPath clipGroupSpacerShape(QPointF offset) const; QPainterPath transitionGroupShape(QPointF offset) const; void setItemLocked(bool locked); bool isItemLocked() const; @@ -71,6 +72,7 @@ protected: private: void fixItemRect(); QPainterPath groupShape(GRAPHICSRECTITEM type, QPointF offset) const; + QPainterPath spacerGroupShape(GRAPHICSRECTITEM type, QPointF offset) const; /** Stores the original info of the items beeing resized. */ QList m_resizeInfos; }; diff --git a/src/customtrackview.cpp b/src/customtrackview.cpp index b178039a..bd5d4d72 100644 --- a/src/customtrackview.cpp +++ b/src/customtrackview.cpp @@ -511,7 +511,7 @@ void CustomTrackView::mouseMoveEvent(QMouseEvent * event) // Make sure there is no collision QList children = m_selectionGroup->childItems(); - QPainterPath shape = m_selectionGroup->clipGroupShape(QPointF(snappedPos - m_selectionGroup->sceneBoundingRect().left(), 0)); + QPainterPath shape = m_selectionGroup->clipGroupSpacerShape(QPointF(snappedPos - m_selectionGroup->sceneBoundingRect().left(), 0)); QList collidingItems = scene()->items(shape, Qt::IntersectsItemShape); collidingItems.removeAll(m_selectionGroup); for (int i = 0; i < children.count(); i++) { @@ -537,7 +537,7 @@ void CustomTrackView::mouseMoveEvent(QMouseEvent * event) } snappedPos += offset; // make sure we have no collision - shape = m_selectionGroup->clipGroupShape(QPointF(snappedPos - m_selectionGroup->sceneBoundingRect().left(), 0)); + shape = m_selectionGroup->clipGroupSpacerShape(QPointF(snappedPos - m_selectionGroup->sceneBoundingRect().left(), 0)); collidingItems = scene()->items(shape, Qt::IntersectsItemShape); collidingItems.removeAll(m_selectionGroup); for (int i = 0; i < children.count(); i++) { diff --git a/src/documentchecker.cpp b/src/documentchecker.cpp index ca612bc1..41067fd5 100644 --- a/src/documentchecker.cpp +++ b/src/documentchecker.cpp @@ -465,7 +465,8 @@ void DocumentChecker::slotSearchClips() if (newpath.isEmpty()) return; int ix = 0; bool fixed = false; - m_ui.recursiveSearch->setEnabled(false); + m_ui.recursiveSearch->setChecked(true); + qApp->processEvents(); QTreeWidgetItem *child = m_ui.treeWidget->topLevelItem(ix); QDir searchDir(newpath); while (child) { @@ -514,6 +515,7 @@ void DocumentChecker::slotSearchClips() ix++; child = m_ui.treeWidget->topLevelItem(ix); } + m_ui.recursiveSearch->setChecked(false); m_ui.recursiveSearch->setEnabled(true); if (fixed) { // original doc was modified