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 | |
11 | QT_REQUIRE_CONFIG(undogroup); |
12 | |
13 | QT_BEGIN_NAMESPACE |
14 | |
15 | class QUndoGroupPrivate; |
16 | class QUndoStack; |
17 | class QAction; |
18 | |
19 | class Q_GUI_EXPORT QUndoGroup : public QObject |
20 | { |
21 | Q_OBJECT |
22 | Q_DECLARE_PRIVATE(QUndoGroup) |
23 | |
24 | public: |
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 | |
44 | public Q_SLOTS: |
45 | void undo(); |
46 | void redo(); |
47 | void setActiveStack(QUndoStack *stack); |
48 | |
49 | Q_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 | |
58 | private: |
59 | Q_DISABLE_COPY(QUndoGroup) |
60 | }; |
61 | |
62 | QT_END_NAMESPACE |
63 | |
64 | #endif // QUNDOGROUP_H |
65 | |