]> Shamusworld >> Repos - architektonas/blob - src/actions/rs_actionselectsingle.cpp
Refactoring: Moved RS_GraphicView to GraphicView.
[architektonas] / src / actions / rs_actionselectsingle.cpp
1 // rs_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 // (C) 2010 Underground Software
7 //
8 // JLH = James L. Hammons <jlhamm@acm.org>
9 //
10 // Who  When        What
11 // ---  ----------  -----------------------------------------------------------
12 // JLH  06/05/2010  Added this text. :-)
13 //
14
15 #include "rs_actionselectsingle.h"
16
17 #include "rs_dialogfactory.h"
18 #include "rs_selection.h"
19
20 RS_ActionSelectSingle::RS_ActionSelectSingle(RS_EntityContainer & container, GraphicView & graphicView):
21         RS_ActionInterface("Select Entities", container, graphicView)
22 {
23         en = NULL;
24 }
25
26 RS_ActionSelectSingle::~RS_ActionSelectSingle()
27 {
28 }
29
30 /*virtual*/ RS2::ActionType RS_ActionSelectSingle::rtti()
31 {
32         return RS2::ActionSelectSingle;
33 }
34
35 void RS_ActionSelectSingle::trigger()
36 {
37         if (en != NULL)
38         {
39                 RS_Selection s(*container, graphicView);
40                 s.selectSingle(en);
41
42                 RS_DIALOGFACTORY->updateSelectionWidget(container->countSelected());
43         }
44         else
45                 RS_DEBUG->print("RS_ActionSelectSingle::trigger: Entity is NULL\n");
46 }
47
48 void RS_ActionSelectSingle::keyPressEvent(QKeyEvent * e)
49 {
50         if (e->key() == Qt::Key_Enter)
51                 finish();
52 }
53
54 void RS_ActionSelectSingle::mouseReleaseEvent(QMouseEvent * e)
55 {
56         if (e->button() == Qt::RightButton)
57                 init(getStatus() - 1);
58         else
59         {
60                 en = catchEntity(e);
61                 trigger();
62         }
63 }
64
65 void RS_ActionSelectSingle::updateMouseCursor()
66 {
67         graphicView->setMouseCursor(RS2::SelectCursor);
68 }
69
70 // EOF