#include "cadtoolbarselect.h"
#include "qg_actionhandler.h"
-#include "rs_actioninterface.h"
+#include "actioninterface.h"
#include "cadtoolbar.h"
#include "createqtactions.h"
CadToolBarSelect::CadToolBarSelect(CadToolBar * parent, Qt::WindowFlags flags/*= 0*/):
- QWidget((QWidget *)parent, flags), cadToolBar(parent), actionHandler(NULL),
- selectAction(NULL), nextAction(-1)
+ QWidget((QWidget *)parent, flags), actionHandler(NULL), selectAction(NULL),
+ nextAction(-1)
{
- actionHandler = cadToolBar->getActionHandler();
+ actionHandler = parent->getActionHandler();
QGridLayout * gridLayout = new QGridLayout(this);
gridLayout->setSpacing(0);
gridLayout->setContentsMargins(0, 0, 0, 0);
- QAction * actionBack = new QAction(QIcon(":/res/qg_back"), tr("Back"), this);
- QToolButton * button = new QToolButton(this);
- button->setDefaultAction(actionBack);
- QSizePolicy policy(QSizePolicy::MinimumExpanding, QSizePolicy::Preferred);
- button->setSizePolicy(policy);
- gridLayout->addWidget(button, 0, 0, 1, 2);
- connect(button, SIGNAL(clicked()), this, SLOT(back()));
+ gridLayout->addWidget(parent->CreateBackButton(this), 0, 0, 1, 2);
- gridLayout->addWidget(CreateToolButton(actionDeselectAll), 1, 0, 1, 1);
- gridLayout->addWidget(CreateToolButton(actionSelectAll), 1, 1, 1, 1);
- gridLayout->addWidget(CreateToolButton(actionSelectSingle), 2, 0, 1, 1);
- gridLayout->addWidget(CreateToolButton(actionSelectContour), 2, 1, 1, 1);
- gridLayout->addWidget(CreateToolButton(actionDeselectWindow), 3, 0, 1, 1);
- gridLayout->addWidget(CreateToolButton(actionSelectWindow), 3, 1, 1, 1);
- gridLayout->addWidget(CreateToolButton(actionDeselectIntersected), 4, 0, 1, 1);
- gridLayout->addWidget(CreateToolButton(actionSelectIntersected), 4, 1, 1, 1);
- gridLayout->addWidget(CreateToolButton(actionSelectInvert), 5, 0, 1, 1);
- gridLayout->addWidget(CreateToolButton(actionSelectLayer), 5, 1, 1, 1);
+ gridLayout->addWidget(parent->CreateToolButton(actionDeselectAll), 1, 0, 1, 1);
+ gridLayout->addWidget(parent->CreateToolButton(actionSelectAll), 1, 1, 1, 1);
+ gridLayout->addWidget(parent->CreateToolButton(actionSelectSingle), 2, 0, 1, 1);
+ gridLayout->addWidget(parent->CreateToolButton(actionSelectContour), 2, 1, 1, 1);
+ gridLayout->addWidget(parent->CreateToolButton(actionDeselectWindow), 3, 0, 1, 1);
+ gridLayout->addWidget(parent->CreateToolButton(actionSelectWindow), 3, 1, 1, 1);
+ gridLayout->addWidget(parent->CreateToolButton(actionDeselectIntersected), 4, 0, 1, 1);
+ gridLayout->addWidget(parent->CreateToolButton(actionSelectIntersected), 4, 1, 1, 1);
+ gridLayout->addWidget(parent->CreateToolButton(actionSelectInvert), 5, 0, 1, 1);
+ gridLayout->addWidget(parent->CreateToolButton(actionSelectLayer), 5, 1, 1, 1);
QAction * actionDoit = new QAction(QIcon(":/res/qg_forward"), tr("Forward"), this);
doit = new QToolButton(this);
doit->setDefaultAction(actionDoit);
+ QSizePolicy policy(QSizePolicy::MinimumExpanding, QSizePolicy::Preferred);
doit->setSizePolicy(policy);
gridLayout->addWidget(doit, 6, 0, 1, 2);
connect(doit, SIGNAL(clicked()), this, SLOT(runNextAction()));
}
//hmm, should these three funcs be here???
-void CadToolBarSelect::setSelectAction(RS_ActionInterface * selectAction)
+void CadToolBarSelect::setSelectAction(ActionInterface * selectAction)
{
this->selectAction = selectAction;
}
void CadToolBarSelect::runNextAction()
{
-//printf("CadToolBarSelect::runNextAction(): Entered function...\n");
if (selectAction)
{
-//printf("CadToolBarSelect::runNextAction(): About to do selectAction...\n");
selectAction->finish();
selectAction = NULL;
}
if (nextAction != -1)
{
-//printf("CadToolBarSelect::runNextAction(): About to do nextAction...\n");
actionHandler->killSelectActions();
actionHandler->setCurrentAction((RS2::ActionType)nextAction);
}
}
-
-void CadToolBarSelect::back()
-{
- cadToolBar->back();
-}
-
-QToolButton * CadToolBarSelect::CreateToolButton(QAction * action)
-{
- QToolButton * button = new QToolButton(this);
- button->setDefaultAction(action);
- button->setIconSize(QSize(18, 18));
-
- return button;
-}