Commit 9720e9a9 authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen

MediaListView: Watch project events when applicable

parent 7d6f6abf
......@@ -62,7 +62,8 @@ ImportController::ImportController(QWidget *parent) :
m_ui->previewContainer->setRenderer( m_clipRenderer );
m_stackNav = new StackViewController( m_ui->stackViewContainer );
m_temporaryMedias = new MediaContainer;
m_mediaListView = new MediaListView( m_stackNav, m_temporaryMedias );
m_mediaListView = new MediaListView( m_stackNav );
m_mediaListView->setMediaContainer( m_temporaryMedias );
// m_tag = new TagWidget( m_ui->tagContainer, 6 );
m_filesModel = new QFileSystemModel( this );
m_stackNav->pushViewController( m_mediaListView );
......
......@@ -42,7 +42,7 @@ MediaLibrary::MediaLibrary(QWidget *parent) : QWidget(parent),
setAcceptDrops( true );
StackViewController *nav = new StackViewController( m_ui->mediaListContainer );
m_mediaListView = new MediaListView( nav, Project::getInstance()->library() );
m_mediaListView = new MediaListView( nav );
nav->pushViewController( m_mediaListView );
connect( m_ui->importButton, SIGNAL( clicked() ),
......@@ -57,6 +57,12 @@ MediaLibrary::MediaLibrary(QWidget *parent) : QWidget(parent),
this, SLOT( filterTypeChanged() ) );
}
void
MediaLibrary::setMediaContainer( MediaContainer* container )
{
}
void
MediaLibrary::changeEvent( QEvent *e )
{
......
......@@ -28,6 +28,7 @@
#include "ui_MediaLibrary.h"
class Clip;
class MediaListView;
class MediaContainer;
class ViewController;
class MediaLibrary : public QWidget
......@@ -38,6 +39,8 @@ class MediaLibrary : public QWidget
public:
typedef bool (*Filter)( const Clip*, const QString& filter );
explicit MediaLibrary( QWidget *parent = 0);
void setMediaContainer( MediaContainer* container );
protected:
void dragEnterEvent( QDragEnterEvent *event );
......
......@@ -24,25 +24,19 @@
#include "Media/Clip.h"
#include "MediaCellView.h"
#include "Library/MediaContainer.h"
#include "Library/Library.h"
#include "Main/Core.h"
#include "Project/Project.h"
#include "StackViewController.h"
#include <QApplication>
MediaListView::MediaListView( StackViewController *nav, MediaContainer *mc ) :
MediaListView::MediaListView(StackViewController *nav) :
ListViewController( nav ),
m_nav( nav ),
m_mediaContainer( mc )
m_nav( nav )
{
connect( mc, SIGNAL( newClipLoaded( Clip* ) ),
this, SLOT( newClipLoaded( Clip* ) ) );
connect( this, SIGNAL( clipRemoved( const QUuid& ) ),
mc, SLOT( deleteClip( const QUuid& ) ) );
connect( mc, SIGNAL( clipRemoved( const QUuid& ) ),
this, SLOT( __clipRemoved( const QUuid& ) ) );
connect( mc, SIGNAL( destroyed() ), this, SLOT( deleteLater() ) );
foreach ( Clip *clip, mc->clips() )
newClipLoaded( clip );
connect( Core::getInstance(), SIGNAL( projectLoading( Project* ) ),
this, SLOT( projectLoading( Project* ) ) );
}
MediaListView::~MediaListView()
......@@ -68,6 +62,12 @@ MediaListView::newClipLoaded( Clip *clip )
cellSelection( clip->uuid() );
}
void
MediaListView::projectLoading( Project* project )
{
setMediaContainer( project->library() );
}
void
MediaListView::cellSelection( const QUuid &uuid )
{
......@@ -117,7 +117,9 @@ void
MediaListView::showSubClips( const QUuid &uuid )
{
Clip *clip = m_mediaContainer->clip( uuid );
m_nav->pushViewController( new MediaListView( m_nav, clip->getChilds() ) );
MediaListView* view = new MediaListView( m_nav );
view->setMediaContainer( clip->getChilds() );
m_nav->pushViewController( view );
}
const MediaListView::MediaList&
......@@ -125,3 +127,15 @@ MediaListView::mediaList() const
{
return m_cells;
}
void
MediaListView::setMediaContainer( MediaContainer* container )
{
m_mediaContainer = container;
connect( m_mediaContainer, SIGNAL( newClipLoaded( Clip* ) ),
this, SLOT( newClipLoaded( Clip* ) ) );
connect( this, SIGNAL( clipRemoved( const QUuid& ) ),
m_mediaContainer, SLOT( deleteClip( const QUuid& ) ) );
connect( m_mediaContainer, SIGNAL( clipRemoved( const QUuid& ) ),
this, SLOT( __clipRemoved( const QUuid& ) ) );
}
......@@ -33,6 +33,7 @@ class Clip;
class Media;
class MediaContainer;
class MediaCellView;
class Project;
class StackViewController;
class QWidget;
......@@ -44,10 +45,11 @@ class MediaListView : public ListViewController
public:
typedef QHash<QUuid, MediaCellView*> MediaList;
MediaListView( StackViewController *nav, MediaContainer *mc );
MediaListView( StackViewController *nav );
virtual ~MediaListView();
const MediaList &mediaList() const;
void setMediaContainer( MediaContainer* container );
private:
StackViewController *m_nav;
......@@ -71,6 +73,8 @@ private slots:
void __clipRemoved( const QUuid& );
void newClipLoaded( Clip *clip );
void projectLoading( Project* project );
signals:
void clipSelected( Clip* );
/// Used when the user clicks the deletion arrow.
......
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