Commands.h 6.31 KB
Newer Older
1 2 3
/*****************************************************************************
 * Commands.h: Contains all the implementation of VLMC commands.
 *****************************************************************************
Ludovic Fauvet's avatar
Ludovic Fauvet committed
4
 * Copyright (C) 2008-2010 VideoLAN
5 6
 *
 * Authors: Hugo Beauzee-Luyssen <hugo@vlmc.org>
7
 *          Ludovic Fauvet <etix@l0cal.com>
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
 *
 * 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.
 *****************************************************************************/

24 25
#ifndef COMMANDS_H
#define COMMANDS_H
26

27 28 29 30
#include "config.h"
#ifdef WITH_GUI
# include <QUndoCommand>
#endif
31
#include <QObject>
32
#include <QVector>
33
#include "MainWorkflow.h"
34 35

class   Clip;
36

37
#define NEW_COMMAND(x)      class   x : public Generic
38 39 40

namespace Commands
{
41 42 43 44 45 46 47 48 49 50 51 52 53
#ifdef WITH_GUI
    class       Generic : public QUndoCommand
#else
    class       Generic
#endif
    {
        public:
            virtual void    redo() = 0;
            virtual void    undo() = 0;
            void            setText( const QString& ) {}
    };

#ifdef WITH_GUI
54
    void        trigger( QUndoCommand* command );
55 56 57
#else
    void        trigger( Generic* command );
#endif
58 59 60 61 62 63

    namespace   MainWorkflow
    {
        NEW_COMMAND( AddClip )
        {
            public:
64
                AddClip( Clip* clip, unsigned int trackNumber, qint64 pos,
65
                         ::MainWorkflow::TrackType trackType, bool undoRedoAction = false );
66
                virtual ~AddClip();
67 68
                virtual void    redo();
                virtual void    undo();
69
                const QUuid     &uuid() const;
70
            private:
71 72 73 74
                Clip*                       m_clip;
                unsigned int                m_trackNumber;
                qint64                      m_pos;
                ::MainWorkflow::TrackType   m_trackType;
75
                QUuid                       m_uuid;
76
                bool                        m_undoRedoAction;
77
        };
78 79 80 81 82

        NEW_COMMAND( MoveClip )
        {
            public:
                MoveClip( ::MainWorkflow* workflow, const QUuid& uuid,
83
                        unsigned int oldTrack, unsigned int newTrack,
84
                        qint64 newPos, ::MainWorkflow::TrackType trackType );
85 86
                virtual void    redo();
                virtual void    undo();
87 88

            private:
89 90 91 92 93 94 95 96
                ::MainWorkflow*             m_workflow;
                QUuid                       m_uuid;
                unsigned int                m_oldTrack;
                unsigned int                m_newTrack;
                qint64                      m_pos;
                qint64                      m_oldPos;
                bool                        m_undoRedoAction;
                ::MainWorkflow::TrackType   m_trackType;
97
        };
98

99
        NEW_COMMAND( RemoveClip )
100 101
        {
            public:
102
                RemoveClip( Clip* clip, const QUuid& uuid, unsigned int trackNumber,
103
                            qint64 pos, ::MainWorkflow::TrackType trackType );
104 105
                virtual void redo();
                virtual void undo();
106 107

            private:
108 109 110 111
                Clip*                       m_clip;
                unsigned int                m_trackNumber;
                qint64                      m_pos;
                ::MainWorkflow::TrackType   m_trackType;
112
                QUuid                       m_uuid;
113
        };
114

115 116 117 118 119 120 121 122 123 124 125
        /**
         *  \brief  This command is used to resize a clip.
         *  \param  uuid: The clip's uuid
         *  \param  newBegin: The clip's new beginning
         *  \param  newEnd: The clip's new end
         *  \param  newPos: if the clip was resized from the beginning, it is moved
         *                  so we have to know its new position
         *  \param  trackId:The track in which the modification occurs. This is only
         *                  used when the clip is resized from the beginning.
         *  \param  trackType:  The track's type (Audio or Video)
        */
126 127 128
        NEW_COMMAND( ResizeClip )
        {
            public:
129
                ResizeClip( const QUuid& uuid,
130 131
                            qint64 newBegin, qint64 newEnd, qint64 oldBegin,
                            qint64 oldEnd, qint64 newPos, qint64 oldPos,
132
                            quint32 trackId, ::MainWorkflow::TrackType trackType );
133 134
                virtual void    redo();
                virtual void    undo();
135
            private:
136
                QUuid                       m_uuid;
137 138
                qint64                      m_newBegin;
                qint64                      m_newEnd;
139 140 141 142
                qint64                      m_oldBegin;
                qint64                      m_oldEnd;
                qint64                      m_newPos;
                qint64                      m_oldPos;
143
                quint32                     m_trackId;
144
                Clip*                       m_clip;
145
                ::MainWorkflow::TrackType   m_trackType;
146
                bool                        m_undoRedoAction;
Hugo Beauzee-Luyssen's avatar
Hugo Beauzee-Luyssen committed
147
        };
148 149 150 151

        NEW_COMMAND( SplitClip )
        {
            public:
152
                SplitClip( Clip* toSplit, quint32 trackId,
153
                           qint64 newClipPos, qint64 newClipBegin, ::MainWorkflow::TrackType trackType );
154
                ~SplitClip();
155 156 157 158 159
                virtual void    redo();
                virtual void    undo();
            private:
                Clip*                       m_toSplit;
                Clip*                       m_newClip;
160
                quint32                     m_trackId;
161 162 163 164
                qint64                      m_newClipPos;
                qint64                      m_newClipBegin;
                ::MainWorkflow::TrackType   m_trackType;
        };
165 166 167
    }
}

168
#endif // COMMANDS_H