Skip to content

Commit

Permalink
Layouts have a name
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Jul 18, 2017
1 parent ab79b15 commit a6156d9
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 0 deletions.
13 changes: 13 additions & 0 deletions python/core/layout/qgslayout.sip
Expand Up @@ -26,6 +26,19 @@ class QgsLayout : QGraphicsScene

QgsLayout();

QString name() const;
%Docstring
Returns the layout's name.
.. seealso:: setName()
:rtype: str
%End

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

void setUnits( QgsUnitTypes::LayoutUnit units );
%Docstring
Sets the native measurement ``units`` for the layout. These also form the default unit
Expand Down
14 changes: 14 additions & 0 deletions src/core/layout/qgslayout.h
Expand Up @@ -40,6 +40,18 @@ class CORE_EXPORT QgsLayout : public QGraphicsScene

QgsLayout();

/**
* Returns the layout's name.
* \see setName()
*/
QString name() const { return mName; }

/**
* Sets the layout's name.
* \see name()
*/
void setName( const QString &name ) { mName = name; }

/**
* Sets the native measurement \a units for the layout. These also form the default unit
* for measurements for the layout.
Expand Down Expand Up @@ -117,6 +129,8 @@ class CORE_EXPORT QgsLayout : public QGraphicsScene

private:

QString mName;

QgsUnitTypes::LayoutUnit mUnits = QgsUnitTypes::LayoutMillimeters;
QgsLayoutContext mContext;

Expand Down
9 changes: 9 additions & 0 deletions tests/src/core/testqgslayout.cpp
Expand Up @@ -29,6 +29,7 @@ class TestQgsLayout: public QObject
void cleanup();// will be called after every testfunction.
void creation(); //test creation of QgsLayout
void units();
void name();

private:
QString mReport;
Expand Down Expand Up @@ -117,6 +118,14 @@ void TestQgsLayout::units()
QCOMPARE( pointResult.y(), 2.0 );
}

void TestQgsLayout::name()
{
QgsLayout layout;
QString layoutName = "test name";
layout.setName( layoutName );
QCOMPARE( layout.name(), layoutName );
}


QGSTEST_MAIN( TestQgsLayout )
#include "testqgslayout.moc"

0 comments on commit a6156d9

Please sign in to comment.