QGIS API Documentation  2.18.21-Las Palmas (9fba24a)
qgsaddremoveitemcommand.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsaddremoveitemcommand.h
3  ------------------------
4  begin : 2010-11-27
5  copyright : (C) 2010 by Marco Hugentobler
6  email : marco dot hugentobler at sourcepole dot ch
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 QGSADDREMOVEITEMCOMMAND_H
19 #define QGSADDREMOVEITEMCOMMAND_H
20 
21 #include <QUndoCommand>
22 class QgsComposerItem;
23 class QgsComposition;
24 
28 class CORE_EXPORT QgsAddRemoveItemCommand: public QObject, public QUndoCommand
29 {
30  Q_OBJECT
31 
32  public:
33 
34  enum State
35  {
36  Added = 0,
37  Removed
38  };
39 
40  QgsAddRemoveItemCommand( State s, QgsComposerItem* item, QgsComposition* c, const QString& text, QUndoCommand* parent = nullptr );
42 
43  void redo() override;
44  void undo() override;
45 
46  signals:
47  void itemAdded( QgsComposerItem* item );
48  void itemRemoved( QgsComposerItem* item );
49 
50  private:
51  QgsComposerItem* mItem;
52  QgsComposition* mComposition;
53  State mState;
54  bool mFirstRun; //flag to prevent execution when the command is pushed to the QUndoStack
55 
56  //changes between added / removed state
57  void switchState();
58 };
59 
60 #endif // QGSADDREMOVEITEMCOMMAND_H
A item that forms part of a map composition.
virtual void redo()
Graphics scene for map printing.
virtual void undo()
A composer command class for adding / removing composer items.