]> Shamusworld >> Repos - architektonas/blob - src/actions/rs_actioneditundo.cpp
Initial import
[architektonas] / src / actions / rs_actioneditundo.cpp
1 // rs_actioneditundo.cpp
2 //
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
7 //
8 // JLH = James L. Hammons <jlhamm@acm.org>
9 //
10 // Who  When        What
11 // ---  ----------  -----------------------------------------------------------
12 // JLH  05/22/2010  Added this text. :-)
13 //
14
15 #include "rs_actioneditundo.h"
16 #include "rs_snapper.h"
17 //Added by qt3to4:
18 //#include <QIcon>//needed???
19
20 /**
21  * Constructor.
22  *
23  * @param undo true for undo and false for redo.
24  */
25 RS_ActionEditUndo::RS_ActionEditUndo(bool undo, RS_EntityContainer & container,
26         RS_GraphicView & graphicView): RS_ActionInterface("Edit Undo", container, graphicView)
27 {
28         this->undo = undo;
29 }
30
31 RS_ActionEditUndo::~RS_ActionEditUndo()
32 {
33 }
34
35 QAction * RS_ActionEditUndo::createGUIAction(RS2::ActionType type, QObject * parent)
36 {
37         QAction * action;
38
39         if (type == RS2::ActionEditUndo)
40         {
41                 action = new QAction(QIcon(":/res/undo2.png"), tr("&Undo")/*+ QString("\too")*/, parent);
42                 QList<QKeySequence> ks;
43                 ks.append(QKeySequence(tr("o, o", "Edit|Undo")));
44                 ks.append(Qt::CTRL + Qt::Key_Z);
45 //              action->setShortcut(Qt::CTRL + Qt::Key_Z);
46                 action->setShortcuts(ks);
47                 action->setStatusTip(tr("Undoes last action"));
48         }
49         else
50         {
51                 action = new QAction(QIcon(":/res/redo2.png"), tr("&Redo")/* + QString("\tuu")*/, parent);
52                 QList<QKeySequence> ks;
53                 ks.append(QKeySequence(tr("u, u", "Edit|Redo")));
54                 ks.append(Qt::CTRL + Qt::SHIFT + Qt::Key_Z);
55 //              action->setShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_Z);
56                 action->setShortcuts(ks);
57                 action->setStatusTip(tr("Redoes last action"));
58         }
59
60         return action;
61 }
62
63 void RS_ActionEditUndo::init(int status)
64 {
65         RS_ActionInterface::init(status);
66         trigger();
67 }
68
69 void RS_ActionEditUndo::trigger()
70 {
71         if (undo)
72                 document->undo();
73         else
74                 document->redo();
75
76         document->updateInserts();
77
78         graphicView->redraw();
79
80         finish();
81         RS_DIALOGFACTORY->updateSelectionWidget(container->countSelected());
82 }