Skip to content
Permalink
Browse files
Merge pull request #5119 from nyalldawson/layout_next3
[layouts] Undo/redo framework
  • Loading branch information
nyalldawson committed Sep 10, 2017
2 parents 1caaa2e + 6471876 commit cea7eb8
Show file tree
Hide file tree
Showing 51 changed files with 2,491 additions and 60 deletions.
@@ -30,6 +30,7 @@


class optionsDialog(QDialog, Ui_SettingsDialogPythonConsole):

def __init__(self, parent):
QDialog.__init__(self, parent)
self.setWindowTitle(QCoreApplication.translate(
@@ -160,8 +160,11 @@
%Include layout/qgslayoutmeasurementconverter.sip
%Include layout/qgspagesizeregistry.sip
%Include layout/qgslayoutpoint.sip
%Include layout/qgslayoutserializableobject.sip
%Include layout/qgslayoutsize.sip
%Include layout/qgslayoutsnapper.sip
%Include layout/qgslayoutundocommand.sip
%Include layout/qgslayoutundostack.sip
%Include layout/qgslayoututils.sip
%Include metadata/qgslayermetadata.sip
%Include metadata/qgslayermetadatavalidator.sip
@@ -8,7 +8,7 @@



class QgsLayout : QGraphicsScene, QgsExpressionContextGenerator
class QgsLayout : QGraphicsScene, QgsExpressionContextGenerator, QgsLayoutUndoObjectInterface
{
%Docstring
Base class for layouts, which can contain items such as maps, labels, scalebars, etc.
@@ -39,8 +39,6 @@ class QgsLayout : QGraphicsScene, QgsExpressionContextGenerator
called on the new layout.
%End

~QgsLayout();

void initializeDefaults();
%Docstring
Initializes an empty layout, e.g. by adding a default page to the layout. This should be called after creating
@@ -67,6 +65,14 @@ class QgsLayout : QGraphicsScene, QgsExpressionContextGenerator
.. seealso:: name()
%End


QgsLayoutItem *itemByUuid( const QString &uuid );
%Docstring
Returns the layout item with matching ``uuid`` unique identifier, or a None
if a matching item could not be found.
:rtype: QgsLayoutItem
%End

void setUnits( QgsUnitTypes::LayoutUnit units );
%Docstring
Sets the native measurement ``units`` for the layout. These also form the default unit
@@ -247,6 +253,32 @@ class QgsLayout : QGraphicsScene, QgsExpressionContextGenerator
method. Ownership of the item is transferred to the layout.
%End

QDomElement writeXml( QDomDocument &document, const QgsReadWriteContext &context ) const;
%Docstring
Returns the layout's state encapsulated in a DOM element.
.. seealso:: readXml()
:rtype: QDomElement
%End

bool readXml( const QDomElement &layoutElement, const QDomDocument &document, const QgsReadWriteContext &context );
%Docstring
Sets the collection's state from a DOM element. ``layoutElement`` is the DOM node corresponding to the layout.
.. seealso:: writeXml()
:rtype: bool
%End

QgsLayoutUndoStack *undoStack();
%Docstring
Returns a pointer to the layout's undo stack, which manages undo/redo states for the layout
and it's associated objects.
:rtype: QgsLayoutUndoStack
%End


virtual QgsAbstractLayoutUndoCommand *createCommand( const QString &text, int id = 0, QUndoCommand *parent = 0 ) /Factory/;



public slots:

void updateBounds();
@@ -8,7 +8,7 @@



class QgsLayoutGridSettings
class QgsLayoutGridSettings : QgsLayoutSerializableObject
{
%Docstring
Contains settings relating to the appearance, spacing and offset for layout grids.
@@ -27,11 +27,15 @@ class QgsLayoutGridSettings
StyleCrosses
};

QgsLayoutGridSettings();
QgsLayoutGridSettings( QgsLayout *layout );
%Docstring
Constructor for QgsLayoutGridSettings.
%End

virtual QString stringType() const;
virtual QgsLayout *layout();


void setResolution( const QgsLayoutMeasurement &resolution );
%Docstring
Sets the page/snap grid ``resolution``.
@@ -92,6 +96,22 @@ class QgsLayoutGridSettings
:rtype: Style
%End

virtual bool writeXml( QDomElement &parentElement, QDomDocument &document, const QgsReadWriteContext &context ) const;

%Docstring
Stores the grid's state in a DOM element. The ``parentElement`` should refer to the parent layout's DOM element.
.. seealso:: readXml()
:rtype: bool
%End

virtual bool readXml( const QDomElement &gridElement, const QDomDocument &document, const QgsReadWriteContext &context );

%Docstring
Sets the grid's state from a DOM element. gridElement is the DOM node corresponding to the grid.
.. seealso:: writeXml()
:rtype: bool
%End

};

/************************************************************************
@@ -132,7 +132,7 @@ class QgsLayoutGuide : QObject

};

class QgsLayoutGuideCollection : QAbstractTableModel
class QgsLayoutGuideCollection : QAbstractTableModel, QgsLayoutSerializableObject
{
%Docstring
Stores and manages the snap guides used by a layout.
@@ -160,6 +160,10 @@ class QgsLayoutGuideCollection : QAbstractTableModel
%End
~QgsLayoutGuideCollection();

virtual QString stringType() const;
virtual QgsLayout *layout();


virtual int rowCount( const QModelIndex & ) const;

virtual int columnCount( const QModelIndex & ) const;
@@ -188,6 +192,11 @@ class QgsLayoutGuideCollection : QAbstractTableModel
.. seealso:: clear()
%End

void setGuideLayoutPosition( QgsLayoutGuide *guide, double position );
%Docstring
Sets the absolute ``position`` (in layout coordinates) for ``guide`` within the layout.
%End

void clear();
%Docstring
Removes all guides from the collection.
@@ -233,6 +242,22 @@ class QgsLayoutGuideCollection : QAbstractTableModel
.. seealso:: visible()
%End

virtual bool writeXml( QDomElement &parentElement, QDomDocument &document, const QgsReadWriteContext &context ) const;

%Docstring
Stores the collection's state in a DOM element. The ``parentElement`` should refer to the parent layout's DOM element.
.. seealso:: readXml()
:rtype: bool
%End

virtual bool readXml( const QDomElement &collectionElement, const QDomDocument &document, const QgsReadWriteContext &context );

%Docstring
Sets the collection's state from a DOM element. collectionElement is the DOM node corresponding to the collection.
.. seealso:: writeXml()
:rtype: bool
%End

};


@@ -9,7 +9,7 @@



class QgsLayoutItem : QgsLayoutObject, QGraphicsRectItem
class QgsLayoutItem : QgsLayoutObject, QGraphicsRectItem, QgsLayoutUndoObjectInterface
{
%Docstring
Base class for graphical items within a QgsLayout.
@@ -219,6 +219,9 @@ class QgsLayoutItem : QgsLayoutObject, QGraphicsRectItem
:rtype: bool
%End

virtual QgsAbstractLayoutUndoCommand *createCommand( const QString &text, int id, QUndoCommand *parent = 0 ) /Factory/;


public slots:

virtual void refresh();
@@ -32,6 +32,16 @@ class QgsLayoutItemPage : QgsLayoutItem
%Docstring
Constructor for QgsLayoutItemPage, with the specified parent ``layout``.
%End

static QgsLayoutItemPage *create( QgsLayout *layout, const QVariantMap &settings ) /Factory/;
%Docstring
Returns a new page item for the specified ``layout``.

The caller takes responsibility for deleting the returned object.
:rtype: QgsLayoutItemPage
%End


virtual int type() const;
virtual QString stringType() const;

@@ -80,6 +90,9 @@ class QgsLayoutItemPage : QgsLayoutItem
virtual void attemptResize( const QgsLayoutSize &size );


virtual QgsAbstractLayoutUndoCommand *createCommand( const QString &text, int id, QUndoCommand *parent = 0 ) /Factory/;


public slots:

virtual void redraw();
@@ -9,7 +9,7 @@



class QgsLayoutPageCollection : QObject
class QgsLayoutPageCollection : QObject, QgsLayoutSerializableObject
{
%Docstring
A manager for a collection of pages in a layout.
@@ -28,11 +28,9 @@ class QgsLayoutPageCollection : QObject

~QgsLayoutPageCollection();

QgsLayout *layout() const;
%Docstring
Returns the layout this collection belongs to.
:rtype: QgsLayout
%End
virtual QString stringType() const;
virtual QgsLayout *layout();


QList< QgsLayoutItemPage * > pages();
%Docstring
@@ -130,6 +128,12 @@ class QgsLayoutPageCollection : QObject
Calling deletePage() automatically triggers a reflow() of pages.
%End

QgsLayoutItemPage *takePage( QgsLayoutItemPage *page ) /TransferBack/;
%Docstring
Takes a ``page`` from the collection, returning ownership of the page to the caller.
:rtype: QgsLayoutItemPage
%End

void setPageStyleSymbol( QgsFillSymbol *symbol );
%Docstring
Sets the ``symbol`` to use for drawing pages in the collection.
@@ -211,6 +215,29 @@ class QgsLayoutPageCollection : QObject
:rtype: float
%End

virtual bool writeXml( QDomElement &parentElement, QDomDocument &document, const QgsReadWriteContext &context ) const;

%Docstring
Stores the collection's state in a DOM element. The ``parentElement`` should refer to the parent layout's DOM element.
.. seealso:: readXml()
:rtype: bool
%End

virtual bool readXml( const QDomElement &collectionElement, const QDomDocument &document, const QgsReadWriteContext &context );

%Docstring
Sets the collection's state from a DOM element. collectionElement is the DOM node corresponding to the collection.
.. seealso:: writeXml()
:rtype: bool
%End

QgsLayoutGuideCollection &guides();
%Docstring
Returns a reference to the collection's guide collection, which manages page snap guides.
:rtype: QgsLayoutGuideCollection
%End


public slots:

void redraw();
@@ -0,0 +1,66 @@
/************************************************************************
* This file has been generated automatically from *
* *
* src/core/layout/qgslayoutserializableobject.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/





class QgsLayoutSerializableObject : QgsLayoutUndoObjectInterface
{
%Docstring
An interface for layout objects which can be stored and read from DOM elements.
.. versionadded:: 3.0
%End

%TypeHeaderCode
#include "qgslayoutserializableobject.h"
%End
public:

virtual ~QgsLayoutSerializableObject();

virtual QString stringType() const = 0;
%Docstring
Return the object type as a string.

This string must be a unique, single word, character only representation of the item type, eg "LayoutScaleBar"
:rtype: str
%End

virtual QgsLayout *layout() = 0;
%Docstring
Returns the layout the object belongs to.
:rtype: QgsLayout
%End

virtual bool writeXml( QDomElement &parentElement, QDomDocument &document, const QgsReadWriteContext &context ) const = 0;
%Docstring
Stores the objects's state in a DOM element. The ``parentElement`` should refer to the parent layout's DOM element.
.. seealso:: readXml()
:rtype: bool
%End

virtual bool readXml( const QDomElement &element, const QDomDocument &document, const QgsReadWriteContext &context ) = 0;
%Docstring
Sets the objects's state from a DOM element. ``element`` is the DOM node corresponding to the object.
.. seealso:: writeXml()
:rtype: bool
%End

virtual QgsAbstractLayoutUndoCommand *createCommand( const QString &text, int id, QUndoCommand *parent = 0 ) /Factory/;


};

/************************************************************************
* This file has been generated automatically from *
* *
* src/core/layout/qgslayoutserializableobject.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/

0 comments on commit cea7eb8

Please sign in to comment.