Commit e919874e authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen

TracksView: Support for track effects addition.

parent 3220a333
......@@ -25,6 +25,8 @@
#include "GraphicsTrack.h"
#include "MainWorkflow.h"
#include <QtDebug>
GraphicsTrack::GraphicsTrack( Workflow::TrackType type, quint32 trackNumber,
QGraphicsItem *parent ) :
QGraphicsWidget( parent )
......@@ -106,3 +108,9 @@ GraphicsTrack::trackWorkflow()
{
return m_trackWorkflow;
}
void
GraphicsTrack::setEmphasized( bool )
{
//TODO
}
......@@ -40,14 +40,15 @@ public:
GraphicsTrack( Workflow::TrackType type, quint32 trackNumber,
QGraphicsItem *parent = 0 );
void setHeight( int height );
int height();
void setTrackEnabled( bool enabled );
bool isEnabled();
quint32 trackNumber();
void setHeight( int height );
int height();
void setTrackEnabled( bool enabled );
bool isEnabled();
quint32 trackNumber();
Workflow::TrackType mediaType();
virtual int type() const { return Type; }
TrackWorkflow *trackWorkflow();
virtual int type() const { return Type; }
TrackWorkflow *trackWorkflow();
void setEmphasized( bool value );
QList<AbstractGraphicsMediaItem*> childs();
......
......@@ -356,18 +356,35 @@ TracksView::dragMoveEvent( QDragMoveEvent *event )
moveMediaItem( m_dragAudioItem, event->pos() );
else if ( m_dragEffect != NULL )
{
foreach ( AbstractGraphicsMediaItem *item, m_effectScaledItems )
//first, some cleaning:
foreach ( AbstractGraphicsMediaItem *item, m_effectEmphasizedItems )
item->setEmphasized( false );
m_effectScaledItems.clear();
QList<AbstractGraphicsMediaItem*> items = mediaItems( event->pos() );
if ( items.size() > 0 )
foreach ( GraphicsTrack *item, m_effectEmphasizedTracks )
item->setEmphasized( false );
m_effectEmphasizedItems.clear();
QList<AbstractGraphicsMediaItem*> clips = mediaItems( event->pos() );
if ( clips.size() > 0 )
{
foreach ( AbstractGraphicsMediaItem* item, items )
foreach ( AbstractGraphicsMediaItem* item, clips )
{
m_effectScaledItems.insert( item );
m_effectEmphasizedItems.insert( item );
item->setEmphasized( true );
}
}
else
{
QList<QGraphicsItem*> tracks = items( 0, event->pos().y() );
foreach ( QGraphicsItem* item, tracks )
{
GraphicsTrack *track = qgraphicsitem_cast<GraphicsTrack*>( item );
if ( track != NULL )
{
m_effectEmphasizedTracks.insert( track );
track->setEmphasized( true );
}
}
}
}
}
......@@ -693,9 +710,12 @@ TracksView::dragLeaveEvent( QDragLeaveEvent *event )
m_dragVideoItem = NULL;
m_dragEffect = NULL; //Don't delete the effect.
foreach ( AbstractGraphicsMediaItem *item, m_effectScaledItems )
foreach ( AbstractGraphicsMediaItem *item, m_effectEmphasizedItems )
item->setEmphasized( false );
m_effectScaledItems.clear();
m_effectEmphasizedItems.clear();
foreach ( GraphicsTrack *item, m_effectEmphasizedTracks )
item->setEmphasized( false );
m_effectEmphasizedTracks.clear();
if ( updateDurationNeeded )
updateDuration();
......@@ -752,12 +772,27 @@ TracksView::dropEvent( QDropEvent *event )
}
else if ( m_dragEffect != NULL )
{
QList<AbstractGraphicsMediaItem*> items = mediaItems( event->pos() );
foreach ( AbstractGraphicsMediaItem *item, items )
QList<AbstractGraphicsMediaItem*> clips = mediaItems( event->pos() );
if ( clips.size() > 0 )
{
item->clipHelper()->clipWorkflow()->appendEffect( m_dragEffect );
foreach ( AbstractGraphicsMediaItem *item, clips )
{
item->clipHelper()->clipWorkflow()->appendEffect( m_dragEffect );
}
}
foreach ( AbstractGraphicsMediaItem *item, m_effectScaledItems )
else
{
QList<QGraphicsItem*> tracks = items( 0, event->pos().y() );
foreach ( QGraphicsItem* item, tracks )
{
GraphicsTrack *track = qgraphicsitem_cast<GraphicsTrack*>( item );
if ( track != NULL )
track->trackWorkflow()->addEffect( m_dragEffect );
}
}
foreach ( AbstractGraphicsMediaItem *item, m_effectEmphasizedItems )
item->setEmphasized( false );
foreach ( GraphicsTrack *item, m_effectEmphasizedTracks )
item->setEmphasized( false );
}
}
......
......@@ -332,7 +332,9 @@ private:
GraphicsMovieItem *m_dragVideoItem;
GraphicsAudioItem *m_dragAudioItem;
Effect *m_dragEffect;
QSet<AbstractGraphicsMediaItem*> m_effectScaledItems;
QSet<AbstractGraphicsMediaItem*> m_effectEmphasizedItems;
QSet<GraphicsTrack*> m_effectEmphasizedTracks;
QGraphicsWidget *m_separator;
ToolButtons m_tool;
WorkflowRenderer *m_renderer;
......
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