QGIS API Documentation  2.5.0-Master
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator 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;
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();
37  void redo();
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 );
139  int id() const { return ( int )mContext; }
140 
141  private:
142  Context mContext;
143 };
144 
145 #endif // QGSCOMPOSERITEMCOMMAND_H
Definition: qgscomposeritemcommand.h:128
Definition: qgscomposeritemcommand.h:114
Definition: qgscomposeritemcommand.h:99
Definition: qgscomposeritemcommand.h:97
Definition: qgscomposeritemcommand.h:111
A item that forms part of a map composition.
Definition: qgscomposeritem.h:38
Definition: qgscomposeritemcommand.h:100
Definition: qgscomposeritemcommand.h:108
A composer command that merges together with other commands having the same context (=id)...
Definition: qgscomposeritemcommand.h:77
Definition: qgscomposeritemcommand.h:88
Definition: qgscomposeritemcommand.h:87
Definition: qgscomposeritemcommand.h:115
Definition: qgscomposeritemcommand.h:113
Context
Definition: qgscomposeritemcommand.h:80
Definition: qgsexpression.cpp:123
Definition: qgscomposeritemcommand.h:94
Definition: qgscomposeritemcommand.h:93
Definition: qgscomposeritemcommand.h:110
Definition: qgscomposeritemcommand.h:112
QDomDocument previousState() const
Definition: qgscomposeritemcommand.h:44
Definition: qgscomposeritemcommand.h:123
Definition: qgscomposeritemcommand.h:95
Definition: qgscomposeritemcommand.h:122
Definition: qgscomposeritemcommand.h:90
Definition: qgscomposeritemcommand.h:104
Definition: qgscomposeritemcommand.h:116
Definition: qgscomposeritemcommand.h:126
Abstract base class for composer items with the ability to distribute the content to several frames (...
Definition: qgscomposermultiframe.h:39
int id() const
Definition: qgscomposeritemcommand.h:139
Definition: qgscomposeritemcommand.h:85
Definition: qgscomposeritemcommand.h:91
Definition: qgscomposeritemcommand.h:129
Definition: qgscomposeritemcommand.h:92
Definition: qgscomposeritemcommand.h:84
Definition: qgscomposeritemcommand.h:130
bool mFirstRun
Flag to prevent the first redo() if the command is pushed to the undo stack.
Definition: qgscomposeritemcommand.h:69
Definition: qgscomposeritemcommand.h:131
Definition: qgscomposeritemcommand.h:96
Definition: qgscomposeritemcommand.h:120
int mFrameNumber
Definition: qgscomposeritemcommand.h:66
Undo command to undo/redo all composer item related changes.
Definition: qgscomposeritemcommand.h:28
QDomDocument mAfterState
XML containing the state after executing the command.
Definition: qgscomposeritemcommand.h:61
Definition: qgscomposeritemcommand.h:125
Definition: qgscomposeritemcommand.h:98
QgsComposerItem * mItem
Target item of the command.
Definition: qgscomposeritemcommand.h:57
QgsComposerMultiFrame * mMultiFrame
Parameters for frame items.
Definition: qgscomposeritemcommand.h:65
QDomDocument afterState() const
Definition: qgscomposeritemcommand.h:45
Definition: qgscomposeritemcommand.h:119
Definition: qgscomposeritemcommand.h:103
Definition: qgscomposeritemcommand.h:118
Definition: qgscomposeritemcommand.h:106
Definition: qgscomposeritemcommand.h:109
Definition: qgscomposeritemcommand.h:101
QDomDocument mPreviousState
XML that saves the state before executing the command.
Definition: qgscomposeritemcommand.h:59
Definition: qgscomposeritemcommand.h:102