// 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 <jlhamm@acm.org>
//
#include "rs_eventhandler.h"
-#include <QtGui>
-#include "rs_actioninterface.h"
+#include "actioninterface.h"
#include "rs_commandevent.h"
#include "rs_debug.h"
#include "rs_dialogfactory.h"
}
else
{
- if (defaultAction != NULL)
+ if (defaultAction)
{
defaultAction->mousePressEvent(e);
e->accept();
}
else
{
- if (defaultAction != NULL)
+ if (defaultAction)
defaultAction->mouseReleaseEvent(e);
else
e->ignore();
*/
void RS_EventHandler::mouseMoveEvent(QMouseEvent * e)
{
- if (actionIndex >= 0 && currentActions[actionIndex] != NULL
+ if (actionIndex >= 0 && currentActions[actionIndex]
&& !currentActions[actionIndex]->isFinished())
{
currentActions[actionIndex]->mouseMoveEvent(e);
}
else
{
- if (defaultAction!=NULL)
+ if (defaultAction)
{
defaultAction->mouseMoveEvent(e);
e->accept();
*/
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");
}
*/
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();
}
}
*/
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();
*/
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();
}
else
{
- if (RS_DIALOGFACTORY != NULL)
+ if (RS_DIALOGFACTORY)
RS_DIALOGFACTORY->commandMessage("Expression Syntax Error");
}
// 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);
}
else
{
- if (defaultAction != NULL)
+ if (defaultAction)
defaultAction->commandEvent(e);
}
}
/**
* @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];
/**
* @return The current default action.
*/
-RS_ActionInterface * RS_EventHandler::getDefaultAction()
+ActionInterface * RS_EventHandler::getDefaultAction()
{
return defaultAction;
}
/**
* 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;
/**
* 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];
}
else
{
- if (defaultAction != NULL)
+ if (defaultAction)
{
predecessor = defaultAction;
predecessor->suspend();
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];
{
for(int c=0; c<RS_MAXACTIONS; ++c)
{
- if (currentActions[c] != NULL)
+ if (currentActions[c])
{
if (currentActions[c]->rtti() == RS2::ActionSelectSingle
|| currentActions[c]->rtti() == RS2::ActionSelectContour
*/
bool RS_EventHandler::hasAction()
{
- if (actionIndex != -1 || defaultAction != NULL)
+ if (actionIndex != -1 || defaultAction)
return true;
return false;
// Resume last used action:
if (doResume)
{
- if (currentActions[resume] != NULL && !currentActions[resume]->isFinished())
+ if (currentActions[resume] && !currentActions[resume]->isFinished())
{
currentActions[resume]->resume();
currentActions[resume]->showOptions();
}
else
{
- if (defaultAction != NULL)
+ if (defaultAction)
{
defaultAction->resume();
defaultAction->showOptions();
*/
void RS_EventHandler::setSnapMode(RS2::SnapMode sm)
{
+#if 0
for(int c=0; c<RS_MAXACTIONS; ++c)
- if (currentActions[c] != NULL)
+ if (currentActions[c])
currentActions[c]->setSnapMode(sm);
- if (defaultAction!=NULL)
+ if (defaultAction)
defaultAction->setSnapMode(sm);
+#else
+#warning "!!! Not sure if this is going to work correctly..."
+//seems to
+ graphicView->snapper.setSnapMode(sm);
+#endif
}
/**
*/
void RS_EventHandler::setSnapRestriction(RS2::SnapRestriction sr)
{
+#if 0
for(int c=0; c<RS_MAXACTIONS; ++c)
- if (currentActions[c] != NULL)
+ if (currentActions[c])
currentActions[c]->setSnapRestriction(sr);
- if (defaultAction != NULL)
+ 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()
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");