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

Big big refactoring :

Media aren't meant to be used anywhere, except when rendering. Clip can
now have subclips, we avoid using uuid when using Clip* is possible.
Correcting remaining crap in MediaListViewController and co.
View handle as many things as possible, but do not touch data.
ImportController doesn't have to do anything with deleting media. That's
the MediaContainer's job.
Probably many other things...
parent 02d13fc1
...@@ -42,20 +42,20 @@ ClipProperty::ClipProperty( Clip* clip, QWidget *parent ) : ...@@ -42,20 +42,20 @@ ClipProperty::ClipProperty( Clip* clip, QWidget *parent ) :
//Duration //Duration
ui->durationValueLabel->setText( duration.toString( "hh:mm:ss" ) ); ui->durationValueLabel->setText( duration.toString( "hh:mm:ss" ) );
//Filename || title //Filename || title
ui->nameValueLabel->setText( m_clip->getParent()->fileInfo()->fileName() ); ui->nameValueLabel->setText( m_clip->getMedia()->fileInfo()->fileName() );
setWindowTitle( m_clip->getParent()->fileInfo()->fileName() + " " + tr( "properties" ) ); setWindowTitle( m_clip->getMedia()->fileInfo()->fileName() + " " + tr( "properties" ) );
//Resolution //Resolution
ui->resolutionValueLabel->setText( QString::number( m_clip->getParent()->width() ) ui->resolutionValueLabel->setText( QString::number( m_clip->getMedia()->width() )
+ " x " + QString::number( m_clip->getParent()->height() ) ); + " x " + QString::number( m_clip->getMedia()->height() ) );
//FPS //FPS
ui->fpsValueLabel->setText( QString::number( m_clip->getParent()->fps() ) ); ui->fpsValueLabel->setText( QString::number( m_clip->getMedia()->fps() ) );
//Snapshot //Snapshot
ui->snapshotLabel->setPixmap( m_clip->getParent()->snapshot().scaled( 128, 128, Qt::KeepAspectRatio ) ); ui->snapshotLabel->setPixmap( m_clip->getMedia()->snapshot().scaled( 128, 128, Qt::KeepAspectRatio ) );
//nb tracks : //nb tracks :
ui->nbVideoTracksValueLabel->setText( ui->nbVideoTracksValueLabel->setText(
QString::number( m_clip->getParent()->nbVideoTracks() ) ); QString::number( m_clip->getMedia()->nbVideoTracks() ) );
ui->nbAudioTracksValueLabel->setText( ui->nbAudioTracksValueLabel->setText(
QString::number( m_clip->getParent()->nbAudioTracks() ) ); QString::number( m_clip->getMedia()->nbAudioTracks() ) );
//Metatags //Metatags
const QPushButton* button = ui->buttonBox->button( QDialogButtonBox::Apply ); const QPushButton* button = ui->buttonBox->button( QDialogButtonBox::Apply );
Q_ASSERT( button != NULL); Q_ASSERT( button != NULL);
......
...@@ -229,6 +229,8 @@ void MainWindow::setupLibrary() ...@@ -229,6 +229,8 @@ void MainWindow::setupLibrary()
MediaLibraryWidget* mediaLibraryWidget = new MediaLibraryWidget( this ); MediaLibraryWidget* mediaLibraryWidget = new MediaLibraryWidget( this );
m_importController = new ImportController(); m_importController = new ImportController();
const ClipRenderer* clipRenderer = qobject_cast<const ClipRenderer*>( m_clipPreview->getGenericRenderer() );
Q_ASSERT( clipRenderer != NULL );
DockWidgetManager::instance()->addDockedWidget( mediaLibraryWidget, DockWidgetManager::instance()->addDockedWidget( mediaLibraryWidget,
tr( "Media Library" ), tr( "Media Library" ),
...@@ -236,13 +238,13 @@ void MainWindow::setupLibrary() ...@@ -236,13 +238,13 @@ void MainWindow::setupLibrary()
QDockWidget::AllDockWidgetFeatures, QDockWidget::AllDockWidgetFeatures,
Qt::LeftDockWidgetArea ); Qt::LeftDockWidgetArea );
connect( mediaLibraryWidget, SIGNAL( clipSelected( Clip* ) ), connect( mediaLibraryWidget, SIGNAL( clipSelected( Clip* ) ),
qobject_cast<const ClipRenderer*>( m_clipPreview->getGenericRenderer() ), clipRenderer, SLOT( setClip( Clip* ) ) );
SLOT( setClip( Clip* ) ) );
connect( Library::getInstance(), SIGNAL( mediaRemoved( const QUuid& ) ), connect( Library::getInstance(), SIGNAL( clipRemoved( const Clip* ) ),
m_clipPreview->getGenericRenderer(), SLOT( mediaUnloaded( QUuid ) ) ); clipRenderer, SLOT( clipUnloaded( const Clip* ) ) );
connect( mediaLibraryWidget, SIGNAL( importRequired() ), this, SLOT( on_actionImport_triggered() ) ); connect( mediaLibraryWidget, SIGNAL( importRequired() ),
this, SLOT( on_actionImport_triggered() ) );
} }
void MainWindow::on_actionSave_triggered() void MainWindow::on_actionSave_triggered()
......
...@@ -190,8 +190,11 @@ void PreviewWidget::markerStopClicked() ...@@ -190,8 +190,11 @@ void PreviewWidget::markerStopClicked()
void PreviewWidget::createNewClipFromMarkers() void PreviewWidget::createNewClipFromMarkers()
{ {
Media* selectedMedia = m_renderer->getMedia(); ClipRenderer* clipRenderer = qobject_cast<ClipRenderer*>( m_renderer );
if ( selectedMedia == NULL ) Q_ASSERT( clipRenderer != NULL );
Clip* clip = clipRenderer->getClip();
if ( clip == NULL )
return ; return ;
qint64 beg = m_ui->rulerWidget->getMarker( PreviewRuler::Start ); qint64 beg = m_ui->rulerWidget->getMarker( PreviewRuler::Start );
qint64 end = m_ui->rulerWidget->getMarker( PreviewRuler::Stop ); qint64 end = m_ui->rulerWidget->getMarker( PreviewRuler::Stop );
...@@ -203,10 +206,8 @@ void PreviewWidget::createNewClipFromMarkers() ...@@ -203,10 +206,8 @@ void PreviewWidget::createNewClipFromMarkers()
return ; return ;
beg = beg < 0 ? 0 : beg; beg = beg < 0 ? 0 : beg;
Clip* part = new Clip( selectedMedia, beg, end ); Clip* part = new Clip( clip, beg, end );
//Adding the newly created clip to the media //Adding the newly created clip to the media
if ( selectedMedia->addClip( part ) == false ) clip->addSubclip( part );
delete part;
return ;
} }
...@@ -28,36 +28,23 @@ ...@@ -28,36 +28,23 @@
#include <math.h> #include <math.h>
TagWidget::TagWidget( QWidget *parent, int nbButton, QStringList tagList ) : TagWidget::TagWidget( QWidget *parent, int nbButton, QStringList tagList ) :
QWidget( parent ), m_ui( new Ui::TagWidget ), m_nbButton( nbButton ), m_defaultTagList( tagList ), m_currentMedia( NULL ) QWidget( parent ),
m_ui( new Ui::TagWidget ),
m_nbButton( nbButton ),
m_defaultTagList( tagList ),
m_currentClip( NULL )
{ {
m_ui->setupUi( this ); m_ui->setupUi( this );
m_defaultTagList << "OutDoor" << "Hollidays" << "Seaside" << "Sunset" << "Familly"; m_defaultTagList << "OutDoor" << "Hollidays" << "Seaside" << "Sunset" << "Familly";
// int nbRow = sqrt( nbButton );
// int x = 0;
// int y = 0;
//
// for( int i = 0; i < nbButton; i++ )
// {
// if ( x == nbRow )
// {
// x = 0;
// y++;
// }
// QPushButton* button = new QPushButton();
// button->setCheckable( true );
// connect( button, SIGNAL( clicked() ), this, SLOT( buttonTagClicked() ) );
// m_buttonList.append( button );
// m_ui->buttonGridLayout->addWidget( button, x++, y );
// }
for( int i = 0; i < m_defaultTagList.count(); i++ ) for( int i = 0; i < m_defaultTagList.count(); i++ )
{
if ( i < m_buttonList.count() ) if ( i < m_buttonList.count() )
{ {
static_cast<QPushButton*>( m_buttonList[i])->setText( m_defaultTagList[i] ); static_cast<QPushButton*>( m_buttonList[i])->setText( m_defaultTagList[i] );
static_cast<QPushButton*>( m_buttonList[i])->setEnabled( false ); static_cast<QPushButton*>( m_buttonList[i])->setEnabled( false );
} }
}
connect( m_ui->TagTextEdit, SIGNAL( textChanged() ), this, SLOT( setMetaTags() ) ); connect( m_ui->TagTextEdit, SIGNAL( textChanged() ), this, SLOT( setMetaTags() ) );
} }
...@@ -66,14 +53,14 @@ TagWidget::~TagWidget() ...@@ -66,14 +53,14 @@ TagWidget::~TagWidget()
delete m_ui; delete m_ui;
} }
void TagWidget::mediaSelected( Media* media ) void TagWidget::clipSelected( Clip* clip )
{ {
m_currentMedia = media; m_currentClip = clip;
setTagTextEdit(); setTagTextEdit();
for (int i = 0; i < m_buttonList.count(); i++) for (int i = 0; i < m_buttonList.count(); i++)
{ {
static_cast<QPushButton*>( m_buttonList[i])->setEnabled( true ); static_cast<QPushButton*>( m_buttonList[i])->setEnabled( true );
if ( m_currentMedia->metaTags().contains( static_cast<QPushButton*>(m_buttonList[i])->text() ) ) if ( m_currentClip->metaTags().contains( static_cast<QPushButton*>(m_buttonList[i])->text() ) )
static_cast<QPushButton*>(m_buttonList[i])->setChecked( true ); static_cast<QPushButton*>(m_buttonList[i])->setChecked( true );
else else
static_cast<QPushButton*>(m_buttonList[i])->setChecked( false ); static_cast<QPushButton*>(m_buttonList[i])->setChecked( false );
...@@ -82,18 +69,18 @@ void TagWidget::mediaSelected( Media* media ) ...@@ -82,18 +69,18 @@ void TagWidget::mediaSelected( Media* media )
void TagWidget::setMetaTags() void TagWidget::setMetaTags()
{ {
if ( m_currentMedia != NULL ) if ( m_currentClip != NULL )
{ {
QStringList tagList = m_ui->TagTextEdit->document()->toPlainText().split( ",", QString::SkipEmptyParts ); QStringList tagList = m_ui->TagTextEdit->document()->toPlainText().split( ",", QString::SkipEmptyParts );
m_currentMedia->setMetaTags( tagList ); m_currentClip->setMetaTags( tagList );
} }
} }
void TagWidget:: buttonTagClicked() void TagWidget:: buttonTagClicked()
{ {
if ( m_currentMedia != NULL ) if ( m_currentClip != NULL )
{ {
QStringList tagList = m_currentMedia->metaTags(); QStringList tagList = m_currentClip->metaTags();
for (int i = 0; i < m_buttonList.count(); i++) for (int i = 0; i < m_buttonList.count(); i++)
{ {
QPushButton* button = static_cast<QPushButton*>(m_buttonList[i]); QPushButton* button = static_cast<QPushButton*>(m_buttonList[i]);
...@@ -102,7 +89,7 @@ void TagWidget:: buttonTagClicked() ...@@ -102,7 +89,7 @@ void TagWidget:: buttonTagClicked()
else if ( !button->isChecked() && tagList.contains( button->text() ) ) else if ( !button->isChecked() && tagList.contains( button->text() ) )
tagList.removeAll( button->text() ); tagList.removeAll( button->text() );
} }
m_currentMedia->setMetaTags( tagList ); m_currentClip->setMetaTags( tagList );
setTagTextEdit(); setTagTextEdit();
} }
} }
...@@ -110,13 +97,15 @@ void TagWidget:: buttonTagClicked() ...@@ -110,13 +97,15 @@ void TagWidget:: buttonTagClicked()
void TagWidget::setTagTextEdit() void TagWidget::setTagTextEdit()
{ {
QString tags; QString tags;
if ( m_currentMedia != NULL ) if ( m_currentClip != NULL )
{ {
for( int i = 0; i < m_currentMedia->metaTags().count(); i++ ) for( int i = 0; i < m_currentClip->metaTags().count(); i++ )
{
if (i == 0) if (i == 0)
tags += m_currentMedia->metaTags()[i]; tags += m_currentClip->metaTags()[i];
else else
tags += "," + m_currentMedia->metaTags()[i]; tags += "," + m_currentClip->metaTags()[i];
}
m_ui->TagTextEdit->setText(tags); m_ui->TagTextEdit->setText(tags);
setButtonList( m_defaultTagList ); setButtonList( m_defaultTagList );
} }
...@@ -124,10 +113,14 @@ void TagWidget::setTagTextEdit() ...@@ -124,10 +113,14 @@ void TagWidget::setTagTextEdit()
void TagWidget::setButtonList( QStringList tagList ) void TagWidget::setButtonList( QStringList tagList )
{ {
if ( m_currentMedia != NULL ) if ( m_currentClip != NULL )
{
for( int i = 0; i < tagList.count(); i++ ) for( int i = 0; i < tagList.count(); i++ )
{
if ( i < m_buttonList.count() ) if ( i < m_buttonList.count() )
static_cast<QPushButton*>( m_buttonList[i] )->setText( tagList[i] ); static_cast<QPushButton*>( m_buttonList[i] )->setText( tagList[i] );
}
}
} }
void TagWidget::changeEvent( QEvent *e ) void TagWidget::changeEvent( QEvent *e )
......
...@@ -55,10 +55,10 @@ class TagWidget : public QWidget ...@@ -55,10 +55,10 @@ class TagWidget : public QWidget
int m_nbButton; int m_nbButton;
QStringList m_defaultTagList; QStringList m_defaultTagList;
QWidgetList m_buttonList; QWidgetList m_buttonList;
Media* m_currentMedia; Clip *m_currentClip;
public slots: public slots:
void mediaSelected( Media* media ); void clipSelected( Clip* clip );
void buttonTagClicked(); void buttonTagClicked();
void setMetaTags(); void setMetaTags();
}; };
......
...@@ -92,12 +92,9 @@ ImportController::ImportController(QWidget *parent) : ...@@ -92,12 +92,9 @@ ImportController::ImportController(QWidget *parent) :
SLOT( setClip( Clip* ) ) ); SLOT( setClip( Clip* ) ) );
connect( m_mediaListController, SIGNAL( clipSelected( Clip* ) ), connect( m_mediaListController, SIGNAL( clipSelected( Clip* ) ),
this, SLOT( mediaSelection( Clip* ) ) ); this, SLOT( mediaSelection( Clip* ) ) );
connect( m_mediaListController, SIGNAL( clipDeleted( const QUuid& ) ), connect( m_mediaListController, SIGNAL( clipDeleted( const QUuid& ) ),
this, SLOT( mediaDeletion( const QUuid& ) ) ); qobject_cast<const ClipRenderer*>( m_preview->getGenericRenderer() ),
SLOT( clipUnloaded( const QUuid& ) ) );
connect( m_stackNav, SIGNAL( previousButtonPushed() ),
this, SLOT( restoreContext() ) );
connect( MetaDataManager::getInstance(), SIGNAL( failedToCompute( Media* ) ), connect( MetaDataManager::getInstance(), SIGNAL( failedToCompute( Media* ) ),
this, SLOT( failedToLoad( Media* ) ) ); this, SLOT( failedToLoad( Media* ) ) );
...@@ -131,12 +128,12 @@ ImportController::mediaSelection( Clip* clip ) ...@@ -131,12 +128,12 @@ ImportController::mediaSelection( Clip* clip )
const QUuid& uuid = clip->uuid(); const QUuid& uuid = clip->uuid();
if ( m_currentUuid == uuid ) if ( m_currentUuid == uuid )
return ; return ;
Media* media = m_temporaryMedias->media( uuid ); Media* media = clip->rootClip()->getMedia();
setUIMetaData( media->baseClip() ); setUIMetaData( clip->rootClip() );
m_preview->stop(); m_preview->stop();
m_currentUuid = uuid; m_currentUuid = uuid;
m_tag->mediaSelected( media ); m_tag->clipSelected( clip );
emit clipSelected( media->baseClip() ); emit clipSelected( clip );
} }
void void
...@@ -163,14 +160,14 @@ ImportController::setUIMetaData( Clip* clip ) ...@@ -163,14 +160,14 @@ ImportController::setUIMetaData( Clip* clip )
duration = duration.addSecs( clip->lengthSecond() ); duration = duration.addSecs( clip->lengthSecond() );
m_ui->durationValueLabel->setText( duration.toString( "hh:mm:ss" ) ); m_ui->durationValueLabel->setText( duration.toString( "hh:mm:ss" ) );
//Filename || title //Filename || title
m_ui->nameValueLabel->setText( clip->getParent()->fileInfo()->fileName() ); m_ui->nameValueLabel->setText( clip->getMedia()->fileInfo()->fileName() );
m_ui->nameValueLabel->setWordWrap( true ); m_ui->nameValueLabel->setWordWrap( true );
setWindowTitle( clip->getParent()->fileInfo()->fileName() + " " + tr( "properties" ) ); setWindowTitle( clip->getMedia()->fileInfo()->fileName() + " " + tr( "properties" ) );
//Resolution //Resolution
m_ui->resolutionValueLabel->setText( QString::number( clip->getParent()->width() ) m_ui->resolutionValueLabel->setText( QString::number( clip->getMedia()->width() )
+ " x " + QString::number( clip->getParent()->height() ) ); + " x " + QString::number( clip->getMedia()->height() ) );
//FPS //FPS
m_ui->fpsValueLabel->setText( QString::number( clip->getParent()->fps() ) ); m_ui->fpsValueLabel->setText( QString::number( clip->getMedia()->fps() ) );
} }
else else
{ {
...@@ -186,15 +183,8 @@ ImportController::importMedia( const QString &filePath ) ...@@ -186,15 +183,8 @@ ImportController::importMedia( const QString &filePath )
{ {
++m_nbMediaToLoad; ++m_nbMediaToLoad;
m_ui->progressBar->setMaximum( m_nbMediaToLoad ); m_ui->progressBar->setMaximum( m_nbMediaToLoad );
if ( m_temporaryMedias->mediaAlreadyLoaded( filePath ) == true ||
Library::getInstance()->mediaAlreadyLoaded( filePath ) == true )
return ;
Media* media = new Media( filePath ); m_temporaryMedias->addMedia( filePath );
connect( media, SIGNAL( snapshotComputed( const Media* ) ),
this, SLOT( mediaLoaded() ) );
m_temporaryMedias->addMedia( media );
MetaDataManager::getInstance()->computeMediaMetadata( media );
} }
void void
...@@ -268,8 +258,8 @@ ImportController::accept() ...@@ -268,8 +258,8 @@ ImportController::accept()
m_mediaListController->clear(); m_mediaListController->clear();
m_preview->stop(); m_preview->stop();
collapseAllButCurrentPath(); collapseAllButCurrentPath();
foreach ( Media* media, m_temporaryMedias->medias().values() ) foreach ( Clip* clip, m_temporaryMedias->clips().values() )
Library::getInstance()->addMedia( media ); Library::getInstance()->addMedia( clip->getMedia() );
m_temporaryMedias->removeAll(); m_temporaryMedias->removeAll();
done( Accepted ); done( Accepted );
} }
...@@ -289,49 +279,6 @@ ImportController::collapseAllButCurrentPath() ...@@ -289,49 +279,6 @@ ImportController::collapseAllButCurrentPath()
m_ui->forwardButton->setEnabled( true ); m_ui->forwardButton->setEnabled( true );
} }
void
ImportController::mediaDeletion( const QUuid& uuid )
{
m_temporaryMedias->deleteMedia( uuid );
if ( uuid == m_currentUuid )
{
setUIMetaData( NULL );
m_currentUuid = QUuid();
m_preview->stop();
}
}
void
ImportController::clipDeletion( const QUuid& uuid )
{
m_temporaryMedias->removeClip( uuid );
}
void
ImportController::showClipList( const QUuid& uuid )
{
Media* media = m_temporaryMedias->media( uuid );
if ( media == NULL || media->clipsCount() == 0 )
return ;
m_clipListController = new MediaListViewController( m_stackNav, m_temporaryMedias );
connect( m_clipListController, SIGNAL( clipSelected( const QUuid& ) ),
this, SLOT( clipSelection( const QUuid& ) ) );
connect( m_clipListController, SIGNAL( clipDeleted( const QUuid& ) ),
this, SLOT( clipDeletion( const QUuid& ) ) );
if ( !m_currentUuid.isNull() )
m_savedUuid = m_currentUuid;
m_stackNav->pushViewController( m_clipListController );
}
void
ImportController::restoreContext()
{
qDebug() << "FIXME: update clip count";
m_currentUuid = m_savedUuid;
}
void void
ImportController::saveCurrentPath() ImportController::saveCurrentPath()
{ {
...@@ -376,7 +323,8 @@ ImportController::failedToLoad( Media *media ) ...@@ -376,7 +323,8 @@ ImportController::failedToLoad( Media *media )
m_ui->errorLabelImg->show(); m_ui->errorLabelImg->show();
m_ui->errorLabel->show(); m_ui->errorLabel->show();
QTimer::singleShot( 3000, this, SLOT( hideErrors() ) ); QTimer::singleShot( 3000, this, SLOT( hideErrors() ) );
mediaDeletion( media->baseClip()->uuid() ); delete m_temporaryMedias->removeClip( media->baseClip() );
delete media;
} }
void void
......
...@@ -89,10 +89,6 @@ class ImportController : public QDialog ...@@ -89,10 +89,6 @@ class ImportController : public QDialog
void reject(); void reject();
void mediaSelection( Clip* clip ); void mediaSelection( Clip* clip );
void clipSelection( const QUuid& uuid ); void clipSelection( const QUuid& uuid );
void mediaDeletion( const QUuid& uuid );
void clipDeletion( const QUuid& uuid );
void showClipList( const QUuid& uuid );
void restoreContext();
private slots: private slots:
void forwardButtonClicked(); void forwardButtonClicked();
......
...@@ -40,35 +40,29 @@ MediaCellView::MediaCellView( Clip* clip, QWidget *parent ) : ...@@ -40,35 +40,29 @@ MediaCellView::MediaCellView( Clip* clip, QWidget *parent ) :
setAutoFillBackground( true ); setAutoFillBackground( true );
connect( m_ui->delLabel, SIGNAL( clicked( QWidget*, QMouseEvent* ) ), connect( m_ui->delLabel, SIGNAL( clicked( QWidget*, QMouseEvent* ) ),
this, SLOT( deleteButtonClicked( QWidget*, QMouseEvent* ) ) ); this, SLOT( deleteButtonClicked( QWidget*, QMouseEvent* ) ) );
if ( clip->isRootClip() == true ) connect( m_ui->arrow,
{ SIGNAL( clicked( QWidget*, QMouseEvent* ) ),
connect( m_ui->arrow, SLOT( arrowButtonClicked( QWidget*, QMouseEvent* ) ) );
SIGNAL( clicked( QWidget*, QMouseEvent* ) ), m_ui->clipCount->setText( QString::number( clip->getChilds()->count() ) );
SLOT( arrowButtonClicked( QWidget*, QMouseEvent* ) ) ); connect( clip->getChilds(), SIGNAL( newClipLoaded( Clip* ) ),
m_ui->clipCount->setText( QString::number( clip->getParent()->clipsCount() ) ); this, SLOT( nbClipUpdated( Clip* ) ) );
connect( clip->getParent(), SIGNAL( clipAdded(Clip*) ), connect( clip->getChilds(), SIGNAL( clipRemoved( const Clip* ) ),
this, SLOT( nbClipUpdated( Clip* ) ) ); this, SLOT( nbClipUpdated( const Clip* ) ) );
connect( clip->getParent(), SIGNAL( clipRemoved( Clip* ) ), if ( clip->getChilds()->count() == 0 )
this, SLOT( nbClipUpdated( Clip* ) ) );
}
else
{ {
m_ui->clipCount->hide(); m_ui->clipCount->hide();
m_ui->clipCountLabel->hide(); m_ui->clipCountLabel->hide();
m_ui->arrow->hide(); m_ui->arrow->hide();
disconnect( m_ui->arrow,
SIGNAL( clicked( QWidget*, QMouseEvent* ) ), this,
SLOT( arrowButtonClicked( QWidget*, QMouseEvent* ) ) );
} }
if ( clip->getParent()->isMetadataComputed() == false ) if ( clip->getMedia()->isMetadataComputed() == false )
setEnabled( false ); setEnabled( false );
connect( clip->getParent(), SIGNAL( metaDataComputed(const Media*) ), connect( clip->getMedia(), SIGNAL( metaDataComputed(const Media*) ),
this, SLOT( metadataUpdated( const Media*) ) ); this, SLOT( metadataUpdated( const Media*) ) );
connect( clip->getParent(), SIGNAL( snapshotComputed(const Media*) ), connect( clip->getMedia(), SIGNAL( snapshotComputed(const Media*) ),
this, SLOT( snapshotUpdated(const Media*) ) ); this, SLOT( snapshotUpdated(const Media*) ) );
setThumbnail( clip->getParent()->snapshot() ); setThumbnail( clip->getMedia()->snapshot() );
setTitle( clip->getParent()->fileName() ); setTitle( clip->getMedia()->fileName() );
setLength( clip->lengthSecond() * 1000 ); setLength( clip->lengthSecond() * 1000 );
} }
...@@ -108,9 +102,30 @@ void MediaCellView::setTitle( const QString& title ) ...@@ -108,9 +102,30 @@ void MediaCellView::setTitle( const QString& title )
m_ui->title->setText( title ); m_ui->title->setText( title );
} }
void MediaCellView::nbClipUpdated( Clip *clip ) void
MediaCellView::nbClipUpdated( Clip *clip )
{ {
m_ui->clipCount->setText( QString::number( clip->getParent()->clipsCount() ) ); nbClipUpdated( const_cast<const Clip*>( clip ) );
}
void MediaCellView::nbClipUpdated( const Clip *clip )
{
quint32 nbClips = clip->getParent()->getChilds()->count();
if ( nbClips == 0 )
{
m_ui->clipCount->hide();
m_ui->clipCountLabel->hide();
m_ui->arrow->hide();
m_ui->clipCount->setText( "0" );
}
else
{
m_ui->clipCount->show();
m_ui->clipCountLabel->show();
m_ui->arrow->show();
m_ui->clipCount->setText( QString::number( nbClips ) );
}
} }
void void
...@@ -167,14 +182,14 @@ void MediaCellView::mouseMoveEvent( QMouseEvent* event ) ...@@ -167,14 +182,14 @@ void MediaCellView::mouseMoveEvent( QMouseEvent* event )
mimeData->setData( "vlmc/uuid", m_clip->uuid().toString().toAscii() ); mimeData->setData( "vlmc/uuid", m_clip->uuid().toString().toAscii() );
QDrag* drag = new QDrag( this ); QDrag* drag = new QDrag( this );
drag->setMimeData( mimeData ); drag->setMimeData( mimeData );
const Media* parent = m_clip->getParent(); const Media* parent = m_clip->getMedia();
drag->setPixmap( parent->snapshot().scaled( 100, 100, Qt::KeepAspectRatio ) ); drag->setPixmap( parent->snapshot().scaled( 100, 100, Qt::KeepAspectRatio ) );
drag->exec( Qt::CopyAction | Qt::MoveAction, Qt::CopyAction );