QGIS API Documentation  2.14.11-Essen
qgsgroupungroupitemscommand.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsgroupungroupitemscommand.h
3  ------------------------
4  begin : 2016-06-09
5  copyright : (C) 2016 by Sandro Santilli
6  email : strk at kbt dot io
7 ***************************************************************************/
8 
9 /***************************************************************************
10  * *
11  * This program is free software; you can redistribute it and/or modify *
12  * it under the terms of the GNU General Public License as published by *
13  * the Free Software Foundation; either version 2 of the License, or *
14  * (at your option) any later version. *
15  * *
16  ***************************************************************************/
17 
18 #ifndef QGSGROUPUNGROUPITEMSCOMMAND_H
19 #define QGSGROUPUNGROUPITEMSCOMMAND_H
20 
21 #include <QUndoCommand>
22 #include "qgscomposeritemgroup.h"
23 class QgsComposerItem;
24 class QgsComposition;
25 
30 class CORE_EXPORT QgsGroupUngroupItemsCommand: public QObject, public QUndoCommand
31 {
32  Q_OBJECT
33 
34  public:
35 
37  enum State
38  {
39  Grouped = 0,
40  Ungrouped
41  };
42 
52  QgsGroupUngroupItemsCommand( State s, QgsComposerItemGroup* item, QgsComposition* c, const QString& text, QUndoCommand* parent = nullptr );
54 
55  void redo() override;
56  void undo() override;
57 
58  signals:
60  void itemAdded( QgsComposerItem* item );
62  void itemRemoved( QgsComposerItem* item );
63 
64  private:
65  QgsComposerItemGroup* mGroup;
67  QgsComposition* mComposition;
68  State mState;
69  bool mFirstRun; //flag to prevent execution when the command is pushed to the QUndoStack
70 
71  //changes between added / removed state
72  void switchState();
73 };
74 
75 #endif // QGSGROUPUNGROUPITEMSCOMMAND_H
A item that forms part of a map composition.
A container for grouping several QgsComposerItems.
virtual void redo()
Graphics scene for map printing.
A composer command class for grouping / ungrouping composer items.
virtual void undo()