]> Shamusworld >> Repos - architektonas/blob - src/actions/actionmodifydeletequick.cpp
Still in the middle of fixing preview/snapper rendering...
[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)
42         {
43                 RS_DEBUG->print("Entity found");
44                 RS_EntityContainer * parent = en->getParent();
45
46                 if (parent)
47                 {
48                         en->setSelected(false);
49 #warning "!!! Old rendering path need upgrade !!!"
50 #if 0
51                         graphicView->deleteEntity(en);
52 #endif
53                         en->changeUndoState();
54
55                         if (document)
56                         {
57                                 document->startUndoCycle();
58                                 document->addUndoable(en);
59                                 document->endUndoCycle();
60                         }
61                 }
62
63                 RS_DIALOGFACTORY->updateSelectionWidget(container->countSelected());
64         }
65         else
66                 RS_DEBUG->print("ActionModifyDeleteQuick::mousePressEvent:"
67                         " Entity is NULL\n");
68 }
69
70 void ActionModifyDeleteQuick::mouseReleaseEvent(QMouseEvent * e)
71 {
72         if (e->button() == Qt::RightButton)
73                 init(getStatus() - 1);
74         else
75         {
76                 en = catchEntity(e);
77                 trigger();
78         }
79 }
80
81 void ActionModifyDeleteQuick::updateMouseButtonHints()
82 {
83         switch (getStatus())
84         {
85         case 0:
86                 RS_DIALOGFACTORY->updateMouseWidget(tr("Pick entity to delete"),
87                         tr("Cancel"));
88                 break;
89
90         default:
91                 RS_DIALOGFACTORY->updateMouseWidget("", "");
92                 break;
93         }
94 }
95
96 void ActionModifyDeleteQuick::updateMouseCursor()
97 {
98         graphicView->setMouseCursor(RS2::DelCursor);
99 }