X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fbase%2Frs_eventhandler.cpp;h=fa89eff725573f007b96697744b18476d1bd1d75;hb=bd2b29c8735d83ab48df13c3efee53f63570473e;hp=d12d76bab277ed44e100cd1a3aaed0725b2f15bc;hpb=937ade06241548bfbc7858705b3ce1c7778c3d88;p=architektonas diff --git a/src/base/rs_eventhandler.cpp b/src/base/rs_eventhandler.cpp index d12d76b..fa89eff 100644 --- a/src/base/rs_eventhandler.cpp +++ b/src/base/rs_eventhandler.cpp @@ -3,7 +3,9 @@ // Part of the Architektonas Project // Originally part of QCad Community Edition by Andrew Mustun // Extensively rewritten and refactored by James L. Hammons -// (C) 2010 Underground Software +// Portions copyright (C) 2001-2003 RibbonSoft +// Copyright (C) 2010 Underground Software +// See the README and GPLv2 files for licensing and warranty information // // JLH = James L. Hammons // @@ -14,8 +16,7 @@ #include "rs_eventhandler.h" -#include -#include "rs_actioninterface.h" +#include "actioninterface.h" #include "rs_commandevent.h" #include "rs_debug.h" #include "rs_dialogfactory.h" @@ -102,7 +103,7 @@ void RS_EventHandler::mousePressEvent(QMouseEvent * e) } else { - if (defaultAction != NULL) + if (defaultAction) { defaultAction->mousePressEvent(e); e->accept(); @@ -132,7 +133,7 @@ void RS_EventHandler::mouseReleaseEvent(QMouseEvent * e) } else { - if (defaultAction != NULL) + if (defaultAction) defaultAction->mouseReleaseEvent(e); else e->ignore(); @@ -144,7 +145,7 @@ void RS_EventHandler::mouseReleaseEvent(QMouseEvent * e) */ void RS_EventHandler::mouseMoveEvent(QMouseEvent * e) { - if (actionIndex >= 0 && currentActions[actionIndex] != NULL + if (actionIndex >= 0 && currentActions[actionIndex] && !currentActions[actionIndex]->isFinished()) { currentActions[actionIndex]->mouseMoveEvent(e); @@ -152,7 +153,7 @@ void RS_EventHandler::mouseMoveEvent(QMouseEvent * e) } else { - if (defaultAction!=NULL) + if (defaultAction) { defaultAction->mouseMoveEvent(e); e->accept(); @@ -168,14 +169,14 @@ void RS_EventHandler::mouseMoveEvent(QMouseEvent * e) */ void RS_EventHandler::mouseLeaveEvent() { - if (actionIndex >= 0 && currentActions[actionIndex] != NULL + if (actionIndex >= 0 && currentActions[actionIndex] && !currentActions[actionIndex]->isFinished()) { currentActions[actionIndex]->suspend(); } else { - if (defaultAction != NULL) + if (defaultAction) defaultAction->suspend(); //RS_DEBUG->print("currently no action defined"); } @@ -186,14 +187,14 @@ void RS_EventHandler::mouseLeaveEvent() */ void RS_EventHandler::mouseEnterEvent() { - if (actionIndex >= 0 && currentActions[actionIndex] != NULL + if (actionIndex >= 0 && currentActions[actionIndex] && !currentActions[actionIndex]->isFinished()) { currentActions[actionIndex]->resume(); } else { - if (defaultAction != NULL) + if (defaultAction) defaultAction->resume(); } } @@ -203,14 +204,14 @@ void RS_EventHandler::mouseEnterEvent() */ void RS_EventHandler::keyPressEvent(QKeyEvent * e) { - if (actionIndex >= 0 && currentActions[actionIndex] != NULL + if (actionIndex >= 0 && currentActions[actionIndex] && !currentActions[actionIndex]->isFinished()) { currentActions[actionIndex]->keyPressEvent(e); } else { - if (defaultAction != NULL) + if (defaultAction) defaultAction->keyPressEvent(e); else e->ignore(); @@ -224,14 +225,14 @@ void RS_EventHandler::keyPressEvent(QKeyEvent * e) */ void RS_EventHandler::keyReleaseEvent(QKeyEvent * e) { - if (actionIndex >= 0 && currentActions[actionIndex] != NULL + if (actionIndex >= 0 && currentActions[actionIndex] && !currentActions[actionIndex]->isFinished()) { currentActions[actionIndex]->keyReleaseEvent(e); } else { - if (defaultAction != NULL) + if (defaultAction) defaultAction->keyReleaseEvent(e); else e->ignore(); @@ -375,7 +376,7 @@ void RS_EventHandler::commandEvent(RS_CommandEvent * e) } else { - if (RS_DIALOGFACTORY != NULL) + if (RS_DIALOGFACTORY) RS_DIALOGFACTORY->commandMessage("Expression Syntax Error"); } @@ -388,7 +389,7 @@ void RS_EventHandler::commandEvent(RS_CommandEvent * e) // send command event directly to current action: if (!e->isAccepted()) { - if (actionIndex >= 0 && currentActions[actionIndex] != NULL + if (actionIndex >= 0 && currentActions[actionIndex] && !currentActions[actionIndex]->isFinished()) { currentActions[actionIndex]->commandEvent(e); @@ -396,7 +397,7 @@ void RS_EventHandler::commandEvent(RS_CommandEvent * e) } else { - if (defaultAction != NULL) + if (defaultAction) defaultAction->commandEvent(e); } } @@ -423,9 +424,9 @@ void RS_EventHandler::disableCoordinateInput() /** * @return Current action. */ -RS_ActionInterface * RS_EventHandler::getCurrentAction() +ActionInterface * RS_EventHandler::getCurrentAction() { - if (actionIndex >= 0 && currentActions[actionIndex] != NULL + if (actionIndex >= 0 && currentActions[actionIndex] && !currentActions[actionIndex]->isFinished()) return currentActions[actionIndex]; @@ -435,7 +436,7 @@ RS_ActionInterface * RS_EventHandler::getCurrentAction() /** * @return The current default action. */ -RS_ActionInterface * RS_EventHandler::getDefaultAction() +ActionInterface * RS_EventHandler::getDefaultAction() { return defaultAction; } @@ -443,9 +444,9 @@ RS_ActionInterface * RS_EventHandler::getDefaultAction() /** * Sets the default action. */ -void RS_EventHandler::setDefaultAction(RS_ActionInterface * action) +void RS_EventHandler::setDefaultAction(ActionInterface * action) { - if (defaultAction != NULL) + if (defaultAction) { defaultAction->finish(); delete defaultAction; @@ -458,18 +459,18 @@ void RS_EventHandler::setDefaultAction(RS_ActionInterface * action) /** * Sets the current action. */ -void RS_EventHandler::setCurrentAction(RS_ActionInterface * action) +void RS_EventHandler::setCurrentAction(ActionInterface * action) { RS_DEBUG->print("RS_EventHandler::setCurrentAction"); - if (action == NULL) + if (!action) return; // Predecessor of the new action or NULL: - RS_ActionInterface * predecessor = NULL; + ActionInterface * predecessor = NULL; // Suspend current action: - if (actionIndex >= 0 && currentActions[actionIndex] != NULL + if (actionIndex >= 0 && currentActions[actionIndex] && !currentActions[actionIndex]->isFinished()) { predecessor = currentActions[actionIndex]; @@ -478,7 +479,7 @@ void RS_EventHandler::setCurrentAction(RS_ActionInterface * action) } else { - if (defaultAction != NULL) + if (defaultAction) { predecessor = defaultAction; predecessor->suspend(); @@ -490,7 +491,7 @@ void RS_EventHandler::setCurrentAction(RS_ActionInterface * action) if (actionIndex == RS_MAXACTIONS - 1) { // delete oldest action if necessary (usually never happens): - if (currentActions[0] != NULL) + if (currentActions[0]) { currentActions[0]->finish(); delete currentActions[0]; @@ -538,7 +539,7 @@ void RS_EventHandler::killSelectActions() { for(int c=0; crtti() == RS2::ActionSelectSingle || currentActions[c]->rtti() == RS2::ActionSelectContour @@ -570,7 +571,7 @@ void RS_EventHandler::killAllActions() */ bool RS_EventHandler::hasAction() { - if (actionIndex != -1 || defaultAction != NULL) + if (actionIndex != -1 || defaultAction) return true; return false; @@ -657,12 +658,18 @@ void RS_EventHandler::cleanUp() */ void RS_EventHandler::setSnapMode(RS2::SnapMode sm) { +#if 0 for(int c=0; csetSnapMode(sm); if (defaultAction) defaultAction->setSnapMode(sm); +#else +#warning "!!! Not sure if this is going to work correctly..." +//seems to + graphicView->snapper.setSnapMode(sm); +#endif } /** @@ -670,12 +677,18 @@ void RS_EventHandler::setSnapMode(RS2::SnapMode sm) */ void RS_EventHandler::setSnapRestriction(RS2::SnapRestriction sr) { +#if 0 for(int c=0; csetSnapRestriction(sr); if (defaultAction) defaultAction->setSnapRestriction(sr); +#else +#warning "!!! Not sure if this is going to work correctly..." +//seems to + graphicView->snapper.setSnapRestriction(sr); +#endif } void RS_EventHandler::debugActions() @@ -687,7 +700,7 @@ void RS_EventHandler::debugActions() if (c == actionIndex) RS_DEBUG->print("Current"); - if (currentActions[c] != NULL) + if (currentActions[c]) RS_DEBUG->print("Action %03d: %s [%s]", c, currentActions[c]->getName().toLatin1().data(), currentActions[c]->isFinished() ? "finished" : "active");