]> Shamusworld >> Repos - architektonas/blob - src/actions/rs_actionmodifyentity.cpp
Major refactoring of actions: Moved implementation from header files
[architektonas] / src / actions / rs_actionmodifyentity.cpp
1 // rs_actionmodifyentity.cpp
2 //
3 // Part of the Architektonas Project
4 // Originally part of QCad Community Edition by Andrew Mustun
5 // Extensively rewritten and refactored by James L. Hammons
6 // (C) 2010 Underground Software
7 //
8 // JLH = James L. Hammons <jlhamm@acm.org>
9 //
10 // Who  When        What
11 // ---  ----------  -----------------------------------------------------------
12 // JLH  06/04/2010  Added this text. :-)
13 //
14
15 #include "rs_actionmodifyentity.h"
16
17 #include "rs_dialogfactory.h"
18 #include "rs_graphicview.h"
19
20 RS_ActionModifyEntity::RS_ActionModifyEntity(RS_EntityContainer & container,
21         RS_GraphicView & graphicView):
22         RS_ActionInterface("Modify Entity", container, graphicView)
23 {
24         en = NULL;
25 }
26
27 RS_ActionModifyEntity::~RS_ActionModifyEntity()
28 {
29 }
30
31 void RS_ActionModifyEntity::trigger()
32 {
33         if (en != NULL)
34         {
35                 RS_Entity * clone = en->clone();
36
37                 if (RS_DIALOGFACTORY->requestModifyEntityDialog(clone))
38                 {
39                         container->addEntity(clone);
40
41                         graphicView->deleteEntity(en);
42                         en->setSelected(false);
43
44                         clone->setSelected(false);
45                         graphicView->drawEntity(clone);
46
47                         if (document != NULL)
48                         {
49                                 document->startUndoCycle();
50
51                                 document->addUndoable(clone);
52                                 en->setUndoState(true);
53                                 document->addUndoable(en);
54
55                                 document->endUndoCycle();
56                         }
57                         RS_DIALOGFACTORY->updateSelectionWidget(container->countSelected());
58                 }
59                 else
60                         delete clone;
61
62         }
63         else
64                 RS_DEBUG->print("RS_ActionModifyEntity::trigger: Entity is NULL\n");
65 }
66
67 void RS_ActionModifyEntity::mouseReleaseEvent(QMouseEvent * e)
68 {
69         if (RS2::qtToRsButtonState(e->button()) == RS2::RightButton)
70                 init(getStatus() - 1);
71         else
72         {
73                 en = catchEntity(e);
74                 trigger();
75         }
76 }
77
78 void RS_ActionModifyEntity::updateMouseCursor()
79 {
80         graphicView->setMouseCursor(RS2::SelectCursor);
81 }
82
83 // EOF