]> git.sesse.net Git - kdenlive/blob - src/commands/editkeyframecommand.cpp
bf5de55d2a83b99823c8be309884ee67f0860406
[kdenlive] / src / commands / editkeyframecommand.cpp
1 /***************************************************************************
2                           editkeyframecommand.cpp  -  description
3                              -------------------
4     begin                : 2008
5     copyright            : (C) 2008 by Jean-Baptiste Mardelle
6     email                : jb@kdenlive.org
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 "editkeyframecommand.h"
20 #include "customtrackview.h"
21
22 #include <KLocale>
23
24 EditKeyFrameCommand::EditKeyFrameCommand(CustomTrackView *view, const int track, const GenTime &pos, const int effectIndex, const QString& oldkeyframes, const QString& newkeyframes, bool doIt) :
25     QUndoCommand(),
26     m_view(view),
27     m_oldkfr(oldkeyframes),
28     m_newkfr(newkeyframes),
29     m_track(track),
30     m_index(effectIndex),
31     m_pos(pos),
32     m_doIt(doIt)
33 {
34     int prev = m_oldkfr.split(QLatin1Char(';'), QString::SkipEmptyParts).count();
35     int next = m_newkfr.split(QLatin1Char(';'), QString::SkipEmptyParts).count();
36     if (prev == next)
37         setText(i18n("Edit keyframe"));
38     else if (prev > next)
39         setText(i18n("Delete keyframe"));
40     else
41         setText(i18n("Add keyframe"));
42     //kDebug() << "///  CREATE GUIDE COMMAND, TIMES: " << m_oldPos.frames(25) << "x" << m_pos.frames(25);
43 }
44
45
46 // virtual
47 void EditKeyFrameCommand::undo()
48 {
49     m_view->editKeyFrame(m_pos, m_track, m_index, m_oldkfr);
50     m_doIt = true;
51 }
52 // virtual
53 void EditKeyFrameCommand::redo()
54 {
55     if (m_doIt) {
56         m_view->editKeyFrame(m_pos, m_track, m_index, m_newkfr);
57     }
58     m_doIt = true;
59 }
60