Add QgsLayout subclass, QgsPrintLayout

A print layout is a layout with an atlas
This commit is contained in:
Nyall Dawson 2017-12-19 14:53:11 +10:00
parent bd7784cd00
commit e6a6db89a1
8 changed files with 125 additions and 3 deletions

View File

@ -437,6 +437,7 @@
%Include layout/qgslayouttable.sip
%Include layout/qgslayouttablecolumn.sip
%Include layout/qgslayoutundostack.sip
%Include layout/qgsprintlayout.sip
%Include symbology/qgscptcityarchive.sip
%Include symbology/qgssvgcache.sip
%Include symbology/qgsstyle.sip

View File

@ -29,7 +29,7 @@ QgsLayoutAtlas which is automatically created and attached to the composition.
%End
public:
QgsLayoutAtlas( QgsLayout *layout );
QgsLayoutAtlas( QgsLayout *layout /TransferThis/ );
%Docstring
Constructor for new QgsLayoutAtlas.
%End

View File

@ -0,0 +1,42 @@
/************************************************************************
* This file has been generated automatically from *
* *
* src/core/layout/qgsprintlayout.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/
class QgsPrintLayout : QgsLayout
{
%Docstring
Print layout, a QgsLayout subclass for static or atlas-based layouts.
.. versionadded:: 3.0
%End
%TypeHeaderCode
#include "qgsprintlayout.h"
%End
public:
QgsPrintLayout( QgsProject *project );
%Docstring
Constructor for QgsPrintLayout.
%End
QgsLayoutAtlas *atlas();
%Docstring
Returns the print layout's atlas.
%End
};
/************************************************************************
* This file has been generated automatically from *
* *
* src/core/layout/qgsprintlayout.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/

View File

@ -412,6 +412,7 @@ SET(QGIS_CORE_SRCS
layout/qgslayoutpoint.cpp
layout/qgslayoutserializableobject.cpp
layout/qgslayoutsize.cpp
layout/qgsprintlayout.cpp
pal/costcalculator.cpp
pal/feature.cpp
@ -770,6 +771,7 @@ SET(QGIS_CORE_MOC_HDRS
layout/qgslayouttable.h
layout/qgslayouttablecolumn.h
layout/qgslayoutundostack.h
layout/qgsprintlayout.h
symbology/qgscptcityarchive.h
symbology/qgssvgcache.h

View File

@ -22,7 +22,8 @@
#include "qgslayout.h"
QgsLayoutAtlas::QgsLayoutAtlas( QgsLayout *layout )
: mLayout( layout )
: QObject( layout )
, mLayout( layout )
, mFilenameExpressionString( QStringLiteral( "'output_'||@atlas_featurenumber" ) )
{

View File

@ -40,7 +40,7 @@ class CORE_EXPORT QgsLayoutAtlas : public QObject
/**
* Constructor for new QgsLayoutAtlas.
*/
QgsLayoutAtlas( QgsLayout *layout );
QgsLayoutAtlas( QgsLayout *layout SIP_TRANSFERTHIS );
/**
* Returns whether the atlas generation is enabled

View File

@ -0,0 +1,24 @@
/***************************************************************************
qgsprintlayout.cpp
-------------------
begin : December 2017
copyright : (C) 2017 by Nyall Dawson
email : nyall dot dawson at gmail dot com
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#include "qgsprintlayout.h"
#include "qgslayoutatlas.h"
QgsPrintLayout::QgsPrintLayout( QgsProject *project )
: QgsLayout( project )
, mAtlas( new QgsLayoutAtlas( this ) )
{
}

View File

@ -0,0 +1,52 @@
/***************************************************************************
qgsprintlayout.h
-------------------
begin : December 2017
copyright : (C) 2017 by Nyall Dawson
email : nyall dot dawson at gmail dot com
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef QGSPRINTLAYOUT_H
#define QGSPRINTLAYOUT_H
#include "qgis_core.h"
#include "qgslayout.h"
class QgsLayoutAtlas;
/**
* \ingroup core
* \class QgsPrintLayout
* \brief Print layout, a QgsLayout subclass for static or atlas-based layouts.
* \since QGIS 3.0
*/
class CORE_EXPORT QgsPrintLayout : public QgsLayout
{
Q_OBJECT
public:
/**
* Constructor for QgsPrintLayout.
*/
QgsPrintLayout( QgsProject *project );
/**
* Returns the print layout's atlas.
*/
QgsLayoutAtlas *atlas();
private:
QgsLayoutAtlas *mAtlas = nullptr;
};
#endif //QGSPRINTLAYOUT_H