1 /*
2  * changetileprobability.h
3  * Copyright 2015, Thorbjørn Lindeijer <thorbjorn@lindeijer.nl>
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 <QUndoCommand>
24 
25 namespace Tiled {
26 
27 class Tile;
28 
29 class TilesetDocument;
30 
31 class ChangeTileProbability : public QUndoCommand
32 {
33 public:
34     ChangeTileProbability(TilesetDocument *tilesetDocument,
35                           const QList<Tile*> &tiles,
36                           qreal probability);
37 
38     ChangeTileProbability(TilesetDocument *tilesetDocument,
39                           const QList<Tile*> &tiles,
40                           const QList<qreal> &probabilities,
41                           QUndoCommand *parent = nullptr);
42 
undo()43     void undo() override { swap(); }
redo()44     void redo() override { swap(); }
45 
46 private:
47     void swap();
48 
49     TilesetDocument *mTilesetDocument;
50     QList<Tile*> mTiles;
51     QList<qreal> mProbabilities;
52 };
53 
54 } // namespace Tiled
55