1 // cadtoolbarselect.cpp
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
8 // JLH = James L. Hammons <jlhamm@acm.org>
11 // --- ---------- -----------------------------------------------------------
12 // JLH 05/10/2010 Created this file. :-)
15 #include "cadtoolbarselect.h"
17 #include "qg_actionhandler.h"
18 #include "rs_actioninterface.h"
19 #include "cadtoolbar.h"
20 #include "createqtactions.h"
22 CadToolBarSelect::CadToolBarSelect(CadToolBar * parent, Qt::WindowFlags flags/*= 0*/):
23 QWidget((QWidget *)parent, flags), actionHandler(NULL), selectAction(NULL),
26 actionHandler = parent->getActionHandler();
28 QGridLayout * gridLayout = new QGridLayout(this);
29 gridLayout->setSpacing(0);
30 gridLayout->setContentsMargins(0, 0, 0, 0);
32 gridLayout->addWidget(parent->CreateBackButton(this), 0, 0, 1, 2);
34 gridLayout->addWidget(parent->CreateToolButton(actionDeselectAll), 1, 0, 1, 1);
35 gridLayout->addWidget(parent->CreateToolButton(actionSelectAll), 1, 1, 1, 1);
36 gridLayout->addWidget(parent->CreateToolButton(actionSelectSingle), 2, 0, 1, 1);
37 gridLayout->addWidget(parent->CreateToolButton(actionSelectContour), 2, 1, 1, 1);
38 gridLayout->addWidget(parent->CreateToolButton(actionDeselectWindow), 3, 0, 1, 1);
39 gridLayout->addWidget(parent->CreateToolButton(actionSelectWindow), 3, 1, 1, 1);
40 gridLayout->addWidget(parent->CreateToolButton(actionDeselectIntersected), 4, 0, 1, 1);
41 gridLayout->addWidget(parent->CreateToolButton(actionSelectIntersected), 4, 1, 1, 1);
42 gridLayout->addWidget(parent->CreateToolButton(actionSelectInvert), 5, 0, 1, 1);
43 gridLayout->addWidget(parent->CreateToolButton(actionSelectLayer), 5, 1, 1, 1);
45 QAction * actionDoit = new QAction(QIcon(":/res/qg_forward"), tr("Forward"), this);
46 doit = new QToolButton(this);
47 doit->setDefaultAction(actionDoit);
48 QSizePolicy policy(QSizePolicy::MinimumExpanding, QSizePolicy::Preferred);
49 doit->setSizePolicy(policy);
50 gridLayout->addWidget(doit, 6, 0, 1, 2);
51 connect(doit, SIGNAL(clicked()), this, SLOT(runNextAction()));
54 CadToolBarSelect::~CadToolBarSelect()
58 //hmm, should these three funcs be here???
59 void CadToolBarSelect::setSelectAction(RS_ActionInterface * selectAction)
61 this->selectAction = selectAction;
64 void CadToolBarSelect::setNextAction(int nextAction)
66 this->nextAction = nextAction;
74 void CadToolBarSelect::runNextAction()
78 selectAction->finish();
84 actionHandler->killSelectActions();
85 actionHandler->setCurrentAction((RS2::ActionType)nextAction);