]> Shamusworld >> Repos - architektonas/blob - src/actions/actionmodifydeletequick.cpp
Last checkin before major refactor...
[architektonas] / src / actions / actionmodifydeletequick.cpp
1 // actionmodifydeletequick.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 "actionmodifydeletequick.h"
16
17 #include "rs_dialogfactory.h"
18 #include "graphicview.h"
19
20 ActionModifyDeleteQuick::ActionModifyDeleteQuick(
21         RS_EntityContainer & container, GraphicView & graphicView):
22         ActionInterface("Quick Delete Entities", container, graphicView)
23 {
24         en = NULL;
25 }
26
27 ActionModifyDeleteQuick::~ActionModifyDeleteQuick()
28 {
29 }
30
31 /**
32  * Deletes all entities that were selected.
33  */
34 void ActionModifyDeleteQuick::trigger()
35 {
36         RS_DEBUG->print("ActionModifyDeleteQuick::trigger()");
37
38         if (en != NULL)
39         {
40                 RS_DEBUG->print("Entity found");
41                 RS_EntityContainer * parent = en->getParent();
42
43                 if (parent != NULL)
44                 {
45                         en->setSelected(false);
46                         graphicView->deleteEntity(en);
47                         en->changeUndoState();
48
49                         if (document)
50                         {
51                                 document->startUndoCycle();
52                                 document->addUndoable(en);
53                                 document->endUndoCycle();
54                         }
55                 }
56
57                 RS_DIALOGFACTORY->updateSelectionWidget(container->countSelected());
58         }
59         else
60                 RS_DEBUG->print("ActionModifyDeleteQuick::mousePressEvent:"
61                         " Entity is NULL\n");
62 }
63
64 void ActionModifyDeleteQuick::mouseReleaseEvent(QMouseEvent * e)
65 {
66         if (e->button() == Qt::RightButton)
67                 init(getStatus() - 1);
68         else
69         {
70                 en = catchEntity(e);
71                 trigger();
72         }
73 }
74
75 void ActionModifyDeleteQuick::updateMouseButtonHints()
76 {
77         switch (getStatus())
78         {
79         case 0:
80                 RS_DIALOGFACTORY->updateMouseWidget(tr("Pick entity to delete"),
81                         tr("Cancel"));
82                 break;
83
84         default:
85                 RS_DIALOGFACTORY->updateMouseWidget("", "");
86                 break;
87         }
88 }
89
90 void ActionModifyDeleteQuick::updateMouseCursor()
91 {
92         graphicView->setMouseCursor(RS2::DelCursor);
93 }