]> Shamusworld >> Repos - architektonas/blobdiff - src/base/rs_eventhandler.cpp
Changed RS_Graphic to Drawing; this is less confusing as a drawing is
[architektonas] / src / base / rs_eventhandler.cpp
index 9f68a951f1d9515b3718bc3a28f0002ce8a887a0..29e03186f83c9ae02efed0a8c8679a5dcd31c053 100644 (file)
@@ -220,18 +220,23 @@ void RS_EventHandler::keyPressEvent(QKeyEvent * e)
  */
 void RS_EventHandler::keyReleaseEvent(QKeyEvent* e)
 {
-    if (actionIndex>=0 && currentActions[actionIndex]!=NULL &&
-            !currentActions[actionIndex]->isFinished()) {
-        currentActions[actionIndex]->keyReleaseEvent(e);
-    } else {
-        if (defaultAction!=NULL) {
-            defaultAction->keyReleaseEvent(e);
-        }
-               else {
+       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");
-    }
+               //RS_DEBUG->print("currently no action defined");
+       }
 }
 
 /**
@@ -252,7 +257,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(',');
                                        RS_DEBUG->print("RS_EventHandler::commandEvent: 001");
                                        bool ok1, ok2;
@@ -461,7 +465,7 @@ void RS_EventHandler::setCurrentAction(RS_ActionInterface * action)
                return;
 
        // Predecessor of the new action or NULL:
-       RS_ActionInterface* predecessor = NULL;
+       RS_ActionInterface * predecessor = NULL;
 
        // Suspend current action:
        if (actionIndex >= 0 && currentActions[actionIndex] != NULL
@@ -494,14 +498,10 @@ void RS_EventHandler::setCurrentAction(RS_ActionInterface * action)
 
                // Move up actionstack (optimize):
                for(int i=0; i<RS_MAXACTIONS-1; ++i)
-               {
                        currentActions[i] = currentActions[i + 1];
-               }
        }
        else if (actionIndex < RS_MAXACTIONS - 1)
-       {
                actionIndex++;
-       }
 
        // Set current action:
        currentActions[actionIndex] = action;
@@ -580,65 +580,75 @@ bool RS_EventHandler::hasAction()
  */
 void RS_EventHandler::cleanUp()
 {
-    RS_DEBUG->print("RS_EventHandler::cleanUp");
-
-    int o=0;   // old index
-    int n=0;   // new index
-    int resume=0; // index of action to resume
-    bool doResume=false; // do we need to resume an action
-    actionIndex = -1;
-
-    debugActions();
-    do {
-        // search first used action (o)
-        while (currentActions[o]==NULL && o<RS_MAXACTIONS) {
-            o++;
-        }
+       RS_DEBUG->print("RS_EventHandler::cleanUp");
 
-        // delete action if it is finished
-        if (o<RS_MAXACTIONS && currentActions[o]!=NULL &&
-                currentActions[o]->isFinished()) {
-            delete currentActions[o];
-            currentActions[o] = NULL;
+       int o = 0;                              // old index
+       int n = 0;                              // new index
+       int resume = 0;                 // index of action to resume
+       bool doResume = false;  // do we need to resume an action
+       actionIndex = -1;
 
-            doResume = true;
-        }
+       debugActions();
 
-        // move a running action up in the stack
-        if (o<RS_MAXACTIONS && currentActions[o]!=NULL) {
-            if (n!=o) {
-                currentActions[n] = currentActions[o];
-                resume = n;
-                currentActions[o] = NULL;
-            } else {
-                if (o<RS_MAXACTIONS) {
-                    o++;
-                }
-            }
-            actionIndex = n;
-            if (n<RS_MAXACTIONS-1) {
-                n++;
-            }
-        }
-    } while (o<RS_MAXACTIONS);
-
-    debugActions();
-
-    // Resume last used action:
-    if (doResume) {
-        if (currentActions[resume]!=NULL &&
-                !currentActions[resume]->isFinished()) {
-
-            currentActions[resume]->resume();
-            currentActions[resume]->showOptions();
-        } else {
-            if (defaultAction!=NULL) {
-                defaultAction->resume();
-                       defaultAction->showOptions();
-            }
-        }
-    }
-    RS_DEBUG->print("RS_EventHandler::cleanUp: OK");
+       do
+       {
+               // search first used action (o)
+               while (currentActions[o] == NULL && o < RS_MAXACTIONS)
+                       o++;
+
+               // delete action if it is finished
+               if (o < RS_MAXACTIONS && currentActions[o] != NULL
+                       && currentActions[o]->isFinished())
+               {
+                       delete currentActions[o];
+                       currentActions[o] = NULL;
+                       doResume = true;
+               }
+
+               // move a running action up in the stack
+               if (o < RS_MAXACTIONS && currentActions[o] != NULL)
+               {
+                       if (n != o)
+                       {
+                               currentActions[n] = currentActions[o];
+                               resume = n;
+                               currentActions[o] = NULL;
+                       }
+                       else
+                       {
+                               if (o < RS_MAXACTIONS)
+                                       o++;
+                       }
+
+                       actionIndex = n;
+
+                       if (n < RS_MAXACTIONS - 1)
+                               n++;
+               }
+       }
+       while (o < RS_MAXACTIONS);
+
+       debugActions();
+
+       // Resume last used action:
+       if (doResume)
+       {
+               if (currentActions[resume] != NULL && !currentActions[resume]->isFinished())
+               {
+                       currentActions[resume]->resume();
+                       currentActions[resume]->showOptions();
+               }
+               else
+               {
+                       if (defaultAction != NULL)
+                       {
+                               defaultAction->resume();
+                               defaultAction->showOptions();
+                       }
+               }
+       }
+
+       RS_DEBUG->print("RS_EventHandler::cleanUp: OK");
 }
 
 /**