]> git.sesse.net Git - kdenlive/blob - src/commands/addtransitioncommand.cpp
8a8002f2b077bf2a9026bdcf26b75489ab5f517c
[kdenlive] / src / commands / addtransitioncommand.cpp
1 /***************************************************************************
2                           addtransitioncommand.cpp  -  description
3                              -------------------
4     begin                : 2008
5     copyright            : (C) 2008 by Marco Gittler
6     email                : g.marco@freenet.de
7  ***************************************************************************/
8
9 /***************************************************************************
10  *                                                                         *
11  *   This program is free software; you can redistribute it and/or modify  *
12  *   it under the terms of the GNU General Public License as published by  *
13  *   the Free Software Foundation; either version 2 of the License, or     *
14  *   (at your option) any later version.                                   *
15  *                                                                         *
16  ***************************************************************************/
17
18
19 #include "addtransitioncommand.h"
20 #include "customtrackview.h"
21
22 #include <KLocale>
23
24 AddTransitionCommand::AddTransitionCommand(CustomTrackView *view, const ItemInfo &info, int transitiontrack, const QDomElement &params, bool remove, bool doIt, QUndoCommand * parent) :
25         QUndoCommand(parent),
26         m_view(view),
27         m_info(info),
28         m_params(params),
29         m_track(transitiontrack),
30         m_doIt(doIt),
31         m_remove(remove)
32 {
33     if (m_remove)
34         setText(i18n("Delete transition from clip"));
35     else
36         setText(i18n("Add transition to clip"));
37
38     if (parent) {
39         // command has a parent, so there are several operations ongoing, do not refresh monitor
40         m_refresh = false;
41     } else {
42         m_refresh = true;
43     }
44 }
45
46
47 // virtual
48 void AddTransitionCommand::undo()
49 {
50     if (m_remove)
51         m_view->addTransition(m_info, m_track, m_params, m_refresh);
52     else
53         m_view->deleteTransition(m_info, m_track, m_params, m_refresh);
54 }
55 // virtual
56 void AddTransitionCommand::redo()
57 {
58     if (m_doIt) {
59         if (m_remove)
60             m_view->deleteTransition(m_info, m_track, m_params, m_refresh);
61         else
62             m_view->addTransition(m_info, m_track, m_params, m_refresh);
63     }
64     m_doIt = true;
65 }
66
67