QGIS API Documentation  2.5.0-Master
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules 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;
25 
27 class CORE_EXPORT QgsComposerItemCommand: public QUndoCommand
28 {
29  public:
30  QgsComposerItemCommand( QgsComposerItem* item, const QString& text, QUndoCommand* parent = 0 );
31  virtual ~QgsComposerItemCommand();
32 
34  void undo();
36  void redo();
37 
39  void savePreviousState();
41  void saveAfterState();
42 
43  QDomDocument previousState() const { return mPreviousState.cloneNode().toDocument(); }
44  QDomDocument afterState() const { return mAfterState.cloneNode().toDocument(); }
45 
47  bool containsChange() const;
48 
49  const QgsComposerItem* item() const { return mItem; }
50 
51  protected:
55  QDomDocument mPreviousState;
57  QDomDocument mAfterState;
58 
60  bool mFirstRun;
61 
62  void saveState( QDomDocument& stateDoc ) const;
63  void restoreState( QDomDocument& stateDoc ) const;
64 };
65 
69 {
70  public:
71  enum Context
72  {
73  Unknown = 0,
74  //composer label
77  //composer map
80  //composer legend
96  //composer picture
98  // composer scalebar
108  // composer table
112  //composer shape
115  //composer arrow
118  //item
122  ItemTransparency
123  };
124 
125  QgsComposerMergeCommand( Context c, QgsComposerItem* item, const QString& text );
127 
128  bool mergeWith( const QUndoCommand * command );
129  int id() const { return ( int )mContext; }
130 
131  private:
133 };
134 
135 #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)...
QDomDocument previousState() const
bool mFirstRun
Flag to prevent the first redo() if the command is pushed to the undo stack.
Undo command to undo/redo all composer item related changes.
QDomDocument mAfterState
XML containing the state after executing the command.
QgsComposerItem * mItem
Target item of the command.
const QgsComposerItem * item() const
QDomDocument afterState() const
QDomDocument mPreviousState
XML that saves the state before executing the command.