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