QGIS API Documentation  2.99.0-Master (e077efd)
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 
25 
29 class CORE_EXPORT QgsComposerMultiFrameCommand: public QUndoCommand
30 {
31  public:
32  QgsComposerMultiFrameCommand( QgsComposerMultiFrame* multiFrame, const QString& text, QUndoCommand* parent = nullptr );
34 
35  void undo() override;
36  void redo() override;
37 
38  void savePreviousState();
39  void saveAfterState();
40 
41  QDomDocument previousState() const { return mPreviousState.cloneNode().toDocument(); }
42  QDomDocument afterState() const { return mAfterState.cloneNode().toDocument(); }
43 
45  bool containsChange() const;
46 
47  const QgsComposerMultiFrame* multiFrame() const { return mMultiFrame; }
48 
49  protected:
51 
52  QDomDocument mPreviousState;
53  QDomDocument mAfterState;
54 
55  bool mFirstRun;
56 
57  QgsComposerMultiFrameCommand(); //forbidden
58  void saveState( QDomDocument& stateDoc );
59  void restoreState( QDomDocument& stateDoc );
60  bool checkFirstRun();
61 };
62 
68 {
69  public:
70  enum Context
71  {
72  Unknown = 0,
73  //composer html
77  //attribute table
86  };
87 
88  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...