1 // cadtoolbarselect.cpp
3 // Originally part of QCad Community Edition by Andrew Mustun
4 // Extensively rewritten and refactored by James L. Hammons
5 // (C) 2010 Underground Software
7 // JLH = James L. Hammons <jlhamm@acm.org>
10 // --- ---------- -----------------------------------------------------------
11 // JLH 05/10/2010 Created this file. :-)
14 #include "cadtoolbarselect.h"
16 #include "cadtoolbar.h"
17 #include "qg_actionhandler.h"
18 #include "rs_actioninterface.h"
21 CadToolBarSelect::CadToolBarSelect(QWidget * parent/*= 0*/, Qt::WindowFlags flags/*= 0*/):
22 QWidget(parent, flags), actionHandler(NULL), cadToolBar(NULL), selectAction(NULL),
28 CadToolBarSelect::~CadToolBarSelect()
32 void CadToolBarSelect::mousePressEvent(QMouseEvent * e)
34 if (e->button() == Qt::RightButton && cadToolBar != NULL)
41 void CadToolBarSelect::contextMenuEvent(QContextMenuEvent *e) {
45 void CadToolBarSelect::setCadToolBar(CadToolBar * tb)
50 actionHandler = tb->getActionHandler();
51 //actionHandler->setCadToolBarSelect(this);
53 RS_DEBUG->print(RS_Debug::D_ERROR, "CadToolBarSelect::setCadToolBar(): No valid toolbar set.");
56 void CadToolBarSelect::selectSingle()
58 if (actionHandler!=NULL) {
59 actionHandler->slotSelectSingle();
63 void CadToolBarSelect::selectContour() {
64 if (actionHandler!=NULL) {
65 actionHandler->slotSelectContour();
69 void CadToolBarSelect::deselectAll() {
70 if (actionHandler!=NULL) {
71 actionHandler->slotDeselectAll();
75 void CadToolBarSelect::selectAll() {
76 if (actionHandler!=NULL) {
77 actionHandler->slotSelectAll();
81 void CadToolBarSelect::selectWindow() {
82 if (actionHandler!=NULL) {
83 actionHandler->slotSelectWindow();
87 void CadToolBarSelect::deselectWindow() {
88 if (actionHandler!=NULL) {
89 actionHandler->slotDeselectWindow();
93 void CadToolBarSelect::selectIntersected() {
94 if (actionHandler!=NULL) {
95 actionHandler->slotSelectIntersected();
99 void CadToolBarSelect::deselectIntersected() {
100 if (actionHandler!=NULL) {
101 actionHandler->slotDeselectIntersected();
105 void CadToolBarSelect::selectInvert() {
106 if (actionHandler!=NULL) {
107 actionHandler->slotSelectInvert();
111 void CadToolBarSelect::selectLayer()
113 if (actionHandler!=NULL)
114 actionHandler->slotSelectLayer();
117 void CadToolBarSelect::setSelectAction(RS_ActionInterface * selectAction)
119 this->selectAction = selectAction;
122 void CadToolBarSelect::setNextAction(int nextAction)
124 this->nextAction = nextAction;
126 if (nextAction == -1)
132 void CadToolBarSelect::runNextAction()
134 if (selectAction != NULL)
136 selectAction->finish();
140 if (nextAction != -1)
142 actionHandler->killSelectActions();
143 actionHandler->setCurrentAction((RS2::ActionType)nextAction);
147 void CadToolBarSelect::back()
149 if (cadToolBar != NULL)