editguidecommand.cpp 1.9 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
/***************************************************************************
                          addtransitioncommand.cpp  -  description
                             -------------------
    begin                : 2008
    copyright            : (C) 2008 by Marco Gittler
    email                : g.marco@freenet.de
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   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.                                   *
 *                                                                         *
 ***************************************************************************/
17

18

19
#include "editguidecommand.h"
20 21
#include "customtrackview.h"

22 23
#include <KLocale>

24 25 26 27 28
EditGuideCommand::EditGuideCommand(CustomTrackView *view, const GenTime oldPos, const QString &oldcomment, const GenTime pos, const QString &comment, bool doIt, QUndoCommand * parent) :
        QUndoCommand(parent),
        m_view(view),
        m_oldcomment(oldcomment),
        m_comment(comment),
29 30
        m_oldPos(oldPos),
        m_pos(pos),
31
        m_doIt(doIt)
32
{
33 34
    if (m_oldcomment.isEmpty()) setText(i18n("Add guide"));
    else if (m_oldPos == m_pos) setText(i18n("Edit guide"));
35
    else if (m_pos <= GenTime()) setText(i18n("Delete guide"));
36 37 38 39 40
    else setText(i18n("Move guide"));
}


// virtual
41 42
void EditGuideCommand::undo()
{
43 44 45
    m_view->editGuide(m_pos, m_oldPos, m_oldcomment);
}
// virtual
46 47
void EditGuideCommand::redo()
{
48 49 50 51 52 53
    if (m_doIt) {
        m_view->editGuide(m_oldPos, m_pos, m_comment);
    }
    m_doIt = true;
}