Commit 6f118a3d authored by Clement CHAVANCE's avatar Clement CHAVANCE

removed code duplication

parent cf962ef1
......@@ -29,7 +29,7 @@
#include "TracksView.h"
#include "Timeline.h"
GraphicsAudioItem::GraphicsAudioItem( Clip* clip ) : m_clip( clip ), m_width( 0 ), m_height( 0 )
GraphicsAudioItem::GraphicsAudioItem( Clip* clip ) : m_clip( clip )
{
setFlags( QGraphicsItem::ItemIsSelectable );
......@@ -56,11 +56,6 @@ MainWorkflow::TrackType GraphicsAudioItem::mediaType() const
return MainWorkflow::AudioTrack;
}
QRectF GraphicsAudioItem::boundingRect() const
{
return QRectF( 0, 0, m_width, m_height );
}
void GraphicsAudioItem::paint( QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* )
{
painter->save();
......@@ -72,26 +67,6 @@ void GraphicsAudioItem::paint( QPainter* painter, const QStyleOptionGraphicsItem
painter->restore();
}
void GraphicsAudioItem::setWidth( int width )
{
prepareGeometryChange();
m_width = width;
}
void GraphicsAudioItem::setHeight( int height )
{
prepareGeometryChange();
m_height = height;
}
void GraphicsAudioItem::adjustLength()
{
//FIXME implement clip expanding.
Q_ASSERT_X( m_clip->getLength() <= m_width, "adjustLength", "Clip expanding not supported!" );
prepareGeometryChange();
setWidth( m_clip->getLength() );
}
Clip* GraphicsAudioItem::clip() const
{
return m_clip;
......
......@@ -52,11 +52,8 @@ public:
virtual bool moveable() const { return true; }
virtual const QUuid& uuid() const { return m_clip->getUuid(); }
virtual MainWorkflow::TrackType mediaType() const;
virtual QRectF boundingRect() const;
virtual void paint( QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget = 0 );
void setWidth( int width );
void setHeight( int height );
virtual Clip* clip() const;
protected:
......@@ -77,16 +74,8 @@ protected:
virtual void mousePressEvent( QGraphicsSceneMouseEvent* event );
virtual void mouseReleaseEvent( QGraphicsSceneMouseEvent* event );
private slots:
/**
* \deprecated Do not use.
*/
void adjustLength();
private:
Clip* m_clip;
int m_width;
int m_height;
signals:
/**
......
......@@ -216,16 +216,10 @@ void TracksView::addMediaItem( Clip* clip, unsigned int track, MainWorkflow::Tra
return;
}
AbstractGraphicsMediaItem* item = 0;
if ( trackType == MainWorkflow::VideoTrack )
{
GraphicsMovieItem* item = new GraphicsMovieItem( clip );
item->m_tracksView = this;
item->setHeight( tracksHeight() );
item->setParentItem( getTrack( trackType, track ) );
item->setStartPos( start );
item->oldTrackNumber = track;
item->oldPosition = start;
moveMediaItem( item, track, start );
item = new GraphicsMovieItem( clip );
// Split is currently only supported for video
connect( item, SIGNAL( split(GraphicsMovieItem*,qint64) ),
......@@ -235,16 +229,16 @@ void TracksView::addMediaItem( Clip* clip, unsigned int track, MainWorkflow::Tra
{
//FIXME If a GraphicsAudioItem is downcasted to an AbstractGraphicsMediaItem
// the item is not drawn in the timeline.
GraphicsAudioItem* item = new GraphicsAudioItem( clip );
item->m_tracksView = this;
item->setHeight( tracksHeight() );
item->setParentItem( getTrack( trackType, track ) );
item->setStartPos( start );
item->oldTrackNumber = track;
item->oldPosition = start;
moveMediaItem( item, track, start );
item = new GraphicsAudioItem( clip );
}
item->m_tracksView = this;
item->setHeight( tracksHeight() );
item->setParentItem( getTrack( trackType, track ) );
item->setStartPos( start );
item->oldTrackNumber = track;
item->oldPosition = start;
moveMediaItem( item, track, start );
updateDuration();
}
......
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