QGIS API Documentation  2.18.21-Las Palmas (9fba24a)
qgscomposermultiframecommand.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  qgscomposermultiframecommand.cpp
3  --------------------------------
4  begin : 2012-08-02
5  copyright : (C) 2012 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 
19 #include "qgscomposermultiframe.h"
20 #include "qgsproject.h"
21 
23  QUndoCommand( text, parent ), mMultiFrame( multiFrame ), mFirstRun( true )
24 {
25 }
26 
28 {
29 }
30 
32 {
33 }
34 
36 {
38 }
39 
41 {
42  if ( checkFirstRun() )
43  {
44  return;
45  }
47 }
48 
50 {
52 }
53 
55 {
57 }
58 
60 {
61  if ( mMultiFrame )
62  {
63  stateDoc.clear();
64  QDomElement documentElement = stateDoc.createElement( "ComposerMultiFrameState" );
65  mMultiFrame->writeXML( documentElement, stateDoc );
66  stateDoc.appendChild( documentElement );
67  }
68 }
69 
71 {
72  if ( mMultiFrame )
73  {
74  mMultiFrame->readXML( stateDoc.documentElement().firstChild().toElement(), stateDoc );
75  QgsProject::instance()->setDirty( true );
76  }
77 }
78 
80 {
81  if ( !mFirstRun )
82  {
83  return false;
84  }
85  mFirstRun = false;
86  return true;
87 }
88 
90 {
92 }
93 
94 
96  : QgsComposerMultiFrameCommand( multiFrame, text )
97  , mContext( c )
98 {
99 
100 }
101 
103 {
104 
105 }
106 
108 {
109  const QgsComposerMultiFrameCommand* c = dynamic_cast<const QgsComposerMultiFrameCommand*>( command );
110  if ( !c || mMultiFrame != c->multiFrame() )
111  {
112  return false;
113  }
114  mAfterState = c->afterState();
115  return true;
116 }
bool mergeWith(const QUndoCommand *command) override
void setDirty(bool b=true)
Flag the project as dirty (modified).
Definition: qgsproject.cpp:410
bool containsChange() const
Returns true if previous state and after state are valid and different.
QDomNode appendChild(const QDomNode &newChild)
QString toString(int indent) const
QDomElement documentElement() const
const QgsComposerMultiFrame * multiFrame() const
QDomElement toElement() const
void restoreState(QDomDocument &stateDoc)
void saveState(QDomDocument &stateDoc)
Abstract base class for composer items with the ability to distribute the content to several frames (...
QString text() const
bool isNull() const
void clear()
virtual bool writeXML(QDomElement &elem, QDomDocument &doc, bool ignoreFrames=false) const =0
Stores state information about multiframe in DOM element.
QDomNode firstChild() const
static QgsProject * instance()
Returns the QgsProject singleton instance.
Definition: qgsproject.cpp:382
QgsComposerMultiFrameMergeCommand(Context c, QgsComposerMultiFrame *multiFrame, const QString &text)
virtual bool readXML(const QDomElement &itemElem, const QDomDocument &doc, bool ignoreFrames=false)=0
Reads multiframe state information from a DOM element.
QDomElement createElement(const QString &tagName)