Commit ba069876 authored by Ludovic Fauvet's avatar Ludovic Fauvet

Items are moveable

parent 7e7080cb
......@@ -47,6 +47,9 @@ TracksView::TracksView( QGraphicsScene* scene, MainWorkflow* mainWorkflow, QWidg
m_numVideoTrack = 0;
m_videoTracksCounter = MAX_TRACKS;
m_dragItem = NULL;
m_actionMove = false;
m_actionRelativeX = -1;
m_actionItem = NULL;
setMouseTracking( true );
setAcceptDrops( true );
......@@ -300,6 +303,15 @@ void TracksView::drawBackground( QPainter* painter, const QRectF& rect )
void TracksView::mouseMoveEvent( QMouseEvent* event )
{
if ( event->modifiers() == Qt::NoModifier &&
event->buttons() == Qt::LeftButton &&
m_actionMove == true )
{
if ( m_actionRelativeX < 0 )
m_actionRelativeX = event->pos().x() - mapFromScene( m_actionItem->pos() ).x();
moveMediaItem( m_actionItem, QPoint( event->pos().x() - m_actionRelativeX, event->pos().y() ) );
}
QGraphicsView::mouseMoveEvent( event );
}
......@@ -314,6 +326,15 @@ void TracksView::mousePressEvent( QMouseEvent* event )
return;
}
if ( event->modifiers() == Qt::NoModifier &&
event->button() == Qt::LeftButton &&
mediaCollisionList.count() == 1 )
{
m_actionMove = true;
m_actionItem = mediaCollisionList.at( 0 );
return;
}
/*if ( event->modifiers() & Qt::ShiftModifier && collisionList.count() == 0 )
{
setDragMode( QGraphicsView::RubberBandDrag );
......@@ -328,6 +349,13 @@ void TracksView::mousePressEvent( QMouseEvent* event )
void TracksView::mouseReleaseEvent( QMouseEvent* event )
{
if ( m_actionMove )
{
m_actionMove = false;
m_actionRelativeX = -1;
m_actionItem = NULL;
}
setDragMode( QGraphicsView::NoDrag );
QGraphicsView::mouseReleaseEvent( event );
}
......
......@@ -119,6 +119,11 @@ private:
GraphicsMovieItem* m_dragItem;
QGraphicsWidget* m_separator;
// Mouse actions on Medias
bool m_actionMove;
int m_actionRelativeX;
AbstractGraphicsMediaItem* m_actionItem;
signals:
void zoomIn();
void zoomOut();
......
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