QGIS API Documentation  2.99.0-Master (c558d51)
qgscomposeritemcommand.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgscomposeritemcommand.h
3  ------------------------
4  begin : 2010-11-18
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 QGSCOMPOSERITEMCOMMAND_H
19 #define QGSCOMPOSERITEMCOMMAND_H
20 
21 #include <QUndoCommand>
22 #include <QDomDocument>
23 
24 class QgsComposerItem;
26 
30 class CORE_EXPORT QgsComposerItemCommand: public QUndoCommand
31 {
32  public:
33  QgsComposerItemCommand( QgsComposerItem* item, const QString& text, QUndoCommand* parent = nullptr );
34  virtual ~QgsComposerItemCommand();
35 
37  void undo() override;
39  void redo() override;
40 
42  void savePreviousState();
44  void saveAfterState();
45 
46  QDomDocument previousState() const { return mPreviousState.cloneNode().toDocument(); }
47  QDomDocument afterState() const { return mAfterState.cloneNode().toDocument(); }
48 
50  bool containsChange() const;
51 
55  QgsComposerItem *item() const;
56 
57  protected:
61  QDomDocument mPreviousState;
63  QDomDocument mAfterState;
64 
69 
71  bool mFirstRun;
72 
73  void saveState( QDomDocument& stateDoc ) const;
74  void restoreState( QDomDocument& stateDoc ) const;
75 };
76 
82 {
83  public:
84  enum Context
85  {
86  Unknown = 0,
87  //composer label
91  //composer map
98  //composer legend
117  //composer picture
122  // composer scalebar
136  // composer table
140  //composer shape
143  //composer arrow
148  //item
155  ItemZoomContent
156  };
157 
158  QgsComposerMergeCommand( Context c, QgsComposerItem* item, const QString& text );
160 
161  bool mergeWith( const QUndoCommand * command ) override;
162  int id() const override { return static_cast< int >( mContext ); }
163 
164  private:
165  Context mContext;
166 };
167 
168 #endif // QGSCOMPOSERITEMCOMMAND_H
A item that forms part of a map composition.
A composer command that merges together with other commands having the same context (=id)...
QDomDocument previousState() const
Abstract base class for composer items with the ability to distribute the content to several frames (...
bool mFirstRun
Flag to prevent the first redo() if the command is pushed to the undo stack.
Undo command to undo/redo all composer item related changes.
QDomDocument mAfterState
XML containing the state after executing the command.
QgsComposerItem * mItem
Target item of the command.
QgsComposerMultiFrame * mMultiFrame
Parameters for frame items Parent multiframe.
QDomDocument afterState() const
QDomDocument mPreviousState
XML that saves the state before executing the command.