QGIS API Documentation  2.99.0-Master (19b062c)
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 
33 class CORE_EXPORT QgsComposerMultiFrameCommand: public QUndoCommand
34 {
35  public:
36  QgsComposerMultiFrameCommand( QgsComposerMultiFrame *multiFrame, const QString &text, QUndoCommand *parent SIP_TRANSFERTHIS = 0 );
37 
38  void undo() override;
39  void redo() override;
40 
41  void savePreviousState();
42  void saveAfterState();
43 
44  QDomDocument previousState() const { return mPreviousState.cloneNode().toDocument(); }
45  QDomDocument afterState() const { return mAfterState.cloneNode().toDocument(); }
46 
48  bool containsChange() const;
49 
50  const QgsComposerMultiFrame *multiFrame() const { return mMultiFrame; }
51 
52  protected:
53  QgsComposerMultiFrame *mMultiFrame = nullptr;
54 
55  QDomDocument mPreviousState;
56  QDomDocument mAfterState;
57 
58  bool mFirstRun = false;
59 
60  QgsComposerMultiFrameCommand(); //forbidden
61  void saveState( QDomDocument &stateDoc );
62  void restoreState( QDomDocument &stateDoc );
63  bool checkFirstRun();
64 };
65 
72 {
73  public:
74  enum Context
75  {
76  Unknown = 0,
77  //composer html
81  //attribute table
90  };
91 
92  QgsComposerMultiFrameMergeCommand( Context c, QgsComposerMultiFrame *multiFrame, const QString &text );
93 
94  bool mergeWith( const QUndoCommand *command ) override;
95  int id() const override { return static_cast< int >( mContext ); }
96 
97  private:
98  Context mContext;
99 };
100 
101 #endif // QGSCOMPOSERMULTIFRAMECOMMAND_H
#define SIP_TRANSFERTHIS
Definition: qgis_sip.h:46
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...