QGIS/python/core/composer/qgscomposeritemcommand.sip
Nyall Dawson 4ea5c80948 [composer] Avoid crash when using redo on multiframe (fix #11351)
Since multiframe changes can remove and create new frame items,
it's not safe to directly manipulate frame items in
QgsComposerItemCommand. Now, commands which apply to a frame always
fetch a reference to the correct frame item directly from the
parent multiframe. Also added unit tests for this crash.
2014-10-15 20:17:10 +11:00

106 lines
2.8 KiB
Plaintext

/**\ingroup MapComposer
Undo command to undo/redo all composer item related changes*/
class QgsComposerItemCommand: QUndoCommand
{
%TypeHeaderCode
#include "qgscomposeritemcommand.h"
%End
public:
QgsComposerItemCommand( QgsComposerItem* item, const QString& text, QUndoCommand* parent /TransferThis/ = 0 );
virtual ~QgsComposerItemCommand();
/**Reverses the command*/
void undo();
/**Replays the command*/
void redo();
/**Saves current item state as previous state*/
void savePreviousState();
/**Saves current item state as after state*/
void saveAfterState();
QDomDocument previousState() const;
QDomDocument afterState() const;
/**Returns true if previous state and after state are valid and different*/
bool containsChange() const;
/**Returns the target item the command applies to.
* @returns target composer item
*/
QgsComposerItem* item() const;
protected:
void saveState( QDomDocument& stateDoc ) const;
void restoreState( QDomDocument& stateDoc ) const;
};
/**A composer command that merges together with other commands having the same context (=id). Keeps the oldest previous state and uses the
newest after state. The purpose is to avoid too many micro changes in the history*/
class QgsComposerMergeCommand : QgsComposerItemCommand
{
%TypeHeaderCode
#include "qgscomposeritemcommand.h"
%End
public:
enum Context
{
Unknown,
//composer label
ComposerLabelSetText,
ComposerLabelSetId,
//composer map
ComposerMapRotation,
ComposerMapAnnotationDistance,
//composer legend
ComposerLegendText,
LegendColumnCount,
LegendSplitLayer,
LegendEqualColumnWidth,
LegendSymbolWidth,
LegendSymbolHeight,
LegendWmsLegendWidth,
LegendWmsLegendHeight,
LegendTitleSpaceBottom,
LegendGroupSpace,
LegendLayerSpace,
LegendSymbolSpace,
LegendIconSymbolSpace,
LegendBoxSpace,
LegendColumnSpace,
//composer picture
ComposerPictureRotation,
// composer scalebar
ScaleBarLineWidth,
ScaleBarHeight,
ScaleBarSegmentSize,
ScaleBarSegmentsLeft,
ScaleBarNSegments,
ScaleBarUnitText,
ScaleBarMapUnitsSegment,
ScaleBarLabelBarSize,
ScaleBarBoxContentSpace,
// composer table
TableMaximumFeatures,
TableMargin,
TableGridStrokeWidth,
//composer shape
ShapeCornerRadius,
ShapeOutlineWidth,
//composer arrow
ArrowOutlineWidth,
ArrowHeadWidth,
//item
ItemOutlineWidth,
ItemMove,
ItemRotation,
ItemTransparency
};
QgsComposerMergeCommand( Context c, QgsComposerItem* item, const QString& text );
~QgsComposerMergeCommand();
bool mergeWith( const QUndoCommand * command );
int id() const;
};