]> git.sesse.net Git - kdenlive/blob - src/commands/editguidecommand.cpp
Const'ref
[kdenlive] / src / commands / editguidecommand.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 "editguidecommand.h"
20 #include "customtrackview.h"
21
22 #include <KLocale>
23
24 EditGuideCommand::EditGuideCommand(CustomTrackView *view, const GenTime &oldPos, const QString &oldcomment, const GenTime &pos, const QString &comment, bool doIt, QUndoCommand * parent) :
25     QUndoCommand(parent),
26     m_view(view),
27     m_oldcomment(oldcomment),
28     m_comment(comment),
29     m_oldPos(oldPos),
30     m_pos(pos),
31     m_doIt(doIt)
32 {
33     if (m_oldcomment.isEmpty()) {
34         setText(i18n("Add guide"));
35         m_oldPos = GenTime(-1);
36     }
37     else if (m_oldPos == m_pos)
38         setText(i18n("Edit guide"));
39     else if (m_pos < GenTime() && m_comment.isEmpty())
40         setText(i18n("Delete guide"));
41     else
42         setText(i18n("Move guide"));
43 }
44
45 // virtual
46 void EditGuideCommand::undo()
47 {
48     m_view->editGuide(m_pos, m_oldPos, m_oldcomment);
49 }
50 // virtual
51 void EditGuideCommand::redo()
52 {
53     if (m_doIt) {
54         m_view->editGuide(m_oldPos, m_pos, m_comment);
55     }
56     m_doIt = true;
57 }
58