本文整理汇总了C++中UndoManager::action方法的典型用法代码示例。如果您正苦于以下问题:C++ UndoManager::action方法的具体用法?C++ UndoManager::action怎么用?C++ UndoManager::action使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UndoManager
的用法示例。
在下文中一共展示了UndoManager::action方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: commit
bool UndoTransaction::commit()
{
if (!m_data)
return false;
TransactionData* data = static_cast<TransactionData*>(m_data.data());
UndoManager* UM = data->UM;
int stackLevel = data->stackLevel;
if (!UM->undoEnabled_)
{
cancel();
return false;
}
UndoObject *tmpu = UM->transactions_.at(stackLevel)->transactionObject;
TransactionState *tmps = UM->transactions_.at(stackLevel)->transactionState;
switch (m_data->m_status)
{
case Transaction::STATE_OPEN:
// qDebug() << "UndoManager::commitTransaction" << data << data->transactionObject->getUName() << data->transactionState->getName() << stackLevel;
m_data->m_status = Transaction::STATE_COMMITTED;
// brutal for now:
assert (stackLevel + 1 == signed(UM->transactions_.size()));
if (stackLevel < signed(UM->transactions_.size()))
{
UM->transactions_.erase(UM->transactions_.begin() + stackLevel);
}
if (tmps->sizet() > 0) // are there any actions inside the committed transaction
{
if (tmps->getName().isEmpty())
tmps->useActionName();
UM->action(tmpu, tmps);
} // if not just delete objects
else
{
delete tmpu;
tmpu = 0;
delete tmps;
tmps = 0;
}
return true;
break;
case STATE_WILLFAIL:
return cancel();
break;
default:
// qDebug() << "UndoManager::commitTransaction ** already closed **";
// nothing
break;
}
return false;
}
示例2: run
bool PathFinderPlugin::run(ScribusDoc* doc, QString)
{
ScribusDoc* currDoc = doc;
if (currDoc == 0)
currDoc = ScCore->primaryMainWindow()->doc;
if (currDoc->m_Selection->count() <= 1)
return true;
//<<#9046
UndoTransaction* activeTransaction = NULL;
UndoManager* undoManager = UndoManager::instance();
if (UndoManager::undoEnabled())
activeTransaction = new UndoTransaction(undoManager->beginTransaction(Um::SelectionGroup, Um::IDocument, Um::PathOperation, "", Um::IPolygon));
//>>#9046
PageItem *Item1 = currDoc->m_Selection->itemAt(0);
PageItem *Item2 = currDoc->m_Selection->itemAt(1);
PathFinderDialog *dia = new PathFinderDialog(currDoc->scMW(), currDoc, Item1, Item2);
if (dia->exec())
{
int opMode=dia->opMode;
if (dia->keepItem1)
{
PageItem *newItem;
if (dia->swapped)
{
newItem = new PageItem_Polygon(*Item2);
newItem->setSelected(false);
currDoc->Items->insert(currDoc->Items->indexOf(Item2), newItem);
}
else
{
newItem = new PageItem_Polygon(*Item1);
newItem->setSelected(false);
currDoc->Items->insert(currDoc->Items->indexOf(Item1), newItem);
}
if (UndoManager::undoEnabled())
{
ScItemState<PageItem*> *is = new ScItemState<PageItem*>("Create PageItem");
is->set("CREATE_ITEM", "create_item");
is->setItem(newItem);
UndoObject *target = currDoc->Pages->at(Item1->OwnPage);
undoManager->action(target, is);
}
}
if (dia->keepItem2)
{
PageItem *newItem;
if (dia->swapped)
{
newItem = new PageItem_Polygon(*Item1);
newItem->setSelected(false);
currDoc->Items->insert(currDoc->Items->indexOf(Item1), newItem);
}
else
{
newItem = new PageItem_Polygon(*Item2);
newItem->setSelected(false);
currDoc->Items->insert(currDoc->Items->indexOf(Item2), newItem);
}
if (UndoManager::undoEnabled())
{
ScItemState<PageItem*> *is = new ScItemState<PageItem*>("Create PageItem");
is->set("CREATE_ITEM", "create_item");
is->setItem(newItem);
UndoObject *target = currDoc->Pages->at(Item1->OwnPage);
undoManager->action(target, is);
}
}
if (opMode != 4)
{
PageItem *currItem;
QPainterPath path;
FPointArray points;
if (dia->targetColor == 0)
{
currItem = Item1;
if (dia->swapped)
{
currItem = Item2;
currItem->setXYPos(Item1->xPos(), Item1->yPos());
currItem->setRotation(0.0);
}
}
else
{
if (dia->swapped)
currItem = Item1;
else
{
currItem = Item2;
currItem->setXYPos(Item1->xPos(), Item1->yPos());
currItem->setRotation(0.0);
}
}
path = dia->result;
points.fromQPainterPath(path);
//<<#9046
FPointArray oldPOLine=currItem->PoLine;
//.........这里部分代码省略.........