Commit 4f66175b authored by Hugo Beauzee-Luyssen's avatar Hugo Beauzee-Luyssen

MediaCellView: Unbreak the way clip count should be handled.

This doesn't restore the functionnality yet.
parent 48db69f0
......@@ -38,24 +38,46 @@ MediaCellView::MediaCellView( Clip* clip, QWidget *parent ) :
setAutoFillBackground( true );
connect( m_ui->delLabel, SIGNAL( clicked( QWidget*, QMouseEvent* ) ),
this, SLOT( deleteButtonClicked( QWidget*, QMouseEvent* ) ) );
connect( m_ui->arrow,
SIGNAL( clicked( QWidget*, QMouseEvent* ) ),
SLOT( arrowButtonClicked( QWidget*, QMouseEvent* ) ) );
if ( clip->isBaseClip() == true )
{
connect( m_ui->arrow,
SIGNAL( clicked( QWidget*, QMouseEvent* ) ),
SLOT( arrowButtonClicked( QWidget*, QMouseEvent* ) ) );
m_ui->clipCount->setText( QString::number( clip->getParent()->clipsCount() ) );
connect( clip->getParent(), SIGNAL( clipAdded(Clip*) ),
this, SLOT( nbClipUpdated( Clip* ) ) );
connect( clip->getParent(), SIGNAL( clipRemoved( Clip* ) ),
this, SLOT( nbClipUpdated( Clip* ) ) );
}
else
{
m_ui->clipCount->hide();
m_ui->clipCountLabel->hide();
m_ui->arrow->hide();
disconnect( m_ui->arrow,
SIGNAL( clicked( QWidget*, QMouseEvent* ) ), this,
SLOT( arrowButtonClicked( QWidget*, QMouseEvent* ) ) );
}
if ( clip->getParent()->isMetadataComputed() == false )
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*) ) );
setThumbnail( clip->getParent()->snapshot() );
setTitle( clip->getParent()->fileName() );
setLength( clip->lengthSecond() * 1000 );
}
MediaCellView::~MediaCellView()
{
delete m_ui;
}
void
MediaCellView::metadataUpdated( const Media *media )
{
setNbClips( media->clipsCount() );
setLength( media->lengthMS() );
setEnabled( true );
}
......@@ -66,11 +88,6 @@ MediaCellView::snapshotUpdated( const Media *media )
setThumbnail( media->snapshot() );
}
MediaCellView::~MediaCellView()
{
delete m_ui;
}
void MediaCellView::changeEvent( QEvent *e )
{
QWidget::changeEvent( e );
......@@ -89,9 +106,9 @@ void MediaCellView::setTitle( const QString& title )
m_ui->title->setText( title );
}
void MediaCellView::setNbClips( int nbClip )
void MediaCellView::nbClipUpdated( Clip *clip )
{
m_ui->clipCount->setText( QString::number( nbClip ) );
m_ui->clipCount->setText( QString::number( clip->getParent()->clipsCount() ) );
}
void
......@@ -194,12 +211,7 @@ void MediaCellView::decrementClipCount( const int nb )
void
MediaCellView::containsClip()
{
m_ui->clipCount->hide();
m_ui->clipCountLabel->hide();
m_ui->arrow->hide();
disconnect( m_ui->arrow,
SIGNAL( clicked( QWidget*, QMouseEvent* ) ), this,
SLOT( arrowButtonClicked( QWidget*, QMouseEvent* ) ) );
}
const QUuid&
......
......@@ -45,7 +45,6 @@ public:
~MediaCellView();
void setTitle( const QString& title );
void setNbClips( int nbClip );
void setThumbnail( const QPixmap& pixmap );
const QPixmap* getThumbnail() const;
/**
......@@ -84,6 +83,8 @@ public slots:
private slots:
void snapshotUpdated( const Media *media );
void metadataUpdated( const Media *media );
void nbClipUpdated( Clip *clip );
};
#endif // MEDIACELLVIEW_H
......@@ -54,7 +54,6 @@ void MediaListViewController::newMediaLoaded( Media* media )
this, SLOT( showClipList( const QUuid& ) ) );
connect( media, SIGNAL( clipAdded( Clip* ) ),
this, SLOT( newClipAdded(Clip*) ) );
cell->setNbClips( media->clipsCount() );
addCell(cell);
m_cells->insert( media->baseClip()->uuid(), cell );
}
......
......@@ -236,3 +236,9 @@ Clip::maxEnd() const
{
return m_maxEnd;
}
bool
Clip::isBaseClip() const
{
return ( m_parent->baseClip() == this );
}
......@@ -115,6 +115,8 @@ class Clip : public QObject
void computeLength();
bool isBaseClip() const;
private:
Media *m_parent;
/**
......
......@@ -291,9 +291,12 @@ Media::clips() const
return m_clips;
}
void Media::removeClip( const QUuid& uuid )
Clip*
Media::removeClip( const QUuid& uuid )
{
m_clips.remove( uuid );
Clip* clip = m_clips.take( uuid );
emit clipRemoved( clip );
return clip;
}
bool
......
......@@ -138,7 +138,7 @@ public:
// bool hasMetadata() const;
bool addClip( Clip* clip );
void removeClip( const QUuid& uuid );
Clip *removeClip( const QUuid& uuid );
Clip* clip( const QUuid& uuid );
quint32 clipsCount() const;
const QHash<QUuid, Clip*> &clips() const;
......@@ -181,6 +181,7 @@ signals:
void snapshotComputed( const Media* );
void audioSpectrumComputed( const QUuid& );
void clipAdded( Clip* );
void clipRemoved( Clip* );
};
#endif // CLIP_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