Commit 88077eb0 authored by Hugo Beauzee-Luyssen's avatar Hugo Beauzee-Luyssen

MediaListView: Auto select the latest added Media

parent 30bfb34a
......@@ -65,6 +65,9 @@ void TagWidget::clipSelected( Clip* clip )
else
static_cast<QPushButton*>(m_buttonList[i])->setChecked( false );
}
connect( clip->getMedia(), SIGNAL( metaDataComputed( const Media* ) ),
this, SLOT( setMetaTags() ) );
connect( clip, SIGNAL( destroyed() ), this, SLOT( clipDestroyed() ) );
}
void TagWidget::setMetaTags()
......@@ -135,3 +138,9 @@ void TagWidget::changeEvent( QEvent *e )
break;
}
}
void
TagWidget::clipDestroyed()
{
m_currentClip = NULL;
}
......@@ -61,6 +61,9 @@ class TagWidget : public QWidget
void clipSelected( Clip* clip );
void buttonTagClicked();
void setMetaTags();
private slots:
void clipDestroyed();
};
#endif // TAGWIDGET_H
......@@ -151,7 +151,7 @@ ImportController::clipSelection( const QUuid& uuid )
}
void
ImportController::setUIMetaData( Clip* clip )
ImportController::setUIMetaData( const Clip* clip )
{
if ( clip != NULL )
{
......@@ -184,7 +184,10 @@ ImportController::importMedia( const QString &filePath )
++m_nbMediaToLoad;
m_ui->progressBar->setMaximum( m_nbMediaToLoad );
m_temporaryMedias->addMedia( filePath );
Media* media = m_temporaryMedias->addMedia( filePath );
if ( media )
connect( media, SIGNAL( metaDataComputed( const Media* ) ),
this, SLOT( metaDataComputed( const Media* ) ) );
}
void
......@@ -333,3 +336,9 @@ ImportController::hideErrors()
m_ui->errorLabelImg->hide();
m_ui->errorLabel->hide();
}
void
ImportController::metaDataComputed( const Media *media )
{
setUIMetaData( media->baseClip() );
}
......@@ -59,7 +59,7 @@ class ImportController : public QDialog
public:
ImportController(QWidget *parent = 0);
~ImportController();
void setUIMetaData( Clip *clip );
void setUIMetaData( const Clip *clip );
protected:
void changeEvent( QEvent *e );
......@@ -96,6 +96,7 @@ class ImportController : public QDialog
void mediaLoaded();
void failedToLoad( Media* media );
void hideErrors();
void metaDataComputed( const Media* media );
signals:
void clipSelected( Clip* );
......
......@@ -57,6 +57,7 @@ void MediaListView::newClipLoaded( Clip *clip )
this, SLOT( showSubClips( const QUuid& ) ) );
addCell( cell );
m_cells.insert( clip->uuid(), cell );
cellSelection( clip->uuid() );
}
void MediaListView::cellSelection( const QUuid& uuid )
......
......@@ -48,11 +48,11 @@ MediaContainer::addMedia( Media *media )
emit newClipLoaded( media->baseClip() );
}
bool
Media*
MediaContainer::addMedia( const QFileInfo& fileInfo, const QString& uuid )
{
if ( QFile::exists( fileInfo.absoluteFilePath() ) == false )
return false;
return NULL;
Media* media = new Media( fileInfo.filePath(), uuid );
foreach( Clip* it, m_clips.values() )
......@@ -60,12 +60,12 @@ MediaContainer::addMedia( const QFileInfo& fileInfo, const QString& uuid )
if ( it->getMedia()->fileInfo()->filePath() == media->fileInfo()->filePath() )
{
delete media;
return false;
return NULL;
}
}
MetaDataManager::getInstance()->computeMediaMetadata( media );
addMedia( media );
return true;
return media;
}
bool
......
......@@ -64,7 +64,7 @@ public:
* \sa media( const QUuid& uuid)
* \sa clip( const QUuid& uuid )
*/
bool addMedia( const QFileInfo& fileInfo, const QString& uuid = QString() );
Media* addMedia( const QFileInfo& fileInfo, const QString& uuid = QString() );
/**
* \brief Check if a file has already been loaded into library.
* \param fileInfo The file infos
......
......@@ -103,6 +103,12 @@ Clip::getMedia()
return m_media;
}
const Media*
Clip::getMedia() const
{
return m_media;
}
qint64
Clip::length() const
{
......
......@@ -86,6 +86,7 @@ class Clip : public QObject
\return Returns the Media that the clip was basep uppon.
*/
Media* getMedia();
const Media* getMedia() const;
Clip *getParent();
const Clip *getParent() const;
......
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