1// Copyright (C) 2020 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QUNDOGROUP_H
5#define QUNDOGROUP_H
6
7#include <QtGui/qtguiglobal.h>
8#include <QtCore/qobject.h>
9#include <QtCore/qstring.h>
10
11QT_REQUIRE_CONFIG(undogroup);
12
13QT_BEGIN_NAMESPACE
14
15class QUndoGroupPrivate;
16class QUndoStack;
17class QAction;
18
19class Q_GUI_EXPORT QUndoGroup : public QObject
20{
21 Q_OBJECT
22 Q_DECLARE_PRIVATE(QUndoGroup)
23
24public:
25 explicit QUndoGroup(QObject *parent = nullptr);
26 ~QUndoGroup();
27
28 void addStack(QUndoStack *stack);
29 void removeStack(QUndoStack *stack);
30 QList<QUndoStack*> stacks() const;
31 QUndoStack *activeStack() const;
32
33#ifndef QT_NO_ACTION
34 QAction *createUndoAction(QObject *parent, const QString &prefix = QString()) const;
35 QAction *createRedoAction(QObject *parent, const QString &prefix = QString()) const;
36#endif // QT_NO_ACTION
37
38 bool canUndo() const;
39 bool canRedo() const;
40 QString undoText() const;
41 QString redoText() const;
42 bool isClean() const;
43
44public Q_SLOTS:
45 void undo();
46 void redo();
47 void setActiveStack(QUndoStack *stack);
48
49Q_SIGNALS:
50 void activeStackChanged(QUndoStack *stack);
51 void indexChanged(int idx);
52 void cleanChanged(bool clean);
53 void canUndoChanged(bool canUndo);
54 void canRedoChanged(bool canRedo);
55 void undoTextChanged(const QString &undoText);
56 void redoTextChanged(const QString &redoText);
57
58private:
59 Q_DISABLE_COPY(QUndoGroup)
60};
61
62QT_END_NAMESPACE
63
64#endif // QUNDOGROUP_H
65

source code of qtbase/src/gui/util/qundogroup.h