1
/***************************************************************************
2
* Copyright (c) 2004 Werner Mayer <wmayer[at]users.sourceforge.net> *
4
* This file is part of the FreeCAD CAx development system. *
6
* This library is free software; you can redistribute it and/or *
7
* modify it under the terms of the GNU Library General Public *
8
* License as published by the Free Software Foundation; either *
9
* version 2 of the License, or (at your option) any later version. *
11
* This library is distributed in the hope that it will be useful, *
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14
* GNU Library General Public License for more details. *
16
* You should have received a copy of the GNU Library General Public *
17
* License along with this library; see the file COPYING.LIB. If not, *
18
* write to the Free Software Foundation, Inc., 59 Temple Place, *
19
* Suite 330, Boston, MA 02111-1307, USA *
21
***************************************************************************/
23
#include "PreCompiled.h"
30
#include "DlgUndoRedo.h"
31
#include "Application.h"
32
#include "MainWindow.h"
36
using namespace Gui::Dialog;
38
/* TRANSLATOR Gui::Dialog::UndoRedoDialog */
41
* Constructs a UndoRedoDialog which is a child of 'parent', with the
44
UndoDialog::UndoDialog( QWidget* parent )
47
connect(this, &QMenu::aboutToShow, this, &UndoDialog::onFetchInfo);
51
* Destroys the object and frees any allocated resources.
53
UndoDialog::~UndoDialog() = default;
56
* This method fetches the undo / redo information from the
57
* active document and shows it in the undo / redo dialog.
59
void UndoDialog::onFetchInfo()
61
clear(); // Remove first all items
63
MDIView* mdi = getMainWindow()->activeWindow();
65
QStringList vecUndos = mdi->undoActions();
66
for (QStringList::Iterator i = vecUndos.begin(); i != vecUndos.end(); ++i) {
67
addAction(*i, this, &UndoDialog::onSelected);
72
/** Closes the dialog and sends the message 'Undo' to the currently active MDI view. */
73
void UndoDialog::onSelected()
75
auto a = static_cast<QAction*>(sender());
76
QList<QAction*> acts = this->actions();
77
for (QList<QAction*>::Iterator it = acts.begin(); it != acts.end(); ++it) {
78
Gui::Application::Instance->sendMsgToActiveView("Undo");
84
/* TRANSLATOR Gui::Dialog::RedoDialog */
87
* Constructs a UndoRedoDialog which is a child of 'parent', with the
90
RedoDialog::RedoDialog( QWidget* parent )
93
connect(this, &QMenu::aboutToShow, this, &RedoDialog::onFetchInfo);
97
* Destroys the object and frees any allocated resources.
99
RedoDialog::~RedoDialog() = default;
102
* This method fetches the undo / redo information from the
103
* active document and shows it in the undo / redo dialog.
105
void RedoDialog::onFetchInfo()
107
clear(); // Remove first all items
109
MDIView* mdi = getMainWindow()->activeWindow();
111
QStringList vecRedos = mdi->redoActions();
112
for (QStringList::Iterator i = vecRedos.begin(); i != vecRedos.end(); ++i) {
113
addAction(*i, this, &RedoDialog::onSelected);
118
/** Closes the dialog and sends the message 'Redo' to the currently active MDI view. */
119
void RedoDialog::onSelected()
121
auto a = static_cast<QAction*>(sender());
122
QList<QAction*> acts = this->actions();
123
for (QList<QAction*>::Iterator it = acts.begin(); it != acts.end(); ++it) {
124
Gui::Application::Instance->sendMsgToActiveView("Redo");
130
#include "moc_DlgUndoRedo.cpp"