8#include <QtGui/qtguiglobal.h>
9#include <QtCore/qobject.h>
10#include <QtCore/qstring.h>
18class QUndoStackPrivate;
22 QUndoCommandPrivate *d;
25 explicit QUndoCommand(QUndoCommand *parent =
nullptr);
26 explicit QUndoCommand(
const QString &text, QUndoCommand *parent =
nullptr);
27 virtual ~QUndoCommand();
33 QString actionText()
const;
34 void setText(
const QString &text);
36 bool isObsolete()
const;
37 void setObsolete(
bool obsolete);
39 virtual int id()
const;
40 virtual bool mergeWith(
const QUndoCommand *other);
42 int childCount()
const;
43 const QUndoCommand *child(
int index)
const;
46 Q_DISABLE_COPY(QUndoCommand)
47 friend class QUndoStack;
50#if QT_CONFIG(undostack)
52class Q_GUI_EXPORT QUndoStack :
public QObject
55 Q_DECLARE_PRIVATE(QUndoStack)
56 Q_PROPERTY(
bool active READ isActive WRITE setActive)
57 Q_PROPERTY(
int undoLimit READ undoLimit WRITE setUndoLimit)
58 Q_PROPERTY(
bool canUndo READ canUndo NOTIFY canUndoChanged)
59 Q_PROPERTY(
bool canRedo READ canRedo NOTIFY canRedoChanged)
60 Q_PROPERTY(QString undoText READ undoText NOTIFY undoTextChanged)
61 Q_PROPERTY(QString redoText READ redoText NOTIFY redoTextChanged)
62 Q_PROPERTY(
bool clean READ isClean NOTIFY cleanChanged)
65 explicit QUndoStack(QObject *parent =
nullptr);
69 void push(QUndoCommand *cmd);
73 QString undoText()
const;
74 QString redoText()
const;
78 QString text(
int idx)
const;
81 QAction *createUndoAction(QObject *parent,
const QString &prefix = QString())
const;
82 QAction *createRedoAction(QObject *parent,
const QString &prefix = QString())
const;
85 bool isActive()
const;
87 int cleanIndex()
const;
89 void beginMacro(
const QString &text);
92 void setUndoLimit(
int limit);
93 int undoLimit()
const;
95 const QUndoCommand *command(
int index)
const;
100 void setIndex(
int idx);
103 void setActive(
bool active =
true);
106 void indexChanged(
int idx);
107 void cleanChanged(
bool clean);
108 void canUndoChanged(
bool canUndo);
109 void canRedoChanged(
bool canRedo);
110 void undoTextChanged(
const QString &undoText);
111 void redoTextChanged(
const QString &redoText);
114 Q_DISABLE_COPY(QUndoStack)
115 friend class QUndoGroup;
The QUndoCommand class is the base class of all commands stored on a QUndoStack.
The QUndoGroup class is a group of QUndoStack objects.
QT_REQUIRE_CONFIG(undogroup)
QT_REQUIRE_CONFIG(thread)