QGIS API Documentation  3.6.0-Noosa (5873452)
qgsreport.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  qgsreport.cpp
3  --------------------
4  begin : December 2017
5  copyright : (C) 2017 by Nyall Dawson
6  email : nyall dot dawson at gmail dot com
7  ***************************************************************************/
8 /***************************************************************************
9  * *
10  * This program is free software; you can redistribute it and/or modify *
11  * it under the terms of the GNU General Public License as published by *
12  * the Free Software Foundation; either version 2 of the License, or *
13  * (at your option) any later version. *
14  * *
15  ***************************************************************************/
16 
17 #include "qgsreport.h"
18 #include "qgslayout.h"
19 
21 
22 QgsReport::QgsReport( QgsProject *project )
23  : QgsAbstractReportSection( nullptr )
24  , mProject( project )
25 {}
26 
27 QIcon QgsReport::icon() const
28 {
29  return QgsApplication::getThemeIcon( QStringLiteral( "mIconReport.svg" ) );
30 }
31 
32 QgsReport *QgsReport::clone() const
33 {
34  std::unique_ptr< QgsReport > copy = qgis::make_unique< QgsReport >( mProject );
35  copyCommonProperties( copy.get() );
36  return copy.release();
37 }
38 
39 void QgsReport::setName( const QString &name )
40 {
41  mName = name;
42  emit nameChanged( mName );
43 }
44 
45 QDomElement QgsReport::writeLayoutXml( QDomDocument &document, const QgsReadWriteContext &context ) const
46 {
47  QDomElement element = document.createElement( QStringLiteral( "Report" ) );
48  writeXml( element, document, context );
49  element.setAttribute( QStringLiteral( "name" ), mName );
50  return element;
51 }
52 
53 bool QgsReport::readLayoutXml( const QDomElement &layoutElement, const QDomDocument &document, const QgsReadWriteContext &context )
54 {
55  const QDomNodeList sectionList = layoutElement.elementsByTagName( QStringLiteral( "Section" ) );
56  if ( sectionList.count() > 0 )
57  {
58  readXml( sectionList.at( 0 ).toElement(), document, context );
59  }
60  setName( layoutElement.attribute( QStringLiteral( "name" ) ) );
61  return true;
62 }
63 
64 void QgsReport::updateSettings()
65 {
67 }
68 
69 QgsMasterLayoutInterface::Type QgsReport::layoutType() const
70 {
72 }
73 
The class is used as a container of context for various read/write operations on other objects...
static QIcon getThemeIcon(const QString &name)
Helper to get a theme icon.
bool readXml(const QDomElement &layoutElement, const QDomDocument &document, const QgsReadWriteContext &context) override
Sets the collection&#39;s state from a DOM element.
Reads and writes project states.
Definition: qgsproject.h:89
QDomElement writeXml(QDomDocument &document, const QgsReadWriteContext &context) const override
Returns the layout&#39;s state encapsulated in a DOM element.
void nameChanged(const QString &name)
Emitted when the layout&#39;s name is changed.
void setName(const QString &name) override
Sets the layout&#39;s name.
void reloadSettings()
Refreshes the layout when global layout related options change.
Definition: qgslayout.cpp:377
QString name() const override
Returns the layout&#39;s name.