]> git.sesse.net Git - kdenlive/blob - src/commands/edittransitioncommand.cpp
Use QLatin1String
[kdenlive] / src / commands / edittransitioncommand.cpp
1 /***************************************************************************
2                           edittransitioncommand.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 #include "edittransitioncommand.h"
19 #include "customtrackview.h"
20
21 #include <KLocalizedString>
22
23 EditTransitionCommand::EditTransitionCommand(CustomTrackView *view, const int track, const GenTime &pos, const QDomElement &oldeffect, const QDomElement &effect, bool doIt, QUndoCommand * parent) :
24         QUndoCommand(parent),
25         m_view(view),
26         m_track(track),
27         m_oldeffect(oldeffect),
28         m_pos(pos),
29         m_doIt(doIt)
30 {
31     m_effect = effect.cloneNode().toElement();
32     QString effectName;
33     QDomElement namenode = effect.firstChildElement(QLatin1String("name"));
34     if (!namenode.isNull()) effectName = i18n(namenode.text().toUtf8().data());
35     else effectName = i18n("effect");
36     setText(i18n("Edit transition %1", effectName));
37 }
38
39 // virtual
40 int EditTransitionCommand::id() const
41 {
42     return 2;
43 }
44
45 // virtual
46 bool EditTransitionCommand::mergeWith(const QUndoCommand * other)
47 {
48     if (other->id() != id()) return false;
49     if (m_track != static_cast<const EditTransitionCommand*>(other)->m_track) return false;
50     if (m_pos != static_cast<const EditTransitionCommand*>(other)->m_pos) return false;
51     m_effect = static_cast<const EditTransitionCommand*>(other)->m_effect;
52     return true;
53 }
54
55 // virtual
56 void EditTransitionCommand::undo()
57 {
58     m_view->updateTransition(m_track, m_pos, m_effect, m_oldeffect, m_doIt);
59 }
60 // virtual
61 void EditTransitionCommand::redo()
62 {
63     m_view->updateTransition(m_track, m_pos, m_oldeffect, m_effect, m_doIt);
64     m_doIt = true;
65 }
66