当前位置: 首页>>代码示例>>C++>>正文


C++ KUndo2Command类代码示例

本文整理汇总了C++中KUndo2Command的典型用法代码示例。如果您正苦于以下问题:C++ KUndo2Command类的具体用法?C++ KUndo2Command怎么用?C++ KUndo2Command使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了KUndo2Command类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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();
}
开发者ID:foren197316,项目名称:calligra,代码行数:34,代码来源:KarbonPathRefineCommand.cpp

示例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();
}
开发者ID:abhishekmurthy,项目名称:Calligra,代码行数:40,代码来源:KoTextEditor_undo.cpp

示例3: KisReselectGlobalSelectionCommand

void KisReselectActionFactory::run(KisView2 *view)
{
    KUndo2Command *cmd = new KisReselectGlobalSelectionCommand(view->image());

    KisProcessingApplicator *ap = beginAction(view, cmd->text());
    ap->applyCommand(cmd, KisStrokeJobData::SEQUENTIAL, KisStrokeJobData::EXCLUSIVE);
    endAction(ap, KisOperationConfiguration(id()).toXML());
}
开发者ID:abhishekmurthy,项目名称:Calligra,代码行数:8,代码来源:kis_selection_action_factories.cpp

示例4: KIS_ASSERT_RECOVER_RETURN

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();
}
开发者ID:IGLOU-EU,项目名称:krita,代码行数:9,代码来源:kis_scalar_keyframe_channel.cpp

示例5: scalarValue

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));
}
开发者ID:IGLOU-EU,项目名称:krita,代码行数:10,代码来源:kis_scalar_keyframe_channel.cpp

示例6: QPointF

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;
}
开发者ID:abhishekmurthy,项目名称:Calligra,代码行数:55,代码来源:TestPointRemoveCommand.cpp

示例7: KUndo2Command

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();
}
开发者ID:IGLOU-EU,项目名称:krita,代码行数:12,代码来源:kis_scalar_keyframe_channel.cpp

示例8: it

void KUndo2Command::redoMergedCommands()
{
    if (!mergeCommandsVector().isEmpty()) {

        QVectorIterator<KUndo2Command*> it(mergeCommandsVector());
        it.toBack();
        while (it.hasPrevious()) {
            KUndo2Command* cmd = it.previous();
            cmd->redoMergedCommands();
        }
    }
    redo();
}
开发者ID:KDE,项目名称:calligra,代码行数:13,代码来源:kundo2stack.cpp

示例9: undo

void KUndo2Command::undoMergedCommands()
{

    undo();
    if (!mergeCommandsVector().isEmpty()) {
        QVectorIterator<KUndo2Command*> it(mergeCommandsVector());
        it.toFront();
        while (it.hasNext()) {
            KUndo2Command* cmd = it.next();
            cmd->undoMergedCommands();
        }
    }
}
开发者ID:KDE,项目名称:calligra,代码行数:13,代码来源:kundo2stack.cpp

示例10: KoPathShape

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;
}
开发者ID:abhishekmurthy,项目名称:Calligra,代码行数:47,代码来源:TestPointRemoveCommand.cpp

示例11: QPoint

