1 /* 2 * reparentlayers.h 3 * Copyright 2017, Thorbjørn Lindeijer <bjorn@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 #include <QVector> 25 26 namespace Tiled { 27 28 class GroupLayer; 29 class Layer; 30 31 class MapDocument; 32 33 /** 34 * Undo command that changes the parent or index of a given set of layers. 35 */ 36 class ReparentLayers : public QUndoCommand 37 { 38 public: 39 ReparentLayers(MapDocument *mapDocument, 40 const QList<Layer *> &layers, 41 GroupLayer *layerParent, 42 int index, 43 QUndoCommand *parent = nullptr); 44 45 void undo() override; 46 void redo() override; 47 48 private: 49 MapDocument * const mMapDocument; 50 QList<Layer *> mLayers; 51 GroupLayer * const mLayerParent; 52 int const mIndex; 53 54 struct UndoInfo { 55 GroupLayer *parent; 56 int oldIndex; 57 }; 58 QVector<UndoInfo> mUndoInfo; 59 }; 60 61 } // namespace Tiled 62