Skip to content
Permalink
Browse files

Add a common base class for print layouts and reports, and adapt

QgsLayoutManager to suit
  • Loading branch information
nyalldawson committed Dec 29, 2017
1 parent d8af098 commit 6f2c63f3e59a53f22ffc4646dd8a1defd2d18707
Showing with 543 additions and 210 deletions.
  1. +6 −6 python/core/composer/qgslayoutmanager.sip
  2. +2 −1 python/core/core_auto.sip
  3. +2 −2 python/core/layout/qgsabstractreportsection.sip
  4. +1 −22 python/core/layout/qgslayout.sip
  5. +76 −0 python/core/layout/qgsmasterlayoutinterface.sip
  6. +21 −1 python/core/layout/qgsprintlayout.sip
  7. +18 −7 python/core/layout/qgsreport.sip
  8. +7 −1 python/gui/layout/qgslayoutdesignerinterface.sip
  9. +1 −1 python/gui/qgisinterface.sip
  10. +43 −14 src/app/layout/qgslayoutdesignerdialog.cpp
  11. +16 −0 src/app/layout/qgslayoutdesignerdialog.h
  12. +29 −16 src/app/layout/qgslayoutmanagerdialog.cpp
  13. +3 −3 src/app/layout/qgslayoutmanagerdialog.h
  14. +8 −8 src/app/qgisapp.cpp
  15. +3 −2 src/app/qgisapp.h
  16. +1 −1 src/app/qgisappinterface.cpp
  17. +1 −1 src/app/qgisappinterface.h
  18. +2 −1 src/core/CMakeLists.txt
  19. +52 −19 src/core/composer/qgslayoutmanager.cpp
  20. +8 −8 src/core/composer/qgslayoutmanager.h
  21. +12 −2 src/core/layout/qgsabstractreportsection.cpp
  22. +4 −4 src/core/layout/qgsabstractreportsection.h
  23. +0 −8 src/core/layout/qgslayout.cpp
  24. +2 −22 src/core/layout/qgslayout.h
  25. +5 −1 src/core/layout/qgslayoutexporter.cpp
  26. +77 −0 src/core/layout/qgsmasterlayoutinterface.h
  27. +25 −0 src/core/layout/qgsprintlayout.cpp
  28. +19 −1 src/core/layout/qgsprintlayout.h
  29. +20 −0 src/core/layout/qgsreport.cpp
  30. +17 −6 src/core/layout/qgsreport.h
  31. +1 −1 src/core/layout/qgsreportsectionfieldgroup.cpp
  32. +2 −1 src/core/qgsexpressioncontext.cpp
  33. +7 −1 src/gui/layout/qgslayoutdesignerinterface.h
  34. +2 −1 src/gui/qgisinterface.h
  35. +2 −2 tests/src/core/testqgslayout.cpp
  36. +2 −1 tests/src/core/testqgslayoutobject.cpp
  37. +3 −2 tests/src/python/test_qgslayout.py
  38. +21 −21 tests/src/python/test_qgslayoutmanager.py
  39. +22 −22 tests/src/python/test_qgsreport.py
@@ -50,7 +50,7 @@ as a result of a duplicate composition name).
.. seealso:: :py:func:`compositionAdded()`
%End

bool addLayout( QgsLayout *layout /Transfer/ );
bool addLayout( QgsMasterLayoutInterface *layout /Transfer/ );
%Docstring
Adds a ``layout`` to the manager. Ownership of the layout is transferred to the manager.
Returns true if the addition was successful, or false if the layout could not be added (eg
@@ -76,7 +76,7 @@ of removing a composition which is not contained in the manager).
.. seealso:: :py:func:`clear()`
%End

