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), cadToolBar(parent), actionHandler(NULL),
24 selectAction(NULL), nextAction(-1)
26 actionHandler = cadToolBar->getActionHandler();
28 QGridLayout * gridLayout = new QGridLayout(this);
29 gridLayout->setSpacing(0);
30 gridLayout->setContentsMargins(0, 0, 0, 0);
32 QAction * actionBack = new QAction(QIcon(":/res/qg_back"), tr("Back"), this);
33 QToolButton * button = new QToolButton(this);
34 button->setDefaultAction(actionBack);
35 QSizePolicy policy(QSizePolicy::MinimumExpanding, QSizePolicy::Preferred);
36 button->setSizePolicy(policy);
37 gridLayout->addWidget(button, 0, 0, 1, 2);
38 connect(button, SIGNAL(clicked()), this, SLOT(back()));
40 gridLayout->addWidget(CreateToolButton(actionDeselectAll), 1, 0, 1, 1);
41 gridLayout->addWidget(CreateToolButton(actionSelectAll), 1, 1, 1, 1);
42 gridLayout->addWidget(CreateToolButton(actionSelectSingle), 2, 0, 1, 1);
43 gridLayout->addWidget(CreateToolButton(actionSelectContour), 2, 1, 1, 1);
44 gridLayout->addWidget(CreateToolButton(actionDeselectWindow), 3, 0, 1, 1);
45 gridLayout->addWidget(CreateToolButton(actionSelectWindow), 3, 1, 1, 1);
46 gridLayout->addWidget(CreateToolButton(actionDeselectIntersected), 4, 0, 1, 1);
47 gridLayout->addWidget(CreateToolButton(actionSelectIntersected), 4, 1, 1, 1);
48 gridLayout->addWidget(CreateToolButton(actionSelectInvert), 5, 0, 1, 1);
49 gridLayout->addWidget(CreateToolButton(actionSelectLayer), 5, 1, 1, 1);
51 QAction * actionDoit = new QAction(QIcon(":/res/qg_forward"), tr("Forward"), this);
52 doit = new QToolButton(this);
53 doit->setDefaultAction(actionDoit);
54 doit->setSizePolicy(policy);
55 gridLayout->addWidget(doit, 6, 0, 1, 2);
56 connect(doit, SIGNAL(clicked()), this, SLOT(runNextAction()));
59 CadToolBarSelect::~CadToolBarSelect()
63 //hmm, should these three funcs be here???
64 void CadToolBarSelect::setSelectAction(RS_ActionInterface * selectAction)
66 this->selectAction = selectAction;
69 void CadToolBarSelect::setNextAction(int nextAction)
71 this->nextAction = nextAction;
79 void CadToolBarSelect::runNextAction()
81 //printf("CadToolBarSelect::runNextAction(): Entered function...\n");
84 //printf("CadToolBarSelect::runNextAction(): About to do selectAction...\n");
85 selectAction->finish();
91 //printf("CadToolBarSelect::runNextAction(): About to do nextAction...\n");
92 actionHandler->killSelectActions();
93 actionHandler->setCurrentAction((RS2::ActionType)nextAction);
97 void CadToolBarSelect::back()
102 QToolButton * CadToolBarSelect::CreateToolButton(QAction * action)
104 QToolButton * button = new QToolButton(this);
105 button->setDefaultAction(action);
106 button->setIconSize(QSize(18, 18));