49#include <klocalizedstring.h>
60#ifndef QT_NO_UNDOCOMMAND
124 : m_hasParent(parent != 0)
125 , m_endOfCommand(QTime::currentTime())
129 parent->d->child_list.append(
this);
146 : m_hasParent(parent != 0)
150 parent->d->child_list.append(
this);
242 for (
int i =
d->
child_list.size() - 1; i >= 0; --i)
338 if(other->
timedId() == this->timedId() && other->
timedId() != -1 ) {
405 while (it.hasNext()) {
418 while (it.hasPrevious()) {
447#ifndef QT_NO_UNDOSTACK
530 , m_textTemplate(textTemplate)
531 , m_defaultText(defaultText)
567 if (is_clean != was_clean)
576 bool redoStateChanged =
false;
577 bool cleanStateChanged =
false;
581 redoStateChanged =
true;
586 cleanStateChanged =
true;
589 if (redoStateChanged) {
594 if (cleanStateChanged) {
613 for (
int i = 0; i < del_count; ++i)
635 : QObject(parent), m_index(0), m_clean_index(0), m_group(0), m_undo_limit(0)
636 , m_useCumulativeUndoRedo(false)
638#ifndef QT_NO_UNDOGROUP
639 if (
KUndo2Group *group = qobject_cast<KUndo2Group*>(parent))
640 group->addStack(
this);
653#ifndef QT_NO_UNDOGROUP
746 bool try_merge = cur != 0
748 && cur->
id() == cmd->
id()
769 [
this] (
auto revIt,
bool *isMerged) {
772 auto dst = std::prev(revIt.base());
773 auto src = std::prev(dst);
775 if ((*dst)->timedId() != -1 &&
776 (*dst)->timedId() == (*src)->timedId() &&
779 (*dst)->timedMergeWith(*src)) {
781 const int removedIndex = std::distance(
m_command_list.begin(), src);
798 return std::make_reverse_iterator(std::next(dst));
801 int extraCheckDepth = 0;
803 QTime oldTimeBase = lastcmd->
time();
804 QTime newTimeBase = cmd->
time();
807 auto next = std::next(it);
809 while (next != std::make_reverse_iterator(
m_command_list.begin())) {
814 next = std::next(it);
818 int oldTime = (*it)->endTime().msecsTo(oldTimeBase);
819 int newTime = (*it)->endTime().msecsTo(newTimeBase);
833 it = tryMergeBack(it, &merged);
850 next = std::next(it);
873 }
else if (try_merge && cur->
mergeWith(cmd)) {
908 qWarning(
"KUndo2QStack::setClean(): cannot set clean in the middle of a macro");
960 qWarning(
"KUndo2QStack::undo(): cannot undo in the middle of a macro");
985 qWarning(
"KUndo2QStack::redo(): cannot redo in the middle of a macro");
1029 qWarning(
"KUndo2QStack::setIndex(): cannot set index in the middle of a macro");
1146 result->setEnabled(
canUndo());
1149 result, SLOT(setEnabled(
bool)));
1151 result, SLOT(setPrefixedText(QString)));
1152 connect(result, SIGNAL(triggered()),
this, SLOT(
undo()));
1172 result->setEnabled(
canRedo());
1175 result, SLOT(setEnabled(
bool)));
1177 result, SLOT(setPrefixedText(QString)));
1178 connect(result, SIGNAL(triggered()),
this, SLOT(
redo()));
1250 qWarning(
"KUndo2QStack::endMacro(): no matching beginMacro()");
1312 qWarning(
"KUndo2QStack::setUndoLimit(): an undo limit can only be set when the stack is empty");
1346#ifdef QT_NO_UNDOGROUP
1360#ifdef QT_NO_UNDOGROUP
1390 if (actionName.isEmpty()) {
1393 action->setObjectName(actionName);
1396 action->setIcon(
koIcon(
"edit-redo"));
1397 action->setIconText(i18n(
"Redo"));
1398 action->setShortcuts(KStandardShortcut::redo());
1400 actionCollection->
addAction(action->objectName(), action);
1409 if (actionName.isEmpty()) {
1412 action->setObjectName(actionName);
1415 action->setIcon(
koIcon(
"edit-undo"));
1416 action->setIconText(i18n(
"Undo"));
1417 action->setShortcuts(KStandardShortcut::undo());
1419 actionCollection->
addAction(action->objectName(), action);
float value(const T *src, size_t ch)
connect(this, SIGNAL(optionsChanged()), this, SLOT(saveOptions()))
void setPrefixedText(const QString &text)
KUndo2Action(const QString &textTemplate, const QString &defaultText, QObject *parent=0)
QList< KUndo2Command * > child_list
QScopedPointer< KUndo2CommandExtraData > extraData
virtual bool mergeWith(const KUndo2Command *other)
void setText(const KUndo2MagicString &text)
const KUndo2Command * child(int index) const
virtual void redoMergedCommands()
KUndo2MagicString text() const
QVector< KUndo2Command * > m_mergeCommandsVector
virtual void setTimedID(int timedID)
virtual bool timedMergeWith(KUndo2Command *other)
virtual QTime time() const
virtual QTime endTime() const
virtual bool canAnnihilateWith(const KUndo2Command *other) const
virtual QVector< KUndo2Command * > mergeCommandsVector() const
KUndo2Command(KUndo2Command *parent=0)
KUndo2CommandExtraData * extraData() const
virtual bool isMerged() const
virtual void undoMergedCommands()
QString actionText() const
virtual int timedId() const
void setExtraData(KUndo2CommandExtraData *data)
The KUndo2Group class is a group of KUndo2QStack objects.
void removeStack(KUndo2QStack *stack)
void setActiveStack(KUndo2QStack *stack)
KUndo2QStack * activeStack() const
QString toSecondaryString() const
The KUndo2QStack class is a stack of KUndo2Command objects.
QList< KUndo2Command * > m_command_list
void setUndoLimit(int limit)
virtual void setIndex(int idx)
void setCumulativeUndoData(const KisCumulativeUndoData &data)
void cleanChanged(bool clean)
void beginMacro(const KUndo2MagicString &text)
QList< KUndo2Command * > m_macro_stack
void setUseCumulativeUndoRedo(bool value)
KisCumulativeUndoData cumulativeUndoData()
void redoTextChanged(const QString &redoActionText)
bool useCumulativeUndoRedo() const
void push(KUndo2Command *cmd)
void indexChanged(int idx)
void canUndoChanged(bool canUndo)
bool active
the active status of this stack.
QAction * createUndoAction(QObject *parent) const
void setActive(bool active=true)
QString text(int idx) const
bool m_useCumulativeUndoRedo
void canRedoChanged(bool canRedo)
void undoTextChanged(const QString &undoActionText)
KisCumulativeUndoData m_cumulativeUndoData
QAction * createRedoAction(QObject *parent) const
virtual void notifySetIndexChangedOneCommand()
KUndo2QStack(QObject *parent=0)
int undoLimit
the maximum number of commands on this stack.
const KUndo2Command * command(int index) const
QAction * createRedoAction(KisKActionCollection *actionCollection, const QString &actionName=QString())
KUndo2Stack(QObject *parent=0)
QAction * createUndoAction(KisKActionCollection *actionCollection, const QString &actionName=QString())
A container for a set of QAction objects.
Q_INVOKABLE QAction * addAction(const QString &name, QAction *action)
#define KIS_SAFE_ASSERT_RECOVER_BREAK(cond)
#define koIcon(name)
Use these macros for icons without any issues.
const char * name(StandardAction id)