bool removeLayout( QgsLayout *layout );
bool removeLayout( QgsMasterLayoutInterface *layout );
%Docstring
Removes a ``layout`` from the manager. The layout is deleted.
Returns true if the removal was successful, or false if the removal failed (eg as a result
@@ -103,7 +103,7 @@ Removes and deletes all layouts from the manager.
Returns a list of all compositions contained in the manager.
%End

QList< QgsLayout * > layouts() const;
QList< QgsMasterLayoutInterface * > layouts() const;
%Docstring
Returns a list of all layouts contained in the manager.
%End
@@ -114,7 +114,7 @@ Returns the composition with a matching name, or None if no matching composition
were found.
%End

QgsLayout *layoutByName( const QString &name ) const;
QgsMasterLayoutInterface *layoutByName( const QString &name ) const;
%Docstring
Returns the layout with a matching name, or None if no matching layouts
were found.
@@ -148,7 +148,7 @@ composition will automatically be stored in the manager.
Returns new composition if duplication was successful.
%End

QgsLayout *duplicateLayout( const QgsLayout *layout, const QString &newName );
QgsMasterLayoutInterface *duplicateLayout( const QgsMasterLayoutInterface *layout, const QString &newName );
%Docstring
Duplicates an existing ``layout`` from the manager. The new
layout will automatically be stored in the manager.
@@ -214,7 +214,7 @@ Emitted when a layout is about to be removed from the manager
Emitted when a composition is renamed
%End

void layoutRenamed( QgsLayout *layout, const QString &newName );
void layoutRenamed( QgsMasterLayoutInterface *layout, const QString &newName );
%Docstring
Emitted when a layout is renamed
%End
@@ -163,6 +163,7 @@
%Include composer/qgspaperitem.sip
%Include layout/qgsabstractlayoutiterator.sip
%Include layout/qgsabstractreportsection.sip
%Include layout/qgsmasterlayoutinterface.sip
%Include layout/qgslayoutaligner.sip
%Include layout/qgslayoutexporter.sip
%Include layout/qgslayoutgridsettings.sip
@@ -175,7 +176,6 @@
%Include layout/qgslayoutsnapper.sip
%Include layout/qgslayoutundocommand.sip
%Include layout/qgslayoututils.sip
%Include layout/qgsreport.sip
%Include layout/qgsreportsectionfieldgroup.sip
%Include layout/qgsreportsectionlayout.sip
%Include metadata/qgslayermetadata.sip
@@ -444,6 +444,7 @@
%Include layout/qgslayouttablecolumn.sip
%Include layout/qgslayoutundostack.sip
%Include layout/qgsprintlayout.sip
%Include layout/qgsreport.sip
%Include symbology/qgscptcityarchive.sip
%Include symbology/qgssvgcache.sip
%Include symbology/qgsstyle.sip
@@ -205,7 +205,7 @@ sections form the body of the report section.
.. seealso:: :py:func:`children()`
%End

QList< QgsAbstractReportSection * > children() const;
QList< QgsAbstractReportSection * > childSections() const;
%Docstring
Return all child sections for this report section. The child
sections form the body of the report section.
@@ -221,7 +221,7 @@ sections form the body of the report section.
.. seealso:: :py:func:`removeChild()`
%End

QgsAbstractReportSection *child( int index );
QgsAbstractReportSection *childSection( int index );
%Docstring
Returns the child section at the specified ``index``.

@@ -56,7 +56,7 @@ called on the new layout.

~QgsLayout();

virtual QgsLayout *clone() const /Factory/;
QgsLayout *clone() const /Factory/;
%Docstring
Creates a clone of the layout. Ownership of the return layout
is transferred to the caller.
@@ -86,20 +86,6 @@ relations and various other bits. It is never null.
Returns the items model attached to the layout.
%End

QString name() const;
%Docstring
Returns the layout's name.

.. seealso:: :py:func:`setName()`
%End

void setName( const QString &name );
%Docstring
Sets the layout's name.

.. seealso:: :py:func:`name()`
%End


QList<QgsLayoutItem *> selectedLayoutItems( const bool includeLockedItems = true );
%Docstring
@@ -624,13 +610,6 @@ If None, no item is selected.
%Docstring
Is emitted when the layout has been refreshed and items should also be refreshed
and updated.
%End

void nameChanged( const QString &name );
%Docstring
Emitted when the layout's name is changed.

.. seealso:: :py:func:`setName()`
%End

};
@@ -0,0 +1,76 @@
/************************************************************************
* This file has been generated automatically from *
* *
* src/core/layout/qgsmasterlayoutinterface.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/


class QgsMasterLayoutInterface
{
%Docstring
Interface for master layout type objects, such as print layouts and reports.

.. versionadded:: 3.0
%End

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

virtual ~QgsMasterLayoutInterface();

virtual QgsMasterLayoutInterface *clone() const = 0 /Factory/;
%Docstring
Creates a clone of the layout. Ownership of the returned layout
is transferred to the caller.
%End

virtual QString name() const = 0;
%Docstring
Returns the layout's name.

.. seealso:: :py:func:`setName()`
%End

virtual void setName( const QString &name ) = 0;
%Docstring
Sets the layout's name.

.. seealso:: :py:func:`name()`
%End

virtual QgsProject *layoutProject() const = 0;
%Docstring
The project associated with the layout. Used to get access to layers, map themes,
relations and various other bits. It is never null.
%End

virtual QDomElement writeLayoutXml( QDomDocument &document, const QgsReadWriteContext &context ) const = 0;
%Docstring
Returns the layout's state encapsulated in a DOM element.

.. seealso:: :py:func:`readLayoutXml()`
%End

virtual bool readLayoutXml( const QDomElement &layoutElement, const QDomDocument &document, const QgsReadWriteContext &context ) = 0;
%Docstring
Sets the layout's state from a DOM element. ``layoutElement`` is the DOM node corresponding to the layout.

.. seealso:: :py:func:`writeLayoutXml()`
%End

};




/************************************************************************
* This file has been generated automatically from *
* *
* src/core/layout/qgsmasterlayoutinterface.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/
@@ -8,7 +8,7 @@



class QgsPrintLayout : QgsLayout
class QgsPrintLayout : QgsLayout, QgsMasterLayoutInterface
{
%Docstring
Print layout, a QgsLayout subclass for static or atlas-based layouts.
@@ -28,19 +28,39 @@ Constructor for QgsPrintLayout.

virtual QgsPrintLayout *clone() const /Factory/;

virtual QgsProject *layoutProject() const;


QgsLayoutAtlas *atlas();
%Docstring
Returns the print layout's atlas.
%End

virtual QString name() const;
virtual void setName( const QString &name );


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

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


virtual QDomElement writeLayoutXml( QDomDocument &document, const QgsReadWriteContext &context ) const;

virtual bool readLayoutXml( const QDomElement &layoutElement, const QDomDocument &document, const QgsReadWriteContext &context );

virtual QgsExpressionContext createExpressionContext() const;


signals:

void nameChanged( const QString &name );
%Docstring
Emitted when the layout's name is changed.

.. seealso:: :py:func:`setName()`
%End

};

/************************************************************************
@@ -9,8 +9,7 @@




class QgsReport : QgsAbstractReportSection
class QgsReport : QObject, QgsAbstractReportSection, QgsMasterLayoutInterface
{
%Docstring
Represents a report for use with the QgsLayout engine.
@@ -39,13 +38,25 @@ Constructor for QgsReport, associated with the specified
Note that ownership is not transferred to ``project``.
%End

QgsProject *project();
%Docstring
Returns the associated project.
%End

virtual QgsProject *layoutProject() const;
virtual QgsReport *clone() const /Factory/;

virtual QString name() const;
virtual void setName( const QString &name );

virtual QDomElement writeLayoutXml( QDomDocument &document, const QgsReadWriteContext &context ) const;

virtual bool readLayoutXml( const QDomElement &layoutElement, const QDomDocument &document, const QgsReadWriteContext &context );


signals:

void nameChanged( const QString &name );
%Docstring
Emitted when the report's name is changed.

.. seealso:: :py:func:`setName()`
%End

};

@@ -33,11 +33,17 @@ Constructor for QgsLayoutDesignerInterface.

virtual QgsLayout *layout() = 0;
%Docstring
Returns the layout displayed in the designer.
Returns the current layout displayed in the designer.

.. seealso:: :py:func:`view()`
%End

virtual QgsMasterLayoutInterface *masterLayout() = 0;
%Docstring
Returns the master layout displayed in the designer.

.. seealso:: :py:func:`layout()`
%End

virtual QgsLayoutView *view() = 0;
%Docstring
@@ -636,7 +636,7 @@ Opens the layout manager dialog.
.. versionadded:: 3.0
%End

virtual QgsLayoutDesignerInterface *openLayoutDesigner( QgsLayout *layout ) = 0;
virtual QgsLayoutDesignerInterface *openLayoutDesigner( QgsMasterLayoutInterface *layout ) = 0;
%Docstring
Opens a new layout designer dialog for the specified ``layout``, or
brings an already open designer window to the foreground if one

0 comments on commit 6f2c63f

Please sign in to comment.
You can’t perform that action at this time.