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


C++ QUndoCommand::mergeWith方法代码示例

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


在下文中一共展示了QUndoCommand::mergeWith方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: push

void CUndoRedoStack::push(QUndoCommand* cmd)
{
    if(!cmd)
        return;

    // First register the undo command into the undo stack.
    QUndoCommand* topCmd = d->undoStack.count() ? d->undoStack.top() : 0;
    if(!topCmd)
    {
        d->undoStack.push(cmd);
        CUndoRedoCmdBase* cmd2 = dynamic_cast<CUndoRedoCmdBase*>(cmd);
        if(cmd2)
            addCommand(cmd2);
    }
    else
    {
        if(topCmd->id() == cmd->id())
        {
            bool success = topCmd->mergeWith(cmd);
            if(!success)
            {
                d->undoStack.push(cmd);
                CUndoRedoCmdBase* cmd2 = dynamic_cast<CUndoRedoCmdBase*>(cmd);
                if(cmd2)
                    addCommand(cmd2);
            }
            else
                delete cmd;
        }
    }

    // Now clear the redo stack.
    for(int i=0; i<d->redoStack.count(); i++)
    {
        QUndoCommand* cmd = d->redoStack.pop();
        CUndoRedoCmdBase* cmd2 = dynamic_cast<CUndoRedoCmdBase*>(cmd);
        if(cmd2)
            removeCommand(cmd2);
        delete cmd;
    }

    // emit change notifications.
    emit canUndoChanged(d->undoStack.count());
    emit canRedoChanged(d->redoStack.count());
    emit countChanged(count());
}
开发者ID:banduladh,项目名称:levelfour,代码行数:46,代码来源:CUndoRedo.cpp

示例2: push

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);
        }
    }
}
开发者ID:2gis,项目名称:2gisqt5android,代码行数:45,代码来源:qundostack.cpp

示例3: sipIsDerived

static PyObject *meth_QUndoCommand_mergeWith(PyObject *sipSelf, PyObject *sipArgs)
{
    PyObject *sipParseErr = NULL;
    bool sipSelfWasArg = (!sipSelf || sipIsDerived((sipSimpleWrapper *)sipSelf));

    {
        const QUndoCommand* a0;
        QUndoCommand *sipCpp;

        if (sipParseArgs(&sipParseErr, sipArgs, "BJ8", &sipSelf, sipType_QUndoCommand, &sipCpp, sipType_QUndoCommand, &a0))
        {
            bool sipRes;

            sipRes = (sipSelfWasArg ? sipCpp->QUndoCommand::mergeWith(a0) : sipCpp->mergeWith(a0));

            return PyBool_FromLong(sipRes);
        }
    }

    /* Raise an exception if the arguments couldn't be parsed. */
    sipNoMethod(sipParseErr, sipName_QUndoCommand, sipName_mergeWith, doc_QUndoCommand_mergeWith);

    return NULL;
}
开发者ID:rff255,项目名称:python-qt5,代码行数:24,代码来源:sipQtWidgetsQUndoCommand.cpp


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