QGIS API Documentation
2.0.1-Dufour
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Groups
Pages
src
core
composer
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
18
#include "
qgscomposermultiframecommand.h
"
19
#include "
qgscomposermultiframe.h
"
20
#include "
qgsproject.h
"
21
22
QgsComposerMultiFrameCommand::QgsComposerMultiFrameCommand
(
QgsComposerMultiFrame
* multiFrame,
const
QString& text, QUndoCommand* parent ):
23
QUndoCommand( text, parent ), mMultiFrame( multiFrame ), mFirstRun( true )
24
{
25
}
26
27
QgsComposerMultiFrameCommand::QgsComposerMultiFrameCommand
(): QUndoCommand(
""
, 0 ), mMultiFrame( 0 ), mFirstRun( false )
28
{
29
}
30
31
QgsComposerMultiFrameCommand::~QgsComposerMultiFrameCommand
()
32
{
33
}
34
35
void
QgsComposerMultiFrameCommand::undo
()
36
{
37
restoreState
(
mPreviousState
);
38
}
39
40
void
QgsComposerMultiFrameCommand::redo
()
41
{
42
if
(
checkFirstRun
() )
43
{
44
return
;
45
}
46
restoreState
(
mAfterState
);
47
}
48
49
void
QgsComposerMultiFrameCommand::savePreviousState
()
50
{
51
saveState
(
mPreviousState
);
52
}
53
54
void
QgsComposerMultiFrameCommand::saveAfterState
()
55
{
56
saveState
(
mAfterState
);
57
}
58
59
void
QgsComposerMultiFrameCommand::saveState
( QDomDocument& stateDoc )
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
70
void
QgsComposerMultiFrameCommand::restoreState
( QDomDocument& stateDoc )
71
{
72
if
(
mMultiFrame
)
73
{
74
mMultiFrame
->
readXML
( stateDoc.documentElement().firstChild().toElement(), stateDoc );
75
QgsProject::instance
()->
dirty
(
true
);
76
}
77
}
78
79
bool
QgsComposerMultiFrameCommand::checkFirstRun
()
80
{
81
if
( !
mFirstRun
)
82
{
83
return
false
;
84
}
85
mFirstRun
=
false
;
86
return
true
;
87
}
88
89
bool
QgsComposerMultiFrameCommand::containsChange
()
const
90
{
91
return
!(
mPreviousState
.isNull() ||
mAfterState
.isNull() ||
mPreviousState
.toString() ==
mAfterState
.toString() );
92
}
Generated on Tue Sep 24 2013 14:41:46 for QGIS API Documentation by
1.8.1.2