]> Shamusworld >> Repos - architektonas/blob - src/actions/actionselectsingle.cpp
Bugfixes related to removing Snapper class.
[architektonas] / src / actions / actionselectsingle.cpp
1 // actionselectsingle.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/05/2010  Added this text. :-)
15 //
16
17 #include "actionselectsingle.h"
18
19 #include "debug.h"
20 #include "dialogfactory.h"
21 #include "graphicview.h"
22 #include "selection.h"
23
24 ActionSelectSingle::ActionSelectSingle(EntityContainer & container, GraphicView & graphicView):
25         ActionInterface("Select Entities", container, graphicView)
26 {
27         en = NULL;
28 }
29
30 ActionSelectSingle::~ActionSelectSingle()
31 {
32 }
33
34 /*virtual*/ RS2::ActionType ActionSelectSingle::rtti()
35 {
36         return RS2::ActionSelectSingle;
37 }
38
39 void ActionSelectSingle::trigger()
40 {
41         if (en != NULL)
42         {
43                 Selection s(*container, graphicView);
44                 s.selectSingle(en);
45
46                 DIALOGFACTORY->updateSelectionWidget(container->countSelected());
47         }
48         else
49                 DEBUG->print("ActionSelectSingle::trigger: Entity is NULL\n");
50 }
51
52 void ActionSelectSingle::keyPressEvent(QKeyEvent * e)
53 {
54         if (e->key() == Qt::Key_Enter)
55                 finish();
56 }
57
58 void ActionSelectSingle::mouseReleaseEvent(QMouseEvent * e)
59 {
60         if (e->button() == Qt::RightButton)
61                 init(getStatus() - 1);
62         else
63         {
64                 en = catchEntity(e);
65                 trigger();
66         }
67 }
68
69 void ActionSelectSingle::updateMouseCursor()
70 {
71         graphicView->setMouseCursor(RS2::SelectCursor);
72 }
73
74