QGIS API Documentation  2.99.0-Master (0a63d1f)
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 #include "qgis_core.h"
25 
26 class QgsComposerItem;
28 
32 class CORE_EXPORT QgsComposerItemCommand: public QUndoCommand
33 {
34  public:
35  QgsComposerItemCommand( QgsComposerItem* item, const QString& text, QUndoCommand* parent = nullptr );
36 
38  void undo() override;
40  void redo() override;
41 
43  void savePreviousState();
45  void saveAfterState();
46 
47  QDomDocument previousState() const { return mPreviousState.cloneNode().toDocument(); }
48  QDomDocument afterState() const { return mAfterState.cloneNode().toDocument(); }
49 
51  bool containsChange() const;
52 
56  QgsComposerItem *item() const;
57 
58  protected:
62  QDomDocument mPreviousState;
64  QDomDocument mAfterState;
65 
70 
72  bool mFirstRun;
73 
74  void saveState( QDomDocument& stateDoc ) const;
75  void restoreState( QDomDocument& stateDoc ) const;
76 };
77 
83 {
84  public:
85  enum Context
86  {
87  Unknown = 0,
88  //composer label
92  //composer map
99  //composer legend
119  //composer picture
124  // composer scalebar
138  // composer table
142  //composer shape
145  //composer arrow
150  //item
157  ItemZoomContent
158  };
159 
160  QgsComposerMergeCommand( Context c, QgsComposerItem* item, const QString& text );
161 
162  bool mergeWith( const QUndoCommand * command ) override;
163  int id() const override { return static_cast< int >( mContext ); }
164 
165  private:
166  Context mContext;
167 };
168 
169 #endif // QGSCOMPOSERITEMCOMMAND_H
QDomDocument afterState() const
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 mPreviousState
XML that saves the state before executing the command.