Quantum GIS API Documentation  1.8
src/core/composer/qgscomposeritemcommand.h
Go to the documentation of this file.
00001 /***************************************************************************
00002                           qgscomposeritemcommand.h
00003                           ------------------------
00004     begin                : 2010-11-18
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 QGSCOMPOSERITEMCOMMAND_H
00019 #define QGSCOMPOSERITEMCOMMAND_H
00020 
00021 #include <QUndoCommand>
00022 #include <QDomDocument>
00023 
00024 class QgsComposerItem;
00025 
00027 class CORE_EXPORT QgsComposerItemCommand: public QUndoCommand
00028 {
00029   public:
00030     QgsComposerItemCommand( QgsComposerItem* item, const QString& text, QUndoCommand* parent = 0 );
00031     virtual ~QgsComposerItemCommand();
00032 
00034     void undo();
00036     void redo();
00037 
00039     void savePreviousState();
00041     void saveAfterState();
00042 
00043     QDomDocument previousState() const { return mPreviousState.cloneNode().toDocument(); }
00044     QDomDocument afterState() const { return mAfterState.cloneNode().toDocument(); }
00045 
00047     bool containsChange() const;
00048 
00049   protected:
00051     QgsComposerItem* mItem;
00053     QDomDocument mPreviousState;
00055     QDomDocument mAfterState;
00056 
00058     bool mFirstRun;
00059 
00060     void saveState( QDomDocument& stateDoc ) const;
00061     void restoreState( QDomDocument& stateDoc ) const;
00062 };
00063 
00066 class CORE_EXPORT QgsComposerMergeCommand: public QgsComposerItemCommand
00067 {
00068   public:
00069     enum Context
00070     {
00071       Unknown = 0,
00072       //composer label
00073       ComposerLabelSetText,
00074       ComposerLabelSetId,
00075       //composer map
00076       ComposerMapRotation,
00077       ComposerMapAnnotationDistance,
00078       //composer legend
00079       ComposerLegendText,
00080       LegendSymbolWidth,
00081       LegendSymbolHeight,
00082       LegendGroupSpace,
00083       LegendLayerSpace,
00084       LegendSymbolSpace,
00085       LegendIconSymbolSpace,
00086       LegendBoxSpace,
00087       //composer picture
00088       ComposerPictureRotation,
00089       // composer scalebar
00090       ScaleBarLineWidth,
00091       ScaleBarHeight,
00092       ScaleBarSegmentSize,
00093       ScaleBarSegmentsLeft,
00094       ScaleBarNSegments,
00095       ScaleBarUnitText,
00096       ScaleBarMapUnitsSegment,
00097       ScaleBarLabelBarSize,
00098       ScaleBarBoxContentSpace,
00099       // composer table
00100       TableMaximumFeatures,
00101       TableMargin,
00102       TableGridStrokeWidth,
00103       //composer shape
00104       ShapeRotation,
00105       ShapeOutlineWidth,
00106       //composer arrow
00107       ArrowOutlineWidth,
00108       ArrowHeadWidth,
00109       //item
00110       ItemOutlineWidth
00111     };
00112 
00113     QgsComposerMergeCommand( Context c, QgsComposerItem* item, const QString& text );
00114     ~QgsComposerMergeCommand();
00115 
00116     bool mergeWith( const QUndoCommand * command );
00117     int id() const { return ( int )mContext; }
00118 
00119   private:
00120     Context mContext;
00121 };
00122 
00123 #endif // QGSCOMPOSERITEMCOMMAND_H
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines