QGIS API Documentation  2.0.1-Dufour
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 
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 
30 {
31 }
32 
34 {
35  if ( mState == Removed )
36  {
37  delete mMultiFrame;
38  }
39 }
40 
42 {
43  if ( checkFirstRun() )
44  {
45  return;
46  }
47  switchState();
48 }
49 
51 {
52  if ( checkFirstRun() )
53  {
54  return;
55  }
56  switchState();
57 }
58 
60 {
61  if ( mComposition )
62  {
63  if ( mState == Added )
64  {
66  mState = Removed;
67  }
68  else
69  {
71  mState = Added;
72  }
73  QgsProject::instance()->dirty( true );
74  }
75 }
76 
78 {
79  if ( mFirstRun )
80  {
81  mFirstRun = false;
82  return true;
83  }
84  else
85  {
86  return false;
87  }
88 }