QGIS API Documentation  2.99.0-Master (f1c3692)
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 "qgis.h"
23 #include <QDomDocument>
24 
25 #include "qgis_core.h"
26 
27 class QgsComposerItem;
29 
34 class CORE_EXPORT QgsComposerItemCommand: public QUndoCommand
35 {
36  public:
37  QgsComposerItemCommand( QgsComposerItem *item, const QString &text, QUndoCommand *parent SIP_TRANSFERTHIS = 0 );
38 
40  void undo() override;
42  void redo() override;
43 
45  void savePreviousState();
47  void saveAfterState();
48 
49  QDomDocument previousState() const { return mPreviousState.cloneNode().toDocument(); }
50  QDomDocument afterState() const { return mAfterState.cloneNode().toDocument(); }
51 
53  bool containsChange() const;
54 
59  QgsComposerItem *item() const;
60 
61  protected:
63  QgsComposerItem *mItem = nullptr;
65  QDomDocument mPreviousState;
67  QDomDocument mAfterState;
68 
73  QgsComposerMultiFrame *mMultiFrame = nullptr;
75 
77  bool mFirstRun;
78 
79  void saveState( QDomDocument &stateDoc ) const;
80  void restoreState( QDomDocument &stateDoc ) const;
81 };
82 
89 {
90  public:
91  enum Context
92  {
93  Unknown = 0,
94  //composer label
98  //composer map
105  //composer legend
125  //composer picture
130  // composer scalebar
144  // composer table
148  //composer shape
151  //composer arrow
156  //item
163  ItemZoomContent
164  };
165 
166  QgsComposerMergeCommand( Context c, QgsComposerItem *item, const QString &text );
167 
168  bool mergeWith( const QUndoCommand *command ) override;
169  int id() const override { return static_cast< int >( mContext ); }
170 
171  private:
172  Context mContext;
173 };
174 
175 #endif // QGSCOMPOSERITEMCOMMAND_H
#define SIP_TRANSFERTHIS
Definition: qgis_sip.h:46
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.
QDomDocument mPreviousState
XML that saves the state before executing the command.