Commit d5e0f64e authored by Geoffroy Lacarriere's avatar Geoffroy Lacarriere

Refactor of the import menu.

All the medias are managed by the library now.
parent 6c83ef95
......@@ -22,12 +22,14 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#include <QTime>
#include "ImportController.h"
#include "ui_ImportController.h"
#include "ClipRenderer.h"
#include "ImportController.h"
#include "Library.h"
#include "QPalette"
#include <QPalette>
#include <QTime>
ImportController::ImportController(QWidget *parent) :
QDialog(parent),
......@@ -36,30 +38,25 @@ ImportController::ImportController(QWidget *parent) :
m_controllerSwitched( false )
{
m_ui->setupUi(this);
m_model = new ImportModel();
m_preview = new PreviewWidget( new ClipRenderer, m_ui->previewContainer );
m_stackNav = new StackViewController( m_ui->stackViewContainer, false );
m_mediaListController = new ImportMediaListController( m_stackNav );
m_tag = new TagWidget( m_ui->tagContainer, 6 );
m_filesModel = new QDirModel();
m_stackNav->pushViewController( m_mediaListController );
QStringList filters;
//Video
filters << "*.mov" << "*.avi" << "*.mkv" << "*.mpg" << "*.mpeg" << "*.wmv" << "*.mp4" << "*.ogg" << "*.ogv";
//Audio
filters << "*.mov" << "*.avi" << "*.mkv" << "*.mpg" << "*.mpeg" << "*.wmv" << "*.mp4"
<< "*.ogg" << "*.ogv";
filters << "*.mp3" << "*.oga" << "*.flac" << "*.aac" << "*.wav";
//Picture
filters << "*.gif" << "*.png" << "*.jpg";
m_filesModel->setFilter( QDir::AllDirs | QDir::Files | QDir::Readable | QDir::NoDotAndDotDot );
m_filesModel->setFilter( QDir::AllDirs | QDir::Files | QDir::Readable |
QDir::NoDotAndDotDot );
m_filesModel->sort( 2, Qt::AscendingOrder );
m_filesModel->sort( 0, Qt::AscendingOrder );
m_filesModel->setNameFilters( filters );
m_model->setFilter( filters );
Library::getInstance()->setFilter( filters );
m_ui->treeView->setModel( m_filesModel );
m_ui->treeView->setRootIndex( m_filesModel->index( QDir::rootPath() ) );
m_ui->treeView->setCurrentIndex( m_filesModel->index( QDir::homePath() ) );
......@@ -73,36 +70,47 @@ ImportController::ImportController(QWidget *parent) :
m_fsWatcher->addPath( QDir::homePath() );
m_currentlyWatchedDir = QDir::homePath();
connect( m_fsWatcher, SIGNAL( directoryChanged( QString ) ), m_filesModel, SLOT( refresh() ) );
connect( m_ui->treeView, SIGNAL( clicked( QModelIndex ) ), this, SLOT( treeViewClicked( QModelIndex ) ) );
connect( m_ui->treeView, SIGNAL( doubleClicked( QModelIndex ) ), this, SLOT( treeViewDoubleClicked( QModelIndex ) ) );
connect( m_ui->forwardButton, SIGNAL( clicked() ), this, SLOT( forwardButtonClicked() ) );
connect( m_model, SIGNAL( newMediaLoaded( Media* ) ), this, SLOT( newMediaLoaded( Media* ) ) );
connect( m_model, SIGNAL( updateMediaRequested( Media* ) ), this, SLOT( updateMediaRequested( Media* ) ) );
connect( this, SIGNAL( mediaSelected( Media* ) ), m_preview->getGenericRenderer(), SLOT( setMedia( Media* ) ) );
connect( this, SIGNAL( mediaSelected( Media* ) ), m_tag, SLOT( mediaSelected( Media* ) ) );
//Media
connect( m_mediaListController, SIGNAL( mediaSelected( QUuid ) ), this, SLOT( mediaSelection( QUuid ) ) );
connect( m_mediaListController, SIGNAL( mediaDeleted( QUuid ) ), this, SLOT( mediaDeletion( QUuid ) ) );
//Clips
connect( m_mediaListController, SIGNAL( showClipListAsked( const QUuid& ) ), this, SLOT( showClipList( const QUuid& ) ) );
connect( m_preview, SIGNAL( addClip( Clip* ) ), m_mediaListController, SLOT( clipAdded( Clip* ) ) );
//StackViewController
connect( m_stackNav, SIGNAL( previousButtonPushed() ), this, SLOT( restoreContext() ) );
connect( m_fsWatcher, SIGNAL( directoryChanged( QString ) ),
m_filesModel, SLOT( refresh() ) );
connect( m_ui->treeView, SIGNAL( clicked( QModelIndex ) ),
this, SLOT( treeViewClicked( QModelIndex ) ) );
connect( m_ui->treeView, SIGNAL( doubleClicked( QModelIndex ) ),
this, SLOT( treeViewDoubleClicked( QModelIndex ) ) );
connect( m_ui->forwardButton, SIGNAL( clicked() ),
this, SLOT( forwardButtonClicked() ) );
connect( Library::getInstance(), SIGNAL( newMediaLoaded( const QUuid& ) ),
this, SLOT( newMediaLoaded( const QUuid& ) ) );
connect( Library::getInstance(), SIGNAL( updateMediaRequested( const QUuid& ) ),
this, SLOT( updateMediaRequested( const QUuid& ) ) );
connect( this, SIGNAL( mediaSelected( Media* ) ),
m_preview->getGenericRenderer(), SLOT( setMedia( Media* ) ) );
connect( this, SIGNAL( mediaSelected( Media* ) ),
m_tag, SLOT( mediaSelected( Media* ) ) );
connect( m_mediaListController, SIGNAL( mediaSelected( const QUuid& ) ),
this, SLOT( mediaSelection( const QUuid& ) ) );
connect( m_mediaListController, SIGNAL( mediaDeleted( const QUuid& ) ),
this, SLOT( mediaDeletion( const QUuid& ) ) );
connect( m_mediaListController, SIGNAL( showClipListAsked( const QUuid& ) ),
this, SLOT( showClipList( const QUuid& ) ) );
connect( m_preview, SIGNAL( addClip( Clip* ) ),
m_mediaListController, SLOT( clipAdded( Clip* ) ) ); //StackViewController
connect( m_stackNav, SIGNAL( previousButtonPushed() ),
this, SLOT( restoreContext() ) );
}
ImportController::~ImportController()
{
delete m_ui;
delete m_model;
delete m_stackNav;
delete m_tag;
}
void ImportController::changeEvent( QEvent *e )
void
ImportController::changeEvent( QEvent *e )
{
QDialog::changeEvent( e );
switch ( e->type() )
......@@ -115,42 +123,39 @@ void ImportController::changeEvent( QEvent *e )
}
}
void ImportController::newMediaLoaded( Media* media )
{
m_mediaListController->addMedia( media );
}
void ImportController::mediaSelection( const QUuid& uuid )
void
ImportController::mediaSelection( const QUuid& uuid )
{
if ( m_mediaListController->contains( uuid ) )
{
if ( !m_currentUuid.isNull() && m_mediaListController->contains( m_currentUuid ) )
m_mediaListController->getCell( m_currentUuid )->setPalette( palette() );
QPalette p = m_mediaListController->getCell( uuid )->palette();
m_mediaListController->cell( m_currentUuid )->setPalette( this->palette() );
QPalette p = m_mediaListController->cell( uuid )->palette();
p.setColor( QPalette::Window, QColor( Qt::darkBlue ) );
m_mediaListController->getCell( uuid )->setPalette( p );
m_mediaListController->cell( uuid )->setPalette( p );
setUIMetaData( m_model->getMedia( uuid ) );
setUIMetaData( Library::getInstance()->temporaryMedia( uuid ) );
if ( uuid != NULL && uuid != m_currentUuid )
m_preview->stop();
m_currentUuid = uuid;
emit mediaSelected( m_model->getMedia( uuid ) );
emit mediaSelected( Library::getInstance()->temporaryMedia( uuid ) );
}
}
void ImportController::clipSelection( const QUuid& uuid )
void
ImportController::clipSelection( const QUuid& uuid )
{
if ( !m_currentUuid.isNull() && !m_controllerSwitched )
m_clipListController->getCell( m_currentUuid )->setPalette( palette() );
m_clipListController->cell( m_currentUuid )->setPalette( palette() );
else
m_controllerSwitched = false;
QPalette p = m_clipListController->getCell( uuid )->palette();
QPalette p = m_clipListController->cell( uuid )->palette();
p.setColor( QPalette::Window, QColor( Qt::darkBlue ) );
m_clipListController->getCell( uuid )->setPalette( p );
m_clipListController->cell( uuid )->setPalette( p );
Clip* clip;
foreach(QUuid id, m_model->getMedias()->keys() )
foreach(QUuid id, Library::getInstance()->medias()->keys() )
{
Media* media = m_model->getMedias()->value( id );
Media* media = Library::getInstance()->medias()->value( id );
if ( ( clip = media->clip( uuid ) ) != 0 )
break;
}
......@@ -161,17 +166,30 @@ void ImportController::clipSelection( const QUuid& uuid )
m_currentUuid = uuid;
}
void ImportController::updateMediaRequested( Media* media )
void
ImportController::newMediaLoaded( const QUuid& uuid )
{
if ( m_mediaListController->contains( media->getUuid() ) )
{
ImportMediaCellView* cell = m_mediaListController->getCell( media->getUuid() );
cell->setThumbnail( media->getSnapshot() );
cell->setLength( media->getLengthMS() );
}
Media* media = Library::getInstance()->temporaryMedia( uuid );
if ( media == NULL )
return;
m_mediaListController->addMedia( media );
}
void ImportController::setUIMetaData( Media* media )
void
ImportController::updateMediaRequested( const QUuid& uuid )
{
Media* media = Library::getInstance()->temporaryMedia( uuid );
if ( media == NULL )
return;
ImportMediaCellView* cell = m_mediaListController->cell( media->getUuid() );
if ( cell == NULL )
return;
cell->setThumbnail( media->getSnapshot() );
cell->setLength( media->getLengthMS() );
}
void
ImportController::setUIMetaData( Media* media )
{
if ( media != NULL )
{
......@@ -185,7 +203,7 @@ void ImportController::setUIMetaData( Media* media )
setWindowTitle( media->getFileInfo()->fileName() + " " + tr( "properties" ) );
//Resolution
m_ui->resolutionValueLabel->setText( QString::number( media->getWidth() )
+ " x " + QString::number( media->getHeight() ) );
+ " x " + QString::number( media->getHeight() ) );
//FPS
m_ui->fpsValueLabel->setText( QString::number( media->getFps() ) );
}
......@@ -198,31 +216,33 @@ void ImportController::setUIMetaData( Media* media )
}
}
void ImportController::setUIMetaData( Clip* clip )
void
ImportController::setUIMetaData( Clip* clip )
{
//compute clip length
QTime time;
qint64 length = clip->getLengthSecond();
time = time.addSecs( length );
qDebug() << time;
m_ui->durationValueLabel->setText( time.toString( "hh:mm:ss" ) );
//Filename || title
m_ui->nameValueLabel->setText( clip->getParent()->getFileInfo()->fileName() );
m_ui->nameValueLabel->setWordWrap( true );
setWindowTitle( clip->getParent()->getFileInfo()->fileName() + " " + tr( "properties" ) );
//Resolution
setWindowTitle( clip->getParent()->getFileInfo()->fileName() + " " +
tr( "properties" ) );
m_ui->resolutionValueLabel->setText( QString::number( clip->getParent()->getWidth() )
+ " x " + QString::number( clip->getParent()->getHeight() ) );
//FPS
m_ui->fpsValueLabel->setText( QString::number( clip->getParent()->getFps() ) );
}
void ImportController::forwardButtonClicked()
void
ImportController::forwardButtonClicked()
{
m_model->loadFile( m_filesModel->fileInfo( m_ui->treeView->selectionModel()->currentIndex() ).filePath() );
QModelIndex index = m_ui->treeView->selectionModel()->currentIndex();
QString filePath = m_filesModel->fileInfo( index ).filePath();
Library::getInstance()->loadFile( filePath );
}
void ImportController::treeViewClicked( const QModelIndex& index )
void
ImportController::treeViewClicked( const QModelIndex& index )
{
if ( m_filesModel->isDir( index ) )
{
......@@ -233,35 +253,36 @@ void ImportController::treeViewClicked( const QModelIndex& index )
m_ui->forwardButton->setEnabled( true );
}
void ImportController::treeViewDoubleClicked( const QModelIndex& index )
void
ImportController::treeViewDoubleClicked( const QModelIndex& index )
{
if ( !m_filesModel->isDir( index ) )
forwardButtonClicked();
}
void ImportController::reject()
void
ImportController::reject()
{
m_preview->stop();
m_model->removeAllMedias();
m_mediaListController->cleanAll();
Library::getInstance()->deleteTemporaryMedias();
done( Rejected );
}
void ImportController::accept()
void
ImportController::accept()
{
QUuid id;
foreach( id, m_model->getMedias()->keys() )
{
Media* media = m_model->getMedias()->value( id );
Library::getInstance()->addMedia( media );
}
m_mediaListController->cleanAll();
Library::getInstance()->importDone();
m_preview->stop();
done( Accepted );
}
void ImportController::mediaDeletion( const QUuid& uuid )
void
ImportController::mediaDeletion( const QUuid& uuid )
{
Library::getInstance()->deleteMedia( uuid );
m_mediaListController->removeMedia( uuid );
m_model->removeMedia( uuid );
if ( uuid == m_currentUuid )
{
......@@ -271,29 +292,31 @@ void ImportController::mediaDeletion( const QUuid& uuid )
}
}
void ImportController::clipDeletion( const QUuid& uuid )
void
ImportController::clipDeletion( const QUuid& uuid )
{
m_clipListController->removeClip( uuid );
QUuid id;
foreach( id, m_model->getMedias()->keys() )
foreach( id, Library::getInstance()->temporaryMedias()->keys() )
{
Media* media = m_model->getMedias()->value( id );
if ( media->clip( uuid ) )
{
Media* media = Library::getInstance()->temporaryMedias()->value( id );
if ( media != NULL && media->clip( uuid ) )
media->removeClip( uuid );
}
}
}
void ImportController::showClipList( const QUuid& uuid )
void
ImportController::showClipList( const QUuid& uuid )
{
Media* media = m_model->getMedia( uuid );
if ( media->clips()->size() == 0 )
Media* media = Library::getInstance()->temporaryMedia( uuid );
if ( media == NULL || media->clips()->size() == 0 )
return ;
m_clipListController = new ImportMediaListController( m_stackNav );
connect( m_clipListController, SIGNAL( clipSelected( const QUuid& ) ), this, SLOT( clipSelection( const QUuid& ) ) );
connect( m_clipListController, SIGNAL( clipDeleted( const QUuid& ) ), this, SLOT( clipDeletion( const QUuid& ) ) );
connect( m_clipListController, SIGNAL( clipSelected( const QUuid& ) ),
this, SLOT( clipSelection( const QUuid& ) ) );
connect( m_clipListController, SIGNAL( clipDeleted( const QUuid& ) ),
this, SLOT( clipDeletion( const QUuid& ) ) );
m_clipListController->addClipsFromMedia( media );
if ( !m_currentUuid.isNull() )
m_savedUuid = m_currentUuid;
......@@ -301,12 +324,16 @@ void ImportController::showClipList( const QUuid& uuid )
m_stackNav->pushViewController( m_clipListController );
}
void ImportController::restoreContext()
void
ImportController::restoreContext()
{
if ( m_clipListController->getNbDeletions() != 0 )
if ( m_clipListController->nbDeletions() != 0 )
{
if ( !m_savedUuid.isNull() )
m_mediaListController->getCell( m_savedUuid )->decrementClipCount( m_clipListController->getNbDeletions() );
if ( !m_savedUuid.isNull() && m_mediaListController->cell( m_savedUuid ) != NULL )
{
ImportMediaCellView* cell = m_mediaListController->cell( m_savedUuid );
cell->decrementClipCount( m_clipListController->nbDeletions() );
}
}
if ( !m_savedUuid.isNull() )
m_currentUuid = m_savedUuid;
......
......@@ -22,26 +22,34 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
/** \file
* This file ImportController contains class declaration/definition.
* It's the the controler of the import menu widget of vlmc.
*/
#ifndef IMPORTCONTROLLER_H
#define IMPORTCONTROLLER_H
#include <QDialog>
#include <QDirModel>
#include <QFileSystemWatcher>
#include "Media.h"
#include "Clip.h"
#include "ImportModel.h"
#include "ImportMediaListController.h"
#include "Media.h"
#include "PreviewWidget.h"
#include "StackViewController.h"
#include "TagWidget.h"
#include "ImportMediaListController.h"
#include <QDialog>
#include <QDirModel>
#include <QFileSystemWatcher>
namespace Ui
{
class ImportController;
}
/**
* \class ImportController
* \brief Controller of the import menu
*/
class ImportController : public QDialog
{
Q_OBJECT
......@@ -58,7 +66,6 @@ class ImportController : public QDialog
private:
Ui::ImportController* m_ui;
PreviewWidget* m_preview;
ImportModel* m_model;
StackViewController* m_stackNav;
TagWidget* m_tag;
ImportMediaListController* m_mediaListController;
......@@ -71,8 +78,8 @@ class ImportController : public QDialog
bool m_controllerSwitched;
public slots:
void newMediaLoaded( Media* media );
void updateMediaRequested( Media* media );
void newMediaLoaded( const QUuid& uuid );
void updateMediaRequested( const QUuid& uuid );
void accept();
void reject();
void mediaSelection( const QUuid& uuid );
......
......@@ -25,7 +25,8 @@
#include "ImportMediaListController.h"
#include <QDebug>
ImportMediaListController::ImportMediaListController( StackViewController* nav ) : ListViewController( nav ), m_nav( nav ), m_clipDeleted( 0 )
ImportMediaListController::ImportMediaListController( StackViewController* nav ) :
ListViewController( nav ), m_nav( nav ), m_clipDeleted( 0 )
{
m_mediaCellList = new QHash<QUuid, ImportMediaCellView*>();
}
......@@ -35,48 +36,61 @@ ImportMediaListController::~ImportMediaListController()
delete m_mediaCellList;
}
void ImportMediaListController::addMedia( Media* media )
void
ImportMediaListController::addMedia( Media* media )
{
ImportMediaCellView* cell = new ImportMediaCellView( media->getUuid() );
connect( cell, SIGNAL( cellSelected( const QUuid& ) ), this, SIGNAL( mediaSelected( const QUuid& ) ) );
connect( cell, SIGNAL( cellDeleted( const QUuid& ) ), this, SIGNAL( mediaDeleted( const QUuid& ) ) );
connect( cell, SIGNAL( arrowClicked( const QUuid& ) ), this, SIGNAL( showClipListAsked( const QUuid& ) ) );
connect( cell, SIGNAL( cellSelected( const QUuid& ) ),
this, SIGNAL( mediaSelected( const QUuid& ) ) );
connect( cell, SIGNAL( cellDeleted( const QUuid& ) ),
this, SIGNAL( mediaDeleted( const QUuid& ) ) );
connect( cell, SIGNAL( arrowClicked( const QUuid& ) ),
this, SIGNAL( showClipListAsked( const QUuid& ) ) );
cell->setTitle( media->getFileName() );
cell->setThumbnail( media->getSnapshot() );
addCell( cell );
m_mediaCellList->insert( media->getUuid(), cell );
qDebug() << "addMedia: " << media->getUuid();
}
void ImportMediaListController::metaDataComputed( Media* media )
void
ImportMediaListController::metaDataComputed( Media* media )
{
m_mediaCellList->value( media->getUuid() )->setThumbnail( media->getSnapshot() );
}
ImportMediaCellView* ImportMediaListController::getCell( QUuid uuid ) const
ImportMediaCellView*
ImportMediaListController::cell( QUuid uuid ) const
{
if (m_mediaCellList->contains( uuid ) )
return m_mediaCellList->value( uuid );
return NULL;
}
bool ImportMediaListController::contains( QUuid uuid )
bool
ImportMediaListController::contains( QUuid uuid )
{
return m_mediaCellList->contains( uuid );
}
void ImportMediaListController::removeMedia( const QUuid& uuid )
void
ImportMediaListController::removeMedia( const QUuid& uuid )
{
const QUuid saveUuid = uuid;
removeCell( m_mediaCellList->value( uuid ) );
m_mediaCellList->remove( uuid );
m_mediaCellList->remove( saveUuid );
}
void ImportMediaListController::addClip( Clip* clip )
void
ImportMediaListController::addClip( Clip* clip )
{
ImportMediaCellView* cell = new ImportMediaCellView( clip->getUuid() );
connect( cell, SIGNAL( cellSelected( const QUuid& ) ), this, SIGNAL( clipSelected( const QUuid& ) ) );
connect( cell, SIGNAL( cellDeleted( const QUuid& ) ), this, SLOT( clipDeletion( const QUuid& ) ) );
connect( cell, SIGNAL( cellSelected( const QUuid& ) ),
this, SIGNAL( clipSelected( const QUuid& ) ) );
connect( cell, SIGNAL( cellDeleted( const QUuid& ) ),
this, SLOT( clipDeletion( const QUuid& ) ) );
QString size;
......@@ -90,39 +104,43 @@ void ImportMediaListController::addClip( Clip* clip )
m_mediaCellList->insert( clip->getUuid(), cell );
}
void ImportMediaListController::removeClip( const QUuid& uuid )
void
ImportMediaListController::removeClip( const QUuid& uuid )
{
removeCell( m_mediaCellList->value( uuid ) );
m_mediaCellList->remove( uuid );
}
void ImportMediaListController::cleanAll()
void
ImportMediaListController::cleanAll()
{
QUuid uuid;
MediaCellView* cell;
foreach( uuid, m_mediaCellList->keys() )
{
cell = m_mediaCellList->value( uuid );
m_layout->removeWidget( cell );
delete cell;
removeCell( cell );
}
m_mediaCellList->clear();
}
void ImportMediaListController::addClipsFromMedia( Media* media )
void
ImportMediaListController::addClipsFromMedia( Media* media )
{
QUuid uuid;
foreach( uuid, media->clips()->keys() )
addClip( media->clips()->value( uuid ) );
}
void ImportMediaListController::clipDeletion( const QUuid& uuid )
void
ImportMediaListController::clipDeletion( const QUuid& uuid )
{
m_clipDeleted += 1;
emit clipDeleted( uuid );
}
void ImportMediaListController::clipAdded( Clip* clip )
void
ImportMediaListController::clipAdded( Clip* clip )
{
if ( clip->getParent() == 0 )
return ;
......@@ -131,8 +149,8 @@ void ImportMediaListController::clipAdded( Clip* clip )
m_mediaCellList->value( uuid )->incrementClipCount();
}
int ImportMediaListController::getNbDeletions() const
const QHash<QUuid, ImportMediaCellView*>*
ImportMediaListController::mediaCellList() const
{
return m_clipDeleted;
return m_mediaCellList;
}
......@@ -45,10 +45,10 @@ class ImportMediaListController : public ListViewController
void cleanAll();
void addClipsFromMedia( Media* media );
const QHash<QUuid, ImportMediaCellView*>* getMediaCellList() const { return m_mediaCellList; }
ImportMediaCellView* getCell( QUuid uuid ) const;
const QHash<QUuid, ImportMediaCellView*>* mediaCellList() const;
ImportMediaCellView* cell( QUuid uuid ) const;
bool contains( QUuid uuid );
int getNbDeletions() const;
int nbDeletions() const { return m_clipDeleted; }
private:
StackViewController* m_nav;
......
FORMS += ui/ImportController.ui
HEADERS += ImportController.h \
ImportModel.h
HEADERS += ImportController.h
SOURCES += ImportController.cpp \
ImportModel.cpp
SOURCES += ImportController.cpp
......@@ -101,7 +101,7 @@ void ClipListViewController::clipDeletion( const QUuid& uuid )
removeCell( cell );
m_cells.remove( uuid );
m_currentUuid = QUuid();
Library::getInstance()->getMedia( m_mediaId )->removeClip( uuid );
Library::getInstance()->media( m_mediaId )->removeClip( uuid );
m_cells.remove( uuid );
}
}
......@@ -90,7 +90,7 @@ void MediaCellView::mouseDoubleClickEvent( QMouseEvent* event )
{
if ( ( event->buttons() | Qt::LeftButton ) == Qt::LeftButton )
{
ClipProperty* mp = new ClipProperty( Library::getInstance()->getClip( m_uuid ), this );
ClipProperty* mp = new ClipProperty( Library::getInstance()->clip( m_uuid ), this );
mp->setModal( true );
mp->show();
}
......@@ -109,6 +109,7 @@ void MediaCellView::mousePressEvent( QMouseEvent* event )
void MediaCellView::mouseMoveEvent( QMouseEvent* event )
{
qDebug() << "in MediaCellView::mouseMoveEvent";
if ( ( event->buttons() | Qt::LeftButton ) != Qt::LeftButton )
return;
......@@ -123,14 +124,14 @@ void MediaCellView::mouseMoveEvent( QMouseEvent* event )
QDrag* drag = new QDrag( this );
drag->setMimeData( mimeData );
//FIXME : change the way the library handles Clips
Clip* clip = Library::getInstance()->getClip( m_uuid );
Clip* clip = Library::getInstance()->clip( m_uuid );
if ( 0 == clip )
return ;
//getting the media from the current Clip
Media* parent = Library::getInstance()->getClip( m_uuid )->getParent();
Media* parent = Library::getInstance()->clip( m_uuid )->getParent();
if ( 0 == parent )
return ;
drag->setPixmap( Library::getInstance()->getClip( m_uuid )->getParent()->getSnapshot().scaled( 100, 100, Qt::KeepAspectRatio ) );
drag->setPixmap( Library::getInstance()->clip( m_uuid )->getParent()->getSnapshot().scaled( 100, 100, Qt::KeepAspectRatio ) );
drag->exec( Qt::CopyAction | Qt::MoveAction, Qt::CopyAction );
}
......@@ -151,6 +152,7 @@ void MediaCellView::deleteButtonClicked( QWidget*, QMouseEvent* )
void MediaCellView::arrowButtonClicked( QWidget*, QMouseEvent* )
{
qDebug() << "arrow clicked for uuid" << uuid();
emit arrowClicked( uuid() );
}
......
......@@ -27,7 +27,8 @@
MediaListViewController::MediaListViewController( StackViewController* nav ) :
ListViewController( nav ), m_nav( nav ), m_clipsListView( 0 )
{
connect(Library::getInstance(), SIGNAL( newMediaLoaded( Media* ) ), this, SLOT( newMediaLoaded( Media* ) ) );
connect( Library::getInstance(), SIGNAL( newMediaImported( QUuid ) ),
this, SLOT( newMediaLoaded( QUuid ) ) );
m_cells = new QHash<QUuid, QWidget*>();
connect( m_nav, SIGNAL( previousButtonPushed() ), this, SLOT( restoreContext() ) );
}
......@@ -36,18 +37,22 @@ MediaListViewController::~MediaListViewController()
{
delete m_cells;
}
void MediaListViewController::newMediaLoaded( Media* media )
void MediaListViewController::newMediaLoaded( const QUuid& uuid )
{
Media* media = Library::getInstance()->media( uuid );
if ( media == NULL )
return;
MediaCellView* cell = new MediaCellView( media->getUuid() );
connect( cell, SIGNAL ( cellSelected( QUuid ) ), this, SLOT ( cellSelection( QUuid ) ) );
connect( cell, SIGNAL ( cellDeleted( QUuid ) ), this, SLOT( mediaDeletion( QUuid ) ) );
connect( cell, SIGNAL ( arrowClicked( QUuid ) ), this, SLOT( showClipList( QUuid ) ) );
connect( cell, SIGNAL ( cellSelected( QUuid ) ),
this, SLOT ( cellSelection( QUuid ) ) );
connect( cell, SIGNAL ( cellDeleted( QUuid ) ),
this, SLOT( mediaDeletion( QUuid ) ) );
if ( media->getMetadata() != Media::ParsedWithSnapshot )
connect( media, SIGNAL( snapshotComputed( Media* ) ), this, SLOT( updateCell( Media* ) ) );