mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-13 00:03:09 -04:00
Add python bindings for composer command classes
git-svn-id: http://svn.osgeo.org/qgis/trunk@14827 c8812cc2-4d05-0410-92ff-de0c093fc19c
This commit is contained in:
parent
16f326f0af
commit
2ed7c945c7
@ -11,9 +11,11 @@
|
||||
// TODO: more files to wrap
|
||||
|
||||
%Include qgis.sip
|
||||
%Include qgsaddremoveitemcommand.sip
|
||||
%Include qgsapplication.sip
|
||||
%Include qgscomposerattributetable.sip
|
||||
%Include qgscomposeritem.sip
|
||||
%Include qgscomposeritemcommand.sip
|
||||
%Include qgscomposerlabel.sip
|
||||
%Include qgscomposerlegend.sip
|
||||
%Include qgscomposermap.sip
|
||||
|
25
python/core/qgsaddremoveitemcommand.sip
Normal file
25
python/core/qgsaddremoveitemcommand.sip
Normal file
@ -0,0 +1,25 @@
|
||||
/** \ingroup MapComposer
|
||||
A composer command class for adding / removing composer items. If mState == Removed, the command owns the item*/
|
||||
class QgsAddRemoveItemCommand: QObject, QUndoCommand
|
||||
{
|
||||
%TypeHeaderCode
|
||||
#include "qgsaddremoveitemcommand.h"
|
||||
%End
|
||||
public:
|
||||
|
||||
enum State
|
||||
{
|
||||
Added = 0,
|
||||
Removed
|
||||
};
|
||||
|
||||
QgsAddRemoveItemCommand( State s, QgsComposerItem* item, QgsComposition* c, const QString& text, QUndoCommand* parent = 0 );
|
||||
~QgsAddRemoveItemCommand();
|
||||
|
||||
void redo();
|
||||
void undo();
|
||||
|
||||
signals:
|
||||
void itemAdded( QgsComposerItem* item );
|
||||
void itemRemoved( QgsComposerItem* item );
|
||||
};
|
85
python/core/qgscomposeritemcommand.sip
Normal file
85
python/core/qgscomposeritemcommand.sip
Normal file
@ -0,0 +1,85 @@
|
||||
/**\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 = 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;
|
||||
};
|
||||
|
||||
/**\ingroup MapComposer
|
||||
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 = 0,
|
||||
//composer label
|
||||
ComposerLabelSetText,
|
||||
//composer map
|
||||
ComposerMapRotation,
|
||||
ComposerMapAnnotationDistance,
|
||||
//composer legend
|
||||
ComposerLegendText,
|
||||
LegendSymbolWidth,
|
||||
LegendSymbolHeight,
|
||||
LegendLayerSpace,
|
||||
LegendSymbolSpace,
|
||||
LegendIconSymbolSpace,
|
||||
LegendBoxSpace,
|
||||
//composer picture
|
||||
ComposerPictureRotation,
|
||||
// composer scalebar
|
||||
ScaleBarLineWidth,
|
||||
ScaleBarHeight,
|
||||
ScaleBarSegmentSize,
|
||||
ScaleBarSegmentsLeft,
|
||||
ScaleBarNSegments,
|
||||
ScaleBarUnitText,
|
||||
ScaleBarMapUnitsSegment,
|
||||
ScaleBarLabelBarSize,
|
||||
ScaleBarBoxContentSpace,
|
||||
// composer table
|
||||
TableMaximumFeatures,
|
||||
TableMargin,
|
||||
TableGridStrokeWidth,
|
||||
//composer shape
|
||||
ShapeRotation,
|
||||
ShapeOutlineWidth,
|
||||
//composer arrow
|
||||
ArrowOutlineWidth,
|
||||
ArrowHeadWidth,
|
||||
//item
|
||||
ItemOutlineWidth
|
||||
};
|
||||
|
||||
QgsComposerMergeCommand( Context c, QgsComposerItem* item, const QString& text );
|
||||
~QgsComposerMergeCommand();
|
||||
|
||||
bool mergeWith( const QUndoCommand * command );
|
||||
int id() const;
|
||||
};
|
@ -57,6 +57,9 @@ class QgsComposition: QGraphicsScene
|
||||
void setGridStyle( GridStyle s );
|
||||
GridStyle gridStyle() const;
|
||||
|
||||
/**Returns pointer to undo/redo command storage*/
|
||||
QUndoStack* undoStack();
|
||||
|
||||
/**Returns the topmose composer item. Ignores mPaperItem*/
|
||||
QgsComposerItem* composerItemAt( const QPointF & position );
|
||||
|
||||
@ -125,4 +128,15 @@ class QgsComposition: QGraphicsScene
|
||||
|
||||
/**Snaps a scene coordinate point to grid*/
|
||||
QPointF snapPointToGrid( const QPointF& scenePoint ) const;
|
||||
|
||||
/**Allocates new item command and saves initial state in it
|
||||
@param item target item
|
||||
@param commandText descriptive command text
|
||||
@param c context for merge commands (unknown for non-mergeable commands)*/
|
||||
void beginCommand( QgsComposerItem* item, const QString& commandText, QgsComposerMergeCommand::Context c = QgsComposerMergeCommand::Unknown );
|
||||
|
||||
/**Saves end state of item and pushes command to the undo history*/
|
||||
void endCommand();
|
||||
/**Deletes current command*/
|
||||
void cancelCommand();
|
||||
};
|
||||
|
@ -68,6 +68,12 @@ class QgsComposerView: QGraphicsView
|
||||
/**Returns the composer main window*/
|
||||
QMainWindow* composerWindow();
|
||||
|
||||
void setPaintingEnabled( bool enabled );
|
||||
bool paintingEnabled() const;
|
||||
|
||||
/**Convenience function to create a QgsAddRemoveItemCommand, connect its signals and push it to the undo stack*/
|
||||
void pushAddRemoveCommand( QgsComposerItem* item, const QString& text, QgsAddRemoveItemCommand::State state = QgsAddRemoveItemCommand::Added );
|
||||
|
||||
protected:
|
||||
void mousePressEvent( QMouseEvent* );
|
||||
void mouseReleaseEvent( QMouseEvent* );
|
||||
|
@ -102,6 +102,9 @@ class GUI_EXPORT QgsComposerView: public QGraphicsView
|
||||
void setPaintingEnabled( bool enabled ) { mPaintingEnabled = enabled; }
|
||||
bool paintingEnabled() const { return mPaintingEnabled; }
|
||||
|
||||
/**Convenience function to create a QgsAddRemoveItemCommand, connect its signals and push it to the undo stack*/
|
||||
void pushAddRemoveCommand( QgsComposerItem* item, const QString& text, QgsAddRemoveItemCommand::State state = QgsAddRemoveItemCommand::Added );
|
||||
|
||||
protected:
|
||||
void mousePressEvent( QMouseEvent* );
|
||||
void mouseReleaseEvent( QMouseEvent* );
|
||||
@ -115,9 +118,6 @@ class GUI_EXPORT QgsComposerView: public QGraphicsView
|
||||
|
||||
void paintEvent( QPaintEvent* event );
|
||||
|
||||
/**Convenience function to create a QgsAddRemoveItemCommand, connect its signals and push it to the undo stack*/
|
||||
void pushAddRemoveCommand( QgsComposerItem* item, const QString& text, QgsAddRemoveItemCommand::State state = QgsAddRemoveItemCommand::Added );
|
||||
|
||||
|
||||
private:
|
||||
/**Status of shift key (used for multiple selection)*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user