7#include <QtGui/qtguiglobal.h>
8#include <QtCore/qobject.h>
9#include <QtCore/qstring.h>
17class QUndoStackPrivate;
21 QUndoCommandPrivate *d;
24 explicit QUndoCommand(QUndoCommand *parent =
nullptr);
25 explicit QUndoCommand(
const QString &text, QUndoCommand *parent =
nullptr);
26 virtual ~QUndoCommand();
32 QString actionText()
const;
33 void setText(
const QString &text);
35 bool isObsolete()
const;
36 void setObsolete(
bool obsolete);
38 virtual int id()
const;
39 virtual bool mergeWith(
const QUndoCommand *other);
41 int childCount()
const;
42 const QUndoCommand *child(
int index)
const;
45 Q_DISABLE_COPY(QUndoCommand)
46 friend class QUndoStack;
49#if QT_CONFIG(undostack)
51class Q_GUI_EXPORT QUndoStack :
public QObject
54 Q_DECLARE_PRIVATE(QUndoStack)
55 Q_PROPERTY(
bool active READ isActive WRITE setActive)
56 Q_PROPERTY(
int undoLimit READ undoLimit WRITE setUndoLimit)
57 Q_PROPERTY(
bool canUndo READ canUndo NOTIFY canUndoChanged)
58 Q_PROPERTY(
bool canRedo READ canRedo NOTIFY canRedoChanged)
59 Q_PROPERTY(QString undoText READ undoText NOTIFY undoTextChanged)
60 Q_PROPERTY(QString redoText READ redoText NOTIFY redoTextChanged)
61 Q_PROPERTY(
bool clean READ isClean NOTIFY cleanChanged)
64 explicit QUndoStack(QObject *parent =
nullptr);
68 void push(QUndoCommand *cmd);
72 QString undoText()
const;
73 QString redoText()
const;
77 QString text(
int idx)
const;
80 QAction *createUndoAction(QObject *parent,
const QString &prefix = QString())
const;
81 QAction *createRedoAction(QObject *parent,
const QString &prefix = QString())
const;
84 bool isActive()
const;
86 int cleanIndex()
const;
88 void beginMacro(
const QString &text);
91 void setUndoLimit(
int limit);
92 int undoLimit()
const;
94 const QUndoCommand *command(
int index)
const;
99 void setIndex(
int idx);
102 void setActive(
bool active =
true);
105 void indexChanged(
int idx);
106 void cleanChanged(
bool clean);
107 void canUndoChanged(
bool canUndo);
108 void canRedoChanged(
bool canRedo);
109 void undoTextChanged(
const QString &undoText);
110 void redoTextChanged(
const QString &redoText);
113 Q_DISABLE_COPY(QUndoStack)
114 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(itemmodel)