Qt 4.8
Public Slots | Signals | Public Functions | List of all members
QUndoGroup Class Reference

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

#include <qundogroup.h>

Inheritance diagram for QUndoGroup:
QObject

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

QUndoStackactiveStack () 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...
 
QActioncreateRedoAction (QObject *parent, const QString &prefix=QString()) const
 Creates an redo QAction object with parent parent. More...
 
QActioncreateUndoAction (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 QObjectListchildren () 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< QByteArraydynamicPropertyNames () 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 >
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 QMetaObjectmetaObject () 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
 
QObjectparent () 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...
 
QThreadthread () const
 Returns the thread in which the object lives. More...
 
QObjectUserDatauserData (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...
 
QObjectsender () 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< QObjectDatad_ptr
 
- Static Protected Variables inherited from QObject
static const QMetaObject staticQtMetaObject
 

Detailed Description

The QUndoGroup class is a group of QUndoStack objects.

Since
4.2

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.

Constructors and Destructors

◆ QUndoGroup()

QUndoGroup::QUndoGroup ( QObject parent = 0)
explicit

Creates an empty QUndoGroup object with parent parent.

See also
addStack()

Definition at line 106 of file qundogroup.cpp.

107  : QObject(*new QUndoGroupPrivate(), parent)
108 {
109 }
Q_INVOKABLE QObject(QObject *parent=0)
Constructs an object with parent object parent.
Definition: qobject.cpp:753

◆ ~QUndoGroup()

QUndoGroup::~QUndoGroup ( )

Destroys the QUndoGroup.

Definition at line 114 of file qundogroup.cpp.

115 {
116  // Ensure all QUndoStacks no longer refer to this group.
117  Q_D(QUndoGroup);
118  QList<QUndoStack *>::iterator it = d->stack_list.begin();
119  QList<QUndoStack *>::iterator end = d->stack_list.end();
120  while (it != end) {
121  (*it)->d_func()->group = 0;
122  ++it;
123  }
124 }
double d
Definition: qnumeric_p.h:62
#define it(className, varName)
#define Q_D(Class)
Definition: qglobal.h:2482
The QUndoGroup class is a group of QUndoStack objects.
Definition: qundogroup.h:60
The QList::iterator class provides an STL-style non-const iterator for QList and QQueue.
Definition: qlist.h:181
static const KeyPair *const end

Functions

◆ activeStack()

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.

See also
setActiveStack() QUndoStack::setActive()

Definition at line 255 of file qundogroup.cpp.

256 {
257  Q_D(const QUndoGroup);
258  return d->active;
259 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QUndoGroup class is a group of QUndoStack objects.
Definition: qundogroup.h:60

◆ activeStackChanged

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. stack is the new active stack. If no stack is active, stack is 0.

See also
setActiveStack() QUndoStack::setActive()

Referenced by setActiveStack().

◆ addStack()

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()

Definition at line 135 of file qundogroup.cpp.

136 {
137  Q_D(QUndoGroup);
138 
139  if (d->stack_list.contains(stack))
140  return;
141  d->stack_list.append(stack);
142 
143  if (QUndoGroup *other = stack->d_func()->group)
144  other->removeStack(stack);
145  stack->d_func()->group = this;
146 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QUndoGroup class is a group of QUndoStack objects.
Definition: qundogroup.h:60

◆ canRedo()

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()

Definition at line 318 of file qundogroup.cpp.

Referenced by createRedoAction().

319 {
320  Q_D(const QUndoGroup);
321  return d->active != 0 && d->active->canRedo();
322 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QUndoGroup class is a group of QUndoStack objects.
Definition: qundogroup.h:60

◆ canRedoChanged

void QUndoGroup::canRedoChanged ( bool  canRedo)
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.

See also
QUndoStack::canRedoChanged() setActiveStack()

Referenced by createRedoAction(), and setActiveStack().

◆ canUndo()

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.

See also
canRedo() setActiveStack()

Definition at line 303 of file qundogroup.cpp.

Referenced by createUndoAction().

304 {
305  Q_D(const QUndoGroup);
306  return d->active != 0 && d->active->canUndo();
307 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QUndoGroup class is a group of QUndoStack objects.
Definition: qundogroup.h:60

◆ canUndoChanged

void QUndoGroup::canUndoChanged ( bool  canUndo)
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.

See also
QUndoStack::canUndoChanged() setActiveStack()

Referenced by createUndoAction(), and setActiveStack().

◆ cleanChanged

void QUndoGroup::cleanChanged ( bool  clean)
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.

See also
QUndoStack::cleanChanged() setActiveStack()

Referenced by setActiveStack().

◆ createRedoAction()

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.

See also
createUndoAction() canRedo() QUndoCommand::text()

Definition at line 417 of file qundogroup.cpp.

418 {
419  QUndoAction *result = new QUndoAction(prefix, parent);
420  if (prefix.isEmpty())
421  result->setTextFormat(tr("Redo %1"), tr("Redo", "Default text for redo action"));
422 
423  result->setEnabled(canRedo());
424  result->setPrefixedText(redoText());
425  connect(this, SIGNAL(canRedoChanged(bool)),
426  result, SLOT(setEnabled(bool)));
428  result, SLOT(setPrefixedText(QString)));
429  connect(result, SIGNAL(triggered()), this, SLOT(redo()));
430  return result;
431 }
#define SLOT(a)
Definition: qobjectdefs.h:226
static QString tr(const char *sourceText, const char *comment=0, int n=-1)
The QString class provides a Unicode character string.
Definition: qstring.h:83
void setEnabled(bool)
Definition: qaction.cpp:1192
void setTextFormat(const QString &textFormat, const QString &defaultText)
Definition: qundostack.cpp:435
#define SIGNAL(a)
Definition: qobjectdefs.h:227
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 rece...
Definition: qobject.cpp:2580
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
QString redoText() const
Returns the value of the active stack&#39;s QUndoStack::redoText().
Definition: qundogroup.cpp:348
void redoTextChanged(const QString &redoText)
This signal is emitted whenever the active stack emits QUndoStack::redoTextChanged() or the active st...
void canRedoChanged(bool canRedo)
This signal is emitted whenever the active stack emits QUndoStack::canRedoChanged() or the active sta...
void setPrefixedText(const QString &text)
Definition: qundostack.cpp:419
void redo()
Calls QUndoStack::redo() on the active stack.
Definition: qundogroup.cpp:287
bool canRedo() const
Returns the value of the active stack&#39;s QUndoStack::canRedo().
Definition: qundogroup.cpp:318

◆ createUndoAction()

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.

See also
createRedoAction() canUndo() QUndoCommand::text()

Definition at line 386 of file qundogroup.cpp.

387 {
388  QUndoAction *result = new QUndoAction(prefix, parent);
389  if (prefix.isEmpty())
390  result->setTextFormat(tr("Undo %1"), tr("Undo", "Default text for undo action"));
391 
392  result->setEnabled(canUndo());
393  result->setPrefixedText(undoText());
394  connect(this, SIGNAL(canUndoChanged(bool)),
395  result, SLOT(setEnabled(bool)));
397  result, SLOT(setPrefixedText(QString)));
398  connect(result, SIGNAL(triggered()), this, SLOT(undo()));
399  return result;
400 }
void undo()
Calls QUndoStack::undo() on the active stack.
Definition: qundogroup.cpp:270
#define SLOT(a)
Definition: qobjectdefs.h:226
void canUndoChanged(bool canUndo)
This signal is emitted whenever the active stack emits QUndoStack::canUndoChanged() or the active sta...
static QString tr(const char *sourceText, const char *comment=0, int n=-1)
The QString class provides a Unicode character string.
Definition: qstring.h:83
void setEnabled(bool)
Definition: qaction.cpp:1192
void setTextFormat(const QString &textFormat, const QString &defaultText)
Definition: qundostack.cpp:435
#define SIGNAL(a)
Definition: qobjectdefs.h:227
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 rece...
Definition: qobject.cpp:2580
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
void undoTextChanged(const QString &undoText)
This signal is emitted whenever the active stack emits QUndoStack::undoTextChanged() or the active st...
bool canUndo() const
Returns the value of the active stack&#39;s QUndoStack::canUndo().
Definition: qundogroup.cpp:303
void setPrefixedText(const QString &text)
Definition: qundostack.cpp:419
QString undoText() const
Returns the value of the active stack&#39;s QUndoStack::undoText().
Definition: qundogroup.cpp:333

◆ indexChanged

void QUndoGroup::indexChanged ( int  idx)
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.

See also
QUndoStack::indexChanged() setActiveStack()

Referenced by setActiveStack().

◆ isClean()

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.

See also
setActiveStack()

Definition at line 363 of file qundogroup.cpp.

364 {
365  Q_D(const QUndoGroup);
366  return d->active == 0 || d->active->isClean();
367 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QUndoGroup class is a group of QUndoStack objects.
Definition: qundogroup.h:60

◆ redo

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()

Definition at line 287 of file qundogroup.cpp.

Referenced by createRedoAction().

288 {
289  Q_D(QUndoGroup);
290  if (d->active != 0)
291  d->active->redo();
292 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QUndoGroup class is a group of QUndoStack objects.
Definition: qundogroup.h:60

◆ redoText()

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()

Definition at line 348 of file qundogroup.cpp.

Referenced by createRedoAction().

349 {
350  Q_D(const QUndoGroup);
351  return d->active == 0 ? QString() : d->active->redoText();
352 }
double d
Definition: qnumeric_p.h:62
The QString class provides a Unicode character string.
Definition: qstring.h:83
#define Q_D(Class)
Definition: qglobal.h:2482
The QUndoGroup class is a group of QUndoStack objects.
Definition: qundogroup.h:60
QString redoText() const
Returns the value of the active stack&#39;s QUndoStack::redoText().
Definition: qundogroup.cpp:348

◆ redoTextChanged

void QUndoGroup::redoTextChanged ( const QString redoText)
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.

See also
QUndoStack::redoTextChanged() setActiveStack()

Referenced by createRedoAction(), and setActiveStack().

◆ removeStack()

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.

See also
addStack() stacks() QUndoStack::~QUndoStack()

Definition at line 155 of file qundogroup.cpp.

156 {
157  Q_D(QUndoGroup);
158 
159  if (d->stack_list.removeAll(stack) == 0)
160  return;
161  if (stack == d->active)
162  setActiveStack(0);
163  stack->d_func()->group = 0;
164 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QUndoGroup class is a group of QUndoStack objects.
Definition: qundogroup.h:60
void setActiveStack(QUndoStack *stack)
Sets the active stack of this group to stack.
Definition: qundogroup.cpp:192

◆ setActiveStack

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()

Definition at line 192 of file qundogroup.cpp.

Referenced by removeStack().

193 {
194  Q_D(QUndoGroup);
195  if (d->active == stack)
196  return;
197 
198  if (d->active != 0) {
199  disconnect(d->active, SIGNAL(canUndoChanged(bool)),
200  this, SIGNAL(canUndoChanged(bool)));
202  this, SIGNAL(undoTextChanged(QString)));
203  disconnect(d->active, SIGNAL(canRedoChanged(bool)),
204  this, SIGNAL(canRedoChanged(bool)));
206  this, SIGNAL(redoTextChanged(QString)));
207  disconnect(d->active, SIGNAL(indexChanged(int)),
208  this, SIGNAL(indexChanged(int)));
209  disconnect(d->active, SIGNAL(cleanChanged(bool)),
210  this, SIGNAL(cleanChanged(bool)));
211  }
212 
213  d->active = stack;
214 
215  if (d->active == 0) {
216  emit canUndoChanged(false);
218  emit canRedoChanged(false);
220  emit cleanChanged(true);
221  emit indexChanged(0);
222  } else {
223  connect(d->active, SIGNAL(canUndoChanged(bool)),
224  this, SIGNAL(canUndoChanged(bool)));
226  this, SIGNAL(undoTextChanged(QString)));
227  connect(d->active, SIGNAL(canRedoChanged(bool)),
228  this, SIGNAL(canRedoChanged(bool)));
230  this, SIGNAL(redoTextChanged(QString)));
231  connect(d->active, SIGNAL(indexChanged(int)),
232  this, SIGNAL(indexChanged(int)));
233  connect(d->active, SIGNAL(cleanChanged(bool)),
234  this, SIGNAL(cleanChanged(bool)));
235  emit canUndoChanged(d->active->canUndo());
236  emit undoTextChanged(d->active->undoText());
237  emit canRedoChanged(d->active->canRedo());
238  emit redoTextChanged(d->active->redoText());
239  emit cleanChanged(d->active->isClean());
240  emit indexChanged(d->active->index());
241  }
242 
243  emit activeStackChanged(d->active);
244 }
double d
Definition: qnumeric_p.h:62
void canUndoChanged(bool canUndo)
This signal is emitted whenever the active stack emits QUndoStack::canUndoChanged() or the active sta...
void indexChanged(int idx)
This signal is emitted whenever the active stack emits QUndoStack::indexChanged() or the active stack...
The QString class provides a Unicode character string.
Definition: qstring.h:83
#define Q_D(Class)
Definition: qglobal.h:2482
The QUndoGroup class is a group of QUndoStack objects.
Definition: qundogroup.h:60
#define SIGNAL(a)
Definition: qobjectdefs.h:227
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 rece...
Definition: qobject.cpp:2580
#define emit
Definition: qobjectdefs.h:76
void activeStackChanged(QUndoStack *stack)
This signal is emitted whenever the active stack of the group changes.
void cleanChanged(bool clean)
This signal is emitted whenever the active stack emits QUndoStack::cleanChanged() or the active stack...
void redoTextChanged(const QString &redoText)
This signal is emitted whenever the active stack emits QUndoStack::redoTextChanged() or the active st...
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.
Definition: qobject.cpp:2895
void undoTextChanged(const QString &undoText)
This signal is emitted whenever the active stack emits QUndoStack::undoTextChanged() or the active st...
void canRedoChanged(bool canRedo)
This signal is emitted whenever the active stack emits QUndoStack::canRedoChanged() or the active sta...

◆ stacks()

QList< QUndoStack * > QUndoGroup::stacks ( ) const

Returns a list of stacks in this group.

See also
addStack() removeStack()

Definition at line 172 of file qundogroup.cpp.

173 {
174  Q_D(const QUndoGroup);
175  return d->stack_list;
176 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QUndoGroup class is a group of QUndoStack objects.
Definition: qundogroup.h:60

◆ undo

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 function does nothing.

See also
redo() canUndo() setActiveStack()

Definition at line 270 of file qundogroup.cpp.

Referenced by createUndoAction().

271 {
272  Q_D(QUndoGroup);
273  if (d->active != 0)
274  d->active->undo();
275 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QUndoGroup class is a group of QUndoStack objects.
Definition: qundogroup.h:60

◆ undoText()

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.

See also
redoText() setActiveStack()

Definition at line 333 of file qundogroup.cpp.

Referenced by createUndoAction().

334 {
335  Q_D(const QUndoGroup);
336  return d->active == 0 ? QString() : d->active->undoText();
337 }
double d
Definition: qnumeric_p.h:62
The QString class provides a Unicode character string.
Definition: qstring.h:83
#define Q_D(Class)
Definition: qglobal.h:2482
The QUndoGroup class is a group of QUndoStack objects.
Definition: qundogroup.h:60
QString undoText() const
Returns the value of the active stack&#39;s QUndoStack::undoText().
Definition: qundogroup.cpp:333

◆ undoTextChanged

void QUndoGroup::undoTextChanged ( const QString undoText)
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.

See also
QUndoStack::undoTextChanged() setActiveStack()

Referenced by createUndoAction(), and setActiveStack().


The documentation for this class was generated from the following files: