#include "rs_commandevent.h"
#include "rs_debug.h"
#include "rs_dialogfactory.h"
-#include "rs_graphicview.h"
+#include "graphicview.h"
#include "rs_math.h"
/**
* Constructor.
*/
-RS_EventHandler::RS_EventHandler(RS_GraphicView * graphicView)
+RS_EventHandler::RS_EventHandler(GraphicView * graphicView)
{
this->graphicView = graphicView;
actionIndex = -1;
}
/**
- * Called by RS_GraphicView
+ * Called by GraphicView
*/
void RS_EventHandler::mousePressEvent(QMouseEvent * e)
{
}
/**
- * Called by RS_GraphicView
+ * Called by GraphicView
*/
void RS_EventHandler::mouseReleaseEvent(QMouseEvent * e)
{
}
else
{
- if (defaultAction != NULL)
+ if (defaultAction)
defaultAction->mouseReleaseEvent(e);
else
e->ignore();
}
/**
- * Called by RS_GraphicView
+ * Called by GraphicView
*/
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();
}
/**
- * Called by RS_GraphicView
+ * Called by GraphicView
*/
void RS_EventHandler::mouseLeaveEvent()
{
}
/**
- * Called by RS_GraphicView
+ * Called by GraphicView
*/
void RS_EventHandler::mouseEnterEvent()
{
}
/**
- * Called by RS_GraphicView
+ * Called by GraphicView
*/
void RS_EventHandler::keyPressEvent(QKeyEvent * e)
{
}
/**
- * Called by RS_GraphicView
+ * Called by GraphicView
*/
void RS_EventHandler::keyReleaseEvent(QKeyEvent * e)
{
if (actionIndex >= 0 && currentActions[actionIndex] != NULL
&& !currentActions[actionIndex]->isFinished())
{
-// int commaPos = cmd.find('<');
int commaPos = cmd.indexOf('<');
bool ok1, ok2;
double r = RS_Math::eval(cmd.left(commaPos), &ok1);
}
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);
}
}
{
RS_DEBUG->print("RS_EventHandler::setCurrentAction");
- if (action == NULL)
+ if (!action)
return;
// Predecessor of the new action or NULL:
RS_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();
RS_DEBUG->print("RS_EventHandler::setCurrentAction: debugging actions");
debugActions();
- RS_DEBUG->print("RS_GraphicView::setCurrentAction: OK");
+ RS_DEBUG->print("GraphicView::setCurrentAction: OK");
}
/**
*/
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)
{
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);
}
void RS_EventHandler::setSnapRestriction(RS2::SnapRestriction sr)
{
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);
}