Commit 3659c7f1 authored by Ludovic Fauvet's avatar Ludovic Fauvet

Base class for movies items can return their current track number

parent ca06ebce
......@@ -41,3 +41,14 @@ void AbstractGraphicsMediaItem::mouseReleaseEvent( QGraphicsSceneMouseEvent* )
{
setCursor( Qt::OpenHandCursor );
}
int AbstractGraphicsMediaItem::trackNumber()
{
if ( parentItem() )
{
GraphicsTrack* graphicsTrack = dynamic_cast<GraphicsTrack*>( parentItem() );
if ( graphicsTrack )
return graphicsTrack->trackNumber();
}
return -1;
}
......@@ -47,6 +47,8 @@ public:
/// Should return the unique uid of the contained media.
virtual const QUuid& uuid() const = 0;
int trackNumber();
protected:
/**
* Returns the current tracksView for the item,
......
......@@ -45,7 +45,7 @@ TracksView::TracksView( QGraphicsScene* scene, MainWorkflow* mainWorkflow, QWidg
m_numAudioTrack = 0;
m_numVideoTrack = 0;
m_videoTracksCounter = MAX_TRACKS;
m_videoTracksCounter = MAX_TRACKS - 1;
m_dragItem = NULL;
m_actionMove = false;
m_actionRelativeX = -1;
......@@ -245,14 +245,11 @@ void TracksView::dropEvent( QDropEvent* event )
addVideoTrack();
event->acceptProposedAction();
int track = (unsigned int)( mapToScene( event->pos() ).y() / m_tracksHeight );
if ( track > m_numVideoTrack - 1)
track = m_numVideoTrack - 1;
qreal mappedXPos = ( mapToScene( event->pos() ).x() + 0.5 );
//FIXME this leaks, but it will be corrected once we really use Clip instead
// of Media
m_mainWorkflow->addClip( m_dragItem->clip(),
m_videoTracksCounter + track,
m_dragItem->trackNumber(),
(qint64)mappedXPos );
m_dragItem = NULL; // Temporary action
}
......@@ -364,12 +361,8 @@ void TracksView::mouseReleaseEvent( QMouseEvent* event )
updateDuration();
if ( m_layout->itemAt( 0 )->graphicsItem()->childItems().count() > 0 )
addVideoTrack();
int track = (unsigned int)( mapToScene( movieItem->pos().toPoint() ).y() / m_tracksHeight );
if ( track > m_numVideoTrack - 1)
track = m_numVideoTrack - 1;
emit clipMoved( movieItem->clip()->getUuid(),
m_videoTracksCounter + track,
movieItem->trackNumber(),
(qint64)movieItem->pos().x() );
m_actionMove = false;
m_actionRelativeX = -1;
......
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