Commit a10daf9d authored by Hugo Beauzee-Luyssen's avatar Hugo Beauzee-Luyssen

MediaCellView: Let the media cell view update itself when metadata are computed.

parent c5fbaea6
......@@ -172,19 +172,6 @@ ImportController::clipSelection( const QUuid& uuid )
m_currentUuid = uuid;
}
void
ImportController::updateMediaRequested( const Media *media )
{
if ( m_temporaryMedias.contains( media->baseClip()->uuid() ) == false )
return ;
MediaCellView* cell = m_mediaListController->cell( media->baseClip()->uuid() );
if ( cell == NULL )
return;
cell->setThumbnail( media->snapshot() );
cell->setLength( media->lengthMS() );
cell->setEnabled( true );
}
void
ImportController::setUIMetaData( Media* media )
{
......@@ -241,10 +228,6 @@ ImportController::importMedia( const QString &filePath )
return ;
Media* media = new Media( filePath );
connect( media, SIGNAL( metaDataComputed( const Media* ) ),
this, SLOT( updateMediaRequested( const Media* ) ) );
connect( media, SIGNAL( snapshotComputed( const Media* ) ),
this, SLOT( updateMediaRequested( const Media* ) ) );
connect( media, SIGNAL( snapshotComputed( const Media* ) ),
this, SLOT( mediaLoaded() ) );
m_temporaryMedias[media->baseClip()->uuid()] = media;
......
......@@ -87,7 +87,6 @@ class ImportController : public QDialog
quint32 m_nbMediaLoaded;
public slots:
void updateMediaRequested( const Media* media );
void accept();
void reject();
void mediaSelection( const QUuid& uuid );
......
......@@ -39,7 +39,7 @@ ImportMediaListController::~ImportMediaListController()
void
ImportMediaListController::addMedia( Media* media )
{
MediaCellView* cell = new MediaCellView( media->baseClip()->uuid() );
MediaCellView* cell = new MediaCellView( media->baseClip() );
connect( cell, SIGNAL( cellSelected( const QUuid& ) ),
this, SIGNAL( mediaSelected( const QUuid& ) ) );
connect( cell, SIGNAL( cellDeleted( const QUuid& ) ),
......@@ -49,20 +49,9 @@ ImportMediaListController::addMedia( Media* media )
connect( media, SIGNAL( clipAdded(Clip*) ),
this, SLOT( clipAdded( Clip* ) ) );
cell->setTitle( media->fileName() );
cell->setThumbnail( media->snapshot() );
addCell( cell );
m_mediaCellList->insert( media->baseClip()->uuid(), cell );
if ( media->baseClip() == NULL )
connect( media, SIGNAL( metaDataComputed( const Media* ) ),
cell, SLOT( enableCell() ) );
}
void
ImportMediaListController::metaDataComputed( const Media* media )
{
m_mediaCellList->value( media->baseClip()->uuid() )->setThumbnail( media->snapshot() );
}
MediaCellView*
......@@ -90,7 +79,7 @@ ImportMediaListController::removeMedia( const QUuid& uuid )
void
ImportMediaListController::addClip( Clip* clip )
{
MediaCellView* cell = new MediaCellView( clip->uuid() );
MediaCellView* cell = new MediaCellView( clip );
cell->containsClip();
connect( cell, SIGNAL( cellSelected( const QUuid& ) ),
this, SIGNAL( clipSelected( const QUuid& ) ) );
......
......@@ -57,7 +57,6 @@ class ImportMediaListController : public ListViewController
int m_clipDeleted;
public slots:
void metaDataComputed( const Media* media );
void clipDeletion( const QUuid& uuid );
void clipAdded( Clip* clip );
......
......@@ -61,7 +61,7 @@ void ClipListViewController::resetNbDeletion()
void ClipListViewController::addClip( Clip* clip )
{
MediaCellView* cell = new MediaCellView( clip->uuid() );
MediaCellView* cell = new MediaCellView( clip );
cell->containsClip();
connect( cell, SIGNAL( cellSelected( QUuid ) ), this, SLOT( cellSelection( const QUuid& ) ) );
connect( cell, SIGNAL( cellDeleted( const QUuid& ) ), this, SLOT( clipDeletion( const QUuid& ) ) );
......@@ -73,7 +73,7 @@ void ClipListViewController::addClip( Clip* clip )
cell->setLength( clip->lengthSecond(), false );
addCell( cell );
m_cells.insert( clip->uuid(), cell );
cell->enableCell();
cell->setEnabled( true );
}
void ClipListViewController::clean()
......
......@@ -28,19 +28,38 @@
#include <QTime>
MediaCellView::MediaCellView( const QUuid& uuid, QWidget *parent ) :
QWidget( parent ), m_ui( new Ui::MediaCellView ), m_uuid( uuid )
MediaCellView::MediaCellView( Clip* clip, QWidget *parent ) :
QWidget( parent ),
m_ui( new Ui::MediaCellView ),
m_clip( clip )
{
m_ui->setupUi( this );
setFocusPolicy( Qt::ClickFocus );
setAutoFillBackground( true );
connect( m_ui->delLabel, SIGNAL( clicked( QWidget*, QMouseEvent* ) ),
this, SLOT( deleteButtonClicked( QWidget*, QMouseEvent* ) ) );
//TODO : if it's a clip, disable the arrow
connect( m_ui->arrow,
SIGNAL( clicked( QWidget*, QMouseEvent* ) ),
SLOT( arrowButtonClicked( QWidget*, QMouseEvent* ) ) );
setEnabled( false );
connect( clip->getParent(), SIGNAL( metaDataComputed(const Media*) ),
this, SLOT( metadataUpdated( const Media*) ) );
connect( clip->getParent(), SIGNAL( snapshotComputed(const Media*) ),
this, SLOT( snapshotUpdated(const Media*) ) );
}
void
MediaCellView::metadataUpdated( const Media *media )
{
setNbClips( media->clipsCount() );
setLength( media->lengthMS() );
setEnabled( true );
}
void
MediaCellView::snapshotUpdated( const Media *media )
{
setThumbnail( media->snapshot() );
}
MediaCellView::~MediaCellView()
......@@ -71,7 +90,8 @@ void MediaCellView::setNbClips( int nbClip )
m_ui->clipCount->setText( QString::number( nbClip ) );
}
void MediaCellView::setThumbnail( const QPixmap& pixmap )
void
MediaCellView::setThumbnail( const QPixmap &pixmap )
{
m_ui->thumbnail->setScaledContents( false );
m_ui->thumbnail->setPixmap( pixmap.scaled( 64, 64, Qt::KeepAspectRatio ) );
......@@ -87,19 +107,11 @@ QString MediaCellView::title() const
return m_ui->title->text();
}
const QUuid& MediaCellView::uuid() const
{
return m_uuid;
}
void MediaCellView::mouseDoubleClickEvent( QMouseEvent* event )
{
if ( ( event->buttons() | Qt::LeftButton ) == Qt::LeftButton )
{
Clip* clip = Library::getInstance()->clip( m_uuid );
if ( clip == NULL )
return;
ClipProperty* cp = new ClipProperty( clip, this );
ClipProperty* cp = new ClipProperty( m_clip, this );
cp->setModal( true );
cp->show();
delete cp;
......@@ -113,7 +125,7 @@ void MediaCellView::mousePressEvent( QMouseEvent* event )
if ( ( event->buttons() | Qt::LeftButton ) == Qt::LeftButton )
{
m_dragStartPos = event->pos();
emit cellSelected( m_uuid );
emit cellSelected( m_clip->uuid() );
}
}
......@@ -127,29 +139,24 @@ void MediaCellView::mouseMoveEvent( QMouseEvent* event )
return;
QMimeData* mimeData = new QMimeData;
mimeData->setData( "vlmc/uuid", m_uuid.toString().toAscii() );
//FIXME the second argument is a media UUID instead of a Clip
// and this is not logical... but it works.
mimeData->setData( "vlmc/uuid", m_clip->uuid().toString().toAscii() );
QDrag* drag = new QDrag( this );
drag->setMimeData( mimeData );
//FIXME : change the way the library handles Clips
const Clip* clip = Library::getInstance()->clip( m_uuid );
if ( 0 == clip )
return ;
//getting the media from the current Clip
const Media* parent = Library::getInstance()->clip( m_uuid )->getParent();
if ( 0 == parent )
return ;
const Media* parent = m_clip->getParent();
drag->setPixmap( parent->snapshot().scaled( 100, 100, Qt::KeepAspectRatio ) );
drag->exec( Qt::CopyAction | Qt::MoveAction, Qt::CopyAction );
}
void MediaCellView::deleteButtonClicked( QWidget*, QMouseEvent* )
{
emit cellDeleted( uuid() );
emit cellDeleted( m_clip->uuid() );
}
void MediaCellView::arrowButtonClicked( QWidget*, QMouseEvent* )
{
emit arrowClicked( uuid() );
emit arrowClicked( m_clip->uuid() );
}
void MediaCellView::setLength( qint64 length, bool mSecs )
......@@ -190,9 +197,3 @@ MediaCellView::containsClip()
SIGNAL( clicked( QWidget*, QMouseEvent* ) ), this,
SLOT( arrowButtonClicked( QWidget*, QMouseEvent* ) ) );
}
void
MediaCellView::enableCell()
{
setEnabled( true );
}
......@@ -28,6 +28,9 @@
#include <QMouseEvent>
#include "ClickableLabel.h"
class Clip;
class Media;
namespace Ui
{
class MediaCellView;
......@@ -38,7 +41,7 @@ class MediaCellView : public QWidget
Q_OBJECT
public:
MediaCellView( const QUuid& uuid, QWidget *parent = 0 );
MediaCellView( Clip* clip, QWidget *parent = 0 );
~MediaCellView();
void setTitle( const QString& title );
......@@ -53,15 +56,14 @@ public:
void incrementClipCount();
void decrementClipCount( const int nb );
QString title() const;
const QUuid& uuid() const;
void containsClip();
protected:
void changeEvent( QEvent *e );
void changeEvent( QEvent *e );
private:
Ui::MediaCellView* m_ui;
const QUuid m_uuid;
Clip* m_clip;
QPoint m_dragStartPos;
protected:
......@@ -77,8 +79,10 @@ signals:
public slots:
void deleteButtonClicked( QWidget* sender, QMouseEvent* event );
void arrowButtonClicked( QWidget* sender, QMouseEvent* event );
void enableCell();
private slots:
void snapshotUpdated( const Media *media );
void metadataUpdated( const Media *media );
};
#endif // MEDIACELLVIEW_H
......@@ -40,7 +40,7 @@ MediaListViewController::~MediaListViewController()
void MediaListViewController::newMediaLoaded( Media* media )
{
MediaCellView* cell = new MediaCellView( media->baseClip()->uuid() );
MediaCellView* cell = new MediaCellView( media->baseClip() );
connect( cell, SIGNAL ( cellSelected( QUuid ) ),
this, SLOT ( cellSelection( QUuid ) ) );
......@@ -48,8 +48,6 @@ void MediaListViewController::newMediaLoaded( Media* media )
this, SIGNAL( mediaDeleted( QUuid ) ) );
connect( cell, SIGNAL( arrowClicked( const QUuid& ) ),
this, SLOT( showClipList( const QUuid& ) ) );
connect( media, SIGNAL( snapshotComputed( const Media* ) ),
this, SLOT( updateCell( const Media* ) ) );
connect( media, SIGNAL( clipAdded( Clip* ) ),
this, SLOT( newClipAdded(Clip*) ) );
cell->setNbClips( media->clipsCount() );
......@@ -90,18 +88,6 @@ void MediaListViewController::mediaRemoved( const QUuid& uuid )
m_currentUuid = QUuid();
}
void MediaListViewController::updateCell( const Media* media )
{
MediaCellView* cell = qobject_cast<MediaCellView*>( m_cells->value( media->baseClip()->uuid(), NULL ) );
if ( cell != NULL )
{
cell->setNbClips( media->clipsCount() );
cell->setLength( media->lengthMS() );
cell->setThumbnail( media->snapshot() );
cell->setEnabled(true);
}
}
void MediaListViewController::showClipList( const QUuid& uuid )
{
if ( !m_cells->contains( uuid ) )
......
......@@ -50,7 +50,6 @@ public slots:
void newMediaLoaded( Media* media );
void cellSelection( const QUuid& uuid );
void mediaRemoved( const QUuid& uuid );
void updateCell( const Media* media );
void showClipList( const QUuid& uuid );
void newClipAdded( Clip* clip );
void clipSelection( const QUuid& uuid );
......
......@@ -48,7 +48,6 @@ Media::Media( const QString& filePath, const QString& uuid /*= QString()*/ )
m_width( 0 ),
m_height( 0 ),
m_fps( .0f ),
m_baseClip( NULL ),
m_nbAudioTracks( 0 ),
m_nbVideoTracks( 0 )
{
......
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