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