Commit c8d48a58 authored by Ludovic Fauvet's avatar Ludovic Fauvet
Browse files

Adjust the GraphicsMovieItem size when the Clip length change

parent 61ffebcc
......@@ -39,6 +39,11 @@ GraphicsMovieItem::GraphicsMovieItem( Clip* clip ) : m_clip( clip ), m_width( 0
.arg( length.toString("hh:mm:ss.zzz") ) );
setToolTip( tooltip );
setAcceptHoverEvents( true );
// Adjust the width
setWidth( clip->getLength() );
// Automatically adjust future changes
connect( clip, SIGNAL( lengthUpdated() ), this, SLOT( adjustLength() ) );
}
GraphicsMovieItem::~GraphicsMovieItem()
......@@ -75,6 +80,13 @@ void GraphicsMovieItem::setHeight( int height )
m_height = height;
}
void GraphicsMovieItem::adjustLength()
{
//FIXME implement clip expanding.
Q_ASSERT( m_clip->getLength() <= m_width );
setWidth( m_clip->getLength() );
}
void GraphicsMovieItem::paintAudioSpectrum( QPainter* painter )
{
qreal x1, x2, y1, y2;
......
......@@ -51,7 +51,6 @@ public:
void setWidth( int width );
void setHeight( int height );
Clip* clip() const;
void setClip( Clip* clip );
//void setAudioSpectrum( QVector<float*> spectrum );
void paintAudioSpectrum( QPainter* painter );
......@@ -61,6 +60,9 @@ protected:
virtual void hoverEnterEvent( QGraphicsSceneHoverEvent* event );
virtual void hoverLeaveEvent( QGraphicsSceneHoverEvent* event );
private slots:
void adjustLength();
private:
Clip* m_clip;
int m_width;
......
......@@ -186,7 +186,6 @@ void TracksView::addMediaItem( Clip* clip, unsigned int track, qint64 start )
}
GraphicsMovieItem* item = new GraphicsMovieItem( clip );
item->setWidth( clip->getLength() );
item->setHeight( tracksHeight() );
item->setParentItem( getTrack( track ) );
item->oldTrackNumber = track;
......@@ -208,7 +207,6 @@ void TracksView::dragEnterEvent( QDragEnterEvent* event )
if ( m_dragItem ) delete m_dragItem;
m_dragItem = new GraphicsMovieItem( clip );
m_dragItem->setWidth( ( int ) ( clip->getLength() ) );
m_dragItem->setHeight( tracksHeight() );
m_dragItem->setPos( mappedXPos, 0 );
m_dragItem->setParentItem( m_layout->itemAt( 0 )->graphicsItem() );
......
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