QGIS API Documentation
2.4.0-Chugiak
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
src
core
composer
qgsaddremoveitemcommand.cpp
Go to the documentation of this file.
1
/***************************************************************************
2
qgsaddremoveitemcommand.cpp
3
---------------------------
4
begin : 2010-11-27
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
#include "
qgsaddremoveitemcommand.h
"
19
#include "
qgscomposeritem.h
"
20
#include "
qgscomposition.h
"
21
#include "
qgsproject.h
"
22
23
QgsAddRemoveItemCommand::QgsAddRemoveItemCommand
(
State
s,
QgsComposerItem
* item,
QgsComposition
* c,
const
QString& text, QUndoCommand* parent ):
24
QUndoCommand( text, parent ), mItem( item ), mComposition( c ), mState( s ), mFirstRun( true )
25
{
26
}
27
28
QgsAddRemoveItemCommand::~QgsAddRemoveItemCommand
()
29
{
30
if
(
mState
==
Removed
)
//command class stores the item if removed from the composition
31
{
32
delete
mItem
;
33
}
34
}
35
36
void
QgsAddRemoveItemCommand::redo
()
37
{
38
if
(
mFirstRun
)
39
{
40
mFirstRun
=
false
;
41
return
;
42
}
43
switchState
();
44
}
45
46
void
QgsAddRemoveItemCommand::undo
()
47
{
48
if
(
mFirstRun
)
49
{
50
mFirstRun
=
false
;
51
return
;
52
}
53
switchState
();
54
}
55
56
void
QgsAddRemoveItemCommand::switchState
()
57
{
58
if
(
mState
==
Added
)
59
{
60
if
(
mComposition
)
61
{
62
mComposition
->removeItem(
mItem
);
63
}
64
emit
itemRemoved
(
mItem
);
65
mState
=
Removed
;
66
}
67
else
//Removed
68
{
69
if
(
mComposition
)
70
{
71
mComposition
->addItem(
mItem
);
72
}
73
emit
itemAdded
(
mItem
);
74
mState
=
Added
;
75
}
76
QgsProject::instance
()->
dirty
(
true
);
77
}
QgsAddRemoveItemCommand::mItem
QgsComposerItem * mItem
Definition:
qgsaddremoveitemcommand.h:49
QgsAddRemoveItemCommand::QgsAddRemoveItemCommand
QgsAddRemoveItemCommand(State s, QgsComposerItem *item, QgsComposition *c, const QString &text, QUndoCommand *parent=0)
Definition:
qgsaddremoveitemcommand.cpp:23
qgsproject.h
QgsAddRemoveItemCommand::~QgsAddRemoveItemCommand
~QgsAddRemoveItemCommand()
Definition:
qgsaddremoveitemcommand.cpp:28
QgsAddRemoveItemCommand::State
State
Definition:
qgsaddremoveitemcommand.h:32
QgsAddRemoveItemCommand::redo
void redo()
Definition:
qgsaddremoveitemcommand.cpp:36
QgsComposerItem
A item that forms part of a map composition.
Definition:
qgscomposeritem.h:36
qgscomposition.h
QgsAddRemoveItemCommand::mState
State mState
Definition:
qgsaddremoveitemcommand.h:51
qgscomposeritem.h
QgsAddRemoveItemCommand::mComposition
QgsComposition * mComposition
Definition:
qgsaddremoveitemcommand.h:50
QgsAddRemoveItemCommand::mFirstRun
bool mFirstRun
Definition:
qgsaddremoveitemcommand.h:52
QgsAddRemoveItemCommand::itemAdded
void itemAdded(QgsComposerItem *item)
qgsaddremoveitemcommand.h
QgsAddRemoveItemCommand::Removed
Definition:
qgsaddremoveitemcommand.h:35
QgsAddRemoveItemCommand::switchState
void switchState()
Definition:
qgsaddremoveitemcommand.cpp:56
QgsAddRemoveItemCommand::undo
void undo()
Definition:
qgsaddremoveitemcommand.cpp:46
QgsComposition
Graphics scene for map printing.
Definition:
qgscomposition.h:66
QgsAddRemoveItemCommand::Added
Definition:
qgsaddremoveitemcommand.h:34
QgsProject::instance
static QgsProject * instance()
access to canonical QgsProject instance
Definition:
qgsproject.cpp:362
QgsAddRemoveItemCommand::itemRemoved
void itemRemoved(QgsComposerItem *item)
QgsProject::dirty
void dirty(bool b)
Definition:
qgsproject.cpp:396
Generated on Wed Mar 18 2015 11:40:11 for QGIS API Documentation by
1.8.9.1