]> Shamusworld >> Repos - architektonas/blob - src/forms/cadtoolbarselect.cpp
Refactoring: Moved RS_GraphicView to GraphicView.
[architektonas] / src / forms / cadtoolbarselect.cpp
1 // cadtoolbarselect.cpp
2 //
3 // Originally part of QCad Community Edition by Andrew Mustun
4 // Extensively rewritten and refactored by James L. Hammons
5 // (C) 2010 Underground Software
6 //
7 // JLH = James L. Hammons <jlhamm@acm.org>
8 //
9 // Who  When        What
10 // ---  ----------  -----------------------------------------------------------
11 // JLH  05/10/2010  Created this file. :-)
12 //
13
14 #include "cadtoolbarselect.h"
15
16 #include "cadtoolbar.h"
17 #include "qg_actionhandler.h"
18 #include "rs_actioninterface.h"
19 #include "rs_debug.h"
20
21 CadToolBarSelect::CadToolBarSelect(QWidget * parent/*= 0*/, Qt::WindowFlags flags/*= 0*/):
22         QWidget(parent, flags), actionHandler(NULL), cadToolBar(NULL), selectAction(NULL),
23         nextAction(-1)
24 {
25         ui.setupUi(this);
26 }
27
28 CadToolBarSelect::~CadToolBarSelect()
29 {
30 }
31
32 void CadToolBarSelect::mousePressEvent(QMouseEvent * e)
33 {
34         if (e->button() == Qt::RightButton && cadToolBar != NULL)
35         {
36                 cadToolBar->back();
37                 e->accept();
38         }
39 }
40
41 void CadToolBarSelect::contextMenuEvent(QContextMenuEvent *e) {
42         e->accept();
43 }
44
45 void CadToolBarSelect::setCadToolBar(CadToolBar * tb)
46 {
47         cadToolBar = tb;
48
49         if (tb != NULL)
50                 actionHandler = tb->getActionHandler();
51                 //actionHandler->setCadToolBarSelect(this);
52         else
53                 RS_DEBUG->print(RS_Debug::D_ERROR, "CadToolBarSelect::setCadToolBar(): No valid toolbar set.");
54 }
55
56 void CadToolBarSelect::selectSingle()
57 {
58         if (actionHandler!=NULL) {
59                 actionHandler->slotSelectSingle();
60         }
61 }
62
63 void CadToolBarSelect::selectContour() {
64         if (actionHandler!=NULL) {
65                 actionHandler->slotSelectContour();
66         }
67 }
68
69 void CadToolBarSelect::deselectAll() {
70         if (actionHandler!=NULL) {
71                 actionHandler->slotDeselectAll();
72         }
73 }
74
75 void CadToolBarSelect::selectAll() {
76         if (actionHandler!=NULL) {
77                 actionHandler->slotSelectAll();
78         }
79 }
80
81 void CadToolBarSelect::selectWindow() {
82         if (actionHandler!=NULL) {
83                 actionHandler->slotSelectWindow();
84         }
85 }
86
87 void CadToolBarSelect::deselectWindow() {
88         if (actionHandler!=NULL) {
89                 actionHandler->slotDeselectWindow();
90         }
91 }
92
93 void CadToolBarSelect::selectIntersected() {
94         if (actionHandler!=NULL) {
95                 actionHandler->slotSelectIntersected();
96         }
97 }
98
99 void CadToolBarSelect::deselectIntersected() {
100         if (actionHandler!=NULL) {
101                 actionHandler->slotDeselectIntersected();
102         }
103 }
104
105 void CadToolBarSelect::selectInvert() {
106         if (actionHandler!=NULL) {
107                 actionHandler->slotSelectInvert();
108         }
109 }
110
111 void CadToolBarSelect::selectLayer()
112 {
113         if (actionHandler!=NULL)
114                 actionHandler->slotSelectLayer();
115 }
116
117 void CadToolBarSelect::setSelectAction(RS_ActionInterface * selectAction)
118 {
119         this->selectAction = selectAction;
120 }
121
122 void CadToolBarSelect::setNextAction(int nextAction)
123 {
124         this->nextAction = nextAction;
125
126         if (nextAction == -1)
127                 ui.bDoit->hide();
128         else
129                 ui.bDoit->show();
130 }
131
132 void CadToolBarSelect::runNextAction()
133 {
134         if (selectAction != NULL)
135         {
136                 selectAction->finish();
137                 selectAction = NULL;
138         }
139
140         if (nextAction != -1)
141         {
142                 actionHandler->killSelectActions();
143                 actionHandler->setCurrentAction((RS2::ActionType)nextAction);
144         }
145 }
146
147 void CadToolBarSelect::back()
148 {
149         if (cadToolBar != NULL)
150                 cadToolBar->back();
151 }