X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fbase%2Frs_eventhandler.cpp;h=29e03186f83c9ae02efed0a8c8679a5dcd31c053;hb=89e127aa3dbd74d3158e6dbe0ca1703420c04395;hp=9f68a951f1d9515b3718bc3a28f0002ce8a887a0;hpb=16ce54abf01ca3032e42a5bb11a4afcf9014dcca;p=architektonas diff --git a/src/base/rs_eventhandler.cpp b/src/base/rs_eventhandler.cpp index 9f68a95..29e0318 100644 --- a/src/base/rs_eventhandler.cpp +++ b/src/base/rs_eventhandler.cpp @@ -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; iprint("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 && oprint("RS_EventHandler::cleanUp"); - // delete action if it is finished - if (oisFinished()) { - 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 (oisFinished()) { - - 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"); } /**