Skip to content

Commit

Permalink
Decouple QgsLayoutExporter from QgsLayout
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Dec 17, 2017
1 parent be8d1d7 commit fb712d7
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 16 deletions.
6 changes: 0 additions & 6 deletions src/core/layout/qgslayout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ QgsLayout::QgsLayout( QgsProject *project )
, mGridSettings( this )
, mPageCollection( new QgsLayoutPageCollection( this ) )
, mUndoStack( new QgsLayoutUndoStack( this ) )
, mExporter( QgsLayoutExporter( this ) )
{
// just to make sure - this should be the default, but maybe it'll change in some future Qt version...
setBackgroundBrush( Qt::NoBrush );
Expand Down Expand Up @@ -112,11 +111,6 @@ QgsLayoutModel *QgsLayout::itemsModel()
return mItemsModel.get();
}

QgsLayoutExporter &QgsLayout::exporter()
{
return mExporter;
}

void QgsLayout::setName( const QString &name )
{
mName = name;
Expand Down
7 changes: 0 additions & 7 deletions src/core/layout/qgslayout.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,6 @@ class CORE_EXPORT QgsLayout : public QGraphicsScene, public QgsExpressionContext
*/
QgsLayoutModel *itemsModel();

/**
* Returns the layout's exporter, which is used for rendering the layout and exporting
* to various formats.
*/
QgsLayoutExporter &exporter();

/**
* Returns the layout's name.
* \see setName()
Expand Down Expand Up @@ -608,7 +602,6 @@ class CORE_EXPORT QgsLayout : public QGraphicsScene, public QgsExpressionContext

std::unique_ptr< QgsLayoutPageCollection > mPageCollection;
std::unique_ptr< QgsLayoutUndoStack > mUndoStack;
QgsLayoutExporter mExporter;

//! List of multiframe objects
QList<QgsLayoutMultiFrame *> mMultiFrames;
Expand Down
3 changes: 2 additions & 1 deletion src/core/qgsmultirenderchecker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,8 @@ bool QgsLayoutChecker::testLayout( QString &checkedReport, int page, int pixelDi
outputImage.setDotsPerMeterY( mDotsPerMeter );
drawBackground( &outputImage );
QPainter p( &outputImage );
mLayout->exporter().renderPage( &p, page );
QgsLayoutExporter exporter( mLayout );
exporter.renderPage( &p, page );
p.end();

QString renderedFilePath = QDir::tempPath() + '/' + QFileInfo( mTestName ).baseName() + "_rendered.png";
Expand Down
5 changes: 3 additions & 2 deletions tests/src/python/qgslayoutchecker.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

from qgis.PyQt.QtCore import QSize, QDir, QFileInfo
from qgis.PyQt.QtGui import QImage, QPainter
from qgis.core import QgsMultiRenderChecker, QgsLayout
from qgis.core import QgsMultiRenderChecker, QgsLayoutExporter


class QgsLayoutChecker(QgsMultiRenderChecker):
Expand Down Expand Up @@ -47,7 +47,8 @@ def testLayout(self, page=0, pixelDiff=0):
outputImage.setDotsPerMeterY(self.dots_per_meter)
QgsMultiRenderChecker.drawBackground(outputImage)
p = QPainter(outputImage)
self.layout.exporter().renderPage(p, page)
exporter = QgsLayoutExporter(self.layout)
exporter.renderPage(p, page)
p.end()

renderedFilePath = QDir.tempPath() + QDir.separator() + QFileInfo(self.test_name).baseName() + "_rendered.png"
Expand Down

0 comments on commit fb712d7

Please sign in to comment.