UndoStack.cpp 2.56 KB
Newer Older
1 2 3
/*****************************************************************************
 * UndoStack.cpp: UndoStack For Undo/Redo Purposes
 *****************************************************************************
Ludovic Fauvet's avatar
Ludovic Fauvet committed
4
 * Copyright (C) 2008-2010 VideoLAN
5 6
 *
 * Authors: Christophe Courtaut <christophe.courtaut@gmail.com>
7
 *          Hugo Beauzee-Luyssen <beauze.h@gmail.com>
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
 *
 * 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.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
 *****************************************************************************/

Ludovic Fauvet's avatar
Ludovic Fauvet committed
24 25 26
#include <QUndoStack>
#include <QUndoCommand>

27
#include "UndoStack.h"
28
#include "project/GuiProjectManager.h"
29 30
#include "SettingsManager.h"
#include "KeyboardShortcutHelper.h"
31

32
UndoStack::UndoStack( QWidget* parent ) : QUndoView( parent )
33
{
34
    setEmptyLabel( tr( "Nothing to undo" ) );
35

36 37
    m_undoStack = new QUndoStack( this );
    setStack( m_undoStack );
38
    connect( m_undoStack, SIGNAL( cleanChanged( bool ) ),
39 40
             GUIProjectManager::getInstance(), SLOT( cleanChanged( bool ) ) );
    connect( GUIProjectManager::getInstance(), SIGNAL( projectSaved() ),
41
             m_undoStack, SLOT( setClean() ) );
42

43 44 45
    connect( m_undoStack, SIGNAL( canRedoChanged(bool) ), this, SIGNAL( canRedoChanged(bool) ) );
    connect( m_undoStack, SIGNAL( canUndoChanged(bool) ), this, SIGNAL( canUndoChanged(bool) ) );

46
    connect( GUIProjectManager::getInstance(), SIGNAL( projectClosed() ), this, SLOT( clear() ) );
47 48 49 50 51
}

void    UndoStack::push( QUndoCommand* command )
{
    m_undoStack->push( command );
52
}
53

54 55 56 57 58 59 60 61 62 63
void    UndoStack::beginMacro( const QString& text )
{
    m_undoStack->beginMacro( text );
}

void    UndoStack::endMacro()
{
    m_undoStack->endMacro();
}

64 65 66 67 68 69 70 71 72 73
bool    UndoStack::canUndo()
{
    m_undoStack->canUndo();
}

bool    UndoStack::canRedo()
{
    m_undoStack->canRedo();
}

74 75
void    UndoStack::clear()
{
76
    m_undoStack->clear();
77
}
78 79 80 81 82 83 84 85 86 87

void    UndoStack::undo()
{
    m_undoStack->undo();
}

void    UndoStack::redo()
{
    m_undoStack->redo();
}