QGIS API Documentation  2.99.0-Master (716ff6c)
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 <QDomDocument>
23 
24 #include "qgis_core.h"
25 
27 
31 class CORE_EXPORT QgsComposerMultiFrameCommand: public QUndoCommand
32 {
33  public:
34  QgsComposerMultiFrameCommand( QgsComposerMultiFrame *multiFrame, const QString &text, QUndoCommand *parent = nullptr );
35 
36  void undo() override;
37  void redo() override;
38 
39  void savePreviousState();
40  void saveAfterState();
41 
42  QDomDocument previousState() const { return mPreviousState.cloneNode().toDocument(); }
43  QDomDocument afterState() const { return mAfterState.cloneNode().toDocument(); }
44 
46  bool containsChange() const;
47 
48  const QgsComposerMultiFrame *multiFrame() const { return mMultiFrame; }
49 
50  protected:
51  QgsComposerMultiFrame *mMultiFrame = nullptr;
52 
53  QDomDocument mPreviousState;
54  QDomDocument mAfterState;
55 
56  bool mFirstRun;
57 
58  QgsComposerMultiFrameCommand(); //forbidden
59  void saveState( QDomDocument &stateDoc );
60  void restoreState( QDomDocument &stateDoc );
61  bool checkFirstRun();
62 };
63 
69 {
70  public:
71  enum Context
72  {
73  Unknown = 0,
74  //composer html
78  //attribute table
87  };
88 
89  QgsComposerMultiFrameMergeCommand( Context c, QgsComposerMultiFrame *multiFrame, const QString &text );
90 
91  bool mergeWith( const QUndoCommand *command ) override;
92  int id() const override { return static_cast< int >( mContext ); }
93 
94  private:
95  Context mContext;
96 };
97 
98 #endif // QGSCOMPOSERMULTIFRAMECOMMAND_H
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...