Skip to content

Commit fb712d7

Browse files
committedDec 17, 2017
Decouple QgsLayoutExporter from QgsLayout
1 parent be8d1d7 commit fb712d7

File tree

4 files changed

+5
-16
lines changed

4 files changed

+5
-16
lines changed
 

‎src/core/layout/qgslayout.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ QgsLayout::QgsLayout( QgsProject *project )
3232
, mGridSettings( this )
3333
, mPageCollection( new QgsLayoutPageCollection( this ) )
3434
, mUndoStack( new QgsLayoutUndoStack( this ) )
35-
, mExporter( QgsLayoutExporter( this ) )
3635
{
3736
// just to make sure - this should be the default, but maybe it'll change in some future Qt version...
3837
setBackgroundBrush( Qt::NoBrush );
@@ -112,11 +111,6 @@ QgsLayoutModel *QgsLayout::itemsModel()
112111
return mItemsModel.get();
113112
}
114113

115-
QgsLayoutExporter &QgsLayout::exporter()
116-
{
117-
return mExporter;
118-
}
119-
120114
void QgsLayout::setName( const QString &name )
121115
{
122116
mName = name;

‎src/core/layout/qgslayout.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -93,12 +93,6 @@ class CORE_EXPORT QgsLayout : public QGraphicsScene, public QgsExpressionContext
9393
*/
9494
QgsLayoutModel *itemsModel();
9595

96-
/**
97-
* Returns the layout's exporter, which is used for rendering the layout and exporting
98-
* to various formats.
99-
*/
100-
QgsLayoutExporter &exporter();
101-
10296
/**
10397
* Returns the layout's name.
10498
* \see setName()
@@ -608,7 +602,6 @@ class CORE_EXPORT QgsLayout : public QGraphicsScene, public QgsExpressionContext
608602

609603
std::unique_ptr< QgsLayoutPageCollection > mPageCollection;
610604
std::unique_ptr< QgsLayoutUndoStack > mUndoStack;
611-
QgsLayoutExporter mExporter;
612605

613606
//! List of multiframe objects
614607
QList<QgsLayoutMultiFrame *> mMultiFrames;

‎src/core/qgsmultirenderchecker.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,8 @@ bool QgsLayoutChecker::testLayout( QString &checkedReport, int page, int pixelDi
217217
outputImage.setDotsPerMeterY( mDotsPerMeter );
218218
drawBackground( &outputImage );
219219
QPainter p( &outputImage );
220-
mLayout->exporter().renderPage( &p, page );
220+
QgsLayoutExporter exporter( mLayout );
221+
exporter.renderPage( &p, page );
221222
p.end();
222223

223224
QString renderedFilePath = QDir::tempPath() + '/' + QFileInfo( mTestName ).baseName() + "_rendered.png";

‎tests/src/python/qgslayoutchecker.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
from qgis.PyQt.QtCore import QSize, QDir, QFileInfo
2121
from qgis.PyQt.QtGui import QImage, QPainter
22-
from qgis.core import QgsMultiRenderChecker, QgsLayout
22+
from qgis.core import QgsMultiRenderChecker, QgsLayoutExporter
2323

2424

2525
class QgsLayoutChecker(QgsMultiRenderChecker):
@@ -47,7 +47,8 @@ def testLayout(self, page=0, pixelDiff=0):
4747
outputImage.setDotsPerMeterY(self.dots_per_meter)
4848
QgsMultiRenderChecker.drawBackground(outputImage)
4949
p = QPainter(outputImage)
50-
self.layout.exporter().renderPage(p, page)
50+
exporter = QgsLayoutExporter(self.layout)
51+
exporter.renderPage(p, page)
5152
p.end()
5253

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

0 commit comments

Comments
 (0)
Please sign in to comment.