QAction *QUndoStack::createRedoAction(QObject *parent, const QString &prefix) const { QUndoAction *result = new QUndoAction(prefix, parent); if (prefix.isEmpty()) result->setTextFormat(tr("Redo %1"), tr("Redo", "Default text for redo action")); result->setEnabled(canRedo()); result->setPrefixedText(redoText()); connect(this, SIGNAL(canRedoChanged(bool)), result, SLOT(setEnabled(bool))); connect(this, SIGNAL(redoTextChanged(QString)), result, SLOT(setPrefixedText(QString))); connect(result, SIGNAL(triggered()), this, SLOT(redo())); return result; }
void EditorClientBlackBerry::redo() { if (canRedo()) { EditCommandStack::iterator back = --m_redoStack.end(); RefPtr<UndoStep> command(*back); m_redoStack.remove(back); ASSERT(!m_inRedo); m_inRedo = true; // Reapply will call us back to push this command onto the undo stack. command->reapply(); m_inRedo = false; } }
void redo() { if (canRedo()) { bool inserted = false; for (int i = m_clonedElements.count() - 1; i >= 0; --i) { Clone &clone = m_clonedElements[i]; QMT_CHECK(clone.m_clonedElement); QMT_CHECK(clone.m_clonedElement->uid() == clone.m_elementKey); MObject *owner = m_modelController->findObject<MObject>(clone.m_ownerKey); QMT_CHECK(owner); QMT_CHECK(clone.m_indexOfElement >= 0); switch (clone.m_elementType) { case TypeObject: { emit m_modelController->beginInsertObject(clone.m_indexOfElement, owner); MObject *object = dynamic_cast<MObject *>(clone.m_clonedElement); QMT_CHECK(object); m_modelController->mapObject(object); owner->insertChild(clone.m_indexOfElement, object); clone.m_clonedElement = 0; emit m_modelController->endInsertObject(clone.m_indexOfElement, owner); inserted = true; break; } case TypeRelation: { emit m_modelController->beginInsertRelation(clone.m_indexOfElement, owner); MRelation *relation = dynamic_cast<MRelation *>(clone.m_clonedElement); QMT_CHECK(relation); m_modelController->mapRelation(relation); owner->insertRelation(clone.m_indexOfElement, relation); clone.m_clonedElement = 0; emit m_modelController->endInsertRelation(clone.m_indexOfElement, owner); inserted = true; break; } default: QMT_CHECK(false); break; } } if (inserted) { emit m_modelController->modified(); } m_modelController->verifyModelIntegrity(); UndoCommand::redo(); } }
void LvlHistoryManager::updateHistoryBuffer() { if(canRedo()) { int lastSize = operationList.size(); for(int i = historyIndex; i < lastSize; i++) { operationList.pop_back(); } } while(operationList.size() >= GlobalSettings::historyLimit) { operationList.pop_front(); historyIndex--; } }
void Board::redo() { if(canRedo()) { clearHighlight(); undrawConnection(); Move* m = _redo.take(0); setField(m->x1, m->y1, EMPTY); setField(m->x2, m->y2, EMPTY); updateField(m->x1, m->y1); updateField(m->x2, m->y2); gravity(m->x1, true); gravity(m->x2, true); _undo.append(m); emit changed(); } }
void QUndoStack::push(QUndoCommand *cmd) { Q_D(QUndoStack); cmd->redo(); bool macro = !d->macro_stack.isEmpty(); QUndoCommand *cur = 0; if (macro) { QUndoCommand *macro_cmd = d->macro_stack.last(); if (!macro_cmd->d->child_list.isEmpty()) cur = macro_cmd->d->child_list.last(); } else { if (d->index > 0) cur = d->command_list.at(d->index - 1); while (d->index < d->command_list.size()) delete d->command_list.takeLast(); if (d->clean_index > d->index) d->clean_index = -1; // we've deleted the clean state } bool try_merge = cur != 0 && cur->id() != -1 && cur->id() == cmd->id() && (macro || d->index != d->clean_index); if (try_merge && cur->mergeWith(cmd)) { delete cmd; if (!macro) { emit indexChanged(d->index); emit canUndoChanged(canUndo()); emit undoTextChanged(undoText()); emit canRedoChanged(canRedo()); emit redoTextChanged(redoText()); } } else { if (macro) { d->macro_stack.last()->d->child_list.append(cmd); } else { d->command_list.append(cmd); d->checkUndoLimit(); d->setIndex(d->index + 1, false); } } }
void CommandStack::redoLast() { if (canRedo()) { assert(redo_index_ < (int) commands_.size()); CommandInterface * to_redo = commands_[redo_index_]; assert(to_redo != NULL); to_redo->execute(); undo_index_ = redo_index_; if (redo_index_ == (int) commands_.size() - 1) { redo_index_ = -1; } else { redo_index_++; } } }
void KUndo2QStack::push(KUndo2Command *cmd) { cmd->redo(); bool macro = !m_macro_stack.isEmpty(); KUndo2Command *cur = 0; if (macro) { KUndo2Command *macro_cmd = m_macro_stack.last(); if (!macro_cmd->d->child_list.isEmpty()) cur = macro_cmd->d->child_list.last(); } else { if (m_index > 0) cur = m_command_list.at(m_index - 1); while (m_index < m_command_list.size()) delete m_command_list.takeLast(); if (m_clean_index > m_index) m_clean_index = -1; // we've deleted the clean state } bool try_merge = cur != 0 && cur->id() != -1 && cur->id() == cmd->id() && (macro || m_index != m_clean_index); if (try_merge && cur->mergeWith(cmd)) { delete cmd; if (!macro) { emit indexChanged(m_index); emit canUndoChanged(canUndo()); emit undoTextChanged(undoText()); emit canRedoChanged(canRedo()); emit redoTextChanged(redoText()); } } else { if (macro) { m_macro_stack.last()->d->child_list.append(cmd); } else { m_command_list.append(cmd); checkUndoLimit(); setIndex(m_index + 1, false); } } }
KAction* Editor::createRedoAction(KActionCollection *actionCollection) { UndoAction *action = new UndoAction(i18n("Redo"), actionCollection); action->setEnabled(canRedo()); action->setPrefixedText(redoText()); connect(this, SIGNAL(canRedoChanged(bool)), action, SLOT(setEnabled(bool))); connect(this, SIGNAL(redoTextChanged(QString)), action, SLOT(setPrefixedText(QString))); connect(action, SIGNAL(triggered()), this, SLOT(redo())); action->setIcon(KIcon("edit-redo")); action->setIconText(i18n("Redo")); action->setShortcuts(KStandardShortcut::redo()); actionCollection->addAction(KStandardAction::name(KStandardAction::Redo), action); return action; }
/* ============================================================================= =============================================================================== */ void CWorld::redo() { if (!canRedo()) return; CEditStack &Stack = g_Set.m_SessionPlayback ? getSessionStack() : getEditStack(); Stack.redo(); bool bLoop = (Stack.getCur().getGroup() == START_GROUP); Stack.undo(); bool bEndLoop = false; do { Stack.redo(); bEndLoop = (Stack.getCur().getGroup() == END_GROUP); processEdit(Stack.getCur(), false); } while(bLoop && !bEndLoop); }
void KUndo2QStack::setIndex(int idx, bool clean) { bool was_clean = m_index == m_clean_index; if (idx != m_index) { m_index = idx; emit indexChanged(m_index); emit canUndoChanged(canUndo()); emit undoTextChanged(undoText()); emit canRedoChanged(canRedo()); emit redoTextChanged(redoText()); } if (clean) m_clean_index = m_index; bool is_clean = m_index == m_clean_index; if (is_clean != was_clean) emit cleanChanged(is_clean); }
/// Reverts the last command issued by undo(). void UndoStack::redo() { if(inGroup()){ endGroup(); } if(!canRedo()){ return; } UndoCommand *command = m_redoStack.top(); m_redoStack.pop(); command->redo(); m_undoStack.push(command); if(m_undoStack.size() == 1){ canUndoChanged(true); } if(m_redoStack.empty()){ canRedoChanged(false); } }
void GameMovesRegistry::undo() { if (!canUndo()) { return; } qDebug() << "Undo"; IMoveCommand::UPtr cmd = std::move(m_performedCmnds.back()); m_performedCmnds.pop_back(); m_undoneCmnds.push_back(std::move(cmd)); if (!m_undoneCmnds.back()->undo(m_board)) { failExecution(); return; } emit newMoveDone(); emit canRedoChanged(canRedo()); emit canUndoChanged(canUndo()); }
//----------------------------------------------------------------------------- // redoAction() //----------------------------------------------------------------------------- BOOL LLUndoBuffer::redoAction() { if (!canRedo()) { return FALSE; } mOperationID++; while(mActions[mNextAction]->mClusterID == mOperationID) { if (mNextAction == mLastAction) { return FALSE; } mActions[mNextAction]->redo(); // do wrap-around of index mNextAction = (mNextAction + 1) % mNumActions; } return TRUE; }
bool KUndo2QStack::push(KUndo2Command *cmd) { cmd->redoMergedCommands(); cmd->setEndTime(); bool macro = !m_macro_stack.isEmpty(); KUndo2Command *cur = 0; if (macro) { KUndo2Command *macro_cmd = m_macro_stack.last(); if (!macro_cmd->d->child_list.isEmpty()) cur = macro_cmd->d->child_list.last(); } else { if (m_index > 0) cur = m_command_list.at(m_index - 1); while (m_index < m_command_list.size()) delete m_command_list.takeLast(); if (m_clean_index > m_index) m_clean_index = -1; // we've deleted the clean state } bool try_merge = cur != 0 && cur->id() != -1 && cur->id() == cmd->id() && (macro || m_index != m_clean_index); /*! *Here we are going to try to merge several commands together using the QVector field in the commands using *3 parameters. N : Number of commands that should remain individual at the top of the stack. T1 : Time lapsed between current command and previously merged command -- signal to *merge throughout the stack. T2 : Time lapsed between two commands signalling both commands belong to the same set *Whenever a KUndo2Command is initialized -- it consists of a start-time and when it is pushed --an end time. *Every time a command is pushed -- it checks whether the command pushed was pushed after T1 seconds of the last merged command *Then the merging begins with each group depending on the time in between each command (T2). * *@TODO : Currently it is not able to merge two merged commands together. */ if (!macro && m_command_list.size() > 1 && cmd->timedId() != -1 && m_useCumulativeUndoRedo) { KUndo2Command* lastcmd = m_command_list.last(); if (qAbs(cmd->time().msecsTo(lastcmd->endTime())) < m_timeT2 * 1000) { m_lastMergedSetCount++; } else { m_lastMergedSetCount = 0; m_lastMergedIndex = m_index-1; } if (lastcmd->timedId() == -1){ m_lastMergedSetCount = 0; m_lastMergedIndex = m_index; } if (m_lastMergedSetCount > m_strokesN) { KUndo2Command* toMerge = m_command_list.at(m_lastMergedIndex); if (toMerge && m_command_list.size() >= m_lastMergedIndex + 1 && m_command_list.at(m_lastMergedIndex + 1)) { if(toMerge->timedMergeWith(m_command_list.at(m_lastMergedIndex + 1))){ m_command_list.removeAt(m_lastMergedIndex + 1); } m_lastMergedSetCount--; m_lastMergedIndex = m_command_list.indexOf(toMerge); } } m_index = m_command_list.size(); if(m_lastMergedIndex<m_index){ if (cmd->time().msecsTo(m_command_list.at(m_lastMergedIndex)->endTime()) < -m_timeT1 * 1000) { //T1 time elapsed QListIterator<KUndo2Command*> it(m_command_list); it.toBack(); m_lastMergedSetCount = 1; while (it.hasPrevious()) { KUndo2Command* curr = it.previous(); KUndo2Command* lastCmdInCurrent = curr; if (!lastcmd->mergeCommandsVector().isEmpty()) { if (qAbs(lastcmd->mergeCommandsVector().last()->time().msecsTo(lastCmdInCurrent->endTime())) < int(m_timeT2 * 1000) && lastcmd != lastCmdInCurrent && lastcmd != curr) { if(lastcmd->timedMergeWith(curr)){ if (m_command_list.contains(curr)) { m_command_list.removeOne(curr); } } } else { lastcmd = curr; //end of a merge set } } else { if (qAbs(lastcmd->time().msecsTo(lastCmdInCurrent->endTime())) < int(m_timeT2 * 1000) && lastcmd != lastCmdInCurrent &&lastcmd!=curr) { if(lastcmd->timedMergeWith(curr)){ if (m_command_list.contains(curr)){ m_command_list.removeOne(curr); } } } else { lastcmd = curr; //end of a merge set } } } m_lastMergedIndex = m_command_list.size()-1; } } m_index = m_command_list.size(); } if (try_merge && cur->mergeWith(cmd)) { delete cmd; cmd = 0; if (!macro) { emit indexChanged(m_index); emit canUndoChanged(canUndo()); emit undoTextChanged(undoText()); emit canRedoChanged(canRedo()); emit redoTextChanged(redoText()); } } else { if (macro) { m_macro_stack.last()->d->child_list.append(cmd); } else { m_command_list.append(cmd); if(checkUndoLimit()) { m_lastMergedIndex = m_index - m_strokesN; } setIndex(m_index + 1, false); } } return cmd; }
void UndoManager::redo() { if (canRedo()) { edits[position++]->redo(); } }
void Task::clearStaleHistory() { if (canRedo()) { _currentStep = _stepQueue.erase(_stepQueue.begin(), _currentStep - 1); } }
void KRegExpEditorPrivate::emitUndoRedoSignals() { emit canUndo( _undoStack.count() > 1 ); emit changes( _undoStack.count() > 1 ); emit canRedo( _redoStack.count() > 0 ); }
void KDocumentTextBuffer::resetUndoRedo() { emit canUndo(false); emit canRedo(false); }
void Timeline::clearStaleHistory() { if (canRedo()) { _currentTask = _taskQueue.erase(_taskQueue.begin(), _currentTask - 1); } }
QString redoText() const { return canRedo() ? m_redoable.top()->description() : tr("Nothing to redo"); }
String CMyPaintDoc::getInfo() const { return format(_T("%s %s"),canUndo()?_T("canUndo"):_T("_______"), canRedo()?_T("canRedo"):_T("_______")); }