Qt 4.8
|
The QUndoGroup class is a group of QUndoStack objects. More...
#include <qundogroup.h>
Public Slots | |
void | redo () |
Calls QUndoStack::redo() on the active stack. More... | |
void | setActiveStack (QUndoStack *stack) |
Sets the active stack of this group to stack. More... | |
void | undo () |
Calls QUndoStack::undo() on the active stack. More... | |
Public Slots inherited from QObject | |
void | deleteLater () |
Schedules this object for deletion. More... | |
Signals | |
void | activeStackChanged (QUndoStack *stack) |
This signal is emitted whenever the active stack of the group changes. More... | |
void | canRedoChanged (bool canRedo) |
This signal is emitted whenever the active stack emits QUndoStack::canRedoChanged() or the active stack changes. More... | |
void | canUndoChanged (bool canUndo) |
This signal is emitted whenever the active stack emits QUndoStack::canUndoChanged() or the active stack changes. More... | |
void | cleanChanged (bool clean) |
This signal is emitted whenever the active stack emits QUndoStack::cleanChanged() or the active stack changes. More... | |
void | indexChanged (int idx) |
This signal is emitted whenever the active stack emits QUndoStack::indexChanged() or the active stack changes. More... | |
void | redoTextChanged (const QString &redoText) |
This signal is emitted whenever the active stack emits QUndoStack::redoTextChanged() or the active stack changes. More... | |
void | undoTextChanged (const QString &undoText) |
This signal is emitted whenever the active stack emits QUndoStack::undoTextChanged() or the active stack changes. More... | |
Signals inherited from QObject | |
void | destroyed (QObject *=0) |
This signal is emitted immediately before the object obj is destroyed, and can not be blocked. More... | |
Public Functions | |
QUndoStack * | activeStack () const |
Returns the active stack of this group. More... | |
void | addStack (QUndoStack *stack) |
Adds stack to this group. More... | |
bool | canRedo () const |
Returns the value of the active stack's QUndoStack::canRedo(). More... | |
bool | canUndo () const |
Returns the value of the active stack's QUndoStack::canUndo(). More... | |
QAction * | createRedoAction (QObject *parent, const QString &prefix=QString()) const |
Creates an redo QAction object with parent parent. More... | |
QAction * | createUndoAction (QObject *parent, const QString &prefix=QString()) const |
Creates an undo QAction object with parent parent. More... | |
bool | isClean () const |
Returns the value of the active stack's QUndoStack::isClean(). More... | |
QUndoGroup (QObject *parent=0) | |
Creates an empty QUndoGroup object with parent parent. More... | |
QString | redoText () const |
Returns the value of the active stack's QUndoStack::redoText(). More... | |
void | removeStack (QUndoStack *stack) |
Removes stack from this group. More... | |
QList< QUndoStack * > | stacks () const |
Returns a list of stacks in this group. More... | |
QString | undoText () const |
Returns the value of the active stack's QUndoStack::undoText(). More... | |
~QUndoGroup () | |
Destroys the QUndoGroup. More... | |
Public Functions inherited from QObject | |
bool | blockSignals (bool b) |
If block is true, signals emitted by this object are blocked (i.e., emitting a signal will not invoke anything connected to it). More... | |
const QObjectList & | children () const |
Returns a list of child objects. More... | |
bool | connect (const QObject *sender, const char *signal, const char *member, Qt::ConnectionType type=Qt::AutoConnection) const |
bool | disconnect (const char *signal=0, const QObject *receiver=0, const char *member=0) |
bool | disconnect (const QObject *receiver, const char *member=0) |
void | dumpObjectInfo () |
Dumps information about signal connections, etc. More... | |
void | dumpObjectTree () |
Dumps a tree of children to the debug output. More... | |
QList< QByteArray > | dynamicPropertyNames () const |
Returns the names of all properties that were dynamically added to the object using setProperty(). More... | |
virtual bool | event (QEvent *) |
This virtual function receives events to an object and should return true if the event e was recognized and processed. More... | |
virtual bool | eventFilter (QObject *, QEvent *) |
Filters events if this object has been installed as an event filter for the watched object. More... | |
template<typename T > | |
T | findChild (const QString &aName=QString()) const |
Returns the child of this object that can be cast into type T and that is called name, or 0 if there is no such object. More... | |
template<typename T > | |
QList< T > | findChildren (const QString &aName=QString()) const |
Returns all children of this object with the given name that can be cast to type T, or an empty list if there are no such objects. More... | |
template<typename T > | |
QList< T > | findChildren (const QRegExp &re) const |
bool | inherits (const char *classname) const |
Returns true if this object is an instance of a class that inherits className or a QObject subclass that inherits className; otherwise returns false. More... | |
void | installEventFilter (QObject *) |
Installs an event filter filterObj on this object. More... | |
bool | isWidgetType () const |
Returns true if the object is a widget; otherwise returns false. More... | |
void | killTimer (int id) |
Kills the timer with timer identifier, id. More... | |
virtual const QMetaObject * | metaObject () const |
Returns a pointer to the meta-object of this object. More... | |
void | moveToThread (QThread *thread) |
Changes the thread affinity for this object and its children. More... | |
QString | objectName () const |
QObject * | parent () const |
Returns a pointer to the parent object. More... | |
QVariant | property (const char *name) const |
Returns the value of the object's name property. More... | |
Q_INVOKABLE | QObject (QObject *parent=0) |
Constructs an object with parent object parent. More... | |
void | removeEventFilter (QObject *) |
Removes an event filter object obj from this object. More... | |
void | setObjectName (const QString &name) |
void | setParent (QObject *) |
Makes the object a child of parent. More... | |
bool | setProperty (const char *name, const QVariant &value) |
Sets the value of the object's name property to value. More... | |
void | setUserData (uint id, QObjectUserData *data) |
bool | signalsBlocked () const |
Returns true if signals are blocked; otherwise returns false. More... | |
int | startTimer (int interval) |
Starts a timer and returns a timer identifier, or returns zero if it could not start a timer. More... | |
QThread * | thread () const |
Returns the thread in which the object lives. More... | |
QObjectUserData * | userData (uint id) const |
virtual | ~QObject () |
Destroys the object, deleting all its child objects. More... | |
Additional Inherited Members | |
Static Public Functions inherited from QObject | |
static bool | connect (const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection) |
Creates a connection of the given type from the signal in the sender object to the method in the receiver object. More... | |
static bool | connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type=Qt::AutoConnection) |
static bool | disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *member) |
Disconnects signal in object sender from method in object receiver. More... | |
static bool | disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &member) |
static uint | registerUserData () |
static QString | tr (const char *sourceText, const char *comment=0, int n=-1) |
static QString | trUtf8 (const char *sourceText, const char *comment=0, int n=-1) |
Static Public Variables inherited from QObject | |
static const QMetaObject | staticMetaObject |
This variable stores the meta-object for the class. More... | |
Protected Functions inherited from QObject | |
virtual void | childEvent (QChildEvent *) |
This event handler can be reimplemented in a subclass to receive child events. More... | |
virtual void | connectNotify (const char *signal) |
This virtual function is called when something has been connected to signal in this object. More... | |
virtual void | customEvent (QEvent *) |
This event handler can be reimplemented in a subclass to receive custom events. More... | |
virtual void | disconnectNotify (const char *signal) |
This virtual function is called when something has been disconnected from signal in this object. More... | |
QObject (QObjectPrivate &dd, QObject *parent=0) | |
int | receivers (const char *signal) const |
Returns the number of receivers connected to the signal. More... | |
QObject * | sender () const |
Returns a pointer to the object that sent the signal, if called in a slot activated by a signal; otherwise it returns 0. More... | |
int | senderSignalIndex () const |
virtual void | timerEvent (QTimerEvent *) |
This event handler can be reimplemented in a subclass to receive timer events for the object. More... | |
Protected Variables inherited from QObject | |
QScopedPointer< QObjectData > | d_ptr |
Static Protected Variables inherited from QObject | |
static const QMetaObject | staticQtMetaObject |
Related Functions inherited from QObject | |
T | qFindChildqFindChildren (const QObject *obj, const QString &name)() |
QList< T > | qFindChildrenqFindChildren (const QObject *obj, const QString &name)() |
QList< T > | qFindChildrenqFindChildren (const QObject *obj, const QRegExp ®Exp)() |
T * | qobject_cast (QObject *object) |
QObjectList | |
void * | qt_find_obj_child (QObject *parent, const char *type, const QString &name) |
Returns a pointer to the object named name that inherits type and with a given parent. More... | |
The QUndoGroup class is a group of QUndoStack objects.
For an overview of the Qt's undo framework, see the overview.
An application often has multiple undo stacks, one for each opened document. At the same time, an application usually has one undo action and one redo action, which triggers undo or redo in the active document.
QUndoGroup is a group of QUndoStack objects, one of which may be active. It has an undo() and redo() slot, which calls QUndoStack::undo() and QUndoStack::redo() for the active stack. It also has the functions createUndoAction() and createRedoAction(). The actions returned by these functions behave in the same way as those returned by QUndoStack::createUndoAction() and QUndoStack::createRedoAction() of the active stack.
Stacks are added to a group with addStack() and removed with removeStack(). A stack is implicitly added to a group when it is created with the group as its parent QObject.
It is the programmer's responsibility to specify which stack is active by calling QUndoStack::setActive(), usually when the associated document window receives focus. The active stack may also be set with setActiveStack(), and is returned by activeStack().
When a stack is added to a group using addStack(), the group does not take ownership of the stack. This means the stack has to be deleted separately from the group. When a stack is deleted, it is automatically removed from a group. A stack may belong to only one group. Adding it to another group will cause it to be removed from the previous group.
A QUndoGroup is also useful in conjunction with QUndoView. If a QUndoView is set to watch a group using QUndoView::setGroup(), it will update itself to display the active stack.
Definition at line 60 of file qundogroup.h.
|
explicit |
Creates an empty QUndoGroup object with parent parent.
Definition at line 106 of file qundogroup.cpp.
QUndoGroup::~QUndoGroup | ( | ) |
Destroys the QUndoGroup.
Definition at line 114 of file qundogroup.cpp.
QUndoStack * QUndoGroup::activeStack | ( | ) | const |
Returns the active stack of this group.
If none of the stacks are active, or if the group is empty, this function returns 0.
Definition at line 255 of file qundogroup.cpp.
|
signal |
This signal is emitted whenever the active stack of the group changes.
This can happen when setActiveStack() or QUndoStack::setActive() is called, or when the active stack is removed form the group. stack is the new active stack. If no stack is active, stack is 0.
Referenced by setActiveStack().
void QUndoGroup::addStack | ( | QUndoStack * | stack | ) |
Adds stack to this group.
The group does not take ownership of the stack. Another way of adding a stack to a group is by specifying the group as the stack's parent QObject in QUndoStack::QUndoStack(). In this case, the stack is deleted when the group is deleted, in the usual manner of QObjects.
Definition at line 135 of file qundogroup.cpp.
bool QUndoGroup::canRedo | ( | ) | const |
Returns the value of the active stack's QUndoStack::canRedo().
If none of the stacks are active, or if the group is empty, this function returns false.
Definition at line 318 of file qundogroup.cpp.
Referenced by createRedoAction().
|
signal |
This signal is emitted whenever the active stack emits QUndoStack::canRedoChanged() or the active stack changes.
canRedo is the new state, or false if the active stack is 0.
Referenced by createRedoAction(), and setActiveStack().
bool QUndoGroup::canUndo | ( | ) | const |
Returns the value of the active stack's QUndoStack::canUndo().
If none of the stacks are active, or if the group is empty, this function returns false.
Definition at line 303 of file qundogroup.cpp.
Referenced by createUndoAction().
|
signal |
This signal is emitted whenever the active stack emits QUndoStack::canUndoChanged() or the active stack changes.
canUndo is the new state, or false if the active stack is 0.
Referenced by createUndoAction(), and setActiveStack().
|
signal |
This signal is emitted whenever the active stack emits QUndoStack::cleanChanged() or the active stack changes.
clean is the new state, or true if the active stack is 0.
Referenced by setActiveStack().
QAction * QUndoGroup::createRedoAction | ( | QObject * | parent, |
const QString & | prefix = QString() |
||
) | const |
Creates an redo QAction object with parent parent.
Triggering this action will cause a call to QUndoStack::redo() on the active stack. The text of this action will always be the text of the command which will be redone in the next call to redo(), prefixed by prefix. If there is no command available for redo, if the group is empty or if none of the stacks are active, this action will be disabled.
If prefix is empty, the default template "Redo %1" is used instead of prefix. Before Qt 4.8, the prefix "Redo" was used by default.
Definition at line 417 of file qundogroup.cpp.
QAction * QUndoGroup::createUndoAction | ( | QObject * | parent, |
const QString & | prefix = QString() |
||
) | const |
Creates an undo QAction object with parent parent.
Triggering this action will cause a call to QUndoStack::undo() on the active stack. The text of this action will always be the text of the command which will be undone in the next call to undo(), prefixed by prefix. If there is no command available for undo, if the group is empty or if none of the stacks are active, this action will be disabled.
If prefix is empty, the default template "Undo %1" is used instead of prefix. Before Qt 4.8, the prefix "Undo" was used by default.
Definition at line 386 of file qundogroup.cpp.
|
signal |
This signal is emitted whenever the active stack emits QUndoStack::indexChanged() or the active stack changes.
idx is the new current index, or 0 if the active stack is 0.
Referenced by setActiveStack().
bool QUndoGroup::isClean | ( | ) | const |
Returns the value of the active stack's QUndoStack::isClean().
If none of the stacks are active, or if the group is empty, this function returns true.
Definition at line 363 of file qundogroup.cpp.
|
slot |
Calls QUndoStack::redo() on the active stack.
If none of the stacks are active, or if the group is empty, this function does nothing.
Definition at line 287 of file qundogroup.cpp.
Referenced by createRedoAction().
QString QUndoGroup::redoText | ( | ) | const |
Returns the value of the active stack's QUndoStack::redoText().
If none of the stacks are active, or if the group is empty, this function returns an empty string.
Definition at line 348 of file qundogroup.cpp.
Referenced by createRedoAction().
|
signal |
This signal is emitted whenever the active stack emits QUndoStack::redoTextChanged() or the active stack changes.
redoText is the new state, or an empty string if the active stack is 0.
Referenced by createRedoAction(), and setActiveStack().
void QUndoGroup::removeStack | ( | QUndoStack * | stack | ) |
Removes stack from this group.
If the stack was the active stack in the group, the active stack becomes 0.
Definition at line 155 of file qundogroup.cpp.
|
slot |
Sets the active stack of this group to stack.
If the stack is not a member of this group, this function does nothing.
Synonymous with calling QUndoStack::setActive() on stack.
The actions returned by createUndoAction() and createRedoAction() will now behave in the same way as those returned by stack's QUndoStack::createUndoAction() and QUndoStack::createRedoAction().
Definition at line 192 of file qundogroup.cpp.
Referenced by removeStack().
QList< QUndoStack * > QUndoGroup::stacks | ( | ) | const |
Returns a list of stacks in this group.
Definition at line 172 of file qundogroup.cpp.
|
slot |
Calls QUndoStack::undo() on the active stack.
If none of the stacks are active, or if the group is empty, this function does nothing.
Definition at line 270 of file qundogroup.cpp.
Referenced by createUndoAction().
QString QUndoGroup::undoText | ( | ) | const |
Returns the value of the active stack's QUndoStack::undoText().
If none of the stacks are active, or if the group is empty, this function returns an empty string.
Definition at line 333 of file qundogroup.cpp.
Referenced by createUndoAction().
|
signal |
This signal is emitted whenever the active stack emits QUndoStack::undoTextChanged() or the active stack changes.
undoText is the new state, or an empty string if the active stack is 0.
Referenced by createUndoAction(), and setActiveStack().