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 ) :
//Duration
ui->durationValueLabel->setText( duration.toString( "hh:mm:ss" ) );
//Filename || title
ui->nameValueLabel->setText( m_clip->getParent()->fileInfo()->fileName() );
setWindowTitle( m_clip->getParent()->fileInfo()->fileName() + " " + tr( "properties" ) );
ui->nameValueLabel->setText( m_clip->getMedia()->fileInfo()->fileName() );
setWindowTitle( m_clip->getMedia()->fileInfo()->fileName() + " " + tr( "properties" ) );
//Resolution
ui->resolutionValueLabel->setText( QString::number( m_clip->getParent()->width() )
+ " x " + QString::number( m_clip->getParent()->height() ) );
ui->resolutionValueLabel->setText( QString::number( m_clip->getMedia()->width() )
+ " x " + QString::number( m_clip->getMedia()->height() ) );
//FPS
ui->fpsValueLabel->setText( QString::number( m_clip->getParent()->fps() ) );
ui->fpsValueLabel->setText( QString::number( m_clip->getMedia()->fps() ) );
//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 :
ui->nbVideoTracksValueLabel->setText(
QString::number( m_clip->getParent()->nbVideoTracks() ) );
QString::number( m_clip->getMedia()->nbVideoTracks() ) );
ui->nbAudioTracksValueLabel->setText(
QString::number( m_clip->getParent()->nbAudioTracks() ) );
QString::number( m_clip->getMedia()->nbAudioTracks() ) );
//Metatags
const QPushButton* button = ui->buttonBox->button( QDialogButtonBox::Apply );
Q_ASSERT( button != NULL);
......
......@@ -229,6 +229,8 @@ void MainWindow::setupLibrary()
MediaLibraryWidget* mediaLibraryWidget = new MediaLibraryWidget( this );
m_importController = new ImportController();
const ClipRenderer* clipRenderer = qobject_cast<const ClipRenderer*>( m_clipPreview->getGenericRenderer() );
Q_ASSERT( clipRenderer != NULL );
DockWidgetManager::instance()->addDockedWidget( mediaLibraryWidget,
tr( "Media Library" ),
......@@ -236,13 +238,13 @@ void MainWindow::setupLibrary()
QDockWidget::AllDockWidgetFeatures,
Qt::LeftDockWidgetArea );
connect( mediaLibraryWidget, SIGNAL( clipSelected( Clip* ) ),
qobject_cast<const ClipRenderer*>( m_clipPreview->getGenericRenderer() ),
SLOT( setClip( Clip* ) ) );
clipRenderer, SLOT( setClip( Clip* ) ) );
connect( Library::getInstance(), SIGNAL( mediaRemoved( const QUuid& ) ),
m_clipPreview->getGenericRenderer(), SLOT( mediaUnloaded( QUuid ) ) );
connect( Library::getInstance(), SIGNAL( clipRemoved( const Clip* ) ),
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()
......
......@@ -190,8 +190,11 @@ void PreviewWidget::markerStopClicked()
void PreviewWidget::createNewClipFromMarkers()
{
Media* selectedMedia = m_renderer->getMedia();
if ( selectedMedia == NULL )
ClipRenderer* clipRenderer = qobject_cast<ClipRenderer*>( m_renderer );
Q_ASSERT( clipRenderer != NULL );
Clip* clip = clipRenderer->getClip();
if ( clip == NULL )
return ;
qint64 beg = m_ui->rulerWidget->getMarker( PreviewRuler::Start );
qint64 end = m_ui->rulerWidget->getMarker( PreviewRuler::Stop );
......@@ -203,10 +206,8 @@ void PreviewWidget::createNewClipFromMarkers()
return ;
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
if ( selectedMedia->addClip( part ) == false )
delete part;
return ;
clip->addSubclip( part );
}
......@@ -28,36 +28,23 @@
#include <math.h>
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_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++ )
{
if ( i < m_buttonList.count() )
{
static_cast<QPushButton*>( m_buttonList[i])->setText( m_defaultTagList[i] );
static_cast<QPushButton*>( m_buttonList[i])->setEnabled( false );
}
}
connect( m_ui->TagTextEdit, SIGNAL( textChanged() ), this, SLOT( setMetaTags() ) );
}
......@@ -66,14 +53,14 @@ TagWidget::~TagWidget()
delete m_ui;
}
void TagWidget::mediaSelected( Media* media )
void TagWidget::clipSelected( Clip* clip )
{
m_currentMedia = media;
m_currentClip = clip;
setTagTextEdit();
for (int i = 0; i < m_buttonList.count(); i++)
{
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 );
else
static_cast<QPushButton*>(m_buttonList[i])->setChecked( false );
......@@ -82,18 +69,18 @@ void TagWidget::mediaSelected( Media* media )
void TagWidget::setMetaTags()
{
if ( m_currentMedia != NULL )
if ( m_currentClip != NULL )
{
QStringList tagList = m_ui->TagTextEdit->document()->toPlainText().split( ",", QString::SkipEmptyParts );
m_currentMedia->setMetaTags( tagList );
m_currentClip->setMetaTags( tagList );
}
}
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++)
{
QPushButton* button = static_cast<QPushButton*>(m_buttonList[i]);
......@@ -102,7 +89,7 @@ void TagWidget:: buttonTagClicked()
else if ( !button->isChecked() && tagList.contains( button->text() ) )
tagList.removeAll( button->text() );
}
m_currentMedia->setMetaTags( tagList );
m_currentClip->setMetaTags( tagList );
setTagTextEdit();
}
}
......@@ -110,13 +97,15 @@ void TagWidget:: buttonTagClicked()
void TagWidget::setTagTextEdit()
{
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)
tags += m_currentMedia->metaTags()[i];
tags += m_currentClip->metaTags()[i];
else
tags += "," + m_currentMedia->metaTags()[i];
tags += "," + m_currentClip->metaTags()[i];
}
m_ui->TagTextEdit->setText(tags);
setButtonList( m_defaultTagList );
}
......@@ -124,10 +113,14 @@ void TagWidget::setTagTextEdit()
void TagWidget::setButtonList( QStringList tagList )
{
if ( m_currentMedia != NULL )
if ( m_currentClip != NULL )
{
for( int i = 0; i < tagList.count(); i++ )
{
if ( i < m_buttonList.count() )
static_cast<QPushButton*>( m_buttonList[i] )->setText( tagList[i] );
}
}
}
void TagWidget::changeEvent( QEvent *e )
......
......@@ -55,10 +55,10 @@ class TagWidget : public QWidget
int m_nbButton;
QStringList m_defaultTagList;
QWidgetList m_buttonList;
Media* m_currentMedia;
Clip *m_currentClip;
public slots:
void mediaSelected( Media* media );
void clipSelected( Clip* clip );
void buttonTagClicked();
void setMetaTags();
};
......
......@@ -92,12 +92,9 @@ ImportController::ImportController(QWidget *parent) :
SLOT( setClip( Clip* ) ) );
connect( m_mediaListController, SIGNAL( clipSelected( Clip* ) ),
this, SLOT( mediaSelection( Clip* ) ) );
connect( m_mediaListController, SIGNAL( clipDeleted( const QUuid& ) ),
this, SLOT( mediaDeletion( const QUuid& ) ) );
connect( m_stackNav, SIGNAL( previousButtonPushed() ),
this, SLOT( restoreContext() ) );
qobject_cast<const ClipRenderer*>( m_preview->getGenericRenderer() ),
SLOT( clipUnloaded( const QUuid& ) ) );
connect( MetaDataManager::getInstance(), SIGNAL( failedToCompute( Media* ) ),
this, SLOT( failedToLoad( Media* ) ) );
......@@ -131,12 +128,12 @@ ImportController::mediaSelection( Clip* clip )
const QUuid& uuid = clip->uuid();
if ( m_currentUuid == uuid )
return ;
Media* media = m_temporaryMedias->media( uuid );
setUIMetaData( media->baseClip() );
Media* media = clip->rootClip()->getMedia();
setUIMetaData( clip->rootClip() );
m_preview->stop();
m_currentUuid = uuid;
m_tag->mediaSelected( media );
emit clipSelected( media->baseClip() );
m_tag->clipSelected( clip );
emit clipSelected( clip );
}
void
......@@ -163,14 +160,14 @@ ImportController::setUIMetaData( Clip* clip )
duration = duration.addSecs( clip->lengthSecond() );
m_ui->durationValueLabel->setText( duration.toString( "hh:mm:ss" ) );
//Filename || title
m_ui->nameValueLabel->setText( clip->getParent()->fileInfo()->fileName() );
m_ui->nameValueLabel->setText( clip->getMedia()->fileInfo()->fileName() );
m_ui->nameValueLabel->setWordWrap( true );
setWindowTitle( clip->getParent()->fileInfo()->fileName() + " " + tr( "properties" ) );
setWindowTitle( clip->getMedia()->fileInfo()->fileName() + " " + tr( "properties" ) );
//Resolution
m_ui->resolutionValueLabel->setText( QString::number( clip->getParent()->width() )
+ " x " + QString::number( clip->getParent()->height() ) );
m_ui->resolutionValueLabel->setText( QString::number( clip->getMedia()->width() )
+ " x " + QString::number( clip->getMedia()->height() ) );
//FPS
m_ui->fpsValueLabel->setText( QString::number( clip->getParent()->fps() ) );
m_ui->fpsValueLabel->setText( QString::number( clip->getMedia()->fps() ) );
}
else
{
......@@ -186,15 +183,8 @@ ImportController::importMedia( const QString &filePath )
{
++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 );
connect( media, SIGNAL( snapshotComputed( const Media* ) ),
this, SLOT( mediaLoaded() ) );
m_temporaryMedias->addMedia( media );
MetaDataManager::getInstance()->computeMediaMetadata( media );
m_temporaryMedias->addMedia( filePath );
}
void
......@@ -268,8 +258,8 @@ ImportController::accept()
m_mediaListController->clear();
m_preview->stop();
collapseAllButCurrentPath();
foreach ( Media* media, m_temporaryMedias->medias().values() )
Library::getInstance()->addMedia( media );
foreach ( Clip* clip, m_temporaryMedias->clips().values() )
Library::getInstance()->addMedia( clip->getMedia() );
m_temporaryMedias->removeAll();
done( Accepted );
}
......@@ -289,49 +279,6 @@ ImportController::collapseAllButCurrentPath()
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
ImportController::saveCurrentPath()
{
......@@ -376,7 +323,8 @@ ImportController::failedToLoad( Media *media )
m_ui->errorLabelImg->show();
m_ui->errorLabel->show();
QTimer::singleShot( 3000, this, SLOT( hideErrors() ) );
mediaDeletion( media->baseClip()->uuid() );
delete m_temporaryMedias->removeClip( media->baseClip() );
delete media;
}
void
......
......@@ -89,10 +89,6 @@ class ImportController : public QDialog
void reject();
void mediaSelection( Clip* clip );
void clipSelection( const QUuid& uuid );
void mediaDeletion( const QUuid& uuid );
void clipDeletion( const QUuid& uuid );
void showClipList( const QUuid& uuid );
void restoreContext();
private slots:
void forwardButtonClicked();
......
......@@ -40,35 +40,29 @@ MediaCellView::MediaCellView( Clip* clip, QWidget *parent ) :
setAutoFillBackground( true );
connect( m_ui->delLabel, SIGNAL( clicked( QWidget*, QMouseEvent* ) ),
this, SLOT( deleteButtonClicked( QWidget*, QMouseEvent* ) ) );
if ( clip->isRootClip() == 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
connect( m_ui->arrow,
SIGNAL( clicked( QWidget*, QMouseEvent* ) ),
SLOT( arrowButtonClicked( QWidget*, QMouseEvent* ) ) );
m_ui->clipCount->setText( QString::number( clip->getChilds()->count() ) );
connect( clip->getChilds(), SIGNAL( newClipLoaded( Clip* ) ),
this, SLOT( nbClipUpdated( Clip* ) ) );
connect( clip->getChilds(), SIGNAL( clipRemoved( const Clip* ) ),
this, SLOT( nbClipUpdated( const Clip* ) ) );
if ( clip->getChilds()->count() == 0 )
{
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 )
if ( clip->getMedia()->isMetadataComputed() == false )
setEnabled( false );
connect( clip->getParent(), SIGNAL( metaDataComputed(const Media*) ),
connect( clip->getMedia(), SIGNAL( metaDataComputed(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*) ) );
setThumbnail( clip->getParent()->snapshot() );
setTitle( clip->getParent()->fileName() );
setThumbnail( clip->getMedia()->snapshot() );
setTitle( clip->getMedia()->fileName() );
setLength( clip->lengthSecond() * 1000 );
}
......@@ -108,9 +102,30 @@ void MediaCellView::setTitle( const QString& 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
......@@ -167,14 +182,14 @@ void MediaCellView::mouseMoveEvent( QMouseEvent* event )
mimeData->setData( "vlmc/uuid", m_clip->uuid().toString().toAscii() );
QDrag* drag = new QDrag( this );
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->exec( Qt::CopyAction | Qt::MoveAction, Qt::CopyAction );
}
void MediaCellView::deleteButtonClicked( QWidget*, QMouseEvent* )
{
emit cellDeleted( m_clip->uuid() );
emit cellDeleted( m_clip );
}
void MediaCellView::arrowButtonClicked( QWidget*, QMouseEvent* )
......@@ -192,12 +207,6 @@ void MediaCellView::setLength( qint64 length, bool mSecs )
m_ui->length->setText( duration.toString( "hh:mm:ss" ) );
}
void
MediaCellView::containsClip()
{
}
const QUuid&
MediaCellView::uuid() const
{
......
......@@ -53,7 +53,6 @@ public:
*/
void setLength( qint64 length, bool mSecs = true );
QString title() const;
void containsClip();
const QUuid& uuid() const;
protected:
......@@ -72,7 +71,7 @@ protected:
signals:
void cellSelected( const QUuid& uuid );
void arrowClicked( const QUuid& uuid );
void cellDeleted( const QUuid& uuid );
void cellDeleted( const Clip* );
public slots:
void deleteButtonClicked( QWidget* sender, QMouseEvent* event );
......@@ -81,6 +80,7 @@ public slots:
private slots:
void snapshotUpdated( const Media *media );
void metadataUpdated( const Media *media );
void nbClipUpdated( const Clip *clip );
void nbClipUpdated( Clip *clip );
};
......
......@@ -34,10 +34,10 @@ MediaLibraryWidget::MediaLibraryWidget( QWidget* parent ) : QWidget( parent )
m_nav = new StackViewController( this );
MediaListViewController* list = new MediaListViewController( m_nav, library );
//Media
connect( list, SIGNAL( clipSelected( Clip* ) ), this, SIGNAL( clipSelected( Clip* ) ) );
connect( list, SIGNAL( clipDeleted( const QUuid& ) ), library, SLOT( removingMediaAsked( const QUuid& ) ) );
connect( library, SIGNAL( mediaRemoved( QUuid ) ), list, SLOT( mediaRemoved( const QUuid& ) ) );
connect( m_nav, SIGNAL( importRequired() ), this, SIGNAL( importRequired() ) );
connect( list, SIGNAL( clipSelected( Clip* ) ),
this, SIGNAL( clipSelected( Clip* ) ) );
connect( m_nav, SIGNAL( importRequired() ),
this, SIGNAL( importRequired() ) );
m_nav->pushViewController( list );
setMinimumWidth( 280 );
}
......
......@@ -31,29 +31,33 @@ MediaListViewController::MediaListViewController( StackViewController* nav, Medi
m_clipsListView( 0 ),
m_mediaContainer( mc )
{
connect( mc, SIGNAL( newMediaLoaded( Media* ) ),
this, SLOT( newMediaLoaded( Media* ) ) );
m_cells = new QHash<QUuid, QWidget*>();
connect( m_nav, SIGNAL( previousButtonPushed() ), this, SLOT( restoreContext() ) );
connect( mc, SIGNAL( newClipLoaded(Clip*) ),
this, SLOT( newClipLoaded( Clip* ) ) );
foreach ( Clip* clip, mc->clips() )
newClipLoaded( clip );
connect( m_nav, SIGNAL( previousButtonPushed() ),
this, SLOT( restoreContext() ) );
}
MediaListViewController::~MediaListViewController()
{
delete m_cells;
foreach ( QWidget* cell, m_cells )
delete cell;
m_cells.clear();
}
void MediaListViewController::newMediaLoaded( Media* media )
void MediaListViewController::newClipLoaded( Clip *clip )
{
MediaCellView* cell = new MediaCellView( media->baseClip() );
MediaCellView* cell = new MediaCellView( clip );
connect( cell, SIGNAL ( cellSelected( QUuid ) ),
this, SLOT ( cellSelection( QUuid ) ) );
connect( cell, SIGNAL ( cellDeleted( QUuid ) ),
this, SIGNAL( clipDeleted( QUuid ) ) );
connect( cell, SIGNAL ( cellDeleted( const Clip* ) ),
this, SLOT( clipRemoved( const Clip* ) ) );
connect( cell, SIGNAL( arrowClicked( const QUuid& ) ),
this, SLOT( showClipList( const QUuid& ) ) );
addCell(cell);
m_cells->insert( media->baseClip()->uuid(), cell );
this, SLOT( showSubClips( const QUuid& ) ) );
addCell( cell );
m_cells.insert( clip->uuid(), cell );
}
void MediaListViewController::cellSelection( const QUuid& uuid )
......@@ -61,54 +65,49 @@ void MediaListViewController::cellSelection( const QUuid& uuid )
if ( m_currentUuid == uuid )
return;
if ( m_cells->contains( uuid ) )
if ( m_cells.contains( uuid ) )
{
if ( !m_currentUuid.isNull() && m_cells->contains( m_currentUuid ) )
if ( !m_currentUuid.isNull() && m_cells.contains( m_currentUuid ) )
{
QWidget* cell = m_cells->value( m_currentUuid );
cell->setPalette( m_cells->value( uuid )->palette() );
QWidget* cell = m_cells.value( m_currentUuid );
cell->setPalette( m_cells.value( uuid )->palette() );
}
QPalette p = m_cells->value( uuid )->palette();
QPalette p = m_cells.value( uuid )->palette();
p.setColor( QPalette::Window, QColor( Qt::darkBlue ) );
m_cells->value( uuid )->setPalette( p );
m_cells.value( uuid )->setPalette( p );
m_currentUuid = uuid;
emit clipSelected( m_mediaContainer->clip( uuid ) );
}
}
void MediaListViewController::mediaRemoved( const QUuid& uuid )
void MediaListViewController::clipRemoved( const Clip* clip )
{
QWidget* cell = m_cells->value( uuid );
QWidget* cell = m_cells.value( clip->uuid() );
removeCell( cell );
m_cells->remove( uuid );
m_cells.remove( clip->uuid() );
m_currentUuid = QUuid();
emit clipDeleted( uuid );
m_mediaContainer->removeClip( clip );
emit clipDeleted( clip->uuid() );
delete clip;
}
void
MediaListViewController::clear()
{
foreach ( QWidget* cell, m_cells->values() )
foreach ( QWidget* cell, m_cells.values() )
removeCell( cell );
m_cells->clear();
m_cells.clear();
}
void MediaListViewController::showClipList( const QUuid& uuid )
void MediaListViewController::showSubClips( const QUuid& uuid )
{
if ( !m_cells->contains( uuid ) )
return ;
if ( m_mediaContainer->media( uuid ) == NULL ||
m_mediaContainer->media( uuid )-> clipsCount() == 0 )
return ;
m_lastUuidClipListAsked = uuid;
m_clipsListView = new MediaListViewController( m_nav, m_mediaContainer );
m_clipsListView->newMediaLoaded( m_mediaContainer->media( uuid ) );
connect( m_clipsListView, SIGNAL( clipSelected( const QUuid& ) ),
this, SLOT( clipSelection( const QUuid& ) ) );
Clip* clip = m_mediaContainer->clip( uuid );
m_clipsListView = new MediaListViewController( m_nav, clip->getChilds() );
m_nav->pushViewController( m_clipsListView );
}
void MediaListViewController::restoreContext()
{
delete m_clipsListView;
m_currentUuid = QUuid();
}
......@@ -42,20 +42,20 @@ public:
private:
StackViewController* m_nav;
QUuid m_currentUuid;
QHash<QUuid, QWidget*>* m_cells;
QHash<QUuid, QWidget*> m_cells;
MediaListViewController* m_clipsListView;
QUuid m_lastUuidClipListAsked;
MediaContainer* m_mediaContainer;
public slots:
void cellSelection( const QUuid& uuid );
void showClipList( const QUuid& uuid );
void showSubClips( const QUuid& uuid );
void clear();
private slots:
void restoreContext();
void mediaRemoved( const QUuid& uuid );
void newMediaLoaded( Media* media );
void clipRemoved( const Clip* );
void newClipLoaded( Clip* clip );
signals:
void clipSelected( Clip* );
......
......@@ -215,13 +215,13 @@ void AbstractGraphicsMediaItem::resize( qint64 size, From from )
if ( size < 1 )
return;
if ( clip()->getParent()->fileType() != Media::Image )
if ( clip()->getMedia()->fileType() != Media::Image )
if ( size > clip()->maxEnd() )
return;
if ( from == BEGINNING )
{
if ( clip()->getParent()->fileType() != Media::Image )
if ( clip()->getMedia()->fileType() != Media::Image )