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

Starting a workspace implementation.

For now, files are just copied to the specified workspace directory.
parent f3918c74
......@@ -19,6 +19,8 @@ SET(VLMC_SRCS
Metadata/MetaDataManager.cpp
Metadata/MetaDataWorker.cpp
Project/ProjectManager.cpp
Project/Workspace.cpp
Project/WorkspaceWorker.cpp
Renderer/ClipRenderer.cpp
Renderer/GenericRenderer.cpp
Renderer/WorkflowFileRenderer.cpp
......@@ -59,6 +61,8 @@ SET (VLMC_HDRS
Metadata/MetaDataManager.h
Metadata/MetaDataWorker.h
Project/ProjectManager.h
Project/Workspace.h
Project/WorkspaceWorker.h
Renderer/ClipRenderer.h
Renderer/GenericRenderer.h
Renderer/WorkflowFileRenderer.h
......
......@@ -111,7 +111,7 @@ MediaContainer::addClip( Clip* clip )
( clip->getMedia()->fileInfo() == c->getMedia()->fileInfo() &&
( clip->begin() == c->begin() && clip->end() == c->end() ) ) )
{
qDebug() << "Clip already loaded.";
qWarning() << "Clip already loaded.";
return false;
}
}
......
......@@ -263,3 +263,27 @@ Media::setBaseClip( Clip *clip )
Q_ASSERT( m_baseClip == NULL );
m_baseClip = clip;
}
bool
Media::isInWorkspace() const
{
return m_inWorkspace;
}
void
Media::setInWorkspace(bool inWorkspace )
{
m_inWorkspace = inWorkspace;
}
void
Media::setFilePath( const QString &filePath )
{
delete m_fileInfo;
m_fileInfo = new QFileInfo( filePath );
m_fileName = m_fileInfo->fileName();
if ( m_fileType == Media::Video || m_fileType == Media::Audio )
m_mrl = "file:///" + QUrl::toPercentEncoding( filePath, "/" );
else
m_mrl = "fake:///" + QUrl::toPercentEncoding( filePath, "/" );
}
......@@ -93,6 +93,7 @@ public:
const QFileInfo *fileInfo() const;
const QString &mrl() const;
const QString &fileName() const;
void setFilePath( const QString& path );
/**
\return Returns the length of this media (ie the
......@@ -146,6 +147,9 @@ public:
void save( QXmlStreamWriter& project );
bool isInWorkspace() const;
void setInWorkspace( bool inWorkspace );
private:
void setFileType();
......@@ -167,6 +171,7 @@ protected:
int m_nbAudioTracks;
int m_nbVideoTracks;
bool m_metadataComputed;
bool m_inWorkspace;
signals:
void metaDataComputed( const Media* );
......
......@@ -27,6 +27,7 @@
#include "project/GuiProjectManager.h"
#include "ProjectManager.h"
#include "SettingsManager.h"
#include "Workspace.h"
#include <QDir>
#include <QSettings>
......@@ -69,6 +70,8 @@ ProjectManager::ProjectManager() : m_projectFile( NULL ), m_needSave( false )
//We have to wait for the library to be loaded before loading the workflow
connect( Library::getInstance(), SIGNAL( projectLoaded() ), this, SLOT( loadWorkflow() ) );
//Create the workspace:
Workspace::getInstance();
}
ProjectManager::~ProjectManager()
......
/*****************************************************************************
* Workspace.cpp: Workspace management
*****************************************************************************
* Copyright (C) 2008-2010 VideoLAN
*
* Authors: Hugo Beauzee-Luyssen <hugo@vlmc.org>
*
* 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 "Workspace.h"
#include "Clip.h"
#include "Library.h"
#include "Media.h"
#include "Project/WorkspaceWorker.h"
#include <QtDebug>
const QString Workspace::workspacePrefix = "workspace://";
Workspace::Workspace()
{
connect( Library::getInstance(), SIGNAL( newClipLoaded( Clip* ) ),
this, SLOT( clipLoaded( Clip* ) ) );
}
void
Workspace::copyToWorkspace( Media *media )
{
qDebug() << "Copying media:" << media->fileInfo() << "to workspace.";
if ( media->isInWorkspace() == false )
{
WorkspaceWorker *worker = new WorkspaceWorker( media );
//This one is direct connected since the thread is terminated just after emitting the signal.
connect( worker, SIGNAL( copied( Media*, QString ) ),
this, SLOT( copyTerminated( Media*, QString ) ), Qt::DirectConnection );
worker->start();
}
}
void
Workspace::clipLoaded( Clip *clip )
{
//Don't bother if the clip is a subclip.
if ( clip->isRootClip() == false )
return ;
//If already in workspace : well...
if ( clip->getMedia()->isInWorkspace() == true )
return ;
copyToWorkspace( clip->getMedia() );
}
void
Workspace::copyTerminated( Media *media, QString dest )
{
media->setFilePath( dest );
media->setInWorkspace( true );
}
/*****************************************************************************
* Workspace.h: Workspace management
*****************************************************************************
* Copyright (C) 2008-2010 VideoLAN
*
* Authors: Hugo Beauzee-Luyssen <hugo@vlmc.org>
*
* 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 WORKSPACE_H
#define WORKSPACE_H
#include <QObject>
#include "Singleton.hpp"
class Clip;
class Media;
class Workspace : public QObject, public Singleton<Workspace>
{
Q_OBJECT
public:
static const QString workspacePrefix;
private:
Workspace();
~Workspace(){}
void copyToWorkspace( Media* media );
public slots:
void clipLoaded( Clip* clip );
private slots:
void copyTerminated( Media* media, QString dest );
friend class Singleton<Workspace>;
};
#endif // WORKSPACE_H
/*****************************************************************************
* WorkspaceWorker.cpp: The Workspace worker
*****************************************************************************
* Copyright (C) 2008-2010 VideoLAN
*
* Authors: Hugo Beauzee-Luyssen <hugo@vlmc.org>
*
* 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 "WorkspaceWorker.h"
#include "Media.h"
#include "SettingsManager.h"
#include <QFile>
#include <QFileInfo>
#include <QtDebug>
WorkspaceWorker::WorkspaceWorker( Media *media ) :
m_media( media )
{
connect( this, SIGNAL( finished() ), this, SLOT( deleteLater() ) );
}
void
WorkspaceWorker::run()
{
QFile file( m_media->fileInfo()->absoluteFilePath() );
const QString &projectPath = VLMC_PROJECT_GET_STRING( "general/ProjectDir" );
const QString dest = projectPath + '/' + m_media->fileInfo()->fileName();
file.copy( m_media->fileInfo()->absoluteFilePath(), dest );
emit copied( m_media, dest );
}
/*****************************************************************************
* WorkspaceWorker.h: The Workspace worker
*****************************************************************************
* Copyright (C) 2008-2010 VideoLAN
*
* Authors: Hugo Beauzee-Luyssen <hugo@vlmc.org>
*
* 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 WORKSPACEWORKER_H
#define WORKSPACEWORKER_H
#include <QThread>
class Media;
class WorkspaceWorker : public QThread
{
Q_OBJECT
public:
explicit WorkspaceWorker( Media *filePath );
protected:
void run();
private:
Media* m_media;
signals:
void copied( Media*, QString dest );
};
#endif // WORKSPACEWORKER_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