本文整理汇总了C++中QUndoCommand::id方法的典型用法代码示例。如果您正苦于以下问题:C++ QUndoCommand::id方法的具体用法?C++ QUndoCommand::id怎么用?C++ QUndoCommand::id使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QUndoCommand
的用法示例。
在下文中一共展示了QUndoCommand::id方法的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());
}
示例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);
}
}
}
示例3: sipIsDerived
static PyObject *meth_QUndoCommand_id(PyObject *sipSelf, PyObject *sipArgs)
{
PyObject *sipParseErr = NULL;
bool sipSelfWasArg = (!sipSelf || sipIsDerived((sipSimpleWrapper *)sipSelf));
{
QUndoCommand *sipCpp;
if (sipParseArgs(&sipParseErr, sipArgs, "B", &sipSelf, sipType_QUndoCommand, &sipCpp))
{
int sipRes;
Py_BEGIN_ALLOW_THREADS
sipRes = (sipSelfWasArg ? sipCpp->QUndoCommand::id() : sipCpp->id());
Py_END_ALLOW_THREADS
return SIPLong_FromLong(sipRes);
}
}