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 // Portions copyright (C) 2001-2003 RibbonSoft
7 // Copyright (C) 2010 Underground Software
8 // See the README and GPLv2 files for licensing and warranty information
10 // JLH = James L. Hammons <jlhamm@acm.org>
13 // --- ---------- -----------------------------------------------------------
14 // JLH 05/10/2010 Created this file. :-)
17 #include "cadtoolbarselect.h"
19 #include "actionhandler.h"
20 #include "actioninterface.h"
21 #include "cadtoolbar.h"
22 #include "createqtactions.h"
24 CadToolBarSelect::CadToolBarSelect(CadToolBar * parent, Qt::WindowFlags flags/*= 0*/):
25 QWidget((QWidget *)parent, flags), actionHandler(NULL), selectAction(NULL),
28 actionHandler = parent->getActionHandler();
30 QGridLayout * gridLayout = new QGridLayout(this);
31 gridLayout->setSpacing(0);
32 gridLayout->setContentsMargins(0, 0, 0, 0);
34 gridLayout->addWidget(parent->CreateBackButton(this), 0, 0, 1, 2);
36 gridLayout->addWidget(parent->CreateToolButton(actionDeselectAll), 1, 0, 1, 1);
37 gridLayout->addWidget(parent->CreateToolButton(actionSelectAll), 1, 1, 1, 1);
38 gridLayout->addWidget(parent->CreateToolButton(actionSelectSingle), 2, 0, 1, 1);
39 gridLayout->addWidget(parent->CreateToolButton(actionSelectContour), 2, 1, 1, 1);
40 gridLayout->addWidget(parent->CreateToolButton(actionDeselectWindow), 3, 0, 1, 1);
41 gridLayout->addWidget(parent->CreateToolButton(actionSelectWindow), 3, 1, 1, 1);
42 gridLayout->addWidget(parent->CreateToolButton(actionDeselectIntersected), 4, 0, 1, 1);
43 gridLayout->addWidget(parent->CreateToolButton(actionSelectIntersected), 4, 1, 1, 1);
44 gridLayout->addWidget(parent->CreateToolButton(actionSelectInvert), 5, 0, 1, 1);
45 gridLayout->addWidget(parent->CreateToolButton(actionSelectLayer), 5, 1, 1, 1);
47 QAction * actionDoit = new QAction(QIcon(":/res/qg_forward"), tr("Forward"), this);
48 doit = new QToolButton(this);
49 doit->setDefaultAction(actionDoit);
50 QSizePolicy policy(QSizePolicy::MinimumExpanding, QSizePolicy::Preferred);
51 doit->setSizePolicy(policy);
52 gridLayout->addWidget(doit, 6, 0, 1, 2);
53 connect(doit, SIGNAL(clicked()), this, SLOT(runNextAction()));
56 CadToolBarSelect::~CadToolBarSelect()
60 //hmm, should these three funcs be here???
61 void CadToolBarSelect::setSelectAction(ActionInterface * selectAction)
63 this->selectAction = selectAction;
66 void CadToolBarSelect::setNextAction(int nextAction)
68 this->nextAction = nextAction;
76 void CadToolBarSelect::runNextAction()
80 selectAction->finish();
86 actionHandler->killSelectActions();
87 actionHandler->setCurrentAction((RS2::ActionType)nextAction);