]> Shamusworld >> Repos - architektonas/blobdiff - src/base/eventhandler.cpp
In the middle of removing Snapper class/fixing snapper rendering...
[architektonas] / src / base / eventhandler.cpp
index a8b64179e4207ff8a8a504d10759cdcb1a6de70f..d8d8f2b7addb572252841a57393cabb92cff5a10 100644 (file)
@@ -45,7 +45,7 @@ EventHandler::~EventHandler()
 {
        DEBUG->print("EventHandler::~EventHandler");
 
-       if (defaultAction != NULL)
+       if (defaultAction)
        {
                defaultAction->finish();
                delete defaultAction;
@@ -164,11 +164,22 @@ void EventHandler::mouseMoveEvent(QMouseEvent * e)
        }
 }
 
+#if 0
+Small problem with this approach: Resumes can happen before suspend actions!
+This can wreak havoc with things like snapper/preview states and the like...
+
+Actually, this stuff seems to be pretty useless. Not sure what is accomplished
+by this crap. The only thing I can think of is that it would cause a preview
+to be removed if the mouse goes out of the drawing window, could be a legit
+purpose but this seems too retarded for that. Why wouldn't you just code that
+into GraphicView itself and be done with it?
+#endif
 /**
  * Called by GraphicView
  */
 void EventHandler::mouseLeaveEvent()
 {
+#if 0
        if (actionIndex >= 0 && currentActions[actionIndex]
                && !currentActions[actionIndex]->isFinished())
        {
@@ -180,6 +191,7 @@ void EventHandler::mouseLeaveEvent()
                        defaultAction->suspend();
                //DEBUG->print("currently no action defined");
        }
+#endif
 }
 
 /**
@@ -187,6 +199,7 @@ void EventHandler::mouseLeaveEvent()
  */
 void EventHandler::mouseEnterEvent()
 {
+#if 0
        if (actionIndex >= 0 && currentActions[actionIndex]
                && !currentActions[actionIndex]->isFinished())
        {
@@ -197,6 +210,7 @@ void EventHandler::mouseEnterEvent()
                if (defaultAction)
                        defaultAction->resume();
        }
+#endif
 }
 
 /**
@@ -584,8 +598,8 @@ void EventHandler::cleanUp()
 {
        DEBUG->print("EventHandler::cleanUp");
 
-       int o = 0;                              // old index
-       int n = 0;                              // new index
+       int oldIndex = 0;               // old index
+       int newIndex = 0;               // new index
        int resume = 0;                 // index of action to resume
        bool doResume = false;  // do we need to resume an action
        actionIndex = -1;
@@ -594,41 +608,41 @@ void EventHandler::cleanUp()
 
        do
        {
-               // search first used action (o)
-               while (currentActions[o] == NULL && o < RS_MAXACTIONS)
-                       o++;
+               // Search first used action (oldIndex)
+               while (currentActions[oldIndex] == NULL && oldIndex < RS_MAXACTIONS)
+                       oldIndex++;
 
-               // delete action if it is finished
-               if (o < RS_MAXACTIONS && currentActions[o] != NULL
-                       && currentActions[o]->isFinished())
+               // Delete action if it is finished
+               if (oldIndex < RS_MAXACTIONS && currentActions[oldIndex] != NULL
+                       && currentActions[oldIndex]->isFinished())
                {
-                       delete currentActions[o];
-                       currentActions[o] = NULL;
+                       delete currentActions[oldIndex];
+                       currentActions[oldIndex] = NULL;
                        doResume = true;
                }
 
-               // move a running action up in the stack
-               if (o < RS_MAXACTIONS && currentActions[o] != NULL)
+               // Move a running action up in the stack
+               if (oldIndex < RS_MAXACTIONS && currentActions[oldIndex] != NULL)
                {
-                       if (n != o)
+                       if (newIndex != oldIndex)
                        {
-                               currentActions[n] = currentActions[o];
-                               resume = n;
-                               currentActions[o] = NULL;
+                               currentActions[newIndex] = currentActions[oldIndex];
+                               resume = newIndex;
+                               currentActions[oldIndex] = NULL;
                        }
                        else
                        {
-                               if (o < RS_MAXACTIONS)
-                                       o++;
+                               if (oldIndex < RS_MAXACTIONS)
+                                       oldIndex++;
                        }
 
-                       actionIndex = n;
+                       actionIndex = newIndex;
 
-                       if (n < RS_MAXACTIONS - 1)
-                               n++;
+                       if (newIndex < RS_MAXACTIONS - 1)
+                               newIndex++;
                }
        }
-       while (o < RS_MAXACTIONS);
+       while (oldIndex < RS_MAXACTIONS);
 
        debugActions();