]> Shamusworld >> Repos - architektonas/blobdiff - src/base/eventhandler.cpp
Removed unnecessary RS_ prefix from classes and whatnot.
[architektonas] / src / base / eventhandler.cpp
index 58334af9958ac11b3b2afef28d4d4aadf9be4be6..a8b64179e4207ff8a8a504d10759cdcb1a6de70f 100644 (file)
@@ -26,7 +26,7 @@
 /**
  * Constructor.
  */
-RS_EventHandler::RS_EventHandler(GraphicView * graphicView)
+EventHandler::EventHandler(GraphicView * graphicView)
 {
        this->graphicView = graphicView;
        actionIndex = -1;
@@ -41,9 +41,9 @@ RS_EventHandler::RS_EventHandler(GraphicView * graphicView)
 /**
  * Destructor.
  */
-RS_EventHandler::~RS_EventHandler()
+EventHandler::~EventHandler()
 {
-       RS_DEBUG->print("RS_EventHandler::~RS_EventHandler");
+       DEBUG->print("EventHandler::~EventHandler");
 
        if (defaultAction != NULL)
        {
@@ -54,7 +54,7 @@ RS_EventHandler::~RS_EventHandler()
 
        killAllActions();
 
-       RS_DEBUG->print("RS_EventHandler::~RS_EventHandler: Deleting all actions..");
+       DEBUG->print("EventHandler::~EventHandler: Deleting all actions..");
 
        for(int i=0; i<RS_MAXACTIONS; ++i)
        {
@@ -67,14 +67,14 @@ RS_EventHandler::~RS_EventHandler()
        }
 
        cleanUp();
-       RS_DEBUG->print("RS_EventHandler::~RS_EventHandler: Deleting all actions..: OK");
-       RS_DEBUG->print("RS_EventHandler::~RS_EventHandler: OK");
+       DEBUG->print("EventHandler::~EventHandler: Deleting all actions..: OK");
+       DEBUG->print("EventHandler::~EventHandler: OK");
 }
 
 /**
  * Go back in current action.
  */
-void RS_EventHandler::back()
+void EventHandler::back()
 {
        QMouseEvent e(QEvent::MouseButtonRelease, QPoint(0, 0), Qt::RightButton, Qt::RightButton,
                Qt::NoModifier);
@@ -84,7 +84,7 @@ void RS_EventHandler::back()
 /**
  * Go enter pressed event for current action.
  */
-void RS_EventHandler::enter()
+void EventHandler::enter()
 {
 //     QKeyEvent e(QEvent::KeyPress, Qt::Key_Enter, '\n', 0);
        QKeyEvent e(QEvent::KeyPress, Qt::Key_Enter, Qt::NoModifier, "\n", false, 0);
@@ -94,7 +94,7 @@ void RS_EventHandler::enter()
 /**
  * Called by GraphicView
  */
-void RS_EventHandler::mousePressEvent(QMouseEvent * e)
+void EventHandler::mousePressEvent(QMouseEvent * e)
 {
        if (actionIndex >= 0 && currentActions[actionIndex] != NULL)
        {
@@ -110,7 +110,7 @@ void RS_EventHandler::mousePressEvent(QMouseEvent * e)
                }
                else
                {
-                       RS_DEBUG->print("currently no action defined");
+                       DEBUG->print("currently no action defined");
                        e->ignore();
                }
        }
@@ -119,12 +119,12 @@ void RS_EventHandler::mousePressEvent(QMouseEvent * e)
 /**
  * Called by GraphicView
  */
-void RS_EventHandler::mouseReleaseEvent(QMouseEvent * e)
+void EventHandler::mouseReleaseEvent(QMouseEvent * e)
 {
        if (actionIndex >= 0 && currentActions[actionIndex] != NULL
                && !currentActions[actionIndex]->isFinished())
        {
-               RS_DEBUG->print("call action %s", currentActions[actionIndex]->getName().toLatin1().data());
+               DEBUG->print("call action %s", currentActions[actionIndex]->getName().toLatin1().data());
                currentActions[actionIndex]->mouseReleaseEvent(e);
 
                // Clean up actions - one might be finished now
@@ -143,7 +143,7 @@ void RS_EventHandler::mouseReleaseEvent(QMouseEvent * e)
 /**
  * Called by GraphicView
  */
-void RS_EventHandler::mouseMoveEvent(QMouseEvent * e)
+void EventHandler::mouseMoveEvent(QMouseEvent * e)
 {
        if (actionIndex >= 0 && currentActions[actionIndex]
                && !currentActions[actionIndex]->isFinished())
@@ -160,14 +160,14 @@ void RS_EventHandler::mouseMoveEvent(QMouseEvent * e)
                }
                else
                        e->ignore();
-               //RS_DEBUG->print("currently no action defined");
+               //DEBUG->print("currently no action defined");
        }
 }
 
 /**
  * Called by GraphicView
  */
-void RS_EventHandler::mouseLeaveEvent()
+void EventHandler::mouseLeaveEvent()
 {
        if (actionIndex >= 0 && currentActions[actionIndex]
                && !currentActions[actionIndex]->isFinished())
@@ -178,14 +178,14 @@ void RS_EventHandler::mouseLeaveEvent()
        {
                if (defaultAction)
                        defaultAction->suspend();
-               //RS_DEBUG->print("currently no action defined");
+               //DEBUG->print("currently no action defined");
        }
 }
 
 /**
  * Called by GraphicView
  */
-void RS_EventHandler::mouseEnterEvent()
+void EventHandler::mouseEnterEvent()
 {
        if (actionIndex >= 0 && currentActions[actionIndex]
                && !currentActions[actionIndex]->isFinished())
@@ -202,7 +202,7 @@ void RS_EventHandler::mouseEnterEvent()
 /**
  * Called by GraphicView
  */
-void RS_EventHandler::keyPressEvent(QKeyEvent * e)
+void EventHandler::keyPressEvent(QKeyEvent * e)
 {
        if (actionIndex >= 0 && currentActions[actionIndex]
                && !currentActions[actionIndex]->isFinished())
@@ -216,14 +216,14 @@ void RS_EventHandler::keyPressEvent(QKeyEvent * e)
                else
                        e->ignore();
 
-               //RS_DEBUG->print("currently no action defined");
+               //DEBUG->print("currently no action defined");
        }
 }
 
 /**
  * Called by GraphicView
  */
-void RS_EventHandler::keyReleaseEvent(QKeyEvent * e)
+void EventHandler::keyReleaseEvent(QKeyEvent * e)
 {
        if (actionIndex >= 0 && currentActions[actionIndex]
                && !currentActions[actionIndex]->isFinished())
@@ -237,16 +237,16 @@ void RS_EventHandler::keyReleaseEvent(QKeyEvent * e)
                else
                        e->ignore();
 
-               //RS_DEBUG->print("currently no action defined");
+               //DEBUG->print("currently no action defined");
        }
 }
 
 /**
  * Handles command line events.
  */
-void RS_EventHandler::commandEvent(RS_CommandEvent * e)
+void EventHandler::commandEvent(CommandEvent * e)
 {
-       RS_DEBUG->print("RS_EventHandler::commandEvent");
+       DEBUG->print("EventHandler::commandEvent");
        QString cmd = e->getCommand();
 
        if (coordinateInputEnabled)
@@ -260,27 +260,27 @@ void RS_EventHandler::commandEvent(RS_CommandEvent * e)
                                        && !currentActions[actionIndex]->isFinished())
                                {
                                        int commaPos = cmd.indexOf(',');
-                                       RS_DEBUG->print("RS_EventHandler::commandEvent: 001");
+                                       DEBUG->print("EventHandler::commandEvent: 001");
                                        bool ok1, ok2;
-                                       RS_DEBUG->print("RS_EventHandler::commandEvent: 002");
-                                       double x = RS_Math::eval(cmd.left(commaPos), &ok1);
-                                       RS_DEBUG->print("RS_EventHandler::commandEvent: 003a");
-                                       double y = RS_Math::eval(cmd.mid(commaPos + 1), &ok2);
-                                       RS_DEBUG->print("RS_EventHandler::commandEvent: 004");
+                                       DEBUG->print("EventHandler::commandEvent: 002");
+                                       double x = Math::eval(cmd.left(commaPos), &ok1);
+                                       DEBUG->print("EventHandler::commandEvent: 003a");
+                                       double y = Math::eval(cmd.mid(commaPos + 1), &ok2);
+                                       DEBUG->print("EventHandler::commandEvent: 004");
 
                                        if (ok1 && ok2)
                                        {
-//                                             RS_DEBUG->print("RS_EventHandler::commandEvent: 005");
-//                                             RS_CoordinateEvent ce(Vector(x, y));
-                                               RS_DEBUG->print("RS_EventHandler::commandEvent: 006");
+//                                             DEBUG->print("EventHandler::commandEvent: 005");
+//                                             CoordinateEvent ce(Vector(x, y));
+                                               DEBUG->print("EventHandler::commandEvent: 006");
 //                                             currentActions[actionIndex]->coordinateEvent(&ce);
                                                Vector ce(x, y);
                                                currentActions[actionIndex]->coordinateEvent(&ce);
                                        }
                                        else
                                        {
-                                               if (RS_DIALOGFACTORY != NULL)
-                                                       RS_DIALOGFACTORY->commandMessage("Expression Syntax Error");
+                                               if (DIALOGFACTORY != NULL)
+                                                       DIALOGFACTORY->commandMessage("Expression Syntax Error");
                                        }
 
                                        e->accept();
@@ -298,20 +298,20 @@ void RS_EventHandler::commandEvent(RS_CommandEvent * e)
                                {
                                        int commaPos = cmd.indexOf(',');
                                        bool ok1, ok2;
-                                       double x = RS_Math::eval(cmd.mid(1, commaPos - 1), &ok1);
-                                       double y = RS_Math::eval(cmd.mid(commaPos + 1), &ok2);
+                                       double x = Math::eval(cmd.mid(1, commaPos - 1), &ok1);
+                                       double y = Math::eval(cmd.mid(commaPos + 1), &ok2);
 
                                        if (ok1 && ok2)
                                        {
-//                                             RS_CoordinateEvent ce(Vector(x,y) + graphicView->getRelativeZero());
+//                                             CoordinateEvent ce(Vector(x,y) + graphicView->getRelativeZero());
 //                                             currentActions[actionIndex]->coordinateEvent(&ce);
                                                Vector ce(Vector(x,y) + graphicView->getRelativeZero());
                                                currentActions[actionIndex]->coordinateEvent(&ce);
                                        }
                                        else
                                        {
-                                               if (RS_DIALOGFACTORY != NULL)
-                                                       RS_DIALOGFACTORY->commandMessage("Expression Syntax Error");
+                                               if (DIALOGFACTORY != NULL)
+                                                       DIALOGFACTORY->commandMessage("Expression Syntax Error");
                                        }
 
                                        e->accept();
@@ -329,21 +329,21 @@ void RS_EventHandler::commandEvent(RS_CommandEvent * e)
                                {
                                        int commaPos = cmd.indexOf('<');
                                        bool ok1, ok2;
-                                       double r = RS_Math::eval(cmd.left(commaPos), &ok1);
-                                       double a = RS_Math::eval(cmd.mid(commaPos + 1), &ok2);
+                                       double r = Math::eval(cmd.left(commaPos), &ok1);
+                                       double a = Math::eval(cmd.mid(commaPos + 1), &ok2);
 
                                        if (ok1 && ok2)
                                        {
                                                Vector pos;
-                                               pos.setPolar(r,RS_Math::deg2rad(a));
-//                                             RS_CoordinateEvent ce(pos);
+                                               pos.setPolar(r,Math::deg2rad(a));
+//                                             CoordinateEvent ce(pos);
 //                                             currentActions[actionIndex]->coordinateEvent(&ce);
                                                currentActions[actionIndex]->coordinateEvent(&pos);
                                        }
                                        else
                                        {
-                                               if (RS_DIALOGFACTORY != NULL)
-                                                       RS_DIALOGFACTORY->commandMessage("Expression Syntax Error");
+                                               if (DIALOGFACTORY != NULL)
+                                                       DIALOGFACTORY->commandMessage("Expression Syntax Error");
                                        }
 
                                        e->accept();
@@ -362,22 +362,22 @@ void RS_EventHandler::commandEvent(RS_CommandEvent * e)
 //                                     int commaPos = cmd.find('<');
                                        int commaPos = cmd.indexOf('<');
                                        bool ok1, ok2;
-                                       double r = RS_Math::eval(cmd.mid(1, commaPos - 1), &ok1);
-                                       double a = RS_Math::eval(cmd.mid(commaPos + 1), &ok2);
+                                       double r = Math::eval(cmd.mid(1, commaPos - 1), &ok1);
+                                       double a = Math::eval(cmd.mid(commaPos + 1), &ok2);
 
                                        if (ok1 && ok2)
                                        {
                                                Vector pos;
-                                               pos.setPolar(r,RS_Math::deg2rad(a));
-//                                             RS_CoordinateEvent ce(pos + graphicView->getRelativeZero());
+                                               pos.setPolar(r,Math::deg2rad(a));
+//                                             CoordinateEvent ce(pos + graphicView->getRelativeZero());
 //                                             currentActions[actionIndex]->coordinateEvent(&ce);
                                                Vector ce(pos + graphicView->getRelativeZero());
                                                currentActions[actionIndex]->coordinateEvent(&ce);
                                        }
                                        else
                                        {
-                                               if (RS_DIALOGFACTORY)
-                                                       RS_DIALOGFACTORY->commandMessage("Expression Syntax Error");
+                                               if (DIALOGFACTORY)
+                                                       DIALOGFACTORY->commandMessage("Expression Syntax Error");
                                        }
 
                                        e->accept();
@@ -402,13 +402,13 @@ void RS_EventHandler::commandEvent(RS_CommandEvent * e)
                }
        }
 
-       RS_DEBUG->print("RS_EventHandler::commandEvent: OK");
+       DEBUG->print("EventHandler::commandEvent: OK");
 }
 
 /**
  * Enables coordinate input in the command line.
  */
-void RS_EventHandler::enableCoordinateInput()
+void EventHandler::enableCoordinateInput()
 {
        coordinateInputEnabled = true;
 }
@@ -416,7 +416,7 @@ void RS_EventHandler::enableCoordinateInput()
 /**
  * Enables coordinate input in the command line.
  */
-void RS_EventHandler::disableCoordinateInput()
+void EventHandler::disableCoordinateInput()
 {
        coordinateInputEnabled = false;
 }
@@ -424,7 +424,7 @@ void RS_EventHandler::disableCoordinateInput()
 /**
  * @return Current action.
  */
-ActionInterface * RS_EventHandler::getCurrentAction()
+ActionInterface * EventHandler::getCurrentAction()
 {
        if (actionIndex >= 0 && currentActions[actionIndex]
                && !currentActions[actionIndex]->isFinished())
@@ -436,7 +436,7 @@ ActionInterface * RS_EventHandler::getCurrentAction()
 /**
  * @return The current default action.
  */
-ActionInterface * RS_EventHandler::getDefaultAction()
+ActionInterface * EventHandler::getDefaultAction()
 {
        return defaultAction;
 }
@@ -444,7 +444,7 @@ ActionInterface * RS_EventHandler::getDefaultAction()
 /**
  * Sets the default action.
  */
-void RS_EventHandler::setDefaultAction(ActionInterface * action)
+void EventHandler::setDefaultAction(ActionInterface * action)
 {
        if (defaultAction)
        {
@@ -459,9 +459,9 @@ void RS_EventHandler::setDefaultAction(ActionInterface * action)
 /**
  * Sets the current action.
  */
-void RS_EventHandler::setCurrentAction(ActionInterface * action)
+void EventHandler::setCurrentAction(ActionInterface * action)
 {
-       RS_DEBUG->print("RS_EventHandler::setCurrentAction");
+       DEBUG->print("EventHandler::setCurrentAction");
 
        if (!action)
                return;
@@ -507,35 +507,35 @@ void RS_EventHandler::setCurrentAction(ActionInterface * action)
 
        // Set current action:
        currentActions[actionIndex] = action;
-       RS_DEBUG->print("RS_EventHandler::setCurrentAction: current action is: %s",
+       DEBUG->print("EventHandler::setCurrentAction: current action is: %s",
                currentActions[actionIndex]->getName().toLatin1().data());
 
        // Initialisation of our new action:
-       RS_DEBUG->print("RS_EventHandler::setCurrentAction: init current action");
+       DEBUG->print("EventHandler::setCurrentAction: init current action");
        action->init();
 
        // ## new:
        if (action->isFinished() == false)
        {
-               RS_DEBUG->print("RS_EventHandler::setCurrentAction: show options");
+               DEBUG->print("EventHandler::setCurrentAction: show options");
                currentActions[actionIndex]->showOptions();
-               RS_DEBUG->print("RS_EventHandler::setCurrentAction: set predecessor");
+               DEBUG->print("EventHandler::setCurrentAction: set predecessor");
                action->setPredecessor(predecessor);
        }
 
-       RS_DEBUG->print("RS_EventHandler::setCurrentAction: cleaning up..");
+       DEBUG->print("EventHandler::setCurrentAction: cleaning up..");
        cleanUp();
 
-       RS_DEBUG->print("RS_EventHandler::setCurrentAction: debugging actions");
+       DEBUG->print("EventHandler::setCurrentAction: debugging actions");
        debugActions();
-       RS_DEBUG->print("GraphicView::setCurrentAction: OK");
+       DEBUG->print("GraphicView::setCurrentAction: OK");
 }
 
 /**
  * Kills all running selection actions. Called when a selection action
  * is launched to reduce confusion.
  */
-void RS_EventHandler::killSelectActions()
+void EventHandler::killSelectActions()
 {
        for(int c=0; c<RS_MAXACTIONS; ++c)
        {
@@ -554,7 +554,7 @@ void RS_EventHandler::killSelectActions()
 /**
  * Kills all running actions. Called when a window is closed.
  */
-void RS_EventHandler::killAllActions()
+void EventHandler::killAllActions()
 {
        /*
     for (int c=0; c<RS_MAXACTIONS; ++c) {
@@ -569,7 +569,7 @@ void RS_EventHandler::killAllActions()
 /**
  * @return true if there is at least one action in the action stack.
  */
-bool RS_EventHandler::hasAction()
+bool EventHandler::hasAction()
 {
        if (actionIndex != -1 || defaultAction)
                return true;
@@ -580,9 +580,9 @@ bool RS_EventHandler::hasAction()
 /**
  * Garbage collector for actions.
  */
-void RS_EventHandler::cleanUp()
+void EventHandler::cleanUp()
 {
-       RS_DEBUG->print("RS_EventHandler::cleanUp");
+       DEBUG->print("EventHandler::cleanUp");
 
        int o = 0;                              // old index
        int n = 0;                              // new index
@@ -650,13 +650,13 @@ void RS_EventHandler::cleanUp()
                }
        }
 
-       RS_DEBUG->print("RS_EventHandler::cleanUp: OK");
+       DEBUG->print("EventHandler::cleanUp: OK");
 }
 
 /**
  * Sets the snap mode for all currently active actions.
  */
-void RS_EventHandler::setSnapMode(RS2::SnapMode sm)
+void EventHandler::setSnapMode(RS2::SnapMode sm)
 {
 #if 0
        for(int c=0; c<RS_MAXACTIONS; ++c)
@@ -675,7 +675,7 @@ void RS_EventHandler::setSnapMode(RS2::SnapMode sm)
 /**
  * Sets the snap restriction for all currently active actions.
  */
-void RS_EventHandler::setSnapRestriction(RS2::SnapRestriction sr)
+void EventHandler::setSnapRestriction(RS2::SnapRestriction sr)
 {
 #if 0
        for(int c=0; c<RS_MAXACTIONS; ++c)
@@ -691,20 +691,20 @@ void RS_EventHandler::setSnapRestriction(RS2::SnapRestriction sr)
 #endif
 }
 
-void RS_EventHandler::debugActions()
+void EventHandler::debugActions()
 {
-       RS_DEBUG->print("---");
+       DEBUG->print("---");
 
        for(int c=0; c<RS_MAXACTIONS; ++c)
        {
                if (c == actionIndex)
-                       RS_DEBUG->print("Current");
+                       DEBUG->print("Current");
 
                if (currentActions[c])
-                       RS_DEBUG->print("Action %03d: %s [%s]",
+                       DEBUG->print("Action %03d: %s [%s]",
                                c, currentActions[c]->getName().toLatin1().data(),
                                currentActions[c]->isFinished() ? "finished" : "active");
                else
-                       RS_DEBUG->print("Action %03d: NULL", c);
+                       DEBUG->print("Action %03d: NULL", c);
        }
 }