Commit 163a002d authored by Geoffroy Lacarriere's avatar Geoffroy Lacarriere
Browse files

Import: Refactor of the import menu excluding Clip the benefit of Media.

parent a37e981f
......@@ -34,65 +34,82 @@ Import::Import(QWidget *parent) :
m_previewWidget = new PreviewWidget( new ClipRenderer, m_ui->PreviewWidget );
m_tagWidget = new TagWidget( m_ui->TagWidget, 6 );
m_ui->ImportBrowserWidget = m_importBrowser;
m_ui->PreviewWidget = m_previewWidget;
m_ui->TagWidget = m_tagWidget;
connect( m_importBrowser, SIGNAL( mediaAdded( QFileInfo ) ), this, SLOT( addMedia( QFileInfo ) ) );
connect( m_importBrowser, SIGNAL( mediaRemoved( QFileInfo ) ), this, SLOT( removeMedia( QFileInfo ) ) );
connect( m_importBrowser, SIGNAL( mediaSelected( QFileInfo ) ), this, SLOT( selectCurrentMedia( QFileInfo ) ) );
connect( m_importBrowser, SIGNAL( mediaSelected( QFileInfo ) ), this, SLOT( getMetaData( QFileInfo ) ) );
connect( this, SIGNAL( mediaSelected( Media* ) ), m_previewWidget->getGenericRenderer(), SLOT( setMedia( Media* ) ) );
connect( this, SIGNAL( mediaSelected( Media* ) ), m_tagWidget, SLOT( mediaSelected( Media* ) ) );
}
Import::~Import()
{
delete m_ui;
delete m_currentMedia;
delete m_currentClip;
delete m_metaDataWorker;
delete m_importBrowser;
delete m_previewWidget;
delete m_tagWidget;
}
void Import::getMetaData( QFileInfo fileInfos )
void Import::addMedia( QFileInfo fileInfos )
{
m_ui->nameValueLabel->setText( fileInfos.fileName() );
m_currentMedia = new Media( fileInfos.filePath(), fileInfos.fileName() );
m_currentMedia = new Media( fileInfos.filePath() );
m_mediaList.append( m_currentMedia );
m_metaDataWorker = new MetaDataWorker( m_currentMedia );
connect( m_metaDataWorker, SIGNAL( destroyed() ), this, SLOT( setUIMetaData() ) );
m_metaDataWorker->start();
}
void Import::setUIMetaData()
void Import::removeMedia( QFileInfo fileInfos )
{
m_currentClip = new Clip( m_currentMedia );
for ( int i = 0; i < m_mediaList.count(); i++ )
{
if ( fileInfos == *m_mediaList[i]->getFileInfo() )
{
m_mediaList.removeAt( i );
m_currentMedia = NULL;
break;
}
}
}
connect( this, SIGNAL( mediaSelected( Clip* ) ), m_previewWidget->getGenericRenderer(), SLOT( setClip( Clip* ) ) );
connect( this, SIGNAL( mediaSelected( Media* ) ), m_tagWidget, SLOT( mediaSelected( Media* ) ) );
emit mediaSelected( m_currentMedia );
void Import::selectCurrentMedia( QFileInfo fileInfos )
{
for ( int i = 0; i < m_mediaList.count(); i++ )
{
if ( fileInfos == *m_mediaList[i]->getFileInfo() )
{
m_currentMedia = m_mediaList[i];
// TODO: stop the media player to stop before sending the mediaSelected signal
emit mediaSelected( m_currentMedia );
setUIMetaData();
break;
}
}
}
void Import::setUIMetaData()
{
//Duration
QTime duration;
duration = duration.addSecs( m_currentClip->getLengthSecond() );
duration = duration.addSecs( m_currentMedia->getLength() );
m_ui->durationValueLabel->setText( duration.toString( "hh:mm:ss" ) );
//Filename || title
m_ui->nameValueLabel->setText( m_currentClip->getParent()->getFileInfo()->fileName() );
setWindowTitle( m_currentClip->getParent()->getFileInfo()->fileName() + " " + tr( "properties" ) );
m_ui->nameValueLabel->setText( m_currentMedia->getFileInfo()->fileName() );
setWindowTitle( m_currentMedia->getFileInfo()->fileName() + " " + tr( "properties" ) );
//Resolution
m_ui->resolutionValueLabel->setText( QString::number( m_currentClip->getParent()->getWidth() )
+ " x " + QString::number( m_currentClip->getParent()->getHeight() ) );
m_ui->resolutionValueLabel->setText( QString::number( m_currentMedia->getWidth() )
+ " x " + QString::number( m_currentMedia->getHeight() ) );
//FPS
m_ui->fpsValueLabel->setText( QString::number( m_currentClip->getParent()->getFps() ) );
emit mediaSelected( m_currentClip );
disconnect( this, SIGNAL( mediaSelected( Clip* ) ), m_previewWidget->getGenericRenderer(), SLOT( setClip( Clip* ) ) );
m_ui->fpsValueLabel->setText( QString::number( m_currentMedia->getFps() ) );
}
void Import::accept()
{
//FIXME: When media are stored as Media*, replace newMediaLoadingAsked by addMedia
for(int i = 0; i < m_importBrowser->getMediaInfoList().count(); i++ )
Library::getInstance()->newMediaLoadingAsked( m_importBrowser->getMediaInfoList()[i].filePath() );
for ( int i = 0; i < m_mediaList.count(); i++ )
Library::getInstance()->addMedia( m_mediaList[i] );
done(Accepted);
}
......
......@@ -26,7 +26,6 @@
#include <QDialog>
#include "PreviewWidget.h"
#include "ImportBrowser.h"
#include "Clip.h"
#include "Media.h"
#include "MetaDataWorker.h"
#include "TagWidget.h"
......@@ -39,30 +38,31 @@ namespace Ui
class Import : public QDialog
{
Q_OBJECT
public:
Import( QWidget *parent = 0 );
~Import();
public:
Import( QWidget *parent = 0 );
~Import();
void setUIMetaData();
protected:
void changeEvent( QEvent *e );
protected:
void changeEvent( QEvent *e );
private:
Ui::Import* m_ui;
PreviewWidget* m_previewWidget;
ImportBrowser* m_importBrowser;
Media* m_currentMedia;
Clip* m_currentClip;
MetaDataWorker* m_metaDataWorker;
TagWidget* m_tagWidget;
private:
Ui::Import* m_ui;
PreviewWidget* m_previewWidget;
ImportBrowser* m_importBrowser;
Media* m_currentMedia;
MetaDataWorker* m_metaDataWorker;
TagWidget* m_tagWidget;
QList<Media*> m_mediaList;
private slots:
void accept();
void getMetaData( QFileInfo fileInfos );
void setUIMetaData();
private slots:
void accept();
void addMedia( QFileInfo fileInfos );
void selectCurrentMedia( QFileInfo fileInfos );
void removeMedia( QFileInfo fileInfos );
signals:
void mediaSelected( Clip* clip );
void mediaSelected( Media* media );
signals:
void mediaSelected( Media* media );
};
#endif // IMPORT_H
......@@ -105,6 +105,7 @@ void ImportBrowser::on_pushButtonBackward_clicked()
{
FileInfoListModel* model = static_cast<FileInfoListModel*>( m_ImportListModel );
m_mediaInfoList.removeOne( model->fileInfo( m_ui.listViewBrowser->selectionModel()->currentIndex() ) );
emit mediaRemoved( model->fileInfo( m_ui.listViewBrowser->selectionModel()->currentIndex() ) );
model->setFileInfoList( m_mediaInfoList );
if ( m_mediaInfoList.isEmpty() )
......@@ -117,11 +118,17 @@ void ImportBrowser::on_pushButtonForward_clicked()
if ( !m_FilesModel->isDir( m_ui.treeViewBrowser->selectionModel()->currentIndex() ) &&
!m_mediaInfoList.contains( m_FilesModel->fileInfo( m_ui.treeViewBrowser->selectionModel()->currentIndex() ) ) )
{
m_mediaInfoList << m_FilesModel->fileInfo( m_ui.treeViewBrowser->selectionModel()->currentIndex() );
emit mediaAdded( m_FilesModel->fileInfo( m_ui.treeViewBrowser->selectionModel()->currentIndex() ) );
}
else
for( int i = 0; i < m_FilesModel->rowCount( m_ui.treeViewBrowser->selectionModel()->currentIndex() ); i++)
if ( !m_mediaInfoList.contains( m_FilesModel->fileInfo( m_ui.treeViewBrowser->selectionModel()->currentIndex().child( i, 0 ) ) ) )
{
m_mediaInfoList << m_FilesModel->fileInfo( m_ui.treeViewBrowser->selectionModel()->currentIndex().child( i, 0 ) );
emit mediaAdded( m_FilesModel->fileInfo( m_ui.treeViewBrowser->selectionModel()->currentIndex().child( i, 0 ) ) );
}
model->setFileInfoList( m_mediaInfoList );
m_ui.pushButtonBackward->setEnabled( true );
}
......
......@@ -60,6 +60,8 @@ private slots:
signals:
void mediaSelected( QFileInfo fileInfos );
void mediaAdded( QFileInfo fileInfos );
void mediaRemoved( QFileInfo fileInfos );
};
#endif /* !IMPORTBROWSER_H */
......@@ -68,9 +68,6 @@ void ClipRenderer::setClip( Clip* clip )
m_mediaChanged = true;
else
m_clipLoaded = false;
if ( m_mediaPlayer->isPlaying() )
stop();
}
void ClipRenderer::startPreview()
......
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