[vlmc-devel] commit: TracksView: Fixing bad mouse releasing behaviour. ( Hugo Beauzée-Luyssen )
Rohit Yadav
rohityadav89 at gmail.com
Fri Dec 3 12:08:35 CET 2010
I agree with Hugo the way we're taught at school, no problem...
Okay if we're to use it, perhaps refactor it to something like this:
//Check if the item moved.
- if ( effectItem != NULL )
+ if ( m_actionItem->m_oldTrack ==
m_actionItem->track()->trackWorkflow() )
{
- if ( m_actionItem->m_oldTrack ==
m_actionItem->track()->trackWorkflow() )
+ if( effectItem != NULL )
{
const AbstractGraphicsMediaItem *container =
effectItem->container();
- if ( container != NULL && container->startPos() +
effectItem->begin() == effectItem->startPos() )
- goto out;
- else if ( container == NULL && effectItem->startPos() ==
effectItem->begin() )
+ if ( ( container != NULL && container->startPos() +
effectItem->begin() == effectItem->startPos() ) ||
+ ( container == NULL && effectItem->startPos() ==
effectItem->begin() ) )
goto out;
}
- }
- else
- {
- if ( m_actionItem->m_oldTrack ==
m_actionItem->track()->trackWorkflow() &&
- m_actionItem->startPos() ==
m_actionItem->track()->trackWorkflow()->getClipPosition(
m_actionItem->uuid() ) )
+ else if ( m_actionItem->startPos() ==
m_actionItem->track()->trackWorkflow()->getClipPosition(
m_actionItem->uuid() ) )
goto out;
}
Before this, I worked on this solution without the *goto*:
diff --git a/src/Gui/timeline/TracksView.cpp
b/src/Gui/timeline/TracksView.cpp
index 2fcbf10..5c28cc9 100644
--- a/src/Gui/timeline/TracksView.cpp
+++ b/src/Gui/timeline/TracksView.cpp
@@ -1131,22 +1131,27 @@ TracksView::mouseReleaseEvent( QMouseEvent *event )
GraphicsEffectItem *effectItem =
qgraphicsitem_cast<GraphicsEffectItem*>( m_actionItem );
//Check if the item moved.
- if ( effectItem != NULL )
+ if ( m_actionItem->m_oldTrack ==
m_actionItem->track()->trackWorkflow() )
{
- if ( m_actionItem->m_oldTrack ==
m_actionItem->track()->trackWorkflow() )
+ bool isMoved = false;
+ if( effectItem != NULL )
{
const AbstractGraphicsMediaItem *container =
effectItem->container();
- if ( container != NULL && container->startPos() +
effectItem->begin() == effectItem->startPos() )
- goto out;
- else if ( container == NULL && effectItem->startPos() ==
effectItem->begin() )
- goto out;
+ if ( ( container != NULL && container->startPos() +
effectItem->begin() == effectItem->startPos() ) ||
+ ( container == NULL && effectItem->startPos() ==
effectItem->begin() ) )
+ isMoved = true;
+ }
+ else if ( m_actionItem->startPos() ==
m_actionItem->track()->trackWorkflow()->getClipPosition(
m_actionItem->uuid() ) )
+ isMoved = true;
+
+ if( isMoved )
+ {
+ m_effectTarget = NULL;
+ m_actionItem = NULL;
+ m_action = TracksView::None;
+ //setDragMode( QGraphicsView::NoDrag );
+ QGraphicsView::mouseReleaseEvent( event );
}
- }
- else
- {
- if ( m_actionItem->m_oldTrack ==
m_actionItem->track()->trackWorkflow() &&
- m_actionItem->startPos() ==
m_actionItem->track()->trackWorkflow()->getClipPosition(
m_actionItem->uuid() ) )
- goto out;
}
updateDuration();
@@ -1209,7 +1214,6 @@ TracksView::mouseReleaseEvent( QMouseEvent *event )
updateDuration();
}
-out:
m_effectTarget = NULL;
m_actionItem = NULL;
m_action = TracksView::None;
Cheers,
Rohit
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/vlmc-devel/attachments/20101203/300a15dd/attachment.html>
More information about the Vlmc-devel
mailing list