]> Shamusworld >> Repos - architektonas/blobdiff - src/forms/cadtoolbarselect.cpp
In the middle of major refactoring...
[architektonas] / src / forms / cadtoolbarselect.cpp
index 3f03ab84c243b997da9d513997b0c792db58e0e1..6a70ceca0dd94923efc10aa0f983f21f2d09a75a 100644 (file)
@@ -1,5 +1,6 @@
 // cadtoolbarselect.cpp
 //
+// Part of the Architektonas Project
 // Originally part of QCad Community Edition by Andrew Mustun
 // Extensively rewritten and refactored by James L. Hammons
 // (C) 2010 Underground Software
 
 #include "cadtoolbarselect.h"
 
-#include "cadtoolbar.h"
 #include "qg_actionhandler.h"
-#include "rs_actioninterface.h"
-#include "rs_debug.h"
+#include "actioninterface.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),
+CadToolBarSelect::CadToolBarSelect(CadToolBar * parent, Qt::WindowFlags flags/*= 0*/):
+       QWidget((QWidget *)parent, flags), actionHandler(NULL), selectAction(NULL),
        nextAction(-1)
 {
-       ui.setupUi(this);
+       actionHandler = parent->getActionHandler();
+
+       QGridLayout * gridLayout = new QGridLayout(this);
+       gridLayout->setSpacing(0);
+       gridLayout->setContentsMargins(0, 0, 0, 0);
+
+       gridLayout->addWidget(parent->CreateBackButton(this), 0, 0, 1, 2);
+
+       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()));
 }
 
 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();
-}
-
-void CadToolBarSelect::setSelectAction(RS_ActionInterface * selectAction)
+//hmm, should these three funcs be here???
+void CadToolBarSelect::setSelectAction(ActionInterface * selectAction)
 {
        this->selectAction = selectAction;
 }
@@ -124,14 +66,14 @@ void CadToolBarSelect::setNextAction(int nextAction)
        this->nextAction = nextAction;
 
        if (nextAction == -1)
-               ui.bDoit->hide();
+               doit->hide();
        else
-               ui.bDoit->show();
+               doit->show();
 }
 
 void CadToolBarSelect::runNextAction()
 {
-       if (selectAction != NULL)
+       if (selectAction)
        {
                selectAction->finish();
                selectAction = NULL;
@@ -143,9 +85,3 @@ void CadToolBarSelect::runNextAction()
                actionHandler->setCurrentAction((RS2::ActionType)nextAction);
        }
 }
-
-void CadToolBarSelect::back()
-{
-       if (cadToolBar != NULL)
-               cadToolBar->back();
-}