bool ChangeTileTerrain::mergeWith(const QUndoCommand *other) {
    if (!mMergeable)
        return false;

    const ChangeTileTerrain *o = static_cast<const ChangeTileTerrain*>(other);
    if (o->mMapEditor && !(mMapEditor == o->mMapEditor &&
                             mTileset == o->mTileset))
        return false;

    Changes::const_iterator i = o->mChanges.constBegin();
    Changes::const_iterator i_end = o->mChanges.constEnd();
    while (i != i_end) {
        Tile *tile = i.key();
        const Change &change = i.value();

        if (mChanges.contains(tile))
            mChanges[tile].to = change.to;
        else
            mChanges.insert(tile, change);

        ++i;
    }

    mMergeable = o->mMergeable;

    return true;
}
Beispiel #2
0
bool ChangeTileTerrain::mergeWith(const QUndoCommand *other)
{
    if (!mMergeable)
        return false;

    const ChangeTileTerrain *o = static_cast<const ChangeTileTerrain*>(other);
    if (o->mTilesetDocument && !(mTilesetDocument == o->mTilesetDocument &&
                             mTileset == o->mTileset))
        return false;

    Changes::const_iterator i = o->mChanges.constBegin();
    Changes::const_iterator i_end = o->mChanges.constEnd();
    while (i != i_end) {
        Tile *tile = i.key();
        const Change &change = i.value();

        Changes::iterator tileChange = mChanges.find(tile);
        if (tileChange != mChanges.end())
            tileChange->to = change.to;
        else
            mChanges.insert(tile, change);

        ++i;
    }

    mMergeable = o->mMergeable;

    return true;
}
void ChangeTileTerrain::redo() {
    Changes::const_iterator i = mChanges.constBegin();

    QList<Tile *> changedTiles;
#if QT_VERSION >= 0x040700
    changedTiles.reserve(mChanges.size());
#endif

    while (i != mChanges.constEnd()) {
        Tile *tile = i.key();
        const Change &change = i.value();

        tile->setTerrain(change.to);
        changedTiles.append(tile);

        ++i;
    }

    mMapEditor->emitTileTerrainChanged(changedTiles);
}
Beispiel #4
0
void ChangeTileTerrain::redo()
{
    if (mChanges.isEmpty())
        return;

    Changes::const_iterator i = mChanges.constBegin();

    QList<Tile *> changedTiles;
    changedTiles.reserve(mChanges.size());

    while (i != mChanges.constEnd()) {
        Tile *tile = i.key();
        const Change &change = i.value();

        tile->setTerrain(change.to);
        changedTiles.append(tile);

        ++i;
    }

    emit mTilesetDocument->tileTerrainChanged(changedTiles);
}