Commit 45a5a195 authored by Ludovic Fauvet's avatar Ludovic Fauvet

Clip's visual representation now show the filename of the clip.

parent c7f780d7
......@@ -35,6 +35,14 @@ GraphicsMovieItem::GraphicsMovieItem( Clip* clip ) : m_clip( clip ), m_width( 0
.arg( clip->getParent()->getFileInfo()->fileName() )
.arg( length.toString("hh:mm:ss.zzz") ) );
setToolTip( tooltip );
m_movieTitle = new QGraphicsTextItem( this, scene() );
m_movieTitle->setFlag( QGraphicsItem::ItemIgnoresTransformations );
QFont titleFont = m_movieTitle->font();
titleFont.setPointSize( 8 );
m_movieTitle->setFont( titleFont );
updateTitle();
}
GraphicsMovieItem::~GraphicsMovieItem()
......@@ -57,6 +65,7 @@ void GraphicsMovieItem::paint( QPainter* painter, const QStyleOptionGraphicsItem
painter->drawRect( boundingRect() );
paintAudioSpectrum( painter );
updateTitle();
}
......@@ -118,3 +127,17 @@ Clip* GraphicsMovieItem::clip() const
{
return m_clip;
}
void GraphicsMovieItem::updateTitle()
{
QFontMetrics fm( m_movieTitle->font() );
QString text = m_clip->getParent()->getFileInfo()->fileName();
static int lastWidth = 0;
int width = TracksView::instance()->mapFromScene( boundingRect() ).boundingRect().width();
if ( lastWidth == width ) return;
lastWidth = width;
//FIXME there is a small visual refresh bug here
m_movieTitle->setPlainText( fm.elidedText( text, Qt::ElideRight, width ) );
}
......@@ -23,6 +23,7 @@
#ifndef GRAPHICSMOVIEITEM_H
#define GRAPHICSMOVIEITEM_H
#include <QFontMetrics>
#include "AbstractGraphicsMediaItem.h"
#include "Clip.h"
#include "TracksView.h"
......@@ -49,10 +50,12 @@ public:
void paintAudioSpectrum( QPainter* painter );
private:
Clip* m_clip;
int m_width;
int m_height;
QVector<float*> m_audioSpectrum;
void updateTitle();
Clip* m_clip;
int m_width;
int m_height;
QVector<float*> m_audioSpectrum;
QGraphicsTextItem* m_movieTitle;
};
#endif // GRAPHICSMOVIEITEM_H
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