Commit d6b8c557 authored by Hugo Beauzee-Luyssen's avatar Hugo Beauzee-Luyssen

Removing ImportMediaListController.

This breaks almost everything right now, but clean the code soooo
much...
Will be fixed in next commits.
parent 4c9a1b4e
......@@ -35,7 +35,6 @@ SET(VLMC_SRCS
Gui/WorkflowFileRendererDialog.cpp
Gui/export/RendererSettings.cpp
Gui/import/ImportController.cpp
Gui/import/ImportMediaListController.cpp
Gui/library/ListViewController.cpp
Gui/library/MediaCellView.cpp
Gui/library/MediaLibraryWidget.cpp
......@@ -115,7 +114,6 @@ SET (VLMC_HDRS
Gui/export/RendererSettings.h
Gui/FileInfoListModel.h
Gui/import/ImportController.h
Gui/import/ImportMediaListController.h
Gui/LanguageHelper.h
Gui/LCDTimecode.h
Gui/library/ListViewController.h
......
......@@ -40,14 +40,13 @@ ImportController::ImportController(QWidget *parent) :
QDialog(parent),
m_ui(new Ui::ImportController),
m_clipListController( 0 ),
m_controllerSwitched( false ),
m_nbMediaToLoad( 0 ),
m_nbMediaLoaded( 0 )
{
m_ui->setupUi(this);
m_preview = new PreviewWidget( new ClipRenderer, m_ui->previewContainer );
m_stackNav = new StackViewController( m_ui->stackViewContainer, false );
m_mediaListController = new ImportMediaListController( m_stackNav );
m_mediaListController = new MediaListViewController( m_stackNav );
m_tag = new TagWidget( m_ui->tagContainer, 6 );
m_filesModel = new QFileSystemModel( this );
m_stackNav->pushViewController( m_mediaListController );
......@@ -132,45 +131,32 @@ ImportController::changeEvent( QEvent *e )
void
ImportController::mediaSelection( const QUuid& uuid )
{
if ( m_mediaListController->contains( uuid ) )
{
if ( !m_currentUuid.isNull() && m_mediaListController->contains( m_currentUuid ) )
m_mediaListController->cell( m_currentUuid )->setPalette( this->palette() );
QPalette p = m_mediaListController->cell( uuid )->palette();
p.setColor( QPalette::Window, QColor( Qt::darkBlue ) );
m_mediaListController->cell( uuid )->setPalette( p );
setUIMetaData( m_temporaryMedias[uuid] );
if ( uuid != NULL && uuid != m_currentUuid )
m_preview->stop();
m_currentUuid = uuid;
emit mediaSelected( m_temporaryMedias[uuid] );
}
if ( m_currentUuid == uuid )
return ;
setUIMetaData( m_temporaryMedias[uuid] );
m_preview->stop();
m_currentUuid = uuid;
emit mediaSelected( m_temporaryMedias[uuid] );
}
void
ImportController::clipSelection( const QUuid& uuid )
{
if ( !m_currentUuid.isNull() && !m_controllerSwitched )
m_clipListController->cell( m_currentUuid )->setPalette( palette() );
else
m_controllerSwitched = false;
QPalette p = m_clipListController->cell( uuid )->palette();
p.setColor( QPalette::Window, QColor( Qt::darkBlue ) );
m_clipListController->cell( uuid )->setPalette( p );
if ( uuid == m_currentUuid )
return ;
Clip* clip;
foreach( Media* media, m_temporaryMedias.values() )
{
if ( ( clip = media->clip( uuid ) ) != 0 )
if ( ( clip = media->clip( uuid ) ) != NULL )
break;
}
if ( clip == 0 )
if ( clip == NULL )
return ;
setUIMetaData( clip );
if ( uuid != m_currentUuid )
m_preview->stop();
m_preview->stop();
emit clipSelected( clip );
m_currentUuid = uuid;
}
void
......@@ -233,7 +219,7 @@ ImportController::importMedia( const QString &filePath )
this, SLOT( mediaLoaded() ) );
m_temporaryMedias[media->baseClip()->uuid()] = media;
MetaDataManager::getInstance()->computeMediaMetadata( media );
m_mediaListController->addMedia( media );
m_mediaListController->newMediaLoaded( media );
}
void
......@@ -295,7 +281,7 @@ void
ImportController::reject()
{
m_preview->stop();
m_mediaListController->cleanAll();
m_mediaListController->clear();
deleteTemporaryMedias();
collapseAllButCurrentPath();
done( Rejected );
......@@ -304,7 +290,7 @@ ImportController::reject()
void
ImportController::accept()
{
m_mediaListController->cleanAll();
m_mediaListController->clear();
m_preview->stop();
collapseAllButCurrentPath();
foreach ( Media* media, m_temporaryMedias.values() )
......@@ -339,7 +325,6 @@ ImportController::collapseAllButCurrentPath()
void
ImportController::mediaDeletion( const QUuid& uuid )
{
m_mediaListController->removeMedia( uuid );
if ( m_temporaryMedias.contains( uuid ) == true )
delete m_temporaryMedias.take( uuid );
......@@ -354,7 +339,6 @@ ImportController::mediaDeletion( const QUuid& uuid )
void
ImportController::clipDeletion( const QUuid& uuid )
{
m_clipListController->removeClip( uuid );
foreach( Media* media, m_temporaryMedias.values() )
{
if ( media != NULL && media->clip( uuid ) )
......@@ -371,32 +355,23 @@ ImportController::showClipList( const QUuid& uuid )
if ( media->clipsCount() == 0 )
return ;
m_clipListController = new ImportMediaListController( m_stackNav );
m_clipListController = new MediaListViewController( 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& ) ) );
m_clipListController->addClipsFromMedia( media );
foreach ( Clip* clip, media->clips().values() )
m_clipListController->newClipAdded( clip );
if ( !m_currentUuid.isNull() )
m_savedUuid = m_currentUuid;
m_controllerSwitched = true;
m_stackNav->pushViewController( m_clipListController );
}
void
ImportController::restoreContext()
{
if ( m_clipListController->nbDeletions() != 0 )
{
if ( !m_savedUuid.isNull() && m_mediaListController->cell( m_savedUuid ) != NULL )
{
MediaCellView* cell = m_mediaListController->cell( m_savedUuid );
cell->decrementClipCount( m_clipListController->nbDeletions() );
}
}
if ( !m_savedUuid.isNull() )
m_currentUuid = m_savedUuid;
m_controllerSwitched = false;
qDebug() << "FIXME: update clip count";
m_currentUuid = m_savedUuid;
}
void
......
......@@ -31,7 +31,7 @@
#define IMPORTCONTROLLER_H
#include "Clip.h"
#include "ImportMediaListController.h"
#include "MediaListViewController.h"
#include "Media.h"
#include "PreviewWidget.h"
#include "StackViewController.h"
......@@ -75,13 +75,12 @@ class ImportController : public QDialog
PreviewWidget* m_preview;
StackViewController* m_stackNav;
TagWidget* m_tag;
ImportMediaListController* m_mediaListController;
ImportMediaListController* m_clipListController;
MediaListViewController *m_mediaListController;
MediaListViewController *m_clipListController;
QFileSystemModel *m_filesModel;
QString m_currentlyWatchedDir;
QUuid m_currentUuid;
QUuid m_savedUuid;
bool m_controllerSwitched;
QHash< QUuid, Media*> m_temporaryMedias;
quint32 m_nbMediaToLoad;
quint32 m_nbMediaLoaded;
......
/*****************************************************************************
* ImportMediaListController.cpp
*****************************************************************************
* Copyright (C) 2008-2010 VideoLAN
*
* Authors: Geoffroy Lacarriere <geoffroylaca@gmail.com>
* Thomas Boquet <thomas.boquet@gmail.com>
* Clement CHAVANCE <chavance.c@gmail.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#include "ImportMediaListController.h"
#include "MediaCellView.h"
ImportMediaListController::ImportMediaListController( StackViewController* nav ) :
ListViewController( nav ), m_nav( nav ), m_clipDeleted( 0 )
{
m_mediaCellList = new QHash<QUuid, MediaCellView*>();
}
ImportMediaListController::~ImportMediaListController()
{
delete m_mediaCellList;
}
void
ImportMediaListController::addMedia( Media* media )
{
MediaCellView* cell = new MediaCellView( media->baseClip() );
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( media, SIGNAL( clipAdded(Clip*) ),
this, SLOT( clipAdded( Clip* ) ) );
addCell( cell );
m_mediaCellList->insert( media->baseClip()->uuid(), cell );
}
MediaCellView*
ImportMediaListController::cell( QUuid uuid ) const
{
if (m_mediaCellList->contains( uuid ) )
return m_mediaCellList->value( uuid );
return NULL;
}
bool
ImportMediaListController::contains( QUuid uuid )
{
return m_mediaCellList->contains( uuid );
}
void
ImportMediaListController::removeMedia( const QUuid& uuid )
{
const QUuid saveUuid = uuid;
removeCell( m_mediaCellList->value( uuid ) );
m_mediaCellList->remove( saveUuid );
}
void
ImportMediaListController::addClip( Clip* clip )
{
MediaCellView* cell = new MediaCellView( clip );
cell->containsClip();
connect( cell, SIGNAL( cellSelected( const QUuid& ) ),
this, SIGNAL( clipSelected( const QUuid& ) ) );
connect( cell, SIGNAL( cellDeleted( const QUuid& ) ),
this, SLOT( clipDeletion( const QUuid& ) ) );
addCell( cell );
m_mediaCellList->insert( clip->uuid(), cell );
}
void
ImportMediaListController::removeClip( const QUuid& uuid )
{
removeCell( m_mediaCellList->value( uuid ) );
m_mediaCellList->remove( uuid );
}
void
ImportMediaListController::cleanAll()
{
foreach( MediaCellView* cell, m_mediaCellList->values() )
removeCell( cell );
m_mediaCellList->clear();
}
void
ImportMediaListController::addClipsFromMedia( Media* media )
{
foreach( Clip* clip, media->clips().values() )
addClip( clip );
}
void
ImportMediaListController::clipDeletion( const QUuid& uuid )
{
m_clipDeleted += 1;
emit clipDeleted( uuid );
}
void
ImportMediaListController::clipAdded( Clip* clip )
{
if ( clip->getParent() == 0 )
return ;
const QUuid& uuid = clip->getParent()->baseClip()->uuid();
if ( m_mediaCellList->contains( uuid ) )
m_mediaCellList->value( uuid )->incrementClipCount();
}
const QHash<QUuid, MediaCellView*>*
ImportMediaListController::mediaCellList() const
{
return m_mediaCellList;
}
/*****************************************************************************
* ImportMediaListController.h
*****************************************************************************
* Copyright (C) 2008-2010 VideoLAN
*
* Authors: Geoffroy Lacarriere <geoffroylaca@gmail.com>
* Thomas Boquet <thomas.boquet@gmail.com>
* Clement CHAVANCE <chavance.c@gmail.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#ifndef IMPORTMEDIALISTCONTROLLER_H
#define IMPORTMEDIALISTCONTROLLER_H
#include "StackViewController.h"
#include "ListViewController.h"
#include "Media.h"
#include "Clip.h"
class MediaCellView;
class ImportMediaListController : public ListViewController
{
Q_OBJECT
public:
ImportMediaListController( StackViewController* nav );
~ImportMediaListController();
void addMedia( Media* media );
void removeMedia( const QUuid& uuid );
void addClip( Clip* clip );
void removeClip( const QUuid& uuid );
void cleanAll();
void addClipsFromMedia( Media* media );
const QHash<QUuid, MediaCellView*>* mediaCellList() const;
MediaCellView* cell( QUuid uuid ) const;
bool contains( QUuid uuid );
int nbDeletions() const { return m_clipDeleted; }
private:
StackViewController* m_nav;
QHash<QUuid, MediaCellView*>* m_mediaCellList;
int m_clipDeleted;
public slots:
void clipDeletion( const QUuid& uuid );
void clipAdded( Clip* clip );
signals:
void mediaSelected( const QUuid& uuid );
void clipSelected( const QUuid& uuid );
void mediaDeleted( const QUuid& uuid );
void clipDeleted( const QUuid& uuid );
void showClipListAsked( const QUuid& uuid );
};
#endif // IMPORTMEDIALISTCONTROLLER_H
......@@ -201,3 +201,9 @@ MediaCellView::containsClip()
SIGNAL( clicked( QWidget*, QMouseEvent* ) ), this,
SLOT( arrowButtonClicked( QWidget*, QMouseEvent* ) ) );
}
const QUuid&
MediaCellView::uuid() const
{
return m_clip->uuid();
}
......@@ -57,6 +57,7 @@ public:
void decrementClipCount( const int nb );
QString title() const;
void containsClip();
const QUuid& uuid() const;
protected:
void changeEvent( QEvent *e );
......
......@@ -84,6 +84,14 @@ void MediaListViewController::mediaRemoved( const QUuid& uuid )
emit clipDeleted( uuid );
}
void
MediaListViewController::clear()
{
foreach ( QWidget* cell, m_cells->values() )
removeCell( cell );
m_cells->clear();
}
void MediaListViewController::showClipList( const QUuid& uuid )
{
if ( !m_cells->contains( uuid ) )
......
......@@ -50,6 +50,7 @@ public slots:
void mediaRemoved( const QUuid& uuid );
void showClipList( const QUuid& uuid );
void newClipAdded( Clip* clip );
void clear();
private slots:
void restoreContext();
......
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