[vlmc-devel] commit: timeline: fix a regression with cursor events. (Ludovic Fauvet )

git at videolan.org git at videolan.org
Thu Mar 18 02:12:00 CET 2010


vlmc | branch: master | Ludovic Fauvet <etix at l0cal.com> | Thu Mar 18 02:03:06 2010 +0100| [c5b7e28d4144fbb1d6fe588154fb80909fd2a756] | committer: Ludovic Fauvet 

timeline: fix a regression with cursor events.

- Keep the cursor visible while playing (ticket #17)
- Compatibility fix for Qt 4.6
- Remove a somewhat hazardous method :)

> http://git.videolan.org/gitweb.cgi/vlmc.git/?a=commit;h=c5b7e28d4144fbb1d6fe588154fb80909fd2a756
---

 src/Gui/timeline/GraphicsCursorItem.cpp |   17 +++++++----------
 src/Gui/timeline/GraphicsCursorItem.h   |    2 +-
 src/Gui/timeline/TracksView.cpp         |    2 +-
 3 files changed, 9 insertions(+), 12 deletions(-)

diff --git a/src/Gui/timeline/GraphicsCursorItem.cpp b/src/Gui/timeline/GraphicsCursorItem.cpp
index 1d69cc8..9990b0e 100644
--- a/src/Gui/timeline/GraphicsCursorItem.cpp
+++ b/src/Gui/timeline/GraphicsCursorItem.cpp
@@ -21,12 +21,15 @@
  *****************************************************************************/
 
 #include <QtDebug>
+#include <QGraphicsItem>
 #include "GraphicsCursorItem.h"
 
 GraphicsCursorItem::GraphicsCursorItem( const QPen& pen ) :
         m_pen( pen ), m_mouseDown( false )
 {
-    setFlags( QGraphicsItem::ItemIgnoresTransformations | QGraphicsItem::ItemIsMovable );
+    setFlags( QGraphicsItem::ItemIgnoresTransformations |
+              QGraphicsItem::ItemIsMovable |
+              QGraphicsItem::ItemSendsGeometryChanges );
     setCursor( QCursor( Qt::SizeHorCursor ) );
     setZValue( 100 );
 
@@ -47,17 +50,18 @@ void GraphicsCursorItem::paint( QPainter* painter, const QStyleOptionGraphicsIte
 QVariant GraphicsCursorItem::itemChange( GraphicsItemChange change, const QVariant& value )
 {
     //Position is changing :
-    if ( change == ItemPositionChange )
+    if ( change == QGraphicsItem::ItemPositionChange )
     {
         qreal posX = value.toPointF().x();
         if ( posX < 0 ) posX = 0;
         return QPoint( ( int ) posX, ( int ) pos().y() );
     }
     //The position HAS changed, ie we released the slider, or setPos has been called.
-    else if ( change == ItemPositionHasChanged )
+    else if ( change == QGraphicsItem::ItemPositionHasChanged )
     {
         if ( m_mouseDown )
             emit cursorPositionChanged( ( qint64 ) pos().x() );
+        emit cursorMoved( ( qint64 ) pos().x() );
     }
     return QGraphicsItem::itemChange( change, value );
 }
@@ -70,13 +74,6 @@ void GraphicsCursorItem::mousePressEvent( QGraphicsSceneMouseEvent* event )
     QGraphicsItem::mousePressEvent( event );
 }
 
-void
-GraphicsCursorItem::mouseMoveEvent( QGraphicsSceneMouseEvent *event )
-{
-    QGraphicsItem::mouseMoveEvent( event );
-    setPos( pos().x(), 0.0 );
-}
-
 void GraphicsCursorItem::mouseReleaseEvent( QGraphicsSceneMouseEvent* event )
 {
     m_mouseDown = false;
diff --git a/src/Gui/timeline/GraphicsCursorItem.h b/src/Gui/timeline/GraphicsCursorItem.h
index febb6d5..24ed5be 100644
--- a/src/Gui/timeline/GraphicsCursorItem.h
+++ b/src/Gui/timeline/GraphicsCursorItem.h
@@ -47,7 +47,6 @@ protected:
     virtual QVariant    itemChange( GraphicsItemChange change, const QVariant& value );
     virtual void        mousePressEvent( QGraphicsSceneMouseEvent* event );
     virtual void        mouseReleaseEvent( QGraphicsSceneMouseEvent* event );
-    virtual void        mouseMoveEvent( QGraphicsSceneMouseEvent *event );
 
 private:
     QPen        m_pen;
@@ -56,6 +55,7 @@ private:
 
 signals:
     void cursorPositionChanged( qint64 pos );
+    void cursorMoved( qint64 pos );
 
 public slots:
     void frameChanged( qint64 position, MainWorkflow::FrameChangedReason );
diff --git a/src/Gui/timeline/TracksView.cpp b/src/Gui/timeline/TracksView.cpp
index 9e061f2..bf8500f 100644
--- a/src/Gui/timeline/TracksView.cpp
+++ b/src/Gui/timeline/TracksView.cpp
@@ -71,7 +71,7 @@ TracksView::TracksView( QGraphicsScene *scene, MainWorkflow *mainWorkflow,
 
     m_scene->addItem( m_cursorLine );
 
-    connect( m_cursorLine, SIGNAL( cursorPositionChanged(qint64) ),
+    connect( m_cursorLine, SIGNAL( cursorMoved(qint64) ),
              this, SLOT( ensureCursorVisible() ) );
     connect( Library::getInstance(), SIGNAL( clipRemoved( const QUuid& ) ),
              this, SLOT( deleteMedia( const QUuid& ) ) );



More information about the Vlmc-devel mailing list