1 /* 2 * swaptiles.h 3 * Copyright 2015, Alexander "theHacker" Münch <git@thehacker.biz> 4 * 5 * This file is part of Tiled. 6 * 7 * This program is free software; you can redistribute it and/or modify it 8 * under the terms of the GNU General Public License as published by the Free 9 * Software Foundation; either version 2 of the License, or (at your option) 10 * any later version. 11 * 12 * This program is distributed in the hope that it will be useful, but WITHOUT 13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 15 * more details. 16 * 17 * You should have received a copy of the GNU General Public License along with 18 * this program. If not, see <http://www.gnu.org/licenses/>. 19 */ 20 21 #pragma once 22 23 #include "undocommands.h" 24 25 #include <QUndoCommand> 26 27 namespace Tiled { 28 29 class Tile; 30 31 class MapDocument; 32 33 /** 34 * A command that swaps two tiles on the map. 35 */ 36 class SwapTiles : public QUndoCommand 37 { 38 public: 39 /** 40 * Constructor. 41 * 42 * @param mapDocument the map document that's being edited 43 * @param tile1 the first tile 44 * @param tile2 the second tile 45 */ 46 SwapTiles(MapDocument *mapDocument, 47 Tile *tile1, 48 Tile *tile2); 49 undo()50 void undo() { swap(); } redo()51 void redo() { swap(); } 52 53 private: 54 void swap(); 55 56 MapDocument *mMapDocument; 57 Tile *mTile1; 58 Tile *mTile2; 59 }; 60 61 } // namespace Tiled 62