[vlmc-devel] TracksView: Simplify collision detection on resizing
Yikai Lu
git at videolan.org
Thu Jun 30 16:33:09 CEST 2016
vlmc | branch: master | Yikai Lu <luyikei.qmltu at gmail.com> | Thu Jun 30 17:19:01 2016 +0900| [e90fe020f9f4d7324a752667733a8cc74bd0b60c] | committer: Yikai Lu
TracksView: Simplify collision detection on resizing
> https://code.videolan.org/videolan/vlmc/commit/e90fe020f9f4d7324a752667733a8cc74bd0b60c
---
src/Gui/timeline/TracksView.cpp | 21 ++++++---------------
1 file changed, 6 insertions(+), 15 deletions(-)
diff --git a/src/Gui/timeline/TracksView.cpp b/src/Gui/timeline/TracksView.cpp
index 1a551e1..138de79 100644
--- a/src/Gui/timeline/TracksView.cpp
+++ b/src/Gui/timeline/TracksView.cpp
@@ -997,24 +997,16 @@ TracksView::mouseMoveEvent( QMouseEvent *event )
else
itemNewSize = itemPos + m_actionItem->width() - mapToScene( event->pos() ).x();
- qint32 trackId = m_actionItem->trackNumber();
- Q_ASSERT( trackId >= 0 );
-
- //FIXME: BEGIN UGLY
- GraphicsTrack *track = getTrack( m_actionItem->trackType(), trackId );
- Q_ASSERT( track );
-
- QPointF collidePos = track->sceneBoundingRect().topRight();
- collidePos.setX( itemPos + itemNewSize );
-
- QList<QGraphicsItem*> gi = scene()->items( collidePos );
-
bool collide = false;
if ( m_actionItem->type() != GraphicsEffectItem::Type )
{
- for ( int i = 0; i < gi.count(); ++i )
+ auto items = scene()->items(
+ m_actionItem->mapRectToScene( 0, 0, itemNewSize, m_actionItem->boundingRect().height() )
+ );
+
+ for ( auto item : items )
{
- AbstractGraphicsMediaItem* mi = dynamic_cast<AbstractGraphicsMediaItem*>( gi.at( i ) );
+ AbstractGraphicsMediaItem* mi = dynamic_cast<AbstractGraphicsMediaItem*>( item );
if ( mi && mi != m_actionItem )
{
collide = true;
@@ -1022,7 +1014,6 @@ TracksView::mouseMoveEvent( QMouseEvent *event )
}
}
}
- // END UGLY
if ( !collide )
{
GraphicsEffectItem *effectItem = qgraphicsitem_cast<GraphicsEffectItem*>( m_actionItem );
More information about the Vlmc-devel
mailing list