Skip to content
Permalink
Browse files

Layouts have a name

  • Loading branch information
nyalldawson committed Jul 7, 2017
1 parent ab79b15 commit a6156d9221d2355ebb6aea618203b76d2b0df8a7
Showing with 36 additions and 0 deletions.
  1. +13 −0 python/core/layout/qgslayout.sip
  2. +14 −0 src/core/layout/qgslayout.h
  3. +9 −0 tests/src/core/testqgslayout.cpp
@@ -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
@@ -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.
@@ -117,6 +129,8 @@ class CORE_EXPORT QgsLayout : public QGraphicsScene

private:

QString mName;

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

@@ -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;
@@ -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.
You can’t perform that action at this time.