Quantum GIS API Documentation  1.8
src/core/composer/qgsaddremoveitemcommand.h
Go to the documentation of this file.
00001 /***************************************************************************
00002                           qgsaddremoveitemcommand.h
00003                           ------------------------
00004     begin                : 2010-11-27
00005     copyright            : (C) 2010 by Marco Hugentobler
00006     email                : marco dot hugentobler at sourcepole dot ch
00007 ***************************************************************************/
00008 
00009 /***************************************************************************
00010  *                                                                         *
00011  *   This program is free software; you can redistribute it and/or modify  *
00012  *   it under the terms of the GNU General Public License as published by  *
00013  *   the Free Software Foundation; either version 2 of the License, or     *
00014  *   (at your option) any later version.                                   *
00015  *                                                                         *
00016  ***************************************************************************/
00017 
00018 #ifndef QGSADDREMOVEITEMCOMMAND_H
00019 #define QGSADDREMOVEITEMCOMMAND_H
00020 
00021 #include <QUndoCommand>
00022 class QgsComposerItem;
00023 class QgsComposition;
00024 
00026 class CORE_EXPORT QgsAddRemoveItemCommand: public QObject, public QUndoCommand
00027 {
00028     Q_OBJECT
00029 
00030   public:
00031 
00032     enum State
00033     {
00034       Added = 0,
00035       Removed
00036     };
00037 
00038     QgsAddRemoveItemCommand( State s, QgsComposerItem* item, QgsComposition* c, const QString& text, QUndoCommand* parent = 0 );
00039     ~QgsAddRemoveItemCommand();
00040 
00041     void redo();
00042     void undo();
00043 
00044   signals:
00045     void itemAdded( QgsComposerItem* item );
00046     void itemRemoved( QgsComposerItem* item );
00047 
00048   private:
00049     QgsComposerItem* mItem;
00050     QgsComposition* mComposition;
00051     State mState;
00052     bool mFirstRun; //flag to prevent execution when the command is pushed to the QUndoStack
00053 
00054     //changes between added / removed state
00055     void switchState();
00056 };
00057 
00058 #endif // QGSADDREMOVEITEMCOMMAND_H
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines