Commands.h 8.9 KB
Newer Older
1 2 3
/*****************************************************************************
 * Commands.h: Contains all the implementation of VLMC commands.
 *****************************************************************************
4
 * Copyright (C) 2008-2016 VideoLAN
5
 *
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
6
 * Authors: Hugo Beauzée-Luyssen <hugo@beauzee.fr>
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
#include "config.h"
28
#include "Workflow/SequenceWorkflow.h"
29

Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
30
#ifdef HAVE_GUI
31 32
# include <QUndoCommand>
#endif
33
#include <QObject>
34
#include <QUuid>
35 36
#include <QSharedPointer>

37 38
#include <memory>

39
class   Clip;
luyikei's avatar
luyikei committed
40 41 42

namespace Backend
{
luyikei's avatar
luyikei committed
43
class IInput;
luyikei's avatar
luyikei committed
44 45
}
class   EffectHelper;
46 47 48

namespace Commands
{
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
49
#ifdef HAVE_GUI
50
    class       Generic : public QObject, public QUndoCommand
51
#else
52
    class       Generic : public QObject
53 54
#endif
    {
55 56
        Q_OBJECT

57
        public:
58
            Generic();
59 60 61 62
            virtual void    internalRedo() = 0;
            virtual void    internalUndo() = 0;
            void            redo();
            void            undo();
63
            bool            isValid() const;
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
64
#ifndef HAVE_GUI
65 66 67
            void            setText( const QString& text ) ;
            QString         text() const;
#endif
68 69
        private:
            bool            m_valid;
70
            QString         m_text;
71
        protected slots:
72
            virtual void    retranslate() = 0;
73 74 75
            void            invalidate();
        signals:
            void            invalidated();
76 77
    };

78
    namespace   Clip
79
    {
80
        class   Add : public Generic
81 82
        {
            public:
83
                Add( std::shared_ptr<SequenceWorkflow> const& workflow, const QUuid& uuid, quint32 trackId, qint32 pos );
84 85
                virtual void    internalRedo();
                virtual void    internalUndo();
86
                virtual void    retranslate();
87

88
            private:
89
                std::shared_ptr<SequenceWorkflow> m_workflow;
90
                QUuid                       m_libraryUuid;
91 92
                QUuid                       m_audioInstanceUuid;
                QUuid                       m_videoInstanceUuid;
93
                quint32                     m_trackId;
94
                qint64                      m_pos;
95
        };
96

97
        class   Move : public Generic
98 99
        {
            public:
100
                Move( std::shared_ptr<SequenceWorkflow> const& workflow, const QString& uuid, quint32 trackId, qint64 pos );
101 102
                virtual void    internalRedo();
                virtual void    internalUndo();
103
                virtual void    retranslate();
104 105

            private:
106
                std::shared_ptr<SequenceWorkflow> m_workflow;
107
                QUuid           m_uuid;
108 109
                quint32         m_newTrackId;
                quint32         m_oldTrackId;
110 111
                qint64          m_newPos;
                qint64          m_oldPos;
112
        };
113

114
        class   Remove : public Generic
115 116
        {
            public:
117
                Remove( std::shared_ptr<SequenceWorkflow> const& workflow, const QUuid& uuid );
118 119
                virtual void internalRedo();
                virtual void internalUndo();
120
                virtual void    retranslate();
121 122

            private:
123 124
                std::shared_ptr<SequenceWorkflow>       m_workflow;
                QSharedPointer<SequenceWorkflow::Clip>  m_clip;
125 126
                quint32         m_trackId;
                qint64          m_pos;
127
        };
128

129 130 131 132 133 134 135
        /**
         *  \brief  This command is used to resize a clip.
         *  \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
        */
136
        class   Resize : public Generic
137 138
        {
            public:
139 140
                Resize( std::shared_ptr<SequenceWorkflow> const& workflow,
                        const QUuid& uuid, qint64 newBegin, qint64 newEnd, qint64 newPos );
141 142
                virtual void    internalRedo();
                virtual void    internalUndo();
143 144
                virtual void    retranslate();

145
            private:
146
                std::shared_ptr<SequenceWorkflow> m_workflow;
147
                QSharedPointer<SequenceWorkflow::Clip>  m_clip;
148
                qint64                      m_newBegin;
149
                qint64                      m_oldBegin;
150
                qint64                      m_newEnd;
151 152 153
                qint64                      m_oldEnd;
                qint64                      m_newPos;
                qint64                      m_oldPos;
Hugo Beauzee-Luyssen's avatar
Hugo Beauzee-Luyssen committed
154
        };
155

156
        class   Split : public Generic
157 158
        {
            public:
159 160
                Split( std::shared_ptr<SequenceWorkflow> const& workflow,
                       const QUuid& uuid, qint64 newClipPos, qint64 newClipBegin );
161 162
                virtual void    internalRedo();
                virtual void    internalUndo();
163
                virtual void    retranslate();
164
            private:
165
                std::shared_ptr<SequenceWorkflow> m_workflow;
166
                QSharedPointer<SequenceWorkflow::Clip>  m_toSplit;
167
                quint32                           m_trackId;
168 169
                QSharedPointer<::Clip>      m_newClip;
                QUuid                       m_newClipUuid;
170 171
                qint64                      m_newClipPos;
                qint64                      m_newClipBegin;
172
                qint64                      m_oldEnd;
173
        };
luyikei's avatar
luyikei committed
174 175 176 177

        class   Link : public Generic
        {
            public:
178 179
                Link( std::shared_ptr<SequenceWorkflow> const& workflow,
                      const QUuid& clipA, const QUuid& clipB );
luyikei's avatar
luyikei committed
180 181 182 183
                virtual void    internalRedo();
                virtual void    internalUndo();
                virtual void    retranslate();
            private:
184 185 186
                std::shared_ptr<SequenceWorkflow> m_workflow;
                QUuid     m_clipA;
                QUuid     m_clipB;
luyikei's avatar
luyikei committed
187
        };
188
    }
189 190
    namespace   Effect
    {
191
        class   Add : public Generic
192 193
        {
            public:
luyikei's avatar
luyikei committed
194
                Add( std::shared_ptr<EffectHelper> const& helper, Backend::IInput* target );
195 196
                virtual void    internalRedo();
                virtual void    internalUndo();
197
                virtual void    retranslate();
198
            private:
199
                std::shared_ptr<EffectHelper>   m_helper;
luyikei's avatar
luyikei committed
200
                Backend::IInput*      m_target;
201 202
        };

203
        class   Move : public Generic
204 205
        {
            public:
luyikei's avatar
luyikei committed
206
                Move( std::shared_ptr<EffectHelper> const& helper, std::shared_ptr<Backend::IInput> const& from, Backend::IInput* to, qint64 pos );
207 208
                virtual void    internalRedo();
                virtual void    internalUndo();
209
                virtual void    retranslate();
210
            private:
luyikei's avatar
luyikei committed
211 212 213
                std::shared_ptr<EffectHelper>       m_helper;
                std::shared_ptr<Backend::IInput>    m_from;
                Backend::IInput      *m_to;
214 215
                qint64          m_oldPos;
                qint64          m_newPos;
216 217
                qint64          m_newEnd;
                qint64          m_oldEnd;
218
        };
219

220
        class   Resize : public Generic
221 222
        {
            public:
223
                Resize( std::shared_ptr<EffectHelper> const& helper, qint64 newBegin, qint64 newEnd );
224 225
                virtual void        internalRedo();
                virtual void        internalUndo();
226
                virtual void        retranslate();
227
            private:
228
                std::shared_ptr<EffectHelper>       m_helper;
229 230 231 232 233
                qint64              m_newBegin;
                qint64              m_newEnd;
                qint64              m_oldBegin;
                qint64              m_oldEnd;
        };
234

235
        class   Remove : public Generic
236 237
        {
            public:
238
                Remove( std::shared_ptr<EffectHelper> const& helper );
239 240
                virtual void    internalRedo();
                virtual void    internalUndo();
241
                virtual void    retranslate();
242
            private:
243
                std::shared_ptr<EffectHelper>       m_helper;
244
                std::shared_ptr<Backend::IInput>    m_target;
245
        };
246
    }
247 248
}

249
#endif // COMMANDS_H