本文整理汇总了C++中QUndoCommand::text方法的典型用法代码示例。如果您正苦于以下问题:C++ QUndoCommand::text方法的具体用法?C++ QUndoCommand::text怎么用?C++ QUndoCommand::text使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QUndoCommand
的用法示例。
在下文中一共展示了QUndoCommand::text方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: redoText
QString CUndoRedoStack::redoText() const
{
QUndoCommand* topCmd = d->redoStack.count() ? d->redoStack.top() : 0;
if(topCmd)
return topCmd->text();
return QString();
}
示例2: redo
void CUndoRedoStack::redo()
{
QUndoCommand* topCmd = d->redoStack.count() ? d->redoStack.pop() : 0;
if(!topCmd)
return;
QString cmdText = topCmd->text();
topCmd->redo();
d->undoStack.push(topCmd);
qWarning("Redo: %s", qPrintable(cmdText));
// emit change notifications.
emit redone(cmdText);
emit canUndoChanged(d->undoStack.count());
emit canRedoChanged(d->redoStack.count());
}
示例3: removeTileset
/**
* Removes the tileset at the given index. Prompting the user when the tileset
* is in use by the map.
*/
void TilesetDock::removeTileset(int index)
{
auto &sharedTileset = mTilesets.at(index);
int mapTilesetIndex = mMapDocument->map()->tilesets().indexOf(sharedTileset);
if (mapTilesetIndex == -1)
return;
Tileset *tileset = sharedTileset.data();
const bool inUse = mMapDocument->map()->isTilesetUsed(tileset);
// If the tileset is in use, warn the user and confirm removal
if (inUse) {
QMessageBox warning(QMessageBox::Warning,
tr("Remove Tileset"),
tr("The tileset \"%1\" is still in use by the "
"map!").arg(tileset->name()),
QMessageBox::Yes | QMessageBox::No,
this);
warning.setDefaultButton(QMessageBox::Yes);
warning.setInformativeText(tr("Remove this tileset and all references "
"to the tiles in this tileset?"));
if (warning.exec() != QMessageBox::Yes)
return;
}
QUndoCommand *remove = new RemoveTileset(mMapDocument, mapTilesetIndex);
QUndoStack *undoStack = mMapDocument->undoStack();
if (inUse) {
// Remove references to tiles in this tileset from the current map
auto referencesTileset = [tileset] (const Cell &cell) {
return cell.tileset() == tileset;
};
undoStack->beginMacro(remove->text());
removeTileReferences(mMapDocument, referencesTileset);
}
undoStack->push(remove);
if (inUse)
undoStack->endMacro();
}