void KisPasteActionFactory::run(KisView2 *view)
{
    KisImageWSP image = view->image();

    //figure out where to position the clip
    // XXX: Fix this for internal points & zoom! (BSAR)
    QWidget * w = view->canvas();
    QPoint center = QPoint(w->width() / 2, w->height() / 2);
    QPoint bottomright = QPoint(w->width(), w->height());
    if (bottomright.x() > image->width())
        center.setX(image->width() / 2);
    if (bottomright.y() > image->height())
        center.setY(image->height() / 2);

    const KoCanvasBase* canvasBase = view->canvasBase();
    const KoViewConverter* viewConverter = view->canvasBase()->viewConverter();

    KisPaintDeviceSP clip = KisClipboard::instance()->clip(
        QPoint(
            viewConverter->viewToDocumentX(canvasBase->canvasController()->canvasOffsetX()) + center.x(),
            viewConverter->viewToDocumentY(canvasBase->canvasController()->canvasOffsetY()) + center.y()));

    if (clip) {
        // Pasted layer content could be outside image bounds and invisible, if that is the case move content into the bounds
        QRect exactBounds = clip->exactBounds();
        if (!exactBounds.isEmpty() && !exactBounds.intersects(image->bounds())) {
            clip->setX(clip->x() - exactBounds.x());
            clip->setY(clip->y() - exactBounds.y());
        }

        KisPaintLayer *newLayer = new KisPaintLayer(image.data(), image->nextLayerName() + i18n("(pasted)"), OPACITY_OPAQUE_U8, clip);
        KisNodeSP aboveNode = view->activeLayer();
        KisNodeSP parentNode = aboveNode ? aboveNode->parent() : image->root();

        KUndo2Command *cmd = new KisImageLayerAddCommand(image, newLayer, parentNode, aboveNode);
        KisProcessingApplicator *ap = beginAction(view, cmd->text());
        ap->applyCommand(cmd, KisStrokeJobData::SEQUENTIAL, KisStrokeJobData::NORMAL);
        endAction(ap, KisOperationConfiguration(id()).toXML());
    } else {
#ifdef __GNUC__
#warning "Add saving of XML data for Paste of shapes"
#endif

        view->canvasBase()->toolProxy()->paste();
    }
}
开发者ID:abhishekmurthy,项目名称:Calligra,代码行数:46,代码来源:kis_selection_action_factories.cpp

示例12: indexChanged

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);
        }
    }
}
开发者ID:abhishekmurthy,项目名称:Calligra,代码行数:44,代码来源:kundo2stack.cpp

示例13: KisPaintLayer

void KisPasteActionFactory::run(KisViewManager *view)
{
    KisImageWSP image = view->image();
    if (!image) return;

    KisPaintDeviceSP clip = KisClipboard::instance()->clip(image->bounds(), true);

    if (clip) {
        KisPaintLayer *newLayer = new KisPaintLayer(image.data(), image->nextLayerName() + i18n("(pasted)"), OPACITY_OPAQUE_U8, clip);
        KisNodeSP aboveNode = view->activeLayer();
        KisNodeSP parentNode = aboveNode ? aboveNode->parent() : image->root();

        KUndo2Command *cmd = new KisImageLayerAddCommand(image, newLayer, parentNode, aboveNode);
        KisProcessingApplicator *ap = beginAction(view, cmd->text());
        ap->applyCommand(cmd, KisStrokeJobData::SEQUENTIAL, KisStrokeJobData::NORMAL);
        endAction(ap, KisOperationConfiguration(id()).toXML());
    } else {
        // XXX: "Add saving of XML data for Paste of shapes"
        view->canvasBase()->toolProxy()->paste();
    }
}
开发者ID:hshrimali,项目名称:krita,代码行数:21,代码来源:kis_selection_action_factories.cpp

示例14: KUndo2Command

void KUndo2QStack::beginMacro(const KUndo2MagicString &text)
{
    KUndo2Command *cmd = new KUndo2Command();
    cmd->setText(text);

    if (m_macro_stack.isEmpty()) {
        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
        m_command_list.append(cmd);
    } else {
        m_macro_stack.last()->d->child_list.append(cmd);
    }
    m_macro_stack.append(cmd);

    if (m_macro_stack.count() == 1) {
        emit canUndoChanged(false);
        emit undoTextChanged(QString());
        emit canRedoChanged(false);
        emit redoTextChanged(QString());
    }
}
开发者ID:KDE,项目名称:calligra,代码行数:23,代码来源:kundo2stack.cpp

示例15: KoTextDocument

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);
    }
}
开发者ID:abhishekmurthy,项目名称:Calligra,代码行数:37,代码来源:ShowChangesCommand.cpp


注:本文中的KUndo2Command类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。