|
Krita Source Code Documentation
|
The KUndo2Group class is a group of KUndo2QStack objects. More...
#include <kundo2group.h>
Inheritance diagram for KUndo2Group:Public Slots | |
| void | redo () |
| void | setActiveStack (KUndo2QStack *stack) |
| void | undo () |
Signals | |
| void | activeStackChanged (KUndo2QStack *stack) |
| void | canRedoChanged (bool canRedo) |
| void | canUndoChanged (bool canUndo) |
| void | cleanChanged (bool clean) |
| void | indexChanged (int idx) |
| void | redoTextChanged (const QString &redoActionText) |
| void | undoTextChanged (const QString &undoActionText) |
Public Member Functions | |
| KUndo2QStack * | activeStack () const |
| void | addStack (KUndo2QStack *stack) |
| bool | canRedo () const |
| bool | canUndo () const |
| QAction * | createRedoAction (QObject *parent) const |
| QAction * | createUndoAction (QObject *parent) const |
| bool | isClean () const |
| KUndo2Group (QObject *parent=0) | |
| QString | redoText () const |
| void | removeStack (KUndo2QStack *stack) |
| QList< KUndo2QStack * > | stacks () const |
| QString | undoText () const |
| ~KUndo2Group () override | |
Private Attributes | |
| KUndo2QStack * | m_active |
| QList< KUndo2QStack * > | m_stack_list |
The KUndo2Group class is a group of KUndo2QStack 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.
KUndo2Group is a group of KUndo2QStack objects, one of which may be active. It has an undo() and redo() slot, which calls KUndo2QStack::undo() and KUndo2QStack::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 KUndo2QStack::createUndoAction() and KUndo2QStack::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 KUndo2QStack::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 KUndo2Group is also useful in conjunction with KUndo2View. If a KUndo2View is set to watch a group using KUndo2View::setGroup(), it will update itself to display the active stack.
Definition at line 56 of file kundo2group.h.
|
explicit |
Creates an empty KUndo2Group object with parent parent.
Definition at line 93 of file kundo2group.cpp.
|
override |
Destroys the KUndo2Group.
Definition at line 101 of file kundo2group.cpp.
References m_stack_list.
| KUndo2QStack * KUndo2Group::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 235 of file kundo2group.cpp.
References m_active.
|
signal |
This signal is emitted whenever the active stack of the group changes. This can happen when setActiveStack() or KUndo2QStack::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.
| void KUndo2Group::addStack | ( | KUndo2QStack * | 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 KUndo2QStack::KUndo2QStack(). In this case, the stack is deleted when the group is deleted, in the usual manner of QObjects.
Definition at line 121 of file kundo2group.cpp.
References KUndo2QStack::m_group, and m_stack_list.
| bool KUndo2Group::canRedo | ( | ) | const |
Returns the value of the active stack's KUndo2QStack::canRedo().
If none of the stacks are active, or if the group is empty, this function returns false.
Definition at line 294 of file kundo2group.cpp.
References KUndo2QStack::canRedo(), and m_active.
|
signal |
This signal is emitted whenever the active stack emits KUndo2QStack::canRedoChanged() or the active stack changes.
canRedo is the new state, or false if the active stack is 0.
| bool KUndo2Group::canUndo | ( | ) | const |
Returns the value of the active stack's KUndo2QStack::canUndo().
If none of the stacks are active, or if the group is empty, this function returns false.
Definition at line 280 of file kundo2group.cpp.
References KUndo2QStack::canUndo(), and m_active.
|
signal |
This signal is emitted whenever the active stack emits KUndo2QStack::canUndoChanged() or the active stack changes.
canUndo is the new state, or false if the active stack is 0.
|
signal |
This signal is emitted whenever the active stack emits KUndo2QStack::cleanChanged() or the active stack changes.
clean is the new state, or true if the active stack is 0.
| QAction * KUndo2Group::createRedoAction | ( | QObject * | parent | ) | const |
Creates an redo QAction object with parent parent.
Triggering this action will cause a call to KUndo2QStack::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 prefix "Undo" is used.
Definition at line 384 of file kundo2group.cpp.
References canRedo(), canRedoChanged(), connect(), redo(), redoText(), redoTextChanged(), and KUndo2Action::setPrefixedText().
| QAction * KUndo2Group::createUndoAction | ( | QObject * | parent | ) | const |
Creates an undo QAction object with parent parent.
Triggering this action will cause a call to KUndo2QStack::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 prefix "Undo" is used.
Definition at line 357 of file kundo2group.cpp.
References canUndo(), canUndoChanged(), connect(), KUndo2Action::setPrefixedText(), undo(), undoText(), and undoTextChanged().
|
signal |
This signal is emitted whenever the active stack emits KUndo2QStack::indexChanged() or the active stack changes.
idx is the new current index, or 0 if the active stack is 0.
| bool KUndo2Group::isClean | ( | ) | const |
Returns the value of the active stack's KUndo2QStack::isClean().
If none of the stacks are active, or if the group is empty, this function returns true.
Definition at line 336 of file kundo2group.cpp.
References KUndo2QStack::isClean(), and m_active.
|
slot |
Calls KUndo2QStack::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 265 of file kundo2group.cpp.
References m_active, and KUndo2QStack::redo().
| QString KUndo2Group::redoText | ( | ) | const |
Returns the value of the active stack's KUndo2QStack::redoActionText().
If none of the stacks are active, or if the group is empty, this function returns an empty string.
Definition at line 322 of file kundo2group.cpp.
References m_active, and KUndo2QStack::redoText().
|
signal |
This signal is emitted whenever the active stack emits KUndo2QStack::redoTextChanged() or the active stack changes.
redoText is the new state, or an empty string if the active stack is 0.
| void KUndo2Group::removeStack | ( | KUndo2QStack * | stack | ) |
Removes stack from this group. If the stack was the active stack in the group, the active stack becomes 0.
Definition at line 139 of file kundo2group.cpp.
References m_active, KUndo2QStack::m_group, m_stack_list, and setActiveStack().
|
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 KUndo2QStack::setActive() on stack.
The actions returned by createUndoAction() and createRedoAction() will now behave in the same way as those returned by stack's KUndo2QStack::createUndoAction() and KUndo2QStack::createRedoAction().
Definition at line 173 of file kundo2group.cpp.
References activeStackChanged(), KUndo2QStack::canRedo(), canRedoChanged(), KUndo2QStack::canUndo(), canUndoChanged(), cleanChanged(), connect(), KUndo2QStack::index(), indexChanged(), KUndo2QStack::isClean(), m_active, KUndo2QStack::redoText(), redoTextChanged(), KUndo2QStack::undoText(), and undoTextChanged().
| QList< KUndo2QStack * > KUndo2Group::stacks | ( | ) | const |
Returns a list of stacks in this group.
Definition at line 154 of file kundo2group.cpp.
References m_stack_list.
|
slot |
Calls KUndo2QStack::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 249 of file kundo2group.cpp.
References m_active, and KUndo2QStack::undo().
| QString KUndo2Group::undoText | ( | ) | const |
Returns the value of the active stack's KUndo2QStack::undoActionText().
If none of the stacks are active, or if the group is empty, this function returns an empty string.
Definition at line 308 of file kundo2group.cpp.
References m_active, and KUndo2QStack::undoText().
|
signal |
This signal is emitted whenever the active stack emits KUndo2QStack::undoTextChanged() or the active stack changes.
undoText is the new state, or an empty string if the active stack is 0.
|
private |
Definition at line 96 of file kundo2group.h.
|
private |
Definition at line 97 of file kundo2group.h.