QGIS API Documentation  2.8.2-Wien
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 <QDomDocument>
23 
24 class QgsComposerItem;
26 
28 class CORE_EXPORT QgsComposerItemCommand: public QUndoCommand
29 {
30  public:
31  QgsComposerItemCommand( QgsComposerItem* item, const QString& text, QUndoCommand* parent = 0 );
32  virtual ~QgsComposerItemCommand();
33 
35  void undo() override;
37  void redo() override;
38 
40  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 
53  QgsComposerItem *item() const;
54 
55  protected:
59  QDomDocument mPreviousState;
61  QDomDocument mAfterState;
62 
67 
69  bool mFirstRun;
70 
71  void saveState( QDomDocument& stateDoc ) const;
72  void restoreState( QDomDocument& stateDoc ) const;
73 };
74 
78 {
79  public:
80  enum Context
81  {
82  Unknown = 0,
83  //composer label
86  //composer map
89  //composer legend
105  //composer picture
107  // composer scalebar
117  // composer table
121  //composer shape
124  //composer arrow
127  //item
132  ItemZoomContent
133  };
134 
135  QgsComposerMergeCommand( Context c, QgsComposerItem* item, const QString& text );
137 
138  bool mergeWith( const QUndoCommand * command ) override;
139  int id() const override { return ( int )mContext; }
140 
141  private:
142  Context mContext;
143 };
144 
145 #endif // QGSCOMPOSERITEMCOMMAND_H