Commit e7f8a666 authored by Ludovic Fauvet's avatar Ludovic Fauvet

Helper to extract all AbstractGraphicsMediaItem at a given point

parent 56b1d12b
......@@ -304,10 +304,9 @@ void TracksView::mouseMoveEvent( QMouseEvent* event )
void TracksView::mousePressEvent( QMouseEvent* event )
{
QList<AbstractGraphicsMediaItem*> mediaCollisionList = mediaItems( event->pos() );
QList<QGraphicsItem*> collisionList = items( event->pos() );
if ( event->modifiers() == Qt::ControlModifier && collisionList.count() == 0 )
if ( event->modifiers() == Qt::ControlModifier && mediaCollisionList.count() == 0 )
{
setDragMode( QGraphicsView::ScrollHandDrag );
QGraphicsView::mousePressEvent( event );
......@@ -351,6 +350,20 @@ void TracksView::wheelEvent( QWheelEvent* event )
}
}
QList<AbstractGraphicsMediaItem*> TracksView::mediaItems( const QPoint& pos )
{
QList<QGraphicsItem*> collisionList = items( pos );
QList<AbstractGraphicsMediaItem*> mediaCollisionList;
for ( int i = 0; i < collisionList.size(); ++i )
{
AbstractGraphicsMediaItem* item =
dynamic_cast<AbstractGraphicsMediaItem*>( collisionList.at( i ) );
if ( item )
mediaCollisionList.append( item );
}
return mediaCollisionList;
}
void TracksView::setCursorPos( int pos )
{
if ( pos < 0 ) pos = 0;
......@@ -393,6 +406,7 @@ void TracksView::ensureCursorVisible()
void TracksView::updateDuration()
{
//TODO this should use a variant of mediaItems( const QPoint& )
QList<QGraphicsItem*> sceneItems = m_scene->items();
int projectDuration = 0;
......
......@@ -82,6 +82,7 @@ public:
int cursorPos();
GraphicsCursorItem* tracksCursor() const { return m_cursorLine; }
void setScale( double scaleFactor );
QList<AbstractGraphicsMediaItem*> mediaItems( const QPoint& pos );
protected:
virtual void resizeEvent( QResizeEvent* event );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment