1 // rs_actioneditcopy.cpp
3 // Part of the Architektonas Project
4 // Originally part of QCad Community Edition by Andrew Mustun
5 // Extensively rewritten and refactored by James L. Hammons
6 // (C) 2010 Underground Software
8 // JLH = James L. Hammons <jlhamm@acm.org>
11 // --- ---------- -----------------------------------------------------------
12 // JLH 05/22/2010 Added this text. :-)
15 #include "rs_actioneditcopy.h"
17 #include "rs_modification.h"
22 * @param undo true for undo and false for redo.
24 RS_ActionEditCopy::RS_ActionEditCopy(bool copy,
25 RS_EntityContainer& container, RS_GraphicView& graphicView):
26 RS_ActionInterface("Edit Copy", container, graphicView)
31 RS_ActionEditCopy::~RS_ActionEditCopy()
35 QAction * RS_ActionEditCopy::createGUIAction(RS2::ActionType type, QObject * parent)
39 if (type == RS2::ActionEditCopy)
41 //QPixmap icon = QPixmap(editcopy_xpm);
42 action = new QAction(QIcon(":/res/editcopy2.png"), tr("&Copy"), parent);
43 action->setShortcut(Qt::CTRL + Qt::Key_C);
44 // action = new QAction(tr("Copy"), QPixmap::fromMimeSource("editcopy2.png"), tr("&Copy"),
45 // CTRL+Key_C, parent);
46 action->setStatusTip(tr("Copies entities to the clipboard"));
50 //icon = QPixmap(editcut_xpm);
51 action = new QAction(QIcon(":/res/editcut2.png"), tr("Cu&t"), parent);
52 action->setShortcut(Qt::CTRL + Qt::Key_X);
53 // action = new QAction(tr("Cut"), QPixmap::fromMimeSource("editcut2.png"), tr("Cu&t"),
54 // CTRL+Key_X, parent);
55 action->setStatusTip(tr("Cuts entities to the clipboard"));
61 void RS_ActionEditCopy::init(int status)
63 RS_ActionInterface::init(status);
69 void RS_ActionEditCopy::trigger() {
73 RS_Modification m(*container, graphicView);
74 m.copy(referencePoint, !copy);
76 //graphicView->redraw();
78 graphicView->killSelectActions();
79 //init(getStatus()-1);
80 RS_DIALOGFACTORY->updateSelectionWidget(container->countSelected());
84 void RS_ActionEditCopy::mouseMoveEvent(QMouseEvent* e) {
90 void RS_ActionEditCopy::mouseReleaseEvent(QMouseEvent* e) {
91 if (RS2::qtToRsButtonState(e->button())==RS2::LeftButton) {
92 RS_CoordinateEvent ce(snapPoint(e));
94 } else if (RS2::qtToRsButtonState(e->button())==RS2::RightButton) {
102 void RS_ActionEditCopy::coordinateEvent(RS_CoordinateEvent* e) {
107 referencePoint = e->getCoordinate();
113 void RS_ActionEditCopy::updateMouseButtonHints() {
114 switch (getStatus()) {
115 case SetReferencePoint:
116 RS_DIALOGFACTORY->updateMouseWidget(tr("Specify reference point"),
120 RS_DIALOGFACTORY->updateMouseWidget("", "");
127 void RS_ActionEditCopy::updateMouseCursor() {
128 graphicView->setMouseCursor(RS2::CadCursor);
133 void RS_ActionEditCopy::updateToolBar() {
135 RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarSnap);
137 RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarMain);