X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fbase%2Feventhandler.cpp;h=7d7cd6bba5e60434aac79cbc0a662c3d1e4c9813;hb=5adb444f3e523d3fd028617ced72d1ea6661db21;hp=d8d8f2b7addb572252841a57393cabb92cff5a10;hpb=92c8661cef41f1109908bf645c0a171e34680183;p=architektonas diff --git a/src/base/eventhandler.cpp b/src/base/eventhandler.cpp index d8d8f2b..7d7cd6b 100644 --- a/src/base/eventhandler.cpp +++ b/src/base/eventhandler.cpp @@ -14,6 +14,8 @@ // JLH 05/28/2010 Added this text. :-) // +// This is only used by the GraphicView class... + #include "eventhandler.h" #include "actioninterface.h" @@ -26,16 +28,17 @@ /** * Constructor. */ -EventHandler::EventHandler(GraphicView * graphicView) +EventHandler::EventHandler()://GraphicView * graphicView) + defaultAction(NULL), actionIndex(-1), coordinateInputEnabled(true) { - this->graphicView = graphicView; - actionIndex = -1; +// this->graphicView = graphicView; +// actionIndex = -1; - for(int i=0; iprint("EventHandler::~EventHandler: Deleting all actions.."); @@ -66,7 +69,7 @@ EventHandler::~EventHandler() } } - cleanUp(); + CleanUp(); DEBUG->print("EventHandler::~EventHandler: Deleting all actions..: OK"); DEBUG->print("EventHandler::~EventHandler: OK"); } @@ -74,27 +77,27 @@ EventHandler::~EventHandler() /** * Go back in current action. */ -void EventHandler::back() +void EventHandler::Back() { QMouseEvent e(QEvent::MouseButtonRelease, QPoint(0, 0), Qt::RightButton, Qt::RightButton, Qt::NoModifier); - mouseReleaseEvent(&e); + MouseReleaseEvent(&e); } /** * Go enter pressed event for current action. */ -void EventHandler::enter() +void EventHandler::Enter() { // QKeyEvent e(QEvent::KeyPress, Qt::Key_Enter, '\n', 0); QKeyEvent e(QEvent::KeyPress, Qt::Key_Enter, Qt::NoModifier, "\n", false, 0); - keyPressEvent(&e); + KeyPressEvent(&e); } /** * Called by GraphicView */ -void EventHandler::mousePressEvent(QMouseEvent * e) +void EventHandler::MousePressEvent(QMouseEvent * e) { if (actionIndex >= 0 && currentActions[actionIndex] != NULL) { @@ -119,7 +122,7 @@ void EventHandler::mousePressEvent(QMouseEvent * e) /** * Called by GraphicView */ -void EventHandler::mouseReleaseEvent(QMouseEvent * e) +void EventHandler::MouseReleaseEvent(QMouseEvent * e) { if (actionIndex >= 0 && currentActions[actionIndex] != NULL && !currentActions[actionIndex]->isFinished()) @@ -128,7 +131,7 @@ void EventHandler::mouseReleaseEvent(QMouseEvent * e) currentActions[actionIndex]->mouseReleaseEvent(e); // Clean up actions - one might be finished now - cleanUp(); + CleanUp(); e->accept(); } else @@ -143,7 +146,7 @@ void EventHandler::mouseReleaseEvent(QMouseEvent * e) /** * Called by GraphicView */ -void EventHandler::mouseMoveEvent(QMouseEvent * e) +void EventHandler::MouseMoveEvent(QMouseEvent * e) { if (actionIndex >= 0 && currentActions[actionIndex] && !currentActions[actionIndex]->isFinished()) @@ -177,7 +180,7 @@ into GraphicView itself and be done with it? /** * Called by GraphicView */ -void EventHandler::mouseLeaveEvent() +void EventHandler::MouseLeaveEvent() { #if 0 if (actionIndex >= 0 && currentActions[actionIndex] @@ -197,7 +200,7 @@ void EventHandler::mouseLeaveEvent() /** * Called by GraphicView */ -void EventHandler::mouseEnterEvent() +void EventHandler::MouseEnterEvent() { #if 0 if (actionIndex >= 0 && currentActions[actionIndex] @@ -216,7 +219,7 @@ void EventHandler::mouseEnterEvent() /** * Called by GraphicView */ -void EventHandler::keyPressEvent(QKeyEvent * e) +void EventHandler::KeyPressEvent(QKeyEvent * e) { if (actionIndex >= 0 && currentActions[actionIndex] && !currentActions[actionIndex]->isFinished()) @@ -237,7 +240,7 @@ void EventHandler::keyPressEvent(QKeyEvent * e) /** * Called by GraphicView */ -void EventHandler::keyReleaseEvent(QKeyEvent * e) +void EventHandler::KeyReleaseEvent(QKeyEvent * e) { if (actionIndex >= 0 && currentActions[actionIndex] && !currentActions[actionIndex]->isFinished()) @@ -258,7 +261,7 @@ void EventHandler::keyReleaseEvent(QKeyEvent * e) /** * Handles command line events. */ -void EventHandler::commandEvent(CommandEvent * e) +void EventHandler::HandleCommandEvent(GraphicView * graphicView, CommandEvent * e) { DEBUG->print("EventHandler::commandEvent"); QString cmd = e->getCommand(); @@ -284,16 +287,13 @@ void EventHandler::commandEvent(CommandEvent * e) if (ok1 && ok2) { -// DEBUG->print("EventHandler::commandEvent: 005"); -// CoordinateEvent ce(Vector(x, y)); DEBUG->print("EventHandler::commandEvent: 006"); -// currentActions[actionIndex]->coordinateEvent(&ce); Vector ce(x, y); currentActions[actionIndex]->coordinateEvent(&ce); } else { - if (DIALOGFACTORY != NULL) + if (DIALOGFACTORY) DIALOGFACTORY->commandMessage("Expression Syntax Error"); } @@ -317,14 +317,12 @@ void EventHandler::commandEvent(CommandEvent * e) if (ok1 && ok2) { -// CoordinateEvent ce(Vector(x,y) + graphicView->getRelativeZero()); -// currentActions[actionIndex]->coordinateEvent(&ce); Vector ce(Vector(x,y) + graphicView->getRelativeZero()); currentActions[actionIndex]->coordinateEvent(&ce); } else { - if (DIALOGFACTORY != NULL) + if (DIALOGFACTORY) DIALOGFACTORY->commandMessage("Expression Syntax Error"); } @@ -350,13 +348,11 @@ void EventHandler::commandEvent(CommandEvent * e) { Vector pos; pos.setPolar(r,Math::deg2rad(a)); -// CoordinateEvent ce(pos); -// currentActions[actionIndex]->coordinateEvent(&ce); currentActions[actionIndex]->coordinateEvent(&pos); } else { - if (DIALOGFACTORY != NULL) + if (DIALOGFACTORY) DIALOGFACTORY->commandMessage("Expression Syntax Error"); } @@ -373,7 +369,6 @@ void EventHandler::commandEvent(CommandEvent * e) if (actionIndex >= 0 && currentActions[actionIndex] !=NULL && !currentActions[actionIndex]->isFinished()) { -// int commaPos = cmd.find('<'); int commaPos = cmd.indexOf('<'); bool ok1, ok2; double r = Math::eval(cmd.mid(1, commaPos - 1), &ok1); @@ -383,8 +378,6 @@ void EventHandler::commandEvent(CommandEvent * e) { Vector pos; pos.setPolar(r,Math::deg2rad(a)); -// CoordinateEvent ce(pos + graphicView->getRelativeZero()); -// currentActions[actionIndex]->coordinateEvent(&ce); Vector ce(pos + graphicView->getRelativeZero()); currentActions[actionIndex]->coordinateEvent(&ce); } @@ -400,7 +393,7 @@ void EventHandler::commandEvent(CommandEvent * e) } } - // send command event directly to current action: + // Send command event directly to current action: if (!e->isAccepted()) { if (actionIndex >= 0 && currentActions[actionIndex] @@ -422,7 +415,7 @@ void EventHandler::commandEvent(CommandEvent * e) /** * Enables coordinate input in the command line. */ -void EventHandler::enableCoordinateInput() +void EventHandler::EnableCoordinateInput() { coordinateInputEnabled = true; } @@ -430,7 +423,7 @@ void EventHandler::enableCoordinateInput() /** * Enables coordinate input in the command line. */ -void EventHandler::disableCoordinateInput() +void EventHandler::DisableCoordinateInput() { coordinateInputEnabled = false; } @@ -438,7 +431,7 @@ void EventHandler::disableCoordinateInput() /** * @return Current action. */ -ActionInterface * EventHandler::getCurrentAction() +ActionInterface * EventHandler::GetCurrentAction() { if (actionIndex >= 0 && currentActions[actionIndex] && !currentActions[actionIndex]->isFinished()) @@ -450,7 +443,7 @@ ActionInterface * EventHandler::getCurrentAction() /** * @return The current default action. */ -ActionInterface * EventHandler::getDefaultAction() +ActionInterface * EventHandler::GetDefaultAction() { return defaultAction; } @@ -458,7 +451,7 @@ ActionInterface * EventHandler::getDefaultAction() /** * Sets the default action. */ -void EventHandler::setDefaultAction(ActionInterface * action) +void EventHandler::SetDefaultAction(ActionInterface * action) { if (defaultAction) { @@ -473,7 +466,7 @@ void EventHandler::setDefaultAction(ActionInterface * action) /** * Sets the current action. */ -void EventHandler::setCurrentAction(ActionInterface * action) +void EventHandler::SetCurrentAction(ActionInterface * action) { DEBUG->print("EventHandler::setCurrentAction"); @@ -504,7 +497,7 @@ void EventHandler::setCurrentAction(ActionInterface * action) // Forget about the oldest action and make space for the new action: if (actionIndex == RS_MAXACTIONS - 1) { - // delete oldest action if necessary (usually never happens): + // Delete oldest action if necessary (usually never happens): if (currentActions[0]) { currentActions[0]->finish(); @@ -538,10 +531,10 @@ void EventHandler::setCurrentAction(ActionInterface * action) } DEBUG->print("EventHandler::setCurrentAction: cleaning up.."); - cleanUp(); + CleanUp(); DEBUG->print("EventHandler::setCurrentAction: debugging actions"); - debugActions(); + DebugActions(); DEBUG->print("GraphicView::setCurrentAction: OK"); } @@ -549,7 +542,7 @@ void EventHandler::setCurrentAction(ActionInterface * action) * Kills all running selection actions. Called when a selection action * is launched to reduce confusion. */ -void EventHandler::killSelectActions() +void EventHandler::KillSelectActions() { for(int c=0; cprint("EventHandler::cleanUp"); @@ -604,7 +598,7 @@ void EventHandler::cleanUp() bool doResume = false; // do we need to resume an action actionIndex = -1; - debugActions(); + DebugActions(); do { @@ -644,7 +638,7 @@ void EventHandler::cleanUp() } while (oldIndex < RS_MAXACTIONS); - debugActions(); + DebugActions(); // Resume last used action: if (doResume) @@ -667,45 +661,7 @@ void EventHandler::cleanUp() DEBUG->print("EventHandler::cleanUp: OK"); } -/** - * Sets the snap mode for all currently active actions. - */ -void 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 -} - -/** - * Sets the snap restriction for all currently active actions. - */ -void 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 EventHandler::debugActions() +void EventHandler::DebugActions() { DEBUG->print("---");