#include "rs_actioneditcopy.h"
+#include "rs_dialogfactory.h"
#include "rs_modification.h"
/**
*
* @param undo true for undo and false for redo.
*/
-RS_ActionEditCopy::RS_ActionEditCopy(bool copy,
- RS_EntityContainer& container, RS_GraphicView& graphicView):
+RS_ActionEditCopy::RS_ActionEditCopy(bool copy, RS_EntityContainer & container, GraphicView & graphicView):
RS_ActionInterface("Edit Copy", container, graphicView)
{
- this->copy = copy;
+ this->copy = copy;
}
RS_ActionEditCopy::~RS_ActionEditCopy()
{
}
-QAction * RS_ActionEditCopy::createGUIAction(RS2::ActionType type, QObject * parent)
-{
- QAction * action;
-
- if (type == RS2::ActionEditCopy)
- {
- //QPixmap icon = QPixmap(editcopy_xpm);
- action = new QAction(QIcon(":/res/editcopy2.png"), tr("&Copy"), parent);
- action->setShortcut(Qt::CTRL + Qt::Key_C);
-// action = new QAction(tr("Copy"), QPixmap::fromMimeSource("editcopy2.png"), tr("&Copy"),
-// CTRL+Key_C, parent);
- action->setStatusTip(tr("Copies entities to the clipboard"));
- }
- else
- {
- //icon = QPixmap(editcut_xpm);
- action = new QAction(QIcon(":/res/editcut2.png"), tr("Cu&t"), parent);
- action->setShortcut(Qt::CTRL + Qt::Key_X);
-// action = new QAction(tr("Cut"), QPixmap::fromMimeSource("editcut2.png"), tr("Cu&t"),
-// CTRL+Key_X, parent);
- action->setStatusTip(tr("Cuts entities to the clipboard"));
- }
-
- return action;
-}
-
void RS_ActionEditCopy::init(int status)
{
- RS_ActionInterface::init(status);
- //trigger();
+ RS_ActionInterface::init(status);
+ //trigger();
}
+void RS_ActionEditCopy::trigger()
+{
+ deleteSnapper();
+ RS_Modification m(*container, graphicView);
+ m.copy(referencePoint, !copy);
-void RS_ActionEditCopy::trigger() {
-
- deleteSnapper();
-
- RS_Modification m(*container, graphicView);
- m.copy(referencePoint, !copy);
-
- //graphicView->redraw();
- finish();
- graphicView->killSelectActions();
- //init(getStatus()-1);
- RS_DIALOGFACTORY->updateSelectionWidget(container->countSelected());
+ //graphicView->redraw();
+ finish();
+ graphicView->killSelectActions();
+ //init(getStatus()-1);
+ RS_DIALOGFACTORY->updateSelectionWidget(container->countSelected());
}
-
-void RS_ActionEditCopy::mouseMoveEvent(QMouseEvent* e) {
- snapPoint(e);
+void RS_ActionEditCopy::mouseMoveEvent(QMouseEvent * e)
+{
+ snapPoint(e);
}
-
-
-void RS_ActionEditCopy::mouseReleaseEvent(QMouseEvent* e) {
- if (RS2::qtToRsButtonState(e->button())==RS2::LeftButton) {
- RS_CoordinateEvent ce(snapPoint(e));
- coordinateEvent(&ce);
- } else if (RS2::qtToRsButtonState(e->button())==RS2::RightButton) {
- deleteSnapper();
- init(getStatus()-1);
- }
+void RS_ActionEditCopy::mouseReleaseEvent(QMouseEvent * e)
+{
+ if (e->button() == Qt::LeftButton)
+ {
+ Vector ce(snapPoint(e));
+ coordinateEvent(&ce);
+ }
+ else if (e->button() == Qt::RightButton)
+ {
+ deleteSnapper();
+ init(getStatus() - 1);
+ }
}
+void RS_ActionEditCopy::coordinateEvent(Vector * e)
+{
+ if (e == NULL)
+ return;
-
-void RS_ActionEditCopy::coordinateEvent(RS_CoordinateEvent* e) {
- if (e==NULL) {
- return;
- }
-
- referencePoint = e->getCoordinate();
- trigger();
+ referencePoint = *e;
+ trigger();
}
-
-
-void RS_ActionEditCopy::updateMouseButtonHints() {
- switch (getStatus()) {
- case SetReferencePoint:
- RS_DIALOGFACTORY->updateMouseWidget(tr("Specify reference point"),
- tr("Cancel"));
- break;
- default:
- RS_DIALOGFACTORY->updateMouseWidget("", "");
- break;
- }
+void RS_ActionEditCopy::updateMouseButtonHints()
+{
+ switch (getStatus())
+ {
+ case SetReferencePoint:
+ RS_DIALOGFACTORY->updateMouseWidget(tr("Specify reference point"),
+ tr("Cancel"));
+ break;
+
+ default:
+ RS_DIALOGFACTORY->updateMouseWidget("", "");
+ break;
+ }
}
-
-
-void RS_ActionEditCopy::updateMouseCursor() {
- graphicView->setMouseCursor(RS2::CadCursor);
+void RS_ActionEditCopy::updateMouseCursor()
+{
+ graphicView->setMouseCursor(RS2::CadCursor);
}
-
-
-void RS_ActionEditCopy::updateToolBar() {
- if (!isFinished()) {
- RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarSnap);
- } else {
- RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarMain);
- }
+void RS_ActionEditCopy::updateToolBar()
+{
+ if (!isFinished())
+ RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarSnap);
+ else
+ RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarMain);
}
-
// EOF