Commit 77240e5d authored by Ludovic Fauvet's avatar Ludovic Fauvet

Timeline: Use of dragMode

Handle multiple selection (SHIFT + CLICK) and movements inside the
timeline frame (CTRL + CLICK)
parent 84a6a1bb
......@@ -114,7 +114,6 @@ void TracksView::drawBackground( QPainter* painter, const QRectF& rect )
void TracksView::mouseMoveEvent( QMouseEvent* event )
{
//int xPos = event->x();
int mappedXPos = ( int )( mapToScene( event->pos() ).x() + 0.5 );
if ( event->buttons() == Qt::LeftButton && event->modifiers() == Qt::NoModifier )
{
......@@ -126,7 +125,25 @@ void TracksView::mouseMoveEvent( QMouseEvent* event )
void TracksView::mousePressEvent( QMouseEvent* event )
{
//int xPos = event->x();
QList<QGraphicsItem*> collisionList = items( event->pos() );
if ( event->modifiers() == Qt::ControlModifier && collisionList.count() == 0 )
{
setDragMode( QGraphicsView::ScrollHandDrag );
QGraphicsView::mousePressEvent( event );
return;
}
if ( event->modifiers() & Qt::ShiftModifier && collisionList.count() == 0 )
{
setDragMode( QGraphicsView::RubberBandDrag );
if ( !event->modifiers() & Qt::ControlModifier )
scene()->clearSelection();
QGraphicsView::mousePressEvent( event );
return;
}
int mappedXPos = ( int )( mapToScene( event->pos() ).x() + 0.5 );
if ( event->buttons() == Qt::LeftButton && event->modifiers() == Qt::NoModifier )
{
......@@ -136,6 +153,11 @@ void TracksView::mousePressEvent( QMouseEvent* event )
QGraphicsView::mousePressEvent( event );
}
void TracksView::mouseReleaseEvent( QMouseEvent* event )
{
setDragMode( QGraphicsView::NoDrag );
}
void TracksView::wheelEvent( QWheelEvent* event )
{
if ( event->modifiers() == Qt::ControlModifier )
......
......@@ -51,6 +51,7 @@ protected:
virtual void drawBackground( QPainter* painter, const QRectF& rect );
virtual void mouseMoveEvent( QMouseEvent* event );
virtual void mousePressEvent( QMouseEvent* event );
virtual void mouseReleaseEvent( QMouseEvent* event );
virtual void wheelEvent( QWheelEvent* event );
virtual void dragEnterEvent( QDragEnterEvent* event );
virtual void dropEvent( QDropEvent* 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