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"
20 CadToolBarSelect::CadToolBarSelect(QWidget * parent/*= 0*/, Qt::WindowFlags flags/*= 0*/):
21 QWidget(parent, flags), actionHandler(NULL), cadToolBar(NULL), selectAction(NULL),
27 CadToolBarSelect::~CadToolBarSelect()
31 void CadToolBarSelect::mousePressEvent(QMouseEvent * e)
33 if (e->button() == Qt::RightButton && cadToolBar != NULL)
40 void CadToolBarSelect::contextMenuEvent(QContextMenuEvent *e) {
44 void CadToolBarSelect::setCadToolBar(CadToolBar * tb)
49 actionHandler = tb->getActionHandler();
50 //actionHandler->setCadToolBarSelect(this);
52 RS_DEBUG->print(RS_Debug::D_ERROR, "CadToolBarSelect::setCadToolBar(): No valid toolbar set.");
55 void CadToolBarSelect::selectSingle()
57 if (actionHandler!=NULL) {
58 actionHandler->slotSelectSingle();
62 void CadToolBarSelect::selectContour() {
63 if (actionHandler!=NULL) {
64 actionHandler->slotSelectContour();
68 void CadToolBarSelect::deselectAll() {
69 if (actionHandler!=NULL) {
70 actionHandler->slotDeselectAll();
74 void CadToolBarSelect::selectAll() {
75 if (actionHandler!=NULL) {
76 actionHandler->slotSelectAll();
80 void CadToolBarSelect::selectWindow() {
81 if (actionHandler!=NULL) {
82 actionHandler->slotSelectWindow();
86 void CadToolBarSelect::deselectWindow() {
87 if (actionHandler!=NULL) {
88 actionHandler->slotDeselectWindow();
92 void CadToolBarSelect::selectIntersected() {
93 if (actionHandler!=NULL) {
94 actionHandler->slotSelectIntersected();
98 void CadToolBarSelect::deselectIntersected() {
99 if (actionHandler!=NULL) {
100 actionHandler->slotDeselectIntersected();
104 void CadToolBarSelect::selectInvert() {
105 if (actionHandler!=NULL) {
106 actionHandler->slotSelectInvert();
110 void CadToolBarSelect::selectLayer()
112 if (actionHandler!=NULL)
113 actionHandler->slotSelectLayer();
116 void CadToolBarSelect::setSelectAction(RS_ActionInterface * selectAction)
118 this->selectAction = selectAction;
121 void CadToolBarSelect::setNextAction(int nextAction)
123 this->nextAction = nextAction;
125 if (nextAction == -1)
131 void CadToolBarSelect::runNextAction()
133 if (selectAction != NULL)
135 selectAction->finish();
139 if (nextAction != -1)
141 actionHandler->killSelectActions();
142 actionHandler->setCurrentAction((RS2::ActionType)nextAction);
146 void CadToolBarSelect::back()
148 if (cadToolBar != NULL)