]> Shamusworld >> Repos - architektonas/blob - src/actions/actionselectsingle.cpp
9a54b6fee26ba415839ca501a0e109641b361f19
[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 "rs_dialogfactory.h"
20 #include "rs_selection.h"
21
22 ActionSelectSingle::ActionSelectSingle(RS_EntityContainer & container, GraphicView & graphicView):
23         ActionInterface("Select Entities", container, graphicView)
24 {
25         en = NULL;
26 }
27
28 ActionSelectSingle::~ActionSelectSingle()
29 {
30 }
31
32 /*virtual*/ RS2::ActionType ActionSelectSingle::rtti()
33 {
34         return RS2::ActionSelectSingle;
35 }
36
37 void ActionSelectSingle::trigger()
38 {
39         if (en != NULL)
40         {
41                 RS_Selection s(*container, graphicView);
42                 s.selectSingle(en);
43
44                 RS_DIALOGFACTORY->updateSelectionWidget(container->countSelected());
45         }
46         else
47                 RS_DEBUG->print("ActionSelectSingle::trigger: Entity is NULL\n");
48 }
49
50 void ActionSelectSingle::keyPressEvent(QKeyEvent * e)
51 {
52         if (e->key() == Qt::Key_Enter)
53                 finish();
54 }
55
56 void ActionSelectSingle::mouseReleaseEvent(QMouseEvent * e)
57 {
58         if (e->button() == Qt::RightButton)
59                 init(getStatus() - 1);
60         else
61         {
62                 en = catchEntity(e);
63                 trigger();
64         }
65 }
66
67 void ActionSelectSingle::updateMouseCursor()
68 {
69         graphicView->setMouseCursor(RS2::SelectCursor);
70 }
71
72