QGIS API Documentation  2.10.1-Pisa
 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:
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
A item that forms part of a map composition.
A composer command that merges together with other commands having the same context (=id)...
virtual bool mergeWith(const QUndoCommand *command)
QDomDocument previousState() const
Abstract base class for composer items with the ability to distribute the content to several frames (...
virtual void redo()
bool mFirstRun
Flag to prevent the first redo() if the command is pushed to the undo stack.
virtual void undo()
Undo command to undo/redo all composer item related changes.
QDomDocument mAfterState
XML containing the state after executing the command.
QDomNode cloneNode(bool deep) const
QgsComposerItem * mItem
Target item of the command.
QgsComposerMultiFrame * mMultiFrame
Parameters for frame items.
QDomDocument afterState() const
QDomDocument toDocument() const
QDomDocument mPreviousState
XML that saves the state before executing the command.