QGIS API Documentation  2.0.1-Dufour
 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;
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
78  //composer map
81  //composer legend
95  //composer picture
97  // composer scalebar
107  // composer table
111  //composer shape
114  //composer arrow
117  //item
119  ItemMove
120  };
121 
122  QgsComposerMergeCommand( Context c, QgsComposerItem* item, const QString& text );
124 
125  bool mergeWith( const QUndoCommand * command );
126  int id() const { return ( int )mContext; }
127 
128  private:
130 };
131 
132 #endif // QGSCOMPOSERITEMCOMMAND_H