コード例 #1
0
ファイル: CUndoRedo.cpp プロジェクト: banduladh/levelfour
QString CUndoRedoStack::redoText() const
{
    QUndoCommand* topCmd = d->redoStack.count() ? d->redoStack.top() : 0;
    if(topCmd)
        return topCmd->text();

    return QString();
}
コード例 #2
0
ファイル: CUndoRedo.cpp プロジェクト: banduladh/levelfour
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
0
ファイル: tilesetdock.cpp プロジェクト: Shorttail/tiled
/**
 * 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();
}