]> Shamusworld >> Repos - architektonas/blobdiff - src/base/rs_eventhandler.cpp
Major refactoring of actions: Moved implementation from header files
[architektonas] / src / base / rs_eventhandler.cpp
index 29e03186f83c9ae02efed0a8c8679a5dcd31c053..2961ff733d4e2e8b4e902e62462d67c8cc1ab732 100644 (file)
 
 #include <QtGui>
 #include "rs_actioninterface.h"
-#include "rs_coordinateevent.h"
+#include "rs_commandevent.h"
+#include "rs_debug.h"
+#include "rs_dialogfactory.h"
+#include "rs_graphicview.h"
+#include "rs_math.h"
 
 /**
  * Constructor.
@@ -218,23 +222,20 @@ void RS_EventHandler::keyPressEvent(QKeyEvent * e)
 /**
  * Called by RS_GraphicView
  */
-void RS_EventHandler::keyReleaseEvent(QKeyEvent* e)
+void RS_EventHandler::keyReleaseEvent(QKeyEvent * e)
 {
-       if (actionIndex >= 0 && currentActions[actionIndex] != NULL &&
-               !currentActions[actionIndex]->isFinished())
+       if (actionIndex >= 0 && currentActions[actionIndex] != NULL
+               && !currentActions[actionIndex]->isFinished())
        {
                currentActions[actionIndex]->keyReleaseEvent(e);
        }
        else
        {
                if (defaultAction != NULL)
-               {
                        defaultAction->keyReleaseEvent(e);
-               }
                else
-               {
                        e->ignore();
-               }
+
                //RS_DEBUG->print("currently no action defined");
        }
 }
@@ -268,9 +269,11 @@ void RS_EventHandler::commandEvent(RS_CommandEvent * e)
 
                                        if (ok1 && ok2)
                                        {
-                                               RS_DEBUG->print("RS_EventHandler::commandEvent: 005");
-                                               RS_CoordinateEvent ce(Vector(x, y));
+//                                             RS_DEBUG->print("RS_EventHandler::commandEvent: 005");
+//                                             RS_CoordinateEvent ce(Vector(x, y));
                                                RS_DEBUG->print("RS_EventHandler::commandEvent: 006");
+//                                             currentActions[actionIndex]->coordinateEvent(&ce);
+                                               Vector ce(x, y);
                                                currentActions[actionIndex]->coordinateEvent(&ce);
                                        }
                                        else
@@ -292,7 +295,6 @@ void RS_EventHandler::commandEvent(RS_CommandEvent * e)
                                if (actionIndex >= 0 && currentActions[actionIndex] != NULL
                                        && !currentActions[actionIndex]->isFinished())
                                {
-//                                     int commaPos = cmd.find(',');
                                        int commaPos = cmd.indexOf(',');
                                        bool ok1, ok2;
                                        double x = RS_Math::eval(cmd.mid(1, commaPos - 1), &ok1);
@@ -300,8 +302,9 @@ void RS_EventHandler::commandEvent(RS_CommandEvent * e)
 
                                        if (ok1 && ok2)
                                        {
-                                               RS_CoordinateEvent ce(Vector(x,y) +
-                                                       graphicView->getRelativeZero());
+//                                             RS_CoordinateEvent ce(Vector(x,y) + graphicView->getRelativeZero());
+//                                             currentActions[actionIndex]->coordinateEvent(&ce);
+                                               Vector ce(Vector(x,y) + graphicView->getRelativeZero());
                                                currentActions[actionIndex]->coordinateEvent(&ce);
                                        }
                                        else
@@ -333,8 +336,9 @@ void RS_EventHandler::commandEvent(RS_CommandEvent * e)
                                        {
                                                Vector pos;
                                                pos.setPolar(r,RS_Math::deg2rad(a));
-                                               RS_CoordinateEvent ce(pos);
-                                               currentActions[actionIndex]->coordinateEvent(&ce);
+//                                             RS_CoordinateEvent ce(pos);
+//                                             currentActions[actionIndex]->coordinateEvent(&ce);
+                                               currentActions[actionIndex]->coordinateEvent(&pos);
                                        }
                                        else
                                        {
@@ -365,8 +369,9 @@ void RS_EventHandler::commandEvent(RS_CommandEvent * e)
                                        {
                                                Vector pos;
                                                pos.setPolar(r,RS_Math::deg2rad(a));
-                                               RS_CoordinateEvent ce(pos +
-                                                       graphicView->getRelativeZero());
+//                                             RS_CoordinateEvent ce(pos + graphicView->getRelativeZero());
+//                                             currentActions[actionIndex]->coordinateEvent(&ce);
+                                               Vector ce(pos + graphicView->getRelativeZero());
                                                currentActions[actionIndex]->coordinateEvent(&ce);
                                        }
                                        else
@@ -393,10 +398,7 @@ void RS_EventHandler::commandEvent(RS_CommandEvent * e)
                else
                {
                        if (defaultAction != NULL)
-                       {
                                defaultAction->commandEvent(e);
-                               //e->accept();
-                       }
                }
        }