aboutsummaryrefslogtreecommitdiffstats
path: root/src/libs/modelinglib/qmt/controller/undocontroller.cpp
blob: 8617f7c1023e88d456624c57210eeee2c6211600 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// Copyright (C) 2016 Jochen Becher
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0

#include "undocontroller.h"

#include "undocommand.h"

#include <QUndoStack>

namespace qmt {

UndoController::UndoController(QObject *parent) :
    QObject(parent),
    m_undoStack(new QUndoStack(this))
{
}

UndoController::~UndoController()
{
}

void UndoController::push(UndoCommand *cmd)
{
    cmd->setDoNotMerge(m_doNotMerge);
    m_doNotMerge = false;
    m_undoStack->push(cmd);
}

void UndoController::beginMergeSequence(const QString &text)
{
    m_undoStack->beginMacro(text);
}

void UndoController::endMergeSequence()
{
    m_undoStack->endMacro();
}

void UndoController::reset()
{
    m_undoStack->clear();
}

void UndoController::doNotMerge()
{
    m_doNotMerge = true;
}

} // namespace qmt