#include <qundostack.h>
Inheritance diagram for QUndoStack:
An undo stack maintains a stack of commands that have been applied to a document.
New commands are pushed on the stack using push(). Commands can be undone and redone using undo() and redo(), or by triggering the actions returned by createUndoAction() and createRedoAction().
QUndoStack keeps track of the current command. This is the command which will be executed by the next call to redo(). The index of this command is returned by index(). The state of the edited object can be rolled forward or back using setIndex(). If the top-most command on the stack has already been redone, index() is equal to count().
QUndoStack provides support for undo and redo actions, command compression, command macros, and supports the concept of a {clean state}.
QUndoStack provides convenient undo and redo QAction objects, which can be inserted into a menu or a toolbar. When commands are undone or redone, QUndoStack updates the text properties of these actions to reflect what change they will trigger. The actions are also disabled when no command is available for undo or redo. These actions are returned by QUndoStack::createUndoAction() and QUndoStack::createRedoAction(). @section Command Compression and Macros Command compression is useful when several commands can be compressed into a single command that can be undone and redone in a single operation. For example, when a user types a character in a text editor, a new command is created. This command inserts the character into the document at the cursor position. However, it is more convenient for the user to be able to undo or redo typing of whole words, sentences, or paragraphs. Command compression allows these single-character commands to be merged into a single command which inserts or deletes sections of text. For more information, see QUndoCommand::mergeWith() and push(). A command macro is a sequence of commands, all of which are undone and redone in one go. Command macros are created by giving a command a list of child commands. Undoing or redoing the parent command will cause the child commands to be undone or redone. Command macros may be created explicitly by specifying a parent in the QUndoCommand constructor, or by using the convenience functions beginMacro() and endMacro(). Although command compression and macros appear to have the effect to the user, they often have different uses in an application. Commands that perform small changes to a document may be usefully compressed if there is no need to individually record them, and if only larger changes are relevant to the user. However, for commands that need to be recorded individually, or those that cannot be compressed, it is useful to use macros to provide a more convenient user experience while maintaining a record of each command. @section Clean State QUndoStack supports the concept of a clean state. When the document is saved to disk, the stack can be marked as clean using setClean(). Whenever the stack returns to this state through the use of undo/redo commands, it emits the signal cleanChanged(), which is also emitted when the stack leaves the clean state. This signal is usually used to enable and disable the save actions in the application, and to update the document's title to reflect that it contains unsaved changes. \sa QUndoCommand, QUndoView Definition at line 67 of file qundostack.h.
Public Slots | |
void | setClean () |
void | setIndex (int idx) |
void | undo () |
void | redo () |
void | setActive (bool active=true) |
Signals | |
void | indexChanged (int idx) |
void | cleanChanged (bool clean) |
void | canUndoChanged (bool canUndo) |
void | canRedoChanged (bool canRedo) |
void | undoTextChanged (const QString &undoText) |
void | redoTextChanged (const QString &redoText) |
Public Member Functions | |
QUndoStack (QObject *parent=0) | |
~QUndoStack () | |
void | clear () |
void | push (QUndoCommand *cmd) |
bool | canUndo () const |
bool | canRedo () const |
QString | undoText () const |
QString | redoText () const |
int | count () const |
int | index () const |
QString | text (int idx) const |
QAction * | createUndoAction (QObject *parent, const QString &prefix=QString()) const |
QAction * | createRedoAction (QObject *parent, const QString &prefix=QString()) const |
bool | isActive () const |
bool | isClean () const |
int | cleanIndex () const |
void | beginMacro (const QString &text) |
void | endMacro () |
Friends | |
class | QUndoGroup |
QUndoStack::QUndoStack | ( | QObject * | parent = 0 |
) | [explicit] |
Constructs an empty undo stack with the parent parent. The stack will initally be in the clean state. If parent is a QUndoGroup object, the stack is automatically added to the group.
Definition at line 392 of file qundostack.cpp.
References QObject::parent().
00393 : QObject(*(new QUndoStackPrivate), parent) 00394 { 00395 #ifndef QT_NO_UNDOGROUP 00396 if (QUndoGroup *group = qobject_cast<QUndoGroup*>(parent)) 00397 group->addStack(this); 00398 #endif 00399 }
Here is the call graph for this function:
QUndoStack::~QUndoStack | ( | ) |
Destroys the undo stack, deleting any commands that are on it. If the stack is in a QUndoGroup, the stack is automatically removed from the group.
Definition at line 408 of file qundostack.cpp.
00409 { 00410 #ifndef QT_NO_UNDOGROUP 00411 Q_D(QUndoStack); 00412 if (d->group != 0) 00413 d->group->removeStack(this); 00414 #endif 00415 clear(); 00416 }
Here is the call graph for this function:
void QUndoStack::clear | ( | ) |
Clears the command stack by deleting all commands on it, and returns the stack to the clean state.
Commands are not undone or redone; the state of the edited object remains unchanged.
This function is usually used when the contents of the document are abandoned.
Definition at line 431 of file qundostack.cpp.
References d, and qDeleteAll().
Referenced by ~QUndoStack().
00432 { 00433 Q_D(QUndoStack); 00434 00435 d->macro_stack.clear(); 00436 qDeleteAll(d->command_list); 00437 d->command_list.clear(); 00438 d->setIndex(0, true); 00439 }
Here is the call graph for this function:
void QUndoStack::push | ( | QUndoCommand * | cmd | ) |
Pushes cmd on the stack or merges it with the most recently executed command. In either case, executes cmd by calling its redo() function.
If cmd's id is not -1, and if the id is the same as that of the most recently executed command, QUndoStack will attempt to merge the two commands by calling QUndoCommand::mergeWith() on the most recently executed command. If QUndoCommand::mergeWith() returns true, the cmd is deleted.
In all other cases cmd is simply pushed on the stack.
If the current command index does not point to the top of the stack - ie. if commands were undone before cmd was pushed - the current command and all commands above it are deleted. Hence cmd always ends up being the top-most command on the stack.
Once a command is pushed, the stack takes ownership of it. There are no getters to return the command, since modifying it after it has been executed will almost always lead to corruption of the document's state.
Definition at line 465 of file qundostack.cpp.
References canRedo(), canRedoChanged(), canUndo(), canUndoChanged(), QUndoCommandPrivate::child_list, d, QUndoCommand::d, emit, QUndoCommand::id(), indexChanged(), QList< T >::isEmpty(), QList< T >::last(), QUndoCommand::mergeWith(), QUndoCommand::redo(), redoText(), redoTextChanged(), undoText(), and undoTextChanged().
Referenced by qdesigner_internal::SignalSlotEditor::addEmptyConnection(), qdesigner_internal::ContainerWidgetTaskMenu::addPage(), qdesigner_internal::ContainerWidgetTaskMenu::addPageAfter(), QDesignerToolBox::changeOrder(), QDesignerStackedWidget::changeOrder(), QDesignerToolBar::createAction(), QDesignerMenu::createAction(), QDesignerMenuBar::createAction(), QDesignerMenu::deleteAction(), QDesignerMenuBar::deleteMenu(), qdesigner_internal::ConnectionEdit::deleteSelected(), qdesigner_internal::BuddyEditor::deleteSelected(), qdesigner_internal::FormWindow::deleteWidgets(), qdesigner_internal::QDesignerTaskMenu::demoteFromCustomWidget(), QDesignerToolBar::dropEvent(), QDesignerMenu::dropEvent(), QDesignerMenuBar::dropEvent(), qdesigner_internal::FormWindow::dropWidgets(), qdesigner_internal::ActionEditor::editAction(), qdesigner_internal::ConnectionEdit::endConnection(), qdesigner_internal::BuddyEditor::endConnection(), qdesigner_internal::ConnectionEdit::endDrag(), QDesignerMenu::enterEditMode(), QDesignerTabWidget::eventFilter(), qdesigner_internal::TableWidgetEditor::fillTableWidgetFromContents(), qdesigner_internal::TreeWidgetEditor::fillTreeWidgetFromContents(), qdesigner_internal::FormWindow::handleArrowKeyEvent(), qdesigner_internal::FormWindow::insertWidget(), qdesigner_internal::FormWindow::layoutGrid(), qdesigner_internal::FormWindow::layoutGridContainer(), qdesigner_internal::FormWindow::layoutHorizontal(), qdesigner_internal::FormWindow::layoutHorizontalContainer(), qdesigner_internal::FormWindow::layoutHorizontalSplit(), qdesigner_internal::FormWindow::layoutVertical(), qdesigner_internal::FormWindow::layoutVerticalContainer(), qdesigner_internal::FormWindow::layoutVerticalSplit(), QDesignerMenuBar::leaveEditMode(), QDesignerMenu::leaveEditMode(), qdesigner_internal::TabOrderEditor::mousePressEvent(), qdesigner_internal::WidgetHandle::mouseReleaseEvent(), qdesigner_internal::FormWindow::paste(), qdesigner_internal::QDesignerTaskMenu::promoteToCustomWidget(), qdesigner_internal::ContainerWidgetTaskMenu::removeCurrentPage(), qdesigner_internal::FormWindowCursor::resetWidgetProperty(), qdesigner_internal::FormWindow::resizeWidget(), qdesigner_internal::SignalSlotEditor::setSignal(), qdesigner_internal::SignalSlotEditor::setSlot(), qdesigner_internal::ConnectionEdit::setSource(), qdesigner_internal::SignalSlotEditor::setSource(), qdesigner_internal::ConnectionEdit::setTarget(), qdesigner_internal::SignalSlotEditor::setTarget(), qdesigner_internal::FormWindowCursor::setWidgetProperty(), qdesigner_internal::FormWindowManager::slotActionAdjustSizeActivated(), qdesigner_internal::ActionEditor::slotDeleteAction(), QDesignerToolBar::slotInsertSeparator(), qdesigner_internal::ActionEditor::slotNewAction(), QDesignerToolBar::slotNewToolBar(), QDesignerMenuBar::slotRemoveMenuBar(), QDesignerToolBar::slotRemoveSelectedAction(), QDesignerMenu::slotRemoveSelectedAction(), QDesignerMenuBar::slotRemoveSelectedAction(), QDesignerToolBar::slotRemoveToolBar(), QDesignerMenuBar::startDrag(), QDesignerMenu::startDrag(), QDesignerToolBar::startDrag(), QDesignerMenu::swap(), QDesignerMenuBar::swap(), qdesigner_internal::ConnectionEdit::widgetRemoved(), and qdesigner_internal::BuddyEditor::widgetRemoved().
00466 { 00467 Q_D(QUndoStack); 00468 cmd->redo(); 00469 00470 bool macro = !d->macro_stack.isEmpty(); 00471 00472 QUndoCommand *cur = 0; 00473 if (macro) { 00474 QUndoCommand *macro_cmd = d->macro_stack.last(); 00475 if (!macro_cmd->d->child_list.isEmpty()) 00476 cur = macro_cmd->d->child_list.last(); 00477 } else { 00478 if (d->index > 0) 00479 cur = d->command_list.at(d->index - 1); 00480 while (d->index < d->command_list.size()) 00481 delete d->command_list.takeLast(); 00482 if (d->clean_index > d->index) 00483 d->clean_index = -1; // we've deleted the clean state 00484 } 00485 00486 bool try_merge = cur != 0 00487 && cur->id() != -1 00488 && cur->id() == cmd->id() 00489 && (macro || d->index != d->clean_index); 00490 00491 if (try_merge && cur->mergeWith(cmd)) { 00492 delete cmd; 00493 if (!macro) { 00494 emit indexChanged(d->index); 00495 emit canUndoChanged(canUndo()); 00496 emit undoTextChanged(undoText()); 00497 emit canRedoChanged(canRedo()); 00498 emit redoTextChanged(redoText()); 00499 } 00500 } else { 00501 if (macro) { 00502 d->macro_stack.last()->d->child_list.append(cmd); 00503 } else { 00504 d->command_list.append(cmd); 00505 d->setIndex(d->index + 1, false); 00506 } 00507 } 00508 }
Here is the call graph for this function:
bool QUndoStack::canUndo | ( | ) | const |
Returns true if there is a command available for undo; otherwise returns false.
This function returns false if the stack is empty, or if the bottom command on the stack has already been undone.
Synonymous with index() == 0.
Definition at line 682 of file qundostack.cpp.
References d.
Referenced by createUndoAction(), and push().
00683 { 00684 Q_D(const QUndoStack); 00685 if (!d->macro_stack.isEmpty()) 00686 return false; 00687 return d->index > 0; 00688 }
bool QUndoStack::canRedo | ( | ) | const |
Returns true if there is a command available for redo; otherwise returns false.
This function returns false if the stack is empty or if the top command on the stack has already been redone.
Synonymous with index() == count().
Definition at line 701 of file qundostack.cpp.
References d.
Referenced by createRedoAction(), and push().
00702 { 00703 Q_D(const QUndoStack); 00704 if (!d->macro_stack.isEmpty()) 00705 return false; 00706 return d->index < d->command_list.size(); 00707 }
QString QUndoStack::undoText | ( | ) | const |
Returns the text of the command which will be undone in the next call to undo().
Definition at line 715 of file qundostack.cpp.
References d.
Referenced by createUndoAction(), and push().
00716 { 00717 Q_D(const QUndoStack); 00718 if (!d->macro_stack.isEmpty()) 00719 return QString(); 00720 if (d->index > 0) 00721 return d->command_list.at(d->index - 1)->text(); 00722 return QString(); 00723 }
QString QUndoStack::redoText | ( | ) | const |
Returns the text of the command which will be redone in the next call to redo().
Definition at line 731 of file qundostack.cpp.
References d.
Referenced by createRedoAction(), and push().
00732 { 00733 Q_D(const QUndoStack); 00734 if (!d->macro_stack.isEmpty()) 00735 return QString(); 00736 if (d->index < d->command_list.size()) 00737 return d->command_list.at(d->index)->text(); 00738 return QString(); 00739 }
int QUndoStack::count | ( | ) | const |
Returns the number of commands on the stack. Macro commands are counted as one command.
Definition at line 621 of file qundostack.cpp.
References d.
Referenced by QUndoModel::data(), QUndoModel::index(), and QUndoModel::rowCount().
00622 { 00623 Q_D(const QUndoStack); 00624 return d->command_list.size(); 00625 }
int QUndoStack::index | ( | ) | const |
Returns the index of the current command. This is the command that will be executed on the next call to redo(). It is not always the top-most command on the stack, since a number of commands may have been undone.
Definition at line 635 of file qundostack.cpp.
References d.
Referenced by qdesigner_internal::FormWindow::handleArrowKeyEvent(), QUndoModel::selectedIndex(), qdesigner_internal::FormWindow::setDirty(), and qdesigner_internal::FormWindow::updateDirty().
00636 { 00637 Q_D(const QUndoStack); 00638 return d->index; 00639 }
QString QUndoStack::text | ( | int | idx | ) | const |
Returns the text of the command at index idx.
Definition at line 896 of file qundostack.cpp.
References d.
Referenced by beginMacro(), and QUndoModel::data().
00897 { 00898 Q_D(const QUndoStack); 00899 00900 if (idx < 0 || idx >= d->command_list.size()) 00901 return QString(); 00902 return d->command_list.at(idx)->text(); 00903 }
QAction * QUndoStack::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 undo(). The text of this action is the text of the command which will be undone in the next call to undo(), prefixed by the specified prefix. If there is no command available for undo, this action will be disabled.
If prefix is empty, the default prefix "Undo" is used.
Definition at line 756 of file qundostack.cpp.
References canUndo(), canUndoChanged(), QObject::connect(), QString::isEmpty(), QObject::parent(), QAction::setEnabled(), QUndoAction::setPrefixedText(), SIGNAL, SLOT, undo(), undoText(), and undoTextChanged().
00757 { 00758 QString pref = prefix.isEmpty() ? tr("Undo") : prefix; 00759 QUndoAction *result = new QUndoAction(pref, parent); 00760 result->setEnabled(canUndo()); 00761 result->setPrefixedText(undoText()); 00762 connect(this, SIGNAL(canUndoChanged(bool)), 00763 result, SLOT(setEnabled(bool))); 00764 connect(this, SIGNAL(undoTextChanged(QString)), 00765 result, SLOT(setPrefixedText(QString))); 00766 connect(result, SIGNAL(triggered()), this, SLOT(undo())); 00767 return result; 00768 }
Here is the call graph for this function:
QAction * QUndoStack::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 redo(). The text of this action is the text of the command which will be redone in the next call to redo(), prefixed by the specified prefix. If there is no command available for redo, this action will be disabled.
If prefix is empty, the default prefix "Redo" is used.
Definition at line 783 of file qundostack.cpp.
References canRedo(), canRedoChanged(), QObject::connect(), QString::isEmpty(), QObject::parent(), redo(), redoText(), redoTextChanged(), QAction::setEnabled(), QUndoAction::setPrefixedText(), SIGNAL, and SLOT.
00784 { 00785 QString pref = prefix.isEmpty() ? tr("Redo") : prefix; 00786 QUndoAction *result = new QUndoAction(pref, parent); 00787 result->setEnabled(canRedo()); 00788 result->setPrefixedText(redoText()); 00789 connect(this, SIGNAL(canRedoChanged(bool)), 00790 result, SLOT(setEnabled(bool))); 00791 connect(this, SIGNAL(redoTextChanged(QString)), 00792 result, SLOT(setPrefixedText(QString))); 00793 connect(result, SIGNAL(triggered()), this, SLOT(redo())); 00794 return result; 00795 }
Here is the call graph for this function:
bool QUndoStack::isActive | ( | ) | const |
Definition at line 938 of file qundostack.cpp.
References d.
00939 { 00940 #ifdef QT_NO_UNDOGROUP 00941 return true; 00942 #else 00943 Q_D(const QUndoStack); 00944 return d->group == 0 || d->group->activeStack() == this; 00945 #endif 00946 }
bool QUndoStack::isClean | ( | ) | const |
If the stack is in the clean state, returns true; otherwise returns false.
Definition at line 538 of file qundostack.cpp.
References d.
00539 { 00540 Q_D(const QUndoStack); 00541 if (!d->macro_stack.isEmpty()) 00542 return false; 00543 return d->clean_index == d->index; 00544 }
int QUndoStack::cleanIndex | ( | ) | const |
Returns the clean index. This is the index at which setClean() was called.
A stack may not have a clean index. This happens if a document is saved, some commands are undone, then a new command is pushed. Since push() deletes all the undone commands before pushing the new command, the stack can't return to the clean state again. In this case, this function returns -1.
Definition at line 557 of file qundostack.cpp.
References d.
Referenced by QUndoModel::data().
00558 { 00559 Q_D(const QUndoStack); 00560 return d->clean_index; 00561 }
void QUndoStack::beginMacro | ( | const QString & | text | ) |
Begins composition of a macro command with the given text description.
An empty command described by the specified text is pushed on the stack. Any subsequent commands pushed on the stack will be appended to the empty command's children until endMacro() is called.
Calls to beginMacro() and endMacro() may be nested, but every call to beginMacro() must have a matching call to endMacro().
While a macro is composed, the stack is disabled. This means that: indexChanged() and cleanChanged() are not emitted, canUndo() and canRedo() return false, calling undo() or redo() has no effect, the undo/redo actions are disabled.
The stack becomes enabled and appropriate signals are emitted when endMacro() is called for the outermost macro.
stack.beginMacro("insert red text"); stack.push(new InsertText(document, idx, text)); stack.push(new SetColor(document, idx, text.length(), Qt::red)); stack.endMacro(); // indexChanged() is emitted
This code is equivalent to:
QUndoCommand *insertRed = new QUndoCommand(); // an empty command insertRed->setText("insert red text"); new InsertText(document, idx, text, insertRed); // becomes child of insertRed new SetColor(document, idx, text.length(), Qt::red, insertRed); stack.push(insertRed);
Definition at line 842 of file qundostack.cpp.
References canRedoChanged(), canUndoChanged(), d, emit, redoTextChanged(), QUndoCommand::setText(), text(), and undoTextChanged().
Referenced by qdesigner_internal::FormWindow::beginCommand(), qdesigner_internal::BuddyEditor::deleteSelected(), qdesigner_internal::BuddyEditor::endConnection(), and qdesigner_internal::BuddyEditor::widgetRemoved().
00843 { 00844 Q_D(QUndoStack); 00845 QUndoCommand *cmd = new QUndoCommand(); 00846 cmd->setText(text); 00847 00848 if (d->macro_stack.isEmpty()) { 00849 while (d->index < d->command_list.size()) 00850 delete d->command_list.takeLast(); 00851 if (d->clean_index > d->index) 00852 d->clean_index = -1; // we've deleted the clean state 00853 d->command_list.append(cmd); 00854 } else { 00855 d->macro_stack.last()->d->child_list.append(cmd); 00856 } 00857 d->macro_stack.append(cmd); 00858 00859 if (d->macro_stack.count() == 1) { 00860 emit canUndoChanged(false); 00861 emit undoTextChanged(QString()); 00862 emit canRedoChanged(false); 00863 emit redoTextChanged(QString()); 00864 } 00865 }
Here is the call graph for this function:
void QUndoStack::endMacro | ( | ) |
Ends composition of a macro command.
If this is the outermost macro in a set nested macros, this function emits indexChanged() once for the entire macro command.
Definition at line 876 of file qundostack.cpp.
References d, and qWarning().
Referenced by qdesigner_internal::BuddyEditor::deleteSelected(), qdesigner_internal::FormWindow::endCommand(), qdesigner_internal::BuddyEditor::endConnection(), and qdesigner_internal::BuddyEditor::widgetRemoved().
00877 { 00878 Q_D(QUndoStack); 00879 if (d->macro_stack.isEmpty()) { 00880 qWarning("QUndoStack::endMacro(): no matching beginMacro()"); 00881 return; 00882 } 00883 00884 d->macro_stack.removeLast(); 00885 00886 if (d->macro_stack.isEmpty()) 00887 d->setIndex(d->index + 1, false); 00888 }
Here is the call graph for this function:
void QUndoStack::setClean | ( | ) | [slot] |
Marks the stack as clean and emits cleanChanged() if the stack was not already clean.
Whenever the stack returns to this state through the use of undo/redo commands, it emits the signal cleanChanged(). This signal is also emitted when the stack leaves the clean state.
Definition at line 521 of file qundostack.cpp.
References d, and qWarning().
00522 { 00523 Q_D(QUndoStack); 00524 if (!d->macro_stack.isEmpty()) { 00525 qWarning("QUndoStack::setClean(): cannot set clean in the middle of a macro"); 00526 return; 00527 } 00528 00529 d->setIndex(d->index, true); 00530 }
void QUndoStack::setIndex | ( | int | idx | ) | [slot] |
Repeatedly calls undo() or redo() until the the current command index reaches idx. This function can be used to roll the state of the document forwards of backwards. indexChanged() is emitted only once.
Definition at line 649 of file qundostack.cpp.
References d, i, and qWarning().
Referenced by QUndoModel::setStackCurrentIndex().
00650 { 00651 Q_D(QUndoStack); 00652 if (!d->macro_stack.isEmpty()) { 00653 qWarning("QUndoStack::setIndex(): cannot set index in the middle of a macro"); 00654 return; 00655 } 00656 00657 if (idx < 0) 00658 idx = 0; 00659 else if (idx > d->command_list.size()) 00660 idx = d->command_list.size(); 00661 00662 int i = d->index; 00663 while (i < idx) 00664 d->command_list.at(i++)->redo(); 00665 while (i > idx) 00666 d->command_list.at(--i)->undo(); 00667 00668 d->setIndex(idx, false); 00669 }
void QUndoStack::undo | ( | ) | [slot] |
Undoes the command below the current command by calling QUndoCommand::undo(). Decrements the current command index.
If the stack is empty, or if the bottom command on the stack has already been undone, this function does nothing.
Definition at line 573 of file qundostack.cpp.
References d, and qWarning().
Referenced by createUndoAction().
00574 { 00575 Q_D(QUndoStack); 00576 if (d->index == 0) 00577 return; 00578 00579 if (!d->macro_stack.isEmpty()) { 00580 qWarning("QUndoStack::undo(): cannot undo in the middle of a macro"); 00581 return; 00582 } 00583 00584 int idx = d->index - 1; 00585 d->command_list.at(idx)->undo(); 00586 d->setIndex(idx, false); 00587 }
void QUndoStack::redo | ( | ) | [slot] |
Redoes the current command by calling QUndoCommand::redo(). Increments the current command index.
If the stack is empty, or if the top command on the stack has already been redone, this function does nothing.
Definition at line 599 of file qundostack.cpp.
References d, and qWarning().
Referenced by createRedoAction().
00600 { 00601 Q_D(QUndoStack); 00602 if (d->index == d->command_list.size()) 00603 return; 00604 00605 if (!d->macro_stack.isEmpty()) { 00606 qWarning("QUndoStack::redo(): cannot redo in the middle of a macro"); 00607 return; 00608 } 00609 00610 d->command_list.at(d->index)->redo(); 00611 d->setIndex(d->index + 1, false); 00612 }
void QUndoStack::setActive | ( | bool | active = true |
) | [slot] |
Definition at line 922 of file qundostack.cpp.
References d.
Referenced by qdesigner_internal::FormWindowManager::setActiveFormWindow().
00923 { 00924 #ifdef QT_NO_UNDOGROUP 00925 Q_UNUSED(active); 00926 #else 00927 Q_D(QUndoStack); 00928 00929 if (d->group != 0) { 00930 if (active) 00931 d->group->setActiveStack(this); 00932 else if (d->group->activeStack() == this) 00933 d->group->setActiveStack(0); 00934 } 00935 #endif 00936 }
void QUndoStack::indexChanged | ( | int | idx | ) | [signal] |
This signal is emitted whenever a command modifies the state of the document. This happens when a command is undone or redone. When a macro command is undone or redone, or setIndex() is called, this signal is emitted only once.
idx specifies the index of the current command, ie. the command which will be executed on the next call to redo().
Referenced by push().
void QUndoStack::cleanChanged | ( | bool | clean | ) | [signal] |
This signal is emitted whenever the stack enters or leaves the clean state. If clean is true, the stack is in a clean state; otherwise this signal indicates that it has left the clean state.
void QUndoStack::canUndoChanged | ( | bool | canUndo | ) | [signal] |
This signal is emitted whenever the value of canUndo() changes. It is used to enable or disable the undo action returned by createUndoAction(). canUndo specifies the new value.
Referenced by beginMacro(), createUndoAction(), and push().
void QUndoStack::canRedoChanged | ( | bool | canUndo | ) | [signal] |
This signal is emitted whenever the value of canRedo() changes. It is used to enable or disable the redo action returned by createRedoAction(). canUndo specifies the new value.
Referenced by beginMacro(), createRedoAction(), and push().
void QUndoStack::undoTextChanged | ( | const QString & | undoText | ) | [signal] |
This signal is emitted whenever the value of undoText() changes. It is used to update the text property of the undo action returned by createUndoAction(). undoText specifies the new text.
Referenced by beginMacro(), createUndoAction(), and push().
void QUndoStack::redoTextChanged | ( | const QString & | redoText | ) | [signal] |
This signal is emitted whenever the value of redoText() changes. It is used to update the text property of the redo action returned by createRedoAction(). redoText specifies the new text.
Referenced by beginMacro(), createRedoAction(), and push().
friend class QUndoGroup [friend] |
Definition at line 120 of file qundostack.h.