本文整理汇总了C++中KUndo2Command::redo方法的典型用法代码示例。如果您正苦于以下问题:C++ KUndo2Command::redo方法的具体用法?C++ KUndo2Command::redo怎么用?C++ KUndo2Command::redo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KUndo2Command
的用法示例。
在下文中一共展示了KUndo2Command::redo方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: KoPathPointIndex
void KarbonPathRefineCommand::redo()
{
// check if we have to create the insert points commands
if (! d->initialized) {
// create insert point commands, one for each point to insert
// into each segment
for (uint iteration = 0; iteration < d->insertCount; ++iteration) {
// in each iteration collect the (iteration+1)th point which starts a segments
// into which we insert the point of this iteration
QList<KoPathPointData> pointData;
// calculate the segment position where to insert the point
qreal insertPosition = 1.0 / (d->insertCount + 1 - iteration);
int subpathCount = d->path->subpathCount();
// iterate over the paths subpaths
for (int subpathIndex = 0; subpathIndex < subpathCount; ++subpathIndex) {
int pointCount = d->path->subpathPointCount(subpathIndex);
// iterate over the subpaths points
for (int pointIndex = 0; pointIndex < pointCount; ++pointIndex) {
// we only collect the (iteration+1)th point
if ((pointIndex + 1) % (iteration + 1) != 0)
continue;
pointData.append(KoPathPointData(d->path, KoPathPointIndex(subpathIndex, pointIndex)));
}
}
// create the command and execute it
KUndo2Command * cmd = new KoPathPointInsertCommand(pointData, insertPosition, this);
cmd->redo();
}
d->initialized = true;
} else {
KUndo2Command::redo();
}
d->path->update();
}
示例2: kDebug
/// This method is used to start an on-the-fly macro command. Use KoTextEditor::endEditBlock to stop it.
/// ***
/// Important note:
/// ***
/// The framework does not allow to push a complete KUndo2Command (through KoTextEditor::addCommand) from within an EditBlock. Doing so will lead in the best case to several undo/redo commands on the application's stack instead of one, in the worst case to an out of sync application's stack.
/// ***
KUndo2Command *KoTextEditor::beginEditBlock(const QString &title)
{
kDebug(32500) << "beginEditBlock";
kDebug(32500) << "commandStack count: " << d->commandStack.count();
kDebug(32500) << "customCommandCount counter: " << d->customCommandCount;
if (!d->customCommandCount) {
// We are not in a custom macro command. So we first need to update the KoTextEditor's state to Custom. Additionally, if the commandStack is empty, we need to create a master headCommand for our macro and push it on the stack.
kDebug(32500) << "we are not in a custom command. will update state to custom";
d->updateState(KoTextEditor::Private::Custom, title);
kDebug(32500) << "commandStack count: " << d->commandStack.count();
if (d->commandStack.isEmpty()) {
kDebug(32500) << "the commandStack is empty. we need a dummy headCommand both on the commandStack and on the application's stack";
KUndo2Command *command = new KUndo2Command(title);
d->commandStack.push(command);
++d->customCommandCount;
d->dummyMacroAdded = true; //This bool is used to tell endEditBlock that we have created a master headCommand.
KUndo2QStack *stack = KoTextDocument(d->document).undoStack();
if (stack) {
stack->push(command);
} else {
command->redo();
}
kDebug(32500) << "done adding the headCommand. commandStack count: " << d->commandStack.count() << " inCommand counter: " << d->customCommandCount;
}
}
//QTextDocument sends the undoCommandAdded signal at the end of the QTextCursor edit block. Since we want our master headCommand to parent the signal induced UndoTextCommands, we should not call QTextCursor::beginEditBlock for the headCommand.
if (!(d->dummyMacroAdded && d->customCommandCount == 1)) {
kDebug(32500) << "we did not add a dummy command, or we are further down nesting. call beginEditBlock on the caret to nest the QTextDoc changes";
//we don't call beginEditBlock for the first headCommand because we want the signals to be sent before we finished our command.
d->caret.beginEditBlock();
}
kDebug(32500) << "will return top od commandStack";
return (d->commandStack.isEmpty())?0:d->commandStack.top();
}
示例3: destroyKeyframe
void KisScalarKeyframeChannel::destroyKeyframe(KisKeyframeSP key, KUndo2Command *parentCommand)
{
int index = key->value();
KIS_ASSERT_RECOVER_RETURN(m_d->values.contains(index));
KUndo2Command *cmd = new Private::InsertValueCommand(m_d.data(), index, m_d->values[index], false, parentCommand);
cmd->redo();
}
示例4: createKeyframe
KisKeyframeSP KisScalarKeyframeChannel::createKeyframe(int time, const KisKeyframeSP copySrc, KUndo2Command *parentCommand)
{
qreal value = (copySrc != 0) ? scalarValue(copySrc) : 0;
int index = m_d->firstFreeIndex++;
KUndo2Command *cmd = new Private::InsertValueCommand(m_d.data(), index, value, true, parentCommand);
cmd->redo();
return toQShared(new KisKeyframe(this, time, index));
}
示例5: redoUndoPointRemove
void TestPointRemoveCommand::redoUndoPointRemove()
{
KoPathShape path1;
path1.moveTo(QPointF(0, 0));
path1.lineTo(QPointF(0, 100));
KoPathPoint *point1 = path1.curveTo(QPointF(0, 50), QPointF(100, 50), QPointF(100, 100));
KoPathPoint *point2 = path1.lineTo(QPointF(200, 100));
path1.curveTo(QPointF(200, 50), QPointF(300, 50), QPointF(300, 100));
QPainterPath orig1(QPointF(0, 0));
orig1.lineTo(0, 100);
orig1.cubicTo(0, 50, 100, 50, 100, 100);
orig1.lineTo(200, 100);
orig1.cubicTo(200, 50, 300, 50, 300, 100);
QVERIFY(orig1 == path1.outline());
KoPathShape path2;
path2.moveTo(QPointF(0, 0));
KoPathPoint *point3 = path2.curveTo(QPointF(50, 0), QPointF(100, 50), QPointF(100, 100));
path2.curveTo(QPointF(50, 100), QPointF(0, 50), QPointF(0, 0));
path2.closeMerge();
QList<KoPathPointData> pd;
pd.append(KoPathPointData(&path1, path1.pathPointIndex(point1)));
pd.append(KoPathPointData(&path1, path1.pathPointIndex(point2)));
pd.append(KoPathPointData(&path2, path2.pathPointIndex(point3)));
QPainterPath ppath1Org = path1.outline();
QPainterPath ppath2Org = path2.outline();
MockShapeController mockController;
KoShapeController shapeController(0, &mockController);
KUndo2Command *cmd = KoPathPointRemoveCommand::createCommand(pd, &shapeController);
cmd->redo();
QPainterPath ppath1(QPointF(0, 0));
ppath1.lineTo(0, 100);
ppath1.cubicTo(0, 50, 300, 50, 300, 100);
QPainterPath ppath2(QPointF(0, 0));
ppath2.cubicTo(50, 0, 0, 50, 0, 0);
ppath2.closeSubpath();
QVERIFY(ppath1 == path1.outline());
QVERIFY(ppath2 == path2.outline());
cmd->undo();
QVERIFY(ppath1Org == path1.outline());
QVERIFY(ppath2Org == path2.outline());
delete cmd;
}
示例6: setScalarValue
void KisScalarKeyframeChannel::setScalarValue(KisKeyframeSP keyframe, qreal value, KUndo2Command *parentCommand)
{
QScopedPointer<KUndo2Command> tempCommand;
if (!parentCommand) {
tempCommand.reset(new KUndo2Command());
parentCommand = tempCommand.data();
}
int index = keyframe->value();
KUndo2Command *cmd = new Private::SetValueCommand(m_d.data(), index, m_d->values[index], value, parentCommand);
cmd->redo();
}
示例7: redoUndoShapeRemove
void TestPointRemoveCommand::redoUndoShapeRemove()
{
KoPathShape *path1 = new KoPathShape();
KoPathPoint *point11 = path1->moveTo(QPointF(0, 0));
KoPathPoint *point12 = path1->lineTo(QPointF(0, 100));
KoPathPoint *point13 = path1->curveTo(QPointF(0, 50), QPointF(100, 50), QPointF(100, 100));
KoPathPoint *point14 = path1->lineTo(QPointF(200, 100));
KoPathPoint *point15 = path1->curveTo(QPointF(200, 50), QPointF(300, 50), QPointF(300, 100));
KoPathShape *path2 = new KoPathShape();
KoPathPoint *point21 = path2->moveTo(QPointF(0, 0));
KoPathPoint *point22 = path2->curveTo(QPointF(50, 0), QPointF(100, 50), QPointF(100, 100));
path2->curveTo(QPointF(50, 100), QPointF(0, 50), QPointF(0, 0));
path2->closeMerge();
QList<KoPathPointData> pd;
pd.append(KoPathPointData(path1, path1->pathPointIndex(point12)));
pd.append(KoPathPointData(path1, path1->pathPointIndex(point11)));
pd.append(KoPathPointData(path1, path1->pathPointIndex(point13)));
pd.append(KoPathPointData(path1, path1->pathPointIndex(point15)));
pd.append(KoPathPointData(path1, path1->pathPointIndex(point14)));
pd.append(KoPathPointData(path2, path2->pathPointIndex(point22)));
pd.append(KoPathPointData(path2, path2->pathPointIndex(point21)));
QPainterPath ppath1Org = path1->outline();
QPainterPath ppath2Org = path2->outline();
MockShapeController mockController;
mockController.addShape(path1);
mockController.addShape(path2);
KoShapeController shapeController(0, &mockController);
KUndo2Command *cmd = KoPathPointRemoveCommand::createCommand(pd, &shapeController);
cmd->redo();
QVERIFY(!mockController.contains(path1));
QVERIFY(!mockController.contains(path2));
cmd->undo();
QVERIFY(mockController.contains(path1));
QVERIFY(mockController.contains(path2));
QVERIFY(ppath1Org == path1->outline());
QVERIFY(ppath2Org == path2->outline());
delete cmd;
delete path1;
delete path2;
}
示例8: checkAndAddAnchoredShapes
void ShowChangesCommand::checkAndAddAnchoredShapes(int position, int length)
{
KoInlineTextObjectManager *inlineObjectManager
= KoTextDocument(m_document).inlineTextObjectManager();
Q_ASSERT(inlineObjectManager);
QTextCursor cursor = m_textEditor->document()->find(QString(QChar::ObjectReplacementCharacter), position);
while(!cursor.isNull() && cursor.position() < position + length) {
QTextCharFormat fmt = cursor.charFormat();
KoInlineObject *object = inlineObjectManager->inlineTextObject(fmt);
Q_ASSERT(object);
/* FIXME
KoTextAnchor *anchor = dynamic_cast<KoTextAnchor *>(object);
if (!anchor) {
continue;
}
*/
#if 0
// TODO -- since March 2010...
KoTextDocumentLayout *lay = qobject_cast<KoTextDocumentLayout*>(m_document->documentLayout());
KoShapeContainer *container = dynamic_cast<KoShapeContainer *>(lay->shapeForPosition(i));
// a very ugly hack. Since this class is going away soon, it should be okay
if (!container)
container = dynamic_cast<KoShapeContainer *>((lay->shapes()).at(0));
if (container) {
container->addShape(anchor->shape());
KUndo2Command *shapeCommand = m_canvas->shapeController()->addShapeDirect(anchor->shape());
shapeCommand->redo();
m_shapeCommands.push_front(shapeCommand);
}
#endif
cursor = m_textEditor->document()->find(QString(QChar::ObjectReplacementCharacter), position);
}
}