UndoStack.cpp 2.52 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 24
 *
 * 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.
 *****************************************************************************/

#include "UndoStack.h"
25
#include "project/GuiProjectManager.h"
26
#include "SettingsManager.h"
27

Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
28 29 30 31
#include <QUndoStack>
#include <QUndoCommand>

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

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

Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
42 43
    connect( m_undoStack, SIGNAL( canRedoChanged( bool ) ), this, SIGNAL( canRedoChanged( bool ) ) );
    connect( m_undoStack, SIGNAL( canUndoChanged( bool ) ), this, SIGNAL( canUndoChanged( bool ) ) );
44

45
    connect( GUIProjectManager::getInstance(), SIGNAL( projectClosed() ), this, SLOT( clear() ) );
46 47
}

Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
48 49
void
UndoStack::push( QUndoCommand *command )
50 51
{
    m_undoStack->push( command );
52
}
53

Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
54 55
void
UndoStack::beginMacro( const QString& text )
56 57 58 59
{
    m_undoStack->beginMacro( text );
}

Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
60 61
void
UndoStack::endMacro()
62 63 64 65
{
    m_undoStack->endMacro();
}

Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
66 67
bool
UndoStack::canUndo()
68
{
69
    return m_undoStack->canUndo();
70 71
}

Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
72 73
bool
UndoStack::canRedo()
74
{
75
    return m_undoStack->canRedo();
76 77
}

Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
78 79
void
UndoStack::clear()
80
{
81
    m_undoStack->clear();
82
}
83

Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
84 85
void
UndoStack::undo()
86 87 88 89
{
    m_undoStack->undo();
}

Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
90 91
void
UndoStack::redo()
92 93 94
{
    m_undoStack->redo();
}