-
Notifications
You must be signed in to change notification settings - Fork 0
/
actioncmds.cpp
82 lines (66 loc) · 1.51 KB
/
actioncmds.cpp
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#include "actioncmds.h"
#include "actionitem.h"
AddCmds::AddCmds(KeyItem *pItem, quint16 nTime,qreal value,QUndoCommand *pParent):
QUndoCommand(pParent),
m_pItem(pItem),
m_nKeyId(0),
m_nTime(nTime),
m_value(value)
{
}
void AddCmds::undo()
{
m_pItem->removeKey(m_nKeyId);
}
void AddCmds::redo()
{
m_nKeyId = m_pItem->addKey(m_nTime,m_value);
}
RemoveCmds::RemoveCmds(KeyItem *pItem, quint16 keyId, QUndoCommand *pParent):
QUndoCommand(pParent),
m_pItem(pItem),
m_nSelKeyId(keyId),
m_nTime(pItem->keyTime(keyId)),
m_value(pItem->keyValue(keyId))
{
}
void RemoveCmds::undo()
{
m_nSelKeyId = m_pItem->addKey(m_nTime,m_value);
}
void RemoveCmds::redo()
{
m_pItem->removeKey(m_nSelKeyId);
}
KeyMoveCmds::KeyMoveCmds(KeyItem *pItem, quint16 keyId, quint16 oldTime, quint16 newTime, QUndoCommand *pParent):
QUndoCommand(pParent),
m_pItem(pItem),
m_nSelKeyId(keyId),
m_oldTime(oldTime),
m_newTime(newTime)
{
}
void KeyMoveCmds::undo()
{
m_pItem->setKeyTime(m_nSelKeyId,m_oldTime);
}
void KeyMoveCmds::redo()
{
m_pItem->setKeyTime(m_nSelKeyId,m_newTime);
}
KeyEditCmds::KeyEditCmds(KeyItem *pItem, quint16 keyId, qreal oldValue, qreal newValue, QUndoCommand *pParent):
QUndoCommand(pParent),
m_pItem(pItem),
m_nSelKeyId(keyId),
m_oldValue(oldValue),
m_newValue(newValue)
{
}
void KeyEditCmds::undo()
{
m_pItem->setKeyValue(m_nSelKeyId,m_oldValue);
}
void KeyEditCmds::redo()
{
m_pItem->setKeyValue(m_nSelKeyId,m_newValue);
}