QGIS API Documentation
2.2.0-Valmiera
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
qgsaddremovemultiframecommand.cpp
Go to the documentation of this file.
1
/***************************************************************************
2
qgsaddremovemultiframecommand.cpp
3
---------------------------------
4
begin : 2012-07-31
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 "
qgsaddremovemultiframecommand.h
"
19
#include "
qgscomposermultiframe.h
"
20
#include "
qgscomposition.h
"
21
#include "
qgsproject.h
"
22
23
24
QgsAddRemoveMultiFrameCommand::QgsAddRemoveMultiFrameCommand
(
State
s,
QgsComposerMultiFrame
* multiFrame,
QgsComposition
* c,
const
QString& text, QUndoCommand* parent ):
25
QUndoCommand( text, parent ), mMultiFrame( multiFrame ), mComposition( c ), mState( s ), mFirstRun( true )
26
{
27
}
28
29
QgsAddRemoveMultiFrameCommand::QgsAddRemoveMultiFrameCommand
(): mMultiFrame( 0 ), mComposition( 0 )
30
{
31
}
32
33
QgsAddRemoveMultiFrameCommand::~QgsAddRemoveMultiFrameCommand
()
34
{
35
if
(
mState
==
Removed
)
36
{
37
delete
mMultiFrame
;
38
}
39
}
40
41
void
QgsAddRemoveMultiFrameCommand::redo
()
42
{
43
if
(
checkFirstRun
() )
44
{
45
return
;
46
}
47
switchState
();
48
}
49
50
void
QgsAddRemoveMultiFrameCommand::undo
()
51
{
52
if
(
checkFirstRun
() )
53
{
54
return
;
55
}
56
switchState
();
57
}
58
59
void
QgsAddRemoveMultiFrameCommand::switchState
()
60
{
61
if
(
mComposition
)
62
{
63
if
(
mState
==
Added
)
64
{
65
mComposition
->
removeMultiFrame
(
mMultiFrame
);
66
mState
=
Removed
;
67
}
68
else
69
{
70
mComposition
->
addMultiFrame
(
mMultiFrame
);
71
mState
=
Added
;
72
}
73
QgsProject::instance
()->
dirty
(
true
);
74
}
75
}
76
77
bool
QgsAddRemoveMultiFrameCommand::checkFirstRun
()
78
{
79
if
(
mFirstRun
)
80
{
81
mFirstRun
=
false
;
82
return
true
;
83
}
84
else
85
{
86
return
false
;
87
}
88
}
Generated on Sun Feb 23 2014 14:27:18 for QGIS API Documentation by
1.8.1.2