aboutsummaryrefslogtreecommitdiffstats
path: root/src/libs/modelinglib/qmt/controller/undocommand.cpp
blob: 1a7c79f6ddcc55783408fb5ace0b14b116d833e7 (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
50
51
52
53
54
55
56
// Copyright (C) 2016 Jochen Becher
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0

#include "undocommand.h"

#include "qmt/infrastructure/qmtassert.h"

namespace qmt {

UndoCommand::UndoCommand(const QString &text)
    : QUndoCommand(text)
{
}

UndoCommand::~UndoCommand()
{
}

int UndoCommand::id() const
{
    return 1;
}

void UndoCommand::setDoNotMerge(bool doNotMerge)
{
    m_doNotMerge = doNotMerge;
}

bool UndoCommand::mergeWith(const QUndoCommand *other)
{
    auto otherCommand = dynamic_cast<const UndoCommand *>(other);
    if (!otherCommand || otherCommand->m_doNotMerge)
        return false;
    return mergeWith(otherCommand);
}

bool UndoCommand::mergeWith(const UndoCommand *other)
{
    Q_UNUSED(other)

    return false;
}

void UndoCommand::undo()
{
    QMT_CHECK(!m_canRedo);
    m_canRedo = true;
}

void UndoCommand::redo()
{
    QMT_CHECK(m_canRedo);
    m_canRedo = false;
}

} // namespace qmt