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

Adding a Helper class.

This class is now the parent of both EffectHelper and ClipHelper
classes.
parent 9c673e81
......@@ -45,6 +45,7 @@ SET(VLMC_SRCS
Workflow/AudioClipWorkflow.cpp
Workflow/ClipWorkflow.cpp
Workflow/ClipHelper.cpp
Workflow/Helper.cpp
Workflow/ImageClipWorkflow.cpp
Workflow/MainWorkflow.cpp
Workflow/TrackHandler.cpp
......@@ -89,6 +90,7 @@ SET (VLMC_HDRS
Workflow/AudioClipWorkflow.h
Workflow/ClipWorkflow.h
Workflow/ClipHelper.h
Workflow/Helper.h
Workflow/ImageClipWorkflow.h
Workflow/MainWorkflow.h
Workflow/TrackHandler.h
......
......@@ -24,60 +24,9 @@
EffectHelper::EffectHelper( EffectInstance *effectInstance, qint64 begin, qint64 end,
const QString &uuid ) :
m_effectInstance( effectInstance ),
m_begin( begin ),
m_end( end )
Helper( begin, end, uuid ),
m_effectInstance( effectInstance )
{
if ( uuid.isNull() == true )
m_uuid = QUuid::createUuid();
else
m_uuid = uuid;
}
qint64
EffectHelper::begin() const
{
return m_begin;
}
qint64
EffectHelper::end() const
{
return m_end;
}
void
EffectHelper::setBegin( qint64 begin )
{
m_begin = begin;
emit lengthUpdated();
}
void
EffectHelper::setEnd(qint64 end)
{
m_end = end;
emit lengthUpdated();
}
void
EffectHelper::setBoundaries( qint64 begin, qint64 end )
{
m_begin = begin;
m_end = end;
emit lengthUpdated();
}
qint64
EffectHelper::length() const
{
return m_end - m_begin;
}
const QUuid&
EffectHelper::uuid() const
{
return m_uuid;
}
EffectInstance*
......
......@@ -25,11 +25,13 @@
class EffectInstance;
#include "Helper.h"
#include <QObject>
#include <QUuid>
#include <QMetaType>
class EffectHelper : public QObject
class EffectHelper : public Workflow::Helper
{
Q_OBJECT
......@@ -37,24 +39,11 @@ class EffectHelper : public QObject
EffectHelper( EffectInstance *effectInstance, qint64 begin = 0, qint64 end = -1,
const QString& uuid = QString() );
qint64 begin() const;
qint64 end() const;
void setBegin( qint64 begin );
void setEnd( qint64 end );
void setBoundaries( qint64 begin, qint64 end );
qint64 length() const;
const QUuid &uuid() const;
EffectInstance *effectInstance();
const EffectInstance *effectInstance() const;
private:
EffectInstance *m_effectInstance;
qint64 m_begin;
qint64 m_end;
QUuid m_uuid;
signals:
void lengthUpdated();
EffectInstance *m_effectInstance;
};
Q_DECLARE_METATYPE( EffectHelper* );
......
......@@ -26,19 +26,14 @@
ClipHelper::ClipHelper( Clip* clip, qint64 begin /*= -1*/, qint64 end /*= -1*/,
const QString& uuid /*= QString()*/ ) :
Helper( begin, end, uuid ),
m_clip( clip ),
m_begin( begin ),
m_end( end ),
m_clipWorkflow( NULL )
{
if ( begin == -1 )
m_begin = clip->begin();
if ( end == -1 )
m_end = clip->end();
if ( uuid.isEmpty() == true )
m_uuid = QUuid::createUuid();
else
m_uuid = QUuid( uuid );
}
void
......@@ -46,8 +41,7 @@ ClipHelper::setBegin( qint64 begin )
{
if ( begin < m_clip->m_begin )
return ;
m_begin = begin;
emit lengthUpdated();
Workflow::Helper::setBegin( begin );
}
void
......@@ -55,24 +49,17 @@ ClipHelper::setEnd( qint64 end )
{
if ( end > m_clip->m_end )
return ;
m_end = end;
emit lengthUpdated();
Workflow::Helper::setEnd( end );
}
void
ClipHelper::setBoundaries( qint64 begin, qint64 end )
{
if ( begin >= m_clip->m_begin )
m_begin = begin;
begin = begin;
if ( end <= m_clip->m_end )
m_end = end;
emit lengthUpdated();
}
qint64
ClipHelper::length() const
{
return m_end - m_begin;
end = end;
setBoundaries( begin, end );
}
ClipWorkflow*
......
......@@ -26,10 +26,12 @@
class Clip;
class ClipWorkflow;
#include "Helper.h"
#include <QObject>
#include <QUuid>
class ClipHelper : public QObject
class ClipHelper : public Workflow::Helper
{
Q_OBJECT
......@@ -45,38 +47,17 @@ class ClipHelper : public QObject
{
return m_clip;
}
qint64 begin() const
{
return m_begin;
}
void setBegin( qint64 begin );
qint64 end() const
{
return m_end;
}
void setEnd( qint64 end );
void setBoundaries( qint64 begin, qint64 end );
/**
* \return The length in frames
*/
qint64 length() const;
const QUuid &uuid() const
{
return m_uuid;
}
ClipWorkflow *clipWorkflow();
void setClipWorkflow( ClipWorkflow* cw );
private:
Clip* m_clip;
qint64 m_begin;
qint64 m_end;
QUuid m_uuid;
ClipWorkflow* m_clipWorkflow;
signals:
void lengthUpdated();
void error();
};
......
/*****************************************************************************
* Helper.cpp: Describes a common interface for all workflow helpers.
*****************************************************************************
* Copyright (C) 2008-2010 VideoLAN
*
* Authors: Hugo Beauzée-Luyssen <beauze.h@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 "Helper.h"
using namespace Workflow;
Helper::Helper( qint64 begin /*= 0*/, qint64 end /*= -1*/, const QString &uuid/* = QString()*/ ) :
m_begin( begin ),
m_end( end )
{
if ( uuid.isNull() == true )
m_uuid = QUuid::createUuid();
else
m_uuid = uuid;
}
qint64
Helper::begin() const
{
return m_begin;
}
qint64
Helper::end() const
{
return m_end;
}
void
Helper::setBegin( qint64 begin )
{
m_begin = begin;
emit lengthUpdated();
}
void
Helper::setEnd(qint64 end)
{
m_end = end;
emit lengthUpdated();
}
void
Helper::setBoundaries( qint64 begin, qint64 end )
{
m_begin = begin;
m_end = end;
emit lengthUpdated();
}
qint64
Helper::length() const
{
return m_end - m_begin;
}
const QUuid&
Helper::uuid() const
{
return m_uuid;
}
/*****************************************************************************
* Helper.h: Describes a common interface for all workflow helpers.
*****************************************************************************
* Copyright (C) 2008-2010 VideoLAN
*
* Authors: Hugo Beauzée-Luyssen <beauze.h@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 IHELPER_H
#define IHELPER_H
#include <QObject>
#include <QUuid>
namespace Workflow
{
class Helper : public QObject
{
Q_OBJECT
protected: //This class is not meant to be used by itself.
Helper( qint64 begin = 0, qint64 end = -1, const QString &uuid = QString() );
public:
virtual const QUuid& uuid() const;
virtual qint64 begin() const;
virtual qint64 end() const;
virtual void setBegin( qint64 begin );
virtual void setEnd( qint64 end );
virtual qint64 length() const;
virtual void setBoundaries( qint64 begin, qint64 end );
protected:
qint64 m_begin;
qint64 m_end;
QUuid m_uuid;
signals:
void lengthUpdated();
};
}
#endif // IHELPER_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