QGIS API Documentation  2.99.0-Master (b698612)
qgscomposermultiframecommand.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgscomposermultiframecommand.h
3  ------------------------------
4  begin : 2012-08-02
5  copyright : (C) 2012 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 QGSCOMPOSERMULTIFRAMECOMMAND_H
19 #define QGSCOMPOSERMULTIFRAMECOMMAND_H
20 
21 #include <QUndoCommand>
22 #include "qgis.h"
23 #include <QDomDocument>
24 
25 #include "qgis_core.h"
26 
28 
32 class CORE_EXPORT QgsComposerMultiFrameCommand: public QUndoCommand
33 {
34  public:
35  QgsComposerMultiFrameCommand( QgsComposerMultiFrame *multiFrame, const QString &text, QUndoCommand *parent SIP_TRANSFERTHIS = 0 );
36 
37  void undo() override;
38  void redo() override;
39 
40  void savePreviousState();
41  void saveAfterState();
42 
43  QDomDocument previousState() const { return mPreviousState.cloneNode().toDocument(); }
44  QDomDocument afterState() const { return mAfterState.cloneNode().toDocument(); }
45 
47  bool containsChange() const;
48 
49  const QgsComposerMultiFrame *multiFrame() const { return mMultiFrame; }
50 
51  protected:
52  QgsComposerMultiFrame *mMultiFrame = nullptr;
53 
54  QDomDocument mPreviousState;
55  QDomDocument mAfterState;
56 
57  bool mFirstRun;
58 
59  QgsComposerMultiFrameCommand(); //forbidden
60  void saveState( QDomDocument &stateDoc );
61  void restoreState( QDomDocument &stateDoc );
62  bool checkFirstRun();
63 };
64 
70 {
71  public:
72  enum Context
73  {
74  Unknown = 0,
75  //composer html
79  //attribute table
88  };
89 
90  QgsComposerMultiFrameMergeCommand( Context c, QgsComposerMultiFrame *multiFrame, const QString &text );
91 
92  bool mergeWith( const QUndoCommand *command ) override;
93  int id() const override { return static_cast< int >( mContext ); }
94 
95  private:
96  Context mContext;
97 };
98 
99 #endif // QGSCOMPOSERMULTIFRAMECOMMAND_H
#define SIP_TRANSFERTHIS
Definition: qgis_sip.h:34
const QgsComposerMultiFrame * multiFrame() const
Abstract base class for composer items with the ability to distribute the content to several frames (...
A composer command that merges together with other commands having the same context (=id) for multi f...