Commit e0ea8bd8 authored by Ludovic Fauvet's avatar Ludovic Fauvet
Browse files

Split Commands header from implementation

parent 20fb83e0
/*****************************************************************************
* Commands.cpp: Contains all the implementation of VLMC commands.
*****************************************************************************
* Copyright (C) 2008-2009 the VLMC team
*
* Authors: Hugo Beauzee-Luyssen <hugo@vlmc.org>
* Ludovic Fauvet <etix@l0cal.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 <QUndoCommand>
#include "Commands.h"
#include "UndoStack.h"
#include "MainWorkflow.h"
#include "Clip.h"
void Commands::trigger( QUndoCommand* command )
{
UndoStack::getInstance()->push( command );
}
Commands::MainWorkflow::AddClip::AddClip( ::MainWorkflow* workflow, Clip* clip, unsigned int trackNumber, qint64 pos ) :
m_workflow( workflow ), m_clip( clip ), m_trackNumber( trackNumber ), m_pos( pos )
{
setText( QObject::tr( "Adding clip to track %1" ).arg( QString::number( trackNumber ) ) );
}
void Commands::MainWorkflow::AddClip::redo()
{
m_workflow->addClip( m_clip, m_trackNumber, m_pos );
}
void Commands::MainWorkflow::AddClip::undo()
{
m_workflow->removeClip( m_clip->getUuid(), m_trackNumber );
}
Commands::MainWorkflow::MoveClip::MoveClip( ::MainWorkflow* workflow, const QUuid& uuid,
unsigned int oldTrack, qint64 oldPos, unsigned int newTrack, qint64 newPos ) :
m_workflow( workflow ), m_uuid( uuid ), m_oldTrack( oldTrack ),
m_newTrack( newTrack ), m_pos( newPos ), m_oldPos( oldPos )
{
setText( QObject::tr( "Moving clip" ) );
m_undoRedoAction = false;
}
void Commands::MainWorkflow::MoveClip::redo()
{
m_workflow->moveClip( m_uuid, m_oldTrack, m_newTrack, m_pos, m_undoRedoAction );
m_undoRedoAction = true;
}
void Commands::MainWorkflow::MoveClip::undo()
{
m_workflow->moveClip( m_uuid, m_newTrack, m_oldTrack, m_oldPos, m_undoRedoAction );
m_undoRedoAction = true;
}
Commands::MainWorkflow::RemoveClips::RemoveClips( ::MainWorkflow* workflow, const QVector<ClipActionInfo>& clipsInfos ) :
m_workflow( workflow ), m_clips( clipsInfos )
{
setText( QObject::tr( "Remove clip" ) );
}
void Commands::MainWorkflow::RemoveClips::redo()
{
for (int i = 0; i < m_clips.size(); ++i )
m_workflow->removeClip( m_clips.at( i ).clip->getUuid(), m_clips.at( i ).trackNumber );
}
void Commands::MainWorkflow::RemoveClips::undo()
{
for (int i = 0; i < m_clips.size(); ++i )
m_workflow->addClip( m_clips.at( i ).clip, m_clips.at( i ).trackNumber, m_clips.at( i ).pos );
}
Commands::MainWorkflow::ResizeClip::ResizeClip( ::MainWorkflow* mainWorkflow, const QUuid& uuid, unsigned int trackId,
float newBegin, float newEnd ) :
m_mainWorkflow( mainWorkflow ),
m_newBegin( newBegin ),
m_newEnd( newEnd )
{
m_clip = mainWorkflow->getClip( uuid, trackId );
m_oldBegin = m_clip->getBegin();
m_oldEnd = m_clip->getEnd();
}
void Commands::MainWorkflow::ResizeClip::redo()
{
m_clip->setBegin( m_newBegin );
m_clip->setEnd( m_newEnd );
}
void Commands::MainWorkflow::ResizeClip::undo()
{
m_clip->setBegin( m_oldBegin );
m_clip->setEnd( m_oldEnd );
}
......@@ -4,6 +4,7 @@
* Copyright (C) 2008-2009 the VLMC team
*
* Authors: Hugo Beauzee-Luyssen <hugo@vlmc.org>
* Ludovic Fauvet <etix@l0cal.com>
*
* 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 COMMANDS_HPP
#define COMMANDS_HPP
#ifndef COMMANDS_H
#define COMMANDS_H
#include <QUndoCommand>
#include <QObject>
......@@ -34,10 +35,7 @@
namespace Commands
{
void trigger( QUndoCommand* command )
{
UndoStack::getInstance()->push( command );
}
void trigger( QUndoCommand* command );
namespace MainWorkflow
{
......@@ -51,19 +49,9 @@ namespace Commands
NEW_COMMAND( AddClip )
{
public:
AddClip( ::MainWorkflow* workflow, Clip* clip, unsigned int trackNumber, qint64 pos ) :
m_workflow( workflow ), m_clip( clip ), m_trackNumber( trackNumber ), m_pos( pos )
{
setText( QObject::tr( "Adding clip to track %1" ).arg( QString::number( trackNumber ) ) );
}
virtual void redo()
{
m_workflow->addClip( m_clip, m_trackNumber, m_pos );
}
virtual void undo()
{
m_workflow->removeClip( m_clip->getUuid(), m_trackNumber );
}
AddClip( ::MainWorkflow* workflow, Clip* clip, unsigned int trackNumber, qint64 pos );
virtual void redo();
virtual void undo();
private:
::MainWorkflow* m_workflow;
Clip* m_clip;
......@@ -75,23 +63,9 @@ namespace Commands
{
public:
MoveClip( ::MainWorkflow* workflow, const QUuid& uuid,
unsigned int oldTrack, qint64 oldPos, unsigned int newTrack, qint64 newPos ) :
m_workflow( workflow ), m_uuid( uuid ), m_oldTrack( oldTrack ),
m_newTrack( newTrack ), m_pos( newPos ), m_oldPos( oldPos )
{
setText( QObject::tr( "Moving clip" ) );
m_undoRedoAction = false;
}
virtual void redo()
{
m_workflow->moveClip( m_uuid, m_oldTrack, m_newTrack, m_pos, m_undoRedoAction );
m_undoRedoAction = true;
}
virtual void undo()
{
m_workflow->moveClip( m_uuid, m_newTrack, m_oldTrack, m_oldPos, m_undoRedoAction );
m_undoRedoAction = true;
}
unsigned int oldTrack, qint64 oldPos, unsigned int newTrack, qint64 newPos );
virtual void redo();
virtual void undo();
private:
::MainWorkflow* m_workflow;
......@@ -106,21 +80,9 @@ namespace Commands
NEW_COMMAND( RemoveClips )
{
public:
RemoveClips( ::MainWorkflow* workflow, const QVector<ClipActionInfo>& clipsInfos ) :
m_workflow( workflow ), m_clips( clipsInfos )
{
setText( QObject::tr( "Remove clip" ) );
}
virtual void redo()
{
for (int i = 0; i < m_clips.size(); ++i )
m_workflow->removeClip( m_clips.at( i ).clip->getUuid(), m_clips.at( i ).trackNumber );
}
virtual void undo()
{
for (int i = 0; i < m_clips.size(); ++i )
m_workflow->addClip( m_clips.at( i ).clip, m_clips.at( i ).trackNumber, m_clips.at( i ).pos );
}
RemoveClips( ::MainWorkflow* workflow, const QVector<ClipActionInfo>& clipsInfos );
virtual void redo();
virtual void undo();
private:
::MainWorkflow* m_workflow;
......@@ -131,25 +93,9 @@ namespace Commands
{
public:
ResizeClip( ::MainWorkflow* mainWorkflow, const QUuid& uuid, unsigned int trackId,
float newBegin, float newEnd ) :
m_mainWorkflow( mainWorkflow ),
m_newBegin( newBegin ),
m_newEnd( newEnd )
{
m_clip = mainWorkflow->getClip( uuid, trackId );
m_oldBegin = m_clip->getBegin();
m_oldEnd = m_clip->getEnd();
}
virtual void redo()
{
m_clip->setBegin( m_newBegin );
m_clip->setEnd( m_newEnd );
}
virtual void undo()
{
m_clip->setBegin( m_oldBegin );
m_clip->setEnd( m_oldEnd );
}
float newBegin, float newEnd );
virtual void redo();
virtual void undo();
private:
::MainWorkflow* m_mainWorkflow;
float m_oldBegin;
......@@ -161,4 +107,4 @@ namespace Commands
}
}
#endif // COMMANDS_HPP
#endif // COMMANDS_H
......@@ -33,7 +33,7 @@
#include "Library.h"
#include "GraphicsMovieItem.h"
#include "GraphicsCursorItem.h"
#include "Commands.hpp"
#include "Commands.h"
#include "GraphicsTrack.hpp"
TracksView::TracksView( QGraphicsScene* scene, MainWorkflow* mainWorkflow, QWidget* parent )
......
......@@ -5,7 +5,8 @@ TEMPLATE = app
OBJECTS_DIR = build
MOC_DIR = build/moc
UI_DIR = build/ui
QMAKE_EXT_H = .h .hpp
QMAKE_EXT_H = .h \
.hpp
INCLUDEPATH = build/moc \
build/ui
QT += gui \
......@@ -55,7 +56,8 @@ SOURCES += src/main.cpp \
src/GUI/Settings.cpp \
src/GUI/Panel.cpp \
src/GUI/PreferenceWidget.cpp \
src/GUI/ProjectPreferences.cpp
src/GUI/ProjectPreferences.cpp \
src/Commands/Commands.cpp
HEADERS += src/GUI/MainWindow.h \
src/GUI/DockWidgetManager.h \
src/GUI/LibraryWidget.h \
......@@ -101,13 +103,13 @@ HEADERS += src/GUI/MainWindow.h \
src/GUI/UndoStack.h \
src/Tools/WaitCondition.hpp \
src/Metadata/MetaDataManager.h \
src/Commands/Commands.hpp \
src/Tools/QSingleton.hpp \
src/GUI/ClipProperty.h \
src/GUI/WorkflowFileRendererDialog.h \
src/GUI/Settings.h \
src/GUI/Panel.h \
src/GUI/GraphicsTrack.hpp
src/GUI/GraphicsTrack.hpp \
src/Commands/Commands.h
FORMS += src/GUI/ui/MainWindow.ui \
src/GUI/ui/PreviewWidget.ui \
src/GUI/ui/LanguagePreferences.ui \
......
Supports Markdown
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