Commit 834beff4 authored by Geoffroy Lacarriere's avatar Geoffroy Lacarriere

delete unsused files

parent 4e453ac5
/*****************************************************************************
* Import.cpp: Import menu
*****************************************************************************
* Copyright (C) 2008-2009 the VLMC team
*
* Authors: Geoffroy Lacarriere <geoffroylaca@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 <QTime>
#include "Import.h"
#include "ui_Import.h"
#include "PreviewWidget.h"
#include "TagWidget.h"
#include "ImportMediaCellView.h"
#include "Media.h"
#include "ClipRenderer.h"
#include "Library.h"
Import::Import(QWidget *parent) :
QDialog( parent ), m_ui( new Ui::Import )
{
m_ui->setupUi( this );
m_importBrowser = new ImportBrowser( m_ui->ImportBrowserWidget );
m_previewWidget = new PreviewWidget( new ClipRenderer, m_ui->PreviewWidget );
m_tagWidget = new TagWidget( m_ui->TagWidget, 6 );
connect( m_importBrowser, SIGNAL( mediaAdded( Media*, ImportMediaCellView* ) ), this, SLOT( addMedia( Media*, ImportMediaCellView* ) ) );
connect( m_importBrowser, SIGNAL( mediaRemoved() ), this, SLOT( removeMedia() ) );
connect( this, SIGNAL( mediaSelected( Media* ) ), m_previewWidget->getGenericRenderer(), SLOT( setMedia( Media* ) ) );
connect( this, SIGNAL( mediaSelected( Media* ) ), m_tagWidget, SLOT( mediaSelected( Media* ) ) );
}
Import::~Import()
{
delete m_ui;
delete m_importBrowser;
delete m_previewWidget;
delete m_tagWidget;
}
void Import::addMedia( Media* media, ImportMediaCellView* cell )
{
m_mediaList.insert( media->getUuid(), media );
connect( cell, SIGNAL( mediaSelected( QUuid ) ), this, SLOT( setUIMetaData( QUuid ) ) );
connect( cell->nextButton(), SIGNAL( clicked( QWidget*,QMouseEvent* ) ), this, SLOT( clipViewRequested( QWidget*,QMouseEvent* ) ) );
}
void Import::removeMedia()
{
m_mediaList.remove( m_currentUuid );
m_importBrowser->getMediaListView()->removeMedia( m_currentUuid );
}
void Import::setUIMetaData( QUuid uuid )
{
m_currentUuid = uuid;
//Duration
QTime duration;
duration = duration.addSecs( m_mediaList[uuid]->getLength() );
m_ui->durationValueLabel->setText( duration.toString( "hh:mm:ss" ) );
//Filename || title
m_ui->nameValueLabel->setText( m_mediaList[uuid]->getFileInfo()->fileName() );
m_ui->nameValueLabel->setWordWrap( true );
setWindowTitle( m_mediaList[uuid]->getFileInfo()->fileName() + " " + tr( "properties" ) );
//Resolution
m_ui->resolutionValueLabel->setText( QString::number( m_mediaList[uuid]->getWidth() )
+ " x " + QString::number( m_mediaList[uuid]->getHeight() ) );
//FPS
m_ui->fpsValueLabel->setText( QString::number( m_mediaList[uuid]->getFps() ) );
emit mediaSelected( m_mediaList[uuid] );
}
void Import::accept()
{
QHashIterator<QUuid, Media*> iterator( m_mediaList );
while ( iterator.hasNext() )
{
iterator.next();
Library::getInstance()->addMedia( iterator.value() );
}
done(Accepted);
}
void Import::changeEvent( QEvent *e )
{
QDialog::changeEvent( e );
switch ( e->type() )
{
case QEvent::LanguageChange:
m_ui->retranslateUi( this );
break;
default:
break;
}
}
void Import::clipViewRequested( QWidget* sender, QMouseEvent* ev )
{
MediaCellView* cell = qobject_cast<MediaCellView*>(sender->parent());
ImportMediaListController* clipListView = m_importBrowser->getClipListView();
if ( cell == NULL )
return;
clipListView->cleanAll();
Media* media = m_mediaList[cell->uuid()];
delete clipListView;
clipListView = new ImportMediaListController(m_importBrowser->getStackViewController());
m_importBrowser->getClipListView()->addClipsFromMedia( media );
m_importBrowser->getStackViewController()->pushViewController( m_importBrowser->getClipListView() );
}
/*****************************************************************************
* Import.h: Import menu
*****************************************************************************
* Copyright (C) 2008-2009 the VLMC team
*
* Authors: Geoffroy Lacarriere <geoffroylaca@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 IMPORT_H
#define IMPORT_H
#include <QDialog>
class PreviewWidget;
class TagWidget;
class ImportMediaCellView;
class Media;
namespace Ui
{
class Import;
}
class Import : public QDialog
{
Q_OBJECT
public:
Import( QWidget *parent = 0 );
~Import();
protected:
void changeEvent( QEvent *e );
private:
Ui::Import* m_ui;
PreviewWidget* m_previewWidget;
TagWidget* m_tagWidget;
QHash<QUuid, Media*> m_mediaList;
QUuid m_currentUuid;
private slots:
void accept();
void addMedia( Media* media, ImportMediaCellView* cell );
void removeMedia();
void setUIMetaData( QUuid uuid );
void clipViewRequested( QWidget* sender, QMouseEvent* ev );
signals:
void mediaSelected( Media* );
};
#endif // IMPORT_H
/*****************************************************************************
* ImportModel.cpp
*****************************************************************************
* Copyright (C) 2008-2009 the VLMC team
*
* Authors: Geoffroy Lacarriere <geoffroylaca@gmail.com>
* Thomas Boquet <thomas.boquet@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 <QDebug>
#include <QDir>
#include <QMessageBox>
#include "ImportModel.h"
ImportModel::ImportModel()
{
m_medias = new QHash<QUuid, Media*>();
m_progressDialog = new QProgressDialog("Importing files...", "Cancel", 0, m_loadingMedias, NULL);
m_progressDialog->setWindowModality( Qt::WindowModal );
m_progressDialog->setMinimumDuration( 1000 );
m_nbLoadedMedias = 0;
}
ImportModel::~ImportModel()
{
}
Media* ImportModel::getMedia( const QUuid& mediaId ) const
{
return m_medias->value( mediaId );
}
Clip* ImportModel::getClip( const QUuid& mediaId, const QUuid& clipId ) const
{
Media* media = m_medias->value( mediaId );
if ( !media )
return NULL;
return media->clip( clipId );
}
void ImportModel::cutMedia( const QUuid& mediaId, int frame )
{
Q_UNUSED( mediaId );
Q_UNUSED( frame );
}
void ImportModel::cutClip( const QUuid& mediaId, const QUuid& clipId, int frame )
{
Q_UNUSED( mediaId );
Q_UNUSED( clipId );
Q_UNUSED( frame );
}
void ImportModel::metaDataComputed( Media* media )
{
disconnect( media, SIGNAL( metaDataComputed( Media* ) ), this, SLOT( metaDataComputed( Media* ) ) );
if ( media->getMetadata() == Media::ParsedWithoutSnapshot )
{
m_medias->insert( media->getUuid(), media );
emit updateMediaRequested( media );
}
else
m_invalidMedias.append( media );
m_progressDialog->setValue( ++m_nbLoadedMedias );
if( m_progressDialog->wasCanceled() )
{
Media* media;
foreach( media, m_invalidMedias )
removeMedia( media->getUuid() );
//delete media;
m_nbLoadedMedias = 0;
m_invalidMedias.clear();
return;
}
if ( m_nbLoadedMedias == m_loadingMedias )
{
if ( m_invalidMedias.count() > 0 )
{
QStringList list;
Media* media;
foreach( media, m_invalidMedias )
{
list.append( media->getFileName() );
removeMedia( media->getUuid() );
//delete media;
}
QMessageBox::warning( NULL, QString( "Error!" ), QString( tr( "Error while loading media(s):\n%0" ) ).arg( list.join( QString("\n") ) ) );
m_invalidMedias.clear();
}
m_nbLoadedMedias = 0;
}
}
void ImportModel::snapshotComputed( Media *media )
{
disconnect( media, SIGNAL( snapshotComputed( Media* ) ), this, SLOT( snapshotComputed( Media* ) ) );
if ( !m_invalidMedias.contains( media ) )
emit updateMediaRequested( media );
}
void ImportModel::loadMedia( Media* media )
{
connect( media, SIGNAL( metaDataComputed( Media* ) ), this, SLOT( metaDataComputed( Media* ) ), Qt::QueuedConnection );
connect( media, SIGNAL( snapshotComputed(Media*) ), this, SLOT( snapshotComputed(Media*) ), Qt::QueuedConnection );
connect( media, SIGNAL( audioSpectrumComputed( Media* ) ), this, SLOT( audioSpectrumComputed(Media*) ) );
MetaDataManager::getInstance()->computeMediaMetadata( media );
emit newMediaLoaded( media );
}
bool ImportModel::mediaAlreadyLoaded( const QFileInfo& fileInfo )
{
QUuid id;
foreach(id, m_medias->keys())
if ( m_medias->value( id )->getFileInfo()->filePath() == fileInfo.filePath() )
return true;
return false;
}
void ImportModel::loadFile( const QFileInfo& fileInfo, int loadingMedias )
{
Media* media;
if ( !fileInfo.isDir() )
{
if ( loadingMedias == 1 )
m_progressDialog->setMaximum( 1 );
if ( !mediaAlreadyLoaded( fileInfo ) )
{
media = new Media( fileInfo.filePath() );
loadMedia( media );
}
else
m_progressDialog->setValue( ++m_nbLoadedMedias );
}
else
{
QDir dir = QDir( fileInfo.filePath() );
QFileInfoList list = dir.entryInfoList( m_filters );
QFileInfo file;
m_loadingMedias = list.count();
m_nbLoadedMedias = 0;
m_progressDialog->setValue( 0 );
m_progressDialog->setMaximum( m_loadingMedias );
foreach( file, list )
loadFile( file, m_loadingMedias );
}
}
void ImportModel::removeMedia( const QUuid& mediaId )
{
if ( m_medias->contains( mediaId ) && m_medias->value( mediaId )->getMetadata() == Media::ParsedWithAudioSpectrum )
delete m_medias->take( mediaId );
else
m_invalidMedias.append( m_medias->take( mediaId ) );
}
void ImportModel::audioSpectrumComputed( Media *media )
{
disconnect( media, SIGNAL( audioSpectrumComputed( Media* ) ), this, SLOT( audioSpectrumComputed( Media* ) ) );
if ( m_invalidMedias.contains( media ) )
{
m_invalidMedias.removeAll( media );
delete media;
}
}
void ImportModel::removeClip( const QUuid& mediaId, const QUuid& clipId )
{
if ( ! m_medias->contains( mediaId ) )
return ;
m_medias->value( mediaId )->removeClip( clipId );
}
void ImportModel::removeAllMedias()
{
QUuid id;
foreach( id, m_medias->keys() )
removeMedia( id );
}
/*****************************************************************************
* ImportModel.h
*****************************************************************************
* Copyright (C) 2008-2009 the VLMC team
*
* Authors: Geoffroy Lacarriere <geoffroylaca@gmail.com>
* Thomas Boquet <thomas.boquet@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 IMPORTMODEL_H
#define IMPORTMODEL_H
#include <QObject>
#include <QHash>
#include <QFileSystemModel>
#include <QDirModel>
#include <QProgressDialog>
#include "Media.h"
#include "Clip.h"
#include "MetaDataManager.h"
class ImportModel : public QObject
{
Q_OBJECT
public:
ImportModel();
~ImportModel();
Media* getMedia( const QUuid& mediaId ) const;
Clip* getClip( const QUuid& mediaId, const QUuid& clipId ) const;
void cutMedia( const QUuid& mediaId, int frame );
void cutClip( const QUuid& mediaId, const QUuid& clipId, int frame );
void loadFile( const QFileInfo& fileInfo, int loadingMedias = 1 );
void removeMedia( const QUuid& mediaId );
void removeClip( const QUuid& mediaId, const QUuid& clipId );
QHash<QUuid, Media*>* getMedias() const { return m_medias; }
void setFilter( const QStringList& filter ) { m_filters = filter; }
void removeAllMedias();
signals:
void newMediaLoaded( Media* media );
void updateMediaRequested( Media* media );
private:
QHash<QUuid, Media*>* m_medias;
QStringList m_filters;
QList<Media*> m_invalidMedias;
int m_loadingMedias;
int m_nbLoadedMedias;
QProgressDialog* m_progressDialog;
void loadMedia( Media* media );
bool mediaAlreadyLoaded( const QFileInfo& fileInfo );
private slots:
void metaDataComputed( Media* media );
void snapshotComputed( Media* media );
void audioSpectrumComputed( Media* media );
};
#endif // IMPORTMODEL_H
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