Commit e498c3ed authored by Clement CHAVANCE's avatar Clement CHAVANCE

clip count is now updated in the mediaLibrary

parent ebdf2f8d
......@@ -30,7 +30,8 @@ ClipListViewController::ClipListViewController( StackViewController* nav, const
: ListViewController( nav ),
m_nav( nav ),
m_mediaId( mediaId ),
m_currentUuid()
m_currentUuid(),
m_deletion( 0 )
{
}
......@@ -44,6 +45,11 @@ void ClipListViewController::addClipsFromMedia( Media* media )
addClip( clip );
}
const int ClipListViewController::getNbDeletion() const
{
return m_deletion;
}
void ClipListViewController::addClip( Clip* clip )
{
MediaCellView* cell = new MediaCellView( clip->getUuid() );
......@@ -90,6 +96,7 @@ void ClipListViewController::clipDeletion( const QUuid& uuid )
{
if ( m_cells.contains( uuid ) )
{
++m_deletion;
QWidget* cell = m_cells.value( uuid );
removeCell( cell );
m_cells.remove( uuid );
......
......@@ -35,6 +35,7 @@ class ClipListViewController : public ListViewController
~ClipListViewController();
void addClipsFromMedia( Media* media );
const int getNbDeletion() const;
private:
void addClip( Clip* clip );
......@@ -43,6 +44,7 @@ class ClipListViewController : public ListViewController
QHash<QUuid, QWidget*> m_cells;
QUuid m_mediaId;
QUuid m_currentUuid;
int m_deletion;
public slots:
void cellSelection( const QUuid& uuid );
......
......@@ -165,3 +165,21 @@ void MediaCellView::setLength( qint64 length, bool mSecs )
duration = duration.addSecs( length );
m_ui->length->setText( duration.toString( "hh:mm:ss" ) );
}
void MediaCellView::incrementClipCount()
{
int clips = m_ui->clipCount->text().toInt();
clips += 1;
m_ui->clipCount->setText( QString::number( clips ) );
}
void MediaCellView::decrementClipCount( const int nb )
{
int clips = m_ui->clipCount->text().toInt();
clips -= nb;
if ( clips < 0 )
clips = 0;
m_ui->clipCount->setText( QString::number( clips ) );
}
......@@ -49,6 +49,8 @@ public:
* \param length The media length, in ms.
*/
void setLength( qint64 length, bool mSecs = true );
void incrementClipCount();
void decrementClipCount( const int nb );
QString title() const;
const QUuid& uuid() const;
const ClickableLabel* nextButton() const;
......
......@@ -40,6 +40,7 @@ MediaLibraryWidget::MediaLibraryWidget( QWidget* parent ) : QWidget( parent )
//Clip
//connect( list, SIGNAL( clipSelected( Clip* clip ) ), this, SIGNAL( clipSelected( Clip* ) ) );
//connect( list, SIGNAL( clipRemoved( const QUuid&, const QUuid& ) ), library, SLOT( removeClip( const QUuid&, const QUuid& ) ) );
connect( this, SIGNAL( addClipToViewController( Clip* ) ), list, SLOT( newClipAdded( Clip* ) ) );
m_nav->pushViewController( list );
}
......@@ -56,6 +57,7 @@ const ViewController* MediaLibraryWidget::getCurrentViewController()
void MediaLibraryWidget::clipAdded( Clip* clip )
{
Library::getInstance()->addClip( clip );
emit addClipToViewController( clip );
}
void MediaLibraryWidget::mediaSelection( Media* media )
......
......@@ -53,6 +53,7 @@ signals:
void mediaSelected( Media* media );
void clipSelected( Clip* clip );
void importRequired();
void addClipToViewController( Clip* clip );
};
#endif // MEDIALIBRARYWIDGET_H
......@@ -25,10 +25,11 @@
#include <QDebug>
MediaListViewController::MediaListViewController( StackViewController* nav ) :
ListViewController( nav ), m_nav( nav )
ListViewController( nav ), m_nav( nav ), m_clipsListView( 0 )
{
connect(Library::getInstance(), SIGNAL( newMediaLoaded( Media* ) ), this, SLOT( newMediaLoaded( Media* ) ) );
m_cells = new QHash<QUuid, QWidget*>();
connect( m_nav, SIGNAL( previousButtonPushed() ), this, SLOT( restoreContext() ) );
}
MediaListViewController::~MediaListViewController()
......@@ -36,6 +37,7 @@ MediaListViewController::~MediaListViewController()
delete m_cells;
}
void MediaListViewController::newMediaLoaded( Media* media )
{
MediaCellView* cell = new MediaCellView( media->getUuid() );
......@@ -92,18 +94,45 @@ void MediaListViewController::updateCell( Media* media )
void MediaListViewController::showClipList( const QUuid& uuid )
{
qDebug() << Library::getInstance()->getMedia( uuid )->clips()->size();
if ( Library::getInstance()->getMedia( uuid )->clips()->size() == 0 )
return ;
m_clipsListView = new ClipListViewController( m_nav, uuid );
m_clipsListView->addClipsFromMedia( Library::getInstance()->getMedia( uuid ) );
connect( m_clipsListView, SIGNAL( clipSelected( const QUuid& ) ), this, SIGNAL( clipSelected( const QUuid& ) ) );
if ( m_lastUuidClipListAsked != uuid )
{
m_lastUuidClipListAsked = m_currentUuid;
if ( m_clipsListView != 0 )
delete m_clipsListView;
m_clipsListView = new ClipListViewController( m_nav, uuid );
m_clipsListView->addClipsFromMedia( Library::getInstance()->getMedia( uuid ) );
connect( m_clipsListView, SIGNAL( clipSelected( const QUuid& ) ), this, SIGNAL( clipSelected( const QUuid& ) ) );
}
m_nav->pushViewController( m_clipsListView );
}
void MediaListViewController::newClipAdded( Clip* clip )
{
if ( clip->getParent() == 0 )
return ;
const QUuid& uuid = clip->getParent()->getUuid();
if ( m_cells->contains( uuid ) )
{
MediaCellView* cell = dynamic_cast<MediaCellView*>( m_cells->value( uuid, 0 ) );
if ( cell != 0 )
cell->incrementClipCount();
}
}
void MediaListViewController::restoreContext()
{
if ( m_clipsListView != 0 )
delete m_clipsListView;
m_clipsListView = 0;
qDebug() << "current uuid" << m_currentUuid;
if ( m_clipsListView->getNbDeletion() != 0 )
{
qDebug() << "cells :" << m_cells;
if ( m_cells->contains( m_currentUuid ) )
{
MediaCellView* cell = dynamic_cast<MediaCellView*>( m_cells->value( m_currentUuid, 0 ) );
if ( cell != 0 )
cell->decrementClipCount( m_clipsListView->getNbDeletion() );
}
}
}
......@@ -17,10 +17,12 @@ public:
virtual ~MediaListViewController();
private:
void updateClipCount();
StackViewController* m_nav;
QUuid m_currentUuid;
QHash<QUuid, QWidget*>* m_cells;
ClipListViewController* m_clipsListView;
QUuid m_lastUuidClipListAsked;
public slots:
void newMediaLoaded( Media* );
......@@ -29,9 +31,10 @@ public slots:
void mediaRemoved( const QUuid& uuid );
void updateCell( Media* media );
void showClipList( const QUuid& uuid );
void newClipAdded( Clip* clip );
private slots:
void restoreContext();
private slots:
void restoreContext();
signals:
void mediaSelected( Media* media );
void mediaDeleted( const QUuid& uuid );
......
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