Commit 5ac08f73 authored by Hugo Beauzee-Luyssen's avatar Hugo Beauzee-Luyssen

Clarification: MediaListViewController is now MediaListView.

As it is a view, it doesn't interact directly with the MediaContainer,
but emit signals, and watches for MediaContainer changes to update
itself, thus (mostly) stopping this permanent mvc pattern rape.
parent de5e0219
......@@ -38,7 +38,7 @@ SET(VLMC_SRCS
Gui/library/ListViewController.cpp
Gui/library/MediaCellView.cpp
Gui/library/MediaLibraryWidget.cpp
Gui/library/MediaListViewController.cpp
Gui/library/MediaListView.cpp
Gui/library/StackViewController.cpp
Gui/library/StackViewNavController.cpp
Gui/settings/BoolWidget.cpp
......@@ -120,7 +120,7 @@ SET (VLMC_HDRS
Gui/library/ListViewController.h
Gui/library/MediaCellView.h
Gui/library/MediaLibraryWidget.h
Gui/library/MediaListViewController.h
Gui/library/MediaListView.h
Gui/library/StackViewController.h
Gui/library/StackViewNavController.h
Gui/library/ViewController.h
......
......@@ -30,6 +30,7 @@
#include "Library.h"
#include "MetaDataManager.h"
#include "MediaCellView.h"
#include "MediaListView.h"
#include <QPalette>
#include <QSettings>
......@@ -39,7 +40,6 @@
ImportController::ImportController(QWidget *parent) :
QDialog(parent),
m_ui(new Ui::ImportController),
m_clipListController( 0 ),
m_nbMediaToLoad( 0 ),
m_nbMediaLoaded( 0 )
{
......@@ -47,10 +47,10 @@ ImportController::ImportController(QWidget *parent) :
m_preview = new PreviewWidget( new ClipRenderer, m_ui->previewContainer );
m_stackNav = new StackViewController( m_ui->stackViewContainer, false );
m_temporaryMedias = new MediaContainer;
m_mediaListController = new MediaListViewController( m_stackNav, m_temporaryMedias );
m_mediaListView = new MediaListView( m_stackNav, m_temporaryMedias );
m_tag = new TagWidget( m_ui->tagContainer, 6 );
m_filesModel = new QFileSystemModel( this );
m_stackNav->pushViewController( m_mediaListController );
m_stackNav->pushViewController( m_mediaListView );
QStringList filters;
filters << Media::AudioExtensions.split(' ', QString::SkipEmptyParts)
......@@ -87,12 +87,12 @@ ImportController::ImportController(QWidget *parent) :
connect( m_ui->forwardButton, SIGNAL( clicked() ),
this, SLOT( forwardButtonClicked() ) );
connect( m_mediaListController, SIGNAL( clipSelected( Clip* ) ),
connect( m_mediaListView, SIGNAL( clipSelected( Clip* ) ),
qobject_cast<const ClipRenderer*>( m_preview->getGenericRenderer() ),
SLOT( setClip( Clip* ) ) );
connect( m_mediaListController, SIGNAL( clipSelected( Clip* ) ),
connect( m_mediaListView, SIGNAL( clipSelected( Clip* ) ),
this, SLOT( mediaSelection( Clip* ) ) );
connect( m_mediaListController, SIGNAL( clipDeleted( const QUuid& ) ),
connect( m_mediaListView, SIGNAL( clipDeleted( const QUuid& ) ),
qobject_cast<const ClipRenderer*>( m_preview->getGenericRenderer() ),
SLOT( clipUnloaded( const QUuid& ) ) );
......@@ -246,7 +246,7 @@ void
ImportController::reject()
{
m_preview->stop();
m_mediaListController->clear();
m_mediaListView->clear();
m_temporaryMedias->clear();
collapseAllButCurrentPath();
done( Rejected );
......@@ -255,7 +255,7 @@ ImportController::reject()
void
ImportController::accept()
{
m_mediaListController->clear();
m_mediaListView->clear();
m_preview->stop();
collapseAllButCurrentPath();
foreach ( Clip* clip, m_temporaryMedias->clips().values() )
......
......@@ -31,7 +31,6 @@
#define IMPORTCONTROLLER_H
#include "Clip.h"
#include "MediaListViewController.h"
#include "Media.h"
#include "PreviewWidget.h"
#include "StackViewController.h"
......@@ -42,6 +41,7 @@
#include <QProgressDialog>
class MediaContainer;
class MediaListView;
namespace Ui
{
......@@ -74,8 +74,7 @@ class ImportController : public QDialog
PreviewWidget* m_preview;
StackViewController* m_stackNav;
TagWidget* m_tag;
MediaListViewController *m_mediaListController;
MediaListViewController *m_clipListController;
MediaListView *m_mediaListView;
QFileSystemModel *m_filesModel;
QString m_currentlyWatchedDir;
QUuid m_currentUuid;
......
......@@ -22,7 +22,7 @@
#include "MediaLibraryWidget.h"
#include "StackViewController.h"
#include "MediaListViewController.h"
#include "MediaListView.h"
#include "Media.h"
#include "Clip.h"
......@@ -32,7 +32,7 @@ MediaLibraryWidget::MediaLibraryWidget( QWidget* parent ) : QWidget( parent )
Library* library = Library::getInstance();
m_nav = new StackViewController( this );
MediaListViewController* list = new MediaListViewController( m_nav, library );
MediaListView* list = new MediaListView( m_nav, library );
//Media
connect( list, SIGNAL( clipSelected( Clip* ) ),
this, SIGNAL( clipSelected( Clip* ) ) );
......
......@@ -20,12 +20,12 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#include "MediaListViewController.h"
#include "MediaListView.h"
#include "Clip.h"
#include "MediaContainer.h"
MediaListViewController::MediaListViewController( StackViewController* nav, MediaContainer* mc ) :
MediaListView::MediaListView( StackViewController* nav, MediaContainer* mc ) :
ListViewController( nav ),
m_nav( nav ),
m_clipsListView( 0 ),
......@@ -33,20 +33,22 @@ MediaListViewController::MediaListViewController( StackViewController* nav, Medi
{
connect( mc, SIGNAL( newClipLoaded(Clip*) ),
this, SLOT( newClipLoaded( Clip* ) ) );
connect( this, SIGNAL( clipDeleted( const QUuid& ) ),
mc, SLOT(removeClip( const QUuid& ) ) );
foreach ( Clip* clip, mc->clips() )
newClipLoaded( clip );
connect( m_nav, SIGNAL( previousButtonPushed() ),
this, SLOT( restoreContext() ) );
}
MediaListViewController::~MediaListViewController()
MediaListView::~MediaListView()
{
foreach ( QWidget* cell, m_cells )
delete cell;
m_cells.clear();
}
void MediaListViewController::newClipLoaded( Clip *clip )
void MediaListView::newClipLoaded( Clip *clip )
{
MediaCellView* cell = new MediaCellView( clip );
......@@ -60,7 +62,7 @@ void MediaListViewController::newClipLoaded( Clip *clip )
m_cells.insert( clip->uuid(), cell );
}
void MediaListViewController::cellSelection( const QUuid& uuid )
void MediaListView::cellSelection( const QUuid& uuid )
{
if ( m_currentUuid == uuid )
return;
......@@ -80,33 +82,32 @@ void MediaListViewController::cellSelection( const QUuid& uuid )
}
}
void MediaListViewController::clipRemoved( const Clip* clip )
void MediaListView::clipRemoved( const Clip* clip )
{
QWidget* cell = m_cells.value( clip->uuid() );
removeCell( cell );
m_cells.remove( clip->uuid() );
m_currentUuid = QUuid();
m_mediaContainer->removeClip( clip );
emit clipDeleted( clip->uuid() );
delete clip;
}
void
MediaListViewController::clear()
MediaListView::clear()
{
foreach ( QWidget* cell, m_cells.values() )
removeCell( cell );
m_cells.clear();
}
void MediaListViewController::showSubClips( const QUuid& uuid )
void MediaListView::showSubClips( const QUuid& uuid )
{
Clip* clip = m_mediaContainer->clip( uuid );
m_clipsListView = new MediaListViewController( m_nav, clip->getChilds() );
m_clipsListView = new MediaListView( m_nav, clip->getChilds() );
m_nav->pushViewController( m_clipsListView );
}
void MediaListViewController::restoreContext()
void MediaListView::restoreContext()
{
delete m_clipsListView;
m_currentUuid = QUuid();
......
/*****************************************************************************
* MediaListViewController.h:
* MediaListView.h:
*****************************************************************************
* Copyright (C) 2008-2010 VideoLAN
*
* Authors: Thomas Boquet <thomas.boquet@gmail.com>
* Hugo Beauzée-Luyssen <beauze.h@vlmc.org>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
......@@ -20,8 +21,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#ifndef MEDIALISTVIEWCONTROLLER_H
#define MEDIALISTVIEWCONTROLLER_H
#ifndef MEDIALISTVIEW_H
#define MEDIALISTVIEW_H
#include "StackViewController.h"
#include "ListViewController.h"
......@@ -31,19 +32,19 @@
class MediaContainer;
class MediaListViewController : public ListViewController
class MediaListView : public ListViewController
{
Q_OBJECT
public:
MediaListViewController( StackViewController* nav, MediaContainer* mc );
virtual ~MediaListViewController();
MediaListView( StackViewController* nav, MediaContainer* mc );
virtual ~MediaListView();
private:
StackViewController* m_nav;
QUuid m_currentUuid;
QHash<QUuid, QWidget*> m_cells;
MediaListViewController* m_clipsListView;
MediaListView* m_clipsListView;
QUuid m_lastUuidClipListAsked;
MediaContainer* m_mediaContainer;
......@@ -61,4 +62,4 @@ signals:
void clipSelected( Clip* );
void clipDeleted( const QUuid& );
};
#endif // MEDIALISTVIEWCONTROLLER_H
#endif // MEDIALISTVIEW_H
......@@ -117,34 +117,26 @@ MediaContainer::removeAll()
m_clips.clear();
}
//Clip*
//MediaContainer::removeClip( const QUuid &uuid )
//{
// QHash<QUuid, Clip*>::iterator it = m_clips.find( uuid );
// if ( it != m_clips.end() )
// {
// Clip* clip = it.value();
// emit clipRemoved( it.value() );
// m_clips.remove( uuid );
// return clip;
// }
// return NULL;
//}
Clip*
MediaContainer::removeClip( const Clip* clip )
MediaContainer::removeClip( const QUuid &uuid )
{
QHash<QUuid, Clip*>::iterator it = m_clips.find( clip->uuid() );
QHash<QUuid, Clip*>::iterator it = m_clips.find( uuid );
if ( it != m_clips.end() )
{
Clip* removed = it.value();
Clip* clip = it.value();
emit clipRemoved( it.value() );
m_clips.remove( clip->uuid() );
return removed;
m_clips.remove( uuid );
return clip;
}
return NULL;
}
Clip*
MediaContainer::removeClip( const Clip* clip )
{
return removeClip( clip->uuid() );
}
const QHash<QUuid, Clip*>&
MediaContainer::clips() const
{
......
......@@ -103,6 +103,7 @@ public slots:
* \param clip The clip to remove.
*/
Clip *removeClip( const Clip* clip );
Clip *removeClip( const QUuid& uuid );
/**
* \brief Clear the library (remove all the loaded Clip, delete their subclips, and
* delete them)
......
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