Better display names for page items

These can't have ids set, so default to a nicer looking name
This commit is contained in:
Nyall Dawson 2019-08-10 15:44:51 +10:00
parent 6bf088a106
commit 0f2a4828e4
4 changed files with 9 additions and 1 deletions

View File

@ -48,6 +48,8 @@ The caller takes responsibility for deleting the returned object.
virtual int type() const;
virtual QString displayName() const;
void setPageSize( const QgsLayoutSize &size );
%Docstring

View File

@ -56,6 +56,11 @@ int QgsLayoutItemPage::type() const
return QgsLayoutItemRegistry::LayoutPage;
}
QString QgsLayoutItemPage::displayName() const
{
return QObject::tr( "Page" );
}
void QgsLayoutItemPage::setPageSize( const QgsLayoutSize &size )
{
attemptResize( size );

View File

@ -84,6 +84,7 @@ class CORE_EXPORT QgsLayoutItemPage : public QgsLayoutItem
static QgsLayoutItemPage *create( QgsLayout *layout ) SIP_FACTORY;
int type() const override;
QString displayName() const override;
/**
* Sets the \a size of the page.

View File

@ -89,7 +89,7 @@ void TestQgsLayoutExporter::testHandleLayeredExport()
res = exporter.handleLayeredExport( items, exportFunc );
QCOMPARE( res, QgsLayoutExporter::Success );
QCOMPARE( layerIds, QList< unsigned int >() << 1 );
QCOMPARE( layerNames, QStringList() << QStringLiteral( "<Page>" ) );
QCOMPARE( layerNames, QStringList() << QStringLiteral( "Page" ) );
QCOMPARE( mapLayerIds, QStringList() << QString() );
layerIds.clear();
layerNames.clear();