#include "cadtoolbarselect.h"
-#include "cadtoolbar.h"
#include "qg_actionhandler.h"
#include "rs_actioninterface.h"
-#include "rs_debug.h"
+#include "cadtoolbar.h"
+#include "createqtactions.h"
-CadToolBarSelect::CadToolBarSelect(QWidget * parent/*= 0*/, Qt::WindowFlags flags/*= 0*/):
- QWidget(parent, flags), actionHandler(NULL), cadToolBar(NULL), selectAction(NULL),
- nextAction(-1)
+CadToolBarSelect::CadToolBarSelect(CadToolBar * parent, Qt::WindowFlags flags/*= 0*/):
+ QWidget((QWidget *)parent, flags), cadToolBar(parent), actionHandler(NULL),
+ selectAction(NULL), nextAction(-1)
{
- ui.setupUi(this);
+ actionHandler = cadToolBar->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(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);
+
+ QAction * actionDoit = new QAction(QIcon(":/res/qg_forward"), tr("Forward"), this);
+ doit = new QToolButton(this);
+ doit->setDefaultAction(actionDoit);
+ doit->setSizePolicy(policy);
+ gridLayout->addWidget(doit, 6, 0, 1, 2);
+ connect(doit, SIGNAL(clicked()), this, SLOT(runNextAction()));
}
CadToolBarSelect::~CadToolBarSelect()
{
}
-void CadToolBarSelect::mousePressEvent(QMouseEvent * e)
-{
- if (e->button() == Qt::RightButton && cadToolBar != NULL)
- {
- cadToolBar->back();
- e->accept();
- }
-}
-
-void CadToolBarSelect::contextMenuEvent(QContextMenuEvent *e) {
- e->accept();
-}
-
-void CadToolBarSelect::setCadToolBar(CadToolBar * tb)
-{
- cadToolBar = tb;
-
- if (tb != NULL)
- actionHandler = tb->getActionHandler();
- //actionHandler->setCadToolBarSelect(this);
- else
- RS_DEBUG->print(RS_Debug::D_ERROR, "CadToolBarSelect::setCadToolBar(): No valid toolbar set.");
-}
-
-void CadToolBarSelect::selectSingle()
-{
- if (actionHandler!=NULL) {
- actionHandler->slotSelectSingle();
- }
-}
-
-void CadToolBarSelect::selectContour() {
- if (actionHandler!=NULL) {
- actionHandler->slotSelectContour();
- }
-}
-
-void CadToolBarSelect::deselectAll() {
- if (actionHandler!=NULL) {
- actionHandler->slotDeselectAll();
- }
-}
-
-void CadToolBarSelect::selectAll() {
- if (actionHandler!=NULL) {
- actionHandler->slotSelectAll();
- }
-}
-
-void CadToolBarSelect::selectWindow() {
- if (actionHandler!=NULL) {
- actionHandler->slotSelectWindow();
- }
-}
-
-void CadToolBarSelect::deselectWindow() {
- if (actionHandler!=NULL) {
- actionHandler->slotDeselectWindow();
- }
-}
-
-void CadToolBarSelect::selectIntersected() {
- if (actionHandler!=NULL) {
- actionHandler->slotSelectIntersected();
- }
-}
-
-void CadToolBarSelect::deselectIntersected() {
- if (actionHandler!=NULL) {
- actionHandler->slotDeselectIntersected();
- }
-}
-
-void CadToolBarSelect::selectInvert() {
- if (actionHandler!=NULL) {
- actionHandler->slotSelectInvert();
- }
-}
-
-void CadToolBarSelect::selectLayer()
-{
- if (actionHandler!=NULL)
- actionHandler->slotSelectLayer();
-}
-
+//hmm, should these three funcs be here???
void CadToolBarSelect::setSelectAction(RS_ActionInterface * selectAction)
{
this->selectAction = selectAction;
this->nextAction = nextAction;
if (nextAction == -1)
- ui.bDoit->hide();
+ doit->hide();
else
- ui.bDoit->show();
+ doit->show();
}
void CadToolBarSelect::runNextAction()
{
- if (selectAction != NULL)
+//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()
{
- if (cadToolBar != NULL)
- cadToolBar->back();
+ cadToolBar->back();
+}
+
+QToolButton * CadToolBarSelect::CreateToolButton(QAction * action)
+{
+ QToolButton * button = new QToolButton(this);
+ button->setDefaultAction(action);
+ button->setIconSize(QSize(18, 18));
+
+ return button;
}