forked from KDAB/Charm
/
CommandDeleteEvent.cpp
49 lines (39 loc) · 1 KB
/
CommandDeleteEvent.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
#include <Core/ControllerInterface.h>
#include "CommandDeleteEvent.h"
CommandDeleteEvent::CommandDeleteEvent( const Event& event, QObject* parent )
: CharmCommand( tr("Delete Event"), parent )
, m_event( event )
{
}
CommandDeleteEvent::~CommandDeleteEvent()
{
}
bool CommandDeleteEvent::prepare()
{
return true;
}
bool CommandDeleteEvent::execute( ControllerInterface* controller )
{
qDebug() << "CommandDeleteEvent::execute: deleting:";
m_event.dump();
return controller->deleteEvent( m_event );
}
bool CommandDeleteEvent::rollback(ControllerInterface *controller)
{
int oldId = m_event.id();
m_event = controller->cloneEvent(m_event);
int newId = m_event.id();
if(oldId != newId)
emit emitSlotEventIdChanged(oldId, newId);
return m_event.isValid();
}
bool CommandDeleteEvent::finalize()
{
return true;
}
void CommandDeleteEvent::eventIdChanged(int oid, int nid)
{
if(m_event.id() == oid)
m_event.setId(nid);
}
#include "CommandDeleteEvent.moc"