]> Shamusworld >> Repos - architektonas/blob - src/actions/actionmodifydeletequick.cpp
eeeddf7e32895482033fb90a0e99eb5273b231ef
[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 // Portions copyright (C) 2001-2003 RibbonSoft
7 // Copyright (C) 2010 Underground Software
8 // See the README and GPLv2 files for licensing and warranty information
9 //
10 // JLH = James L. Hammons <jlhamm@acm.org>
11 //
12 // Who  When        What
13 // ---  ----------  -----------------------------------------------------------
14 // JLH  06/04/2010  Added this text. :-)
15 //
16
17 #include "actionmodifydeletequick.h"
18
19 #include "rs_dialogfactory.h"
20 #include "graphicview.h"
21
22 ActionModifyDeleteQuick::ActionModifyDeleteQuick(
23         RS_EntityContainer & container, GraphicView & graphicView):
24         ActionInterface("Quick Delete Entities", container, graphicView)
25 {
26         en = NULL;
27 }
28
29 ActionModifyDeleteQuick::~ActionModifyDeleteQuick()
30 {
31 }
32
33 /**
34  * Deletes all entities that were selected.
35  */
36 void ActionModifyDeleteQuick::trigger()
37 {
38         RS_DEBUG->print("ActionModifyDeleteQuick::trigger()");
39
40         if (en != NULL)
41         {
42                 RS_DEBUG->print("Entity found");
43                 RS_EntityContainer * parent = en->getParent();
44
45                 if (parent != NULL)
46                 {
47                         en->setSelected(false);
48                         graphicView->deleteEntity(en);
49                         en->changeUndoState();
50
51                         if (document)
52                         {
53                                 document->startUndoCycle();
54                                 document->addUndoable(en);
55                                 document->endUndoCycle();
56                         }
57                 }
58
59                 RS_DIALOGFACTORY->updateSelectionWidget(container->countSelected());
60         }
61         else
62                 RS_DEBUG->print("ActionModifyDeleteQuick::mousePressEvent:"
63                         " Entity is NULL\n");
64 }
65
66 void ActionModifyDeleteQuick::mouseReleaseEvent(QMouseEvent * e)
67 {
68         if (e->button() == Qt::RightButton)
69                 init(getStatus() - 1);
70         else
71         {
72                 en = catchEntity(e);
73                 trigger();
74         }
75 }
76
77 void ActionModifyDeleteQuick::updateMouseButtonHints()
78 {
79         switch (getStatus())
80         {
81         case 0:
82                 RS_DIALOGFACTORY->updateMouseWidget(tr("Pick entity to delete"),
83                         tr("Cancel"));
84                 break;
85
86         default:
87                 RS_DIALOGFACTORY->updateMouseWidget("", "");
88                 break;
89         }
90 }
91
92 void ActionModifyDeleteQuick::updateMouseCursor()
93 {
94         graphicView->setMouseCursor(RS2::DelCursor);
95 }