CopperSpice API  1.9.1
QUndoGroup Class Reference

The QUndoGroup class is a group of QUndoStack objects. More...

Inheritance diagram for QUndoGroup:
QObject

Public Signals

void activeStackChanged (QUndoStack *stack)
 
void canRedoChanged (bool canRedo)
 
void canUndoChanged (bool canUndo)
 
void cleanChanged (bool clean)
 
void indexChanged (int idx)
 
void redoTextChanged (const QString &redoText)
 
void undoTextChanged (const QString &undoText)
 
- Public Signals inherited from QObject
void destroyed (QObject *obj=nullptr)
 
void objectNameChanged (const QString &objectName)
 

Public Slots

void redo ()
 
void setActiveStack (QUndoStack *stack)
 
void undo ()
 
- Public Slots inherited from QObject
void deleteLater ()
 

Public Methods

 QUndoGroup (QObject *parent=nullptr)
 
 ~QUndoGroup ()
 
QUndoStackactiveStack () const
 
void addStack (QUndoStack *stack)
 
bool canRedo () const
 
bool canUndo () const
 
QActioncreateRedoAction (QObject *parent, const QString &prefix=QString ()) const
 
QActioncreateUndoAction (QObject *parent, const QString &prefix=QString ()) const
 
bool isClean () const
 
QString redoText () const
 
void removeStack (QUndoStack *stack)
 
QList< QUndoStack * > stacks () const
 
QString undoText () const
 
- Public Methods inherited from QObject
 QObject (QObject *parent=nullptr)
 
 ~QObject ()
 
bool blockSignals (bool block)
 
const QList< QObject * > & children () const
 
bool connect (const QObject *sender, const QString &signalMethod, const QString &location, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection)
 
bool connect (const QObject *sender, const QString &signalMethod, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection)
 
bool disconnect (const QObject *receiver, const QString &slotMethod=QString ()) const
 
bool disconnect (const QString &signalMethod, const QString &location, const QObject *receiver=nullptr, const QString &slotMethod=QString ()) const
 
bool disconnect (const QString &signalMethod=QString (), const QObject *receiver=nullptr, const QString &slotMethod=QString ()) const
 
void dumpObjectInfo ()
 
void dumpObjectTree ()
 
QList< QStringdynamicPropertyNames () const
 
virtual bool event (QEvent *event)
 
virtual bool eventFilter (QObject *watched, QEvent *event)
 
template<typename T >
findChild (const QString &childName=QString ()) const
 
template<class T >
QList< T > findChildren (const QRegularExpression &regExp, Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
 
template<class T >
QList< T > findChildren (const QString &childName=QString (), Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
 
bool inherits (const QString &className) const
 
void installEventFilter (QObject *filterObj)
 
bool isWidgetType () const
 
bool isWindowType () const
 
void killTimer (int id)
 
const QMetaObjectmetaObject () const
 
void moveToThread (QThread *targetThread)
 
QString objectName () const
 
QObject * parent () const
 
template<class T = QVariant>
property (const QString &name) const
 
void removeEventFilter (QObject *obj)
 
void setObjectName (const QString &name)
 
void setParent (QObject *parent)
 
bool setProperty (const QString &name, const QVariant &value)
 
bool signalsBlocked () const
 
int startTimer (int interval, Qt::TimerType timerType=Qt::CoarseTimer)
 
QThreadthread () const
 

Additional Inherited Members

- Static Public Methods inherited from QObject
static bool connect (const QObject *sender, const QMetaMethod &signalMethod, const QObject *receiver, const QMetaMethod &slotMethod, Qt::ConnectionType type=Qt::AutoConnection)
 
static bool connect (const QObject *sender, const QString &signalMethod, const QObject *receiver, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection, const QString &location=QString ())
 
static bool connect (const QObject *sender, const QString &signalMethod, const QString &location, const QObject *receiver, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection)
 
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class SlotClass , class... SlotArgs, class SlotReturn >
static bool connect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, SlotReturn (SlotClass::*slotMethod)(SlotArgs...), Qt::ConnectionType type=Qt::AutoConnection)
 
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class T >
static bool connect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, T slotLambda, Qt::ConnectionType type=Qt::AutoConnection)
 
static bool disconnect (const QObject *sender, const QMetaMethod &signalMethod, const QObject *receiver, const QMetaMethod &slotMethod)
 
static bool disconnect (const QObject *sender, const QString &signalMethod, const QObject *receiver, const QString &slotMethod)
 
static bool disconnect (const QObject *sender, const QString &signalMethod, const QString &location, const QObject *receiver, const QString &slotMethod)
 
static bool disconnect (const QObject *sender, std::nullptr_t, const QObject *receiver, std::nullptr_t)
 
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class SlotClass , class... SlotArgs, class SlotReturn >
static bool disconnect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, SlotReturn (SlotClass::*slotMethod)(SlotArgs...))
 
template<class Sender , class SignalClass , class... SignalArgs, class Receiver >
static bool disconnect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, std::nullptr_t slotMethod=nullptr)
 
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class T >
static bool disconnect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, T slotMethod)
 
static QMetaObjectstaticMetaObject ()
 
static QString tr (const char *text, const char *comment=nullptr, std::optional< int > numArg=std::optional< int >())
 
- Protected Methods inherited from QObject
virtual void childEvent (QChildEvent *event)
 
virtual void connectNotify (const QMetaMethod &signalMethod) const
 
virtual void customEvent (QEvent *event)
 
virtual void disconnectNotify (const QMetaMethod &signalMethod) const
 
bool isSignalConnected (const QMetaMethod &signalMethod) const
 
int receivers (const QString &signal) const
 
QObject * sender () const
 
int senderSignalIndex () const
 
virtual void timerEvent (QTimerEvent *event)
 
- Properties inherited from QObject
 objectName
 

Detailed Description

The QUndoGroup class is a group of QUndoStack objects. For an overview refer to the Undo System documentation.

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.

See also
addStack()

Constructor & Destructor Documentation

QUndoGroup::QUndoGroup ( QObject parent = nullptr)
explicit

Creates an empty QUndoGroup object with the given parent.

See also
addStack()
QUndoGroup::~QUndoGroup ( )

Destroys the QUndoGroup.

Method Documentation

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 method returns a nullptr.

See also
setActiveStack(), QUndoStack::setActive()
void QUndoGroup::activeStackChanged ( QUndoStack stack)
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. The stack is the new active stack. If no undo stack is active, stack is a nullptr.

See also
setActiveStack(), QUndoStack::setActive()
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.

See also
removeStack(), stacks(), QUndoStack::QUndoStack()
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.

See also
canUndo(), setActiveStack()
void QUndoGroup::canRedoChanged ( bool  canRedo)
signal

This signal is emitted whenever the active stack emits QUndoStack::canRedoChanged() or the active stack changes. The canRedo is the new state, or false if the active undo stack is a nullptr.

See also
QUndoStack::canRedoChanged(), 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 method returns false.

See also
canRedo(), setActiveStack()
void QUndoGroup::canUndoChanged ( bool  canUndo)
signal

This signal is emitted whenever the active stack emits QUndoStack::canUndoChanged() or the active stack changes. The canUndo is the new state or false if the active undo stack is a nullptr.

See also
QUndoStack::canUndoChanged(), setActiveStack()
void QUndoGroup::cleanChanged ( bool  clean)
signal

This signal is emitted whenever the active stack emits QUndoStack::cleanChanged() or the active stack changes. The clean is the new state, or true if the active undo stack is a nullptr.

See also
QUndoStack::cleanChanged(), setActiveStack()
QAction * QUndoGroup::createRedoAction ( QObject parent,
const QString prefix = QString() 
) const

Creates an redo QAction object with the given 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.

See also
createUndoAction(), canRedo(), QUndoCommand::text()
QAction * QUndoGroup::createUndoAction ( QObject parent,
const QString prefix = QString() 
) const

Creates an undo QAction object with the given 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.

See also
createRedoAction(), canUndo(), QUndoCommand::text()
void QUndoGroup::indexChanged ( int  idx)
signal

This signal is emitted whenever the active undo stack emits QUndoStack::indexChanged() or the active stack changes. The value for idx is the new current index or 0 if the active undo stack is a nullptr.

See also
QUndoStack::indexChanged(), 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 method returns true.

See also
setActiveStack()
void QUndoGroup::redo ( )
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.

See also
undo(), canRedo(), setActiveStack()
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.

See also
undoText(), setActiveStack()
void QUndoGroup::redoTextChanged ( const QString redoText)
signal

This signal is emitted whenever the active undo stack emits QUndoStack::redoTextChanged() or the active stack changes. The redoText is the new state or an empty string if the active stack is a nullptr.

See also
QUndoStack::redoTextChanged(), 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 a nullptr.

See also
addStack(), stacks(), QUndoStack::~QUndoStack()
void QUndoGroup::setActiveStack ( QUndoStack stack)
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().

See also
QUndoStack::setActive(), activeStack()
QList< QUndoStack * > QUndoGroup::stacks ( ) const

Returns a list of stacks in this group.

See also
addStack(), removeStack()
void QUndoGroup::undo ( )
slot

Calls QUndoStack::undo() on the active stack. If none of the stacks are active, or if the group is empty, this method does nothing.

See also
redo(), canUndo(), setActiveStack()
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 method returns an empty string.

See also
redoText(), setActiveStack()
void QUndoGroup::undoTextChanged ( const QString undoText)
signal

This signal is emitted whenever the active stack emits QUndoStack::undoTextChanged() or the active stack changes. The undoText is the new state, or an empty string if the active undo stack is a nullptr.

See also
QUndoStack::undoTextChanged(), setActiveStack()