diff --git a/python/core/layout/qgsreportsectionfieldgroup.sip b/python/core/layout/qgsreportsectionfieldgroup.sip index d90da6c185d..7164de4d377 100644 --- a/python/core/layout/qgsreportsectionfieldgroup.sip +++ b/python/core/layout/qgsreportsectionfieldgroup.sip @@ -43,6 +43,10 @@ Note that ownership is not transferred to ``parent``. Returns the body layout for the section. .. seealso:: :py:func:`setBody()` + +.. seealso:: :py:func:`bodyEnabled()` + +.. seealso:: :py:func:`setBodyEnabled()` %End void setBody( QgsLayout *body /Transfer/ ); @@ -51,8 +55,35 @@ Sets the ``body`` layout for the section. Ownership of ``body`` is transferred to the report section. .. seealso:: :py:func:`body()` + +.. seealso:: :py:func:`bodyEnabled()` + +.. seealso:: :py:func:`setBodyEnabled()` %End + bool bodyEnabled() const; +%Docstring +Returns true if the body for the section is enabled. + +.. seealso:: :py:func:`setBodyEnabled()` + +.. seealso:: :py:func:`body()` + +.. seealso:: :py:func:`setBody()` +%End + + void setBodyEnabled( bool enabled ); +%Docstring +Sets whether the body for the section is ``enabled``. + +.. seealso:: :py:func:`bodyEnabled()` + +.. seealso:: :py:func:`body()` + +.. seealso:: :py:func:`setBody()` +%End + + QgsVectorLayer *layer(); %Docstring Returns the vector layer associated with this section. diff --git a/python/core/layout/qgsreportsectionlayout.sip b/python/core/layout/qgsreportsectionlayout.sip index 61992e7089c..60c018c4786 100644 --- a/python/core/layout/qgsreportsectionlayout.sip +++ b/python/core/layout/qgsreportsectionlayout.sip @@ -41,6 +41,10 @@ Note that ownership is not transferred to ``parent``. Returns the body layout for the section. .. seealso:: :py:func:`setBody()` + +.. seealso:: :py:func:`bodyEnabled()` + +.. seealso:: :py:func:`setBodyEnabled()` %End void setBody( QgsLayout *body /Transfer/ ); @@ -49,6 +53,32 @@ Sets the ``body`` layout for the section. Ownership of ``body`` is transferred to the report section. .. seealso:: :py:func:`body()` + +.. seealso:: :py:func:`bodyEnabled()` + +.. seealso:: :py:func:`setBodyEnabled()` +%End + + bool bodyEnabled() const; +%Docstring +Returns true if the body for the section is enabled. + +.. seealso:: :py:func:`setBodyEnabled()` + +.. seealso:: :py:func:`body()` + +.. seealso:: :py:func:`setBody()` +%End + + void setBodyEnabled( bool enabled ); +%Docstring +Sets whether the body for the section is ``enabled``. + +.. seealso:: :py:func:`bodyEnabled()` + +.. seealso:: :py:func:`body()` + +.. seealso:: :py:func:`setBody()` %End virtual QgsReportSectionLayout *clone() const /Factory/; diff --git a/src/app/CMakeLists.txt b/src/app/CMakeLists.txt index a59758086e9..a246eeb0c91 100644 --- a/src/app/CMakeLists.txt +++ b/src/app/CMakeLists.txt @@ -208,6 +208,7 @@ SET(QGIS_APP_SRCS layout/qgsreportlayoutsectionwidget.cpp layout/qgsreportorganizerwidget.cpp layout/qgsreportsectionmodel.cpp + layout/qgsreportsectionwidget.cpp locator/qgsinbuiltlocatorfilters.cpp locator/qgslocatoroptionswidget.cpp @@ -431,6 +432,7 @@ SET (QGIS_APP_MOC_HDRS layout/qgsreportlayoutsectionwidget.h layout/qgsreportorganizerwidget.h layout/qgsreportsectionmodel.h + layout/qgsreportsectionwidget.h locator/qgsinbuiltlocatorfilters.h locator/qgslocatoroptionswidget.h diff --git a/src/app/layout/qgsreportfieldgroupsectionwidget.cpp b/src/app/layout/qgsreportfieldgroupsectionwidget.cpp index 64e05556476..32306bca7b4 100644 --- a/src/app/layout/qgsreportfieldgroupsectionwidget.cpp +++ b/src/app/layout/qgsreportfieldgroupsectionwidget.cpp @@ -29,14 +29,70 @@ QgsReportSectionFieldGroupWidget::QgsReportSectionFieldGroupWidget( QWidget *par mLayerComboBox->setFilters( QgsMapLayerProxyModel::VectorLayer ); connect( mLayerComboBox, &QgsMapLayerComboBox::layerChanged, mFieldComboBox, &QgsFieldComboBox::setLayer ); connect( mButtonEditBody, &QPushButton::clicked, this, &QgsReportSectionFieldGroupWidget::editBody ); + connect( mButtonEditHeader, &QPushButton::clicked, this, &QgsReportSectionFieldGroupWidget::editHeader ); + connect( mButtonEditFooter, &QPushButton::clicked, this, &QgsReportSectionFieldGroupWidget::editFooter ); mLayerComboBox->setLayer( section->layer() ); mFieldComboBox->setField( section->field() ); mSortAscendingCheckBox->setChecked( section->sortAscending() ); + mCheckShowHeader->setChecked( section->headerEnabled() ); + mCheckShowFooter->setChecked( section->footerEnabled() ); + mCheckShowBody->setChecked( section->bodyEnabled() ); + connect( mSortAscendingCheckBox, &QCheckBox::toggled, this, &QgsReportSectionFieldGroupWidget::sortAscendingToggled ); connect( mLayerComboBox, &QgsMapLayerComboBox::layerChanged, this, &QgsReportSectionFieldGroupWidget::setLayer ); connect( mFieldComboBox, &QgsFieldComboBox::fieldChanged, this, &QgsReportSectionFieldGroupWidget::setField ); + connect( mCheckShowHeader, &QCheckBox::toggled, this, &QgsReportSectionFieldGroupWidget::toggleHeader ); + connect( mCheckShowFooter, &QCheckBox::toggled, this, &QgsReportSectionFieldGroupWidget::toggleFooter ); + connect( mCheckShowBody, &QCheckBox::toggled, this, &QgsReportSectionFieldGroupWidget::toggleBody ); +} + +void QgsReportSectionFieldGroupWidget::toggleHeader( bool enabled ) +{ + mSection->setHeaderEnabled( enabled ); +} + +void QgsReportSectionFieldGroupWidget::toggleFooter( bool enabled ) +{ + mSection->setFooterEnabled( enabled ); +} + +void QgsReportSectionFieldGroupWidget::editHeader() +{ + if ( !mSection->header() ) + { + std::unique_ptr< QgsLayout > header = qgis::make_unique< QgsLayout >( mSection->project() ); + header->initializeDefaults(); + mSection->setHeader( header.release() ); + } + + if ( mSection->header() ) + { + mSection->header()->reportContext().setLayer( mSection->layer() ); + mDesigner->setCurrentLayout( mSection->header() ); + } +} + +void QgsReportSectionFieldGroupWidget::editFooter() +{ + if ( !mSection->footer() ) + { + std::unique_ptr< QgsLayout > footer = qgis::make_unique< QgsLayout >( mSection->project() ); + footer->initializeDefaults(); + mSection->setFooter( footer.release() ); + } + + if ( mSection->footer() ) + { + mSection->footer()->reportContext().setLayer( mSection->layer() ); + mDesigner->setCurrentLayout( mSection->footer() ); + } +} + +void QgsReportSectionFieldGroupWidget::toggleBody( bool enabled ) +{ + mSection->setBodyEnabled( enabled ); } void QgsReportSectionFieldGroupWidget::editBody() diff --git a/src/app/layout/qgsreportfieldgroupsectionwidget.h b/src/app/layout/qgsreportfieldgroupsectionwidget.h index e75c3f28f3d..bbc3d730819 100644 --- a/src/app/layout/qgsreportfieldgroupsectionwidget.h +++ b/src/app/layout/qgsreportfieldgroupsectionwidget.h @@ -30,6 +30,11 @@ class QgsReportSectionFieldGroupWidget: public QWidget, private Ui::QgsReportWid private slots: + void toggleHeader( bool enabled ); + void toggleFooter( bool enabled ); + void editHeader(); + void editFooter(); + void toggleBody( bool enabled ); void editBody(); void sortAscendingToggled( bool checked ); void setLayer( QgsMapLayer *layer ); diff --git a/src/app/layout/qgsreportlayoutsectionwidget.cpp b/src/app/layout/qgsreportlayoutsectionwidget.cpp index 946e55b26e9..002a310708f 100644 --- a/src/app/layout/qgsreportlayoutsectionwidget.cpp +++ b/src/app/layout/qgsreportlayoutsectionwidget.cpp @@ -27,6 +27,61 @@ QgsReportLayoutSectionWidget::QgsReportLayoutSectionWidget( QWidget *parent, Qgs setupUi( this ); connect( mButtonEditBody, &QPushButton::clicked, this, &QgsReportLayoutSectionWidget::editBody ); + connect( mButtonEditHeader, &QPushButton::clicked, this, &QgsReportLayoutSectionWidget::editHeader ); + connect( mButtonEditFooter, &QPushButton::clicked, this, &QgsReportLayoutSectionWidget::editFooter ); + + mCheckShowHeader->setChecked( section->headerEnabled() ); + mCheckShowFooter->setChecked( section->footerEnabled() ); + mCheckShowBody->setChecked( section->bodyEnabled() ); + + connect( mCheckShowHeader, &QCheckBox::toggled, this, &QgsReportLayoutSectionWidget::toggleHeader ); + connect( mCheckShowFooter, &QCheckBox::toggled, this, &QgsReportLayoutSectionWidget::toggleFooter ); + connect( mCheckShowBody, &QCheckBox::toggled, this, &QgsReportLayoutSectionWidget::toggleBody ); +} + +void QgsReportLayoutSectionWidget::toggleHeader( bool enabled ) +{ + mSection->setHeaderEnabled( enabled ); +} + +void QgsReportLayoutSectionWidget::toggleFooter( bool enabled ) +{ + mSection->setFooterEnabled( enabled ); +} + +void QgsReportLayoutSectionWidget::editHeader() +{ + if ( !mSection->header() ) + { + std::unique_ptr< QgsLayout > header = qgis::make_unique< QgsLayout >( mSection->project() ); + header->initializeDefaults(); + mSection->setHeader( header.release() ); + } + + if ( mSection->header() ) + { + mDesigner->setCurrentLayout( mSection->header() ); + } +} + +void QgsReportLayoutSectionWidget::editFooter() +{ + if ( !mSection->footer() ) + { + std::unique_ptr< QgsLayout > footer = qgis::make_unique< QgsLayout >( mSection->project() ); + footer->initializeDefaults(); + mSection->setFooter( footer.release() ); + } + + if ( mSection->footer() ) + { + mDesigner->setCurrentLayout( mSection->footer() ); + } +} + +void QgsReportLayoutSectionWidget::toggleBody( bool enabled ) +{ + mSection->setBodyEnabled( enabled ); } void QgsReportLayoutSectionWidget::editBody() diff --git a/src/app/layout/qgsreportlayoutsectionwidget.h b/src/app/layout/qgsreportlayoutsectionwidget.h index d1d9c40cafd..82aa8bdb689 100644 --- a/src/app/layout/qgsreportlayoutsectionwidget.h +++ b/src/app/layout/qgsreportlayoutsectionwidget.h @@ -30,6 +30,11 @@ class QgsReportLayoutSectionWidget: public QWidget, private Ui::QgsReportWidgetL private slots: + void toggleHeader( bool enabled ); + void toggleFooter( bool enabled ); + void editHeader(); + void editFooter(); + void toggleBody( bool enabled ); void editBody(); private: diff --git a/src/app/layout/qgsreportorganizerwidget.cpp b/src/app/layout/qgsreportorganizerwidget.cpp index d800b136780..9a7510d9303 100644 --- a/src/app/layout/qgsreportorganizerwidget.cpp +++ b/src/app/layout/qgsreportorganizerwidget.cpp @@ -22,6 +22,7 @@ #include "qgslayout.h" #include "qgslayoutdesignerdialog.h" #include "qgsreportlayoutsectionwidget.h" +#include "qgsreportsectionwidget.h" #include "qgsreportfieldgroupsectionwidget.h" #include #include @@ -61,10 +62,6 @@ QgsReportOrganizerWidget::QgsReportOrganizerWidget( QWidget *parent, QgsLayoutDe addMenu->addAction( fieldGroupSection ); connect( fieldGroupSection, &QAction::triggered, this, &QgsReportOrganizerWidget::addFieldGroupSection ); - connect( mCheckShowHeader, &QCheckBox::toggled, this, &QgsReportOrganizerWidget::toggleHeader ); - connect( mCheckShowFooter, &QCheckBox::toggled, this, &QgsReportOrganizerWidget::toggleFooter ); - connect( mButtonEditHeader, &QPushButton::clicked, this, &QgsReportOrganizerWidget::editHeader ); - connect( mButtonEditFooter, &QPushButton::clicked, this, &QgsReportOrganizerWidget::editFooter ); connect( mViewSections->selectionModel(), &QItemSelectionModel::currentChanged, this, &QgsReportOrganizerWidget::selectionChanged ); mButtonAddSection->setMenu( addMenu ); @@ -109,63 +106,12 @@ void QgsReportOrganizerWidget::removeSection() mSectionModel->removeRow( mViewSections->currentIndex().row(), mViewSections->currentIndex().parent() ); } -void QgsReportOrganizerWidget::toggleHeader( bool enabled ) -{ - QgsAbstractReportSection *parent = mSectionModel->sectionForIndex( mViewSections->currentIndex() ); - if ( !parent ) - parent = mReport; - parent->setHeaderEnabled( enabled ); -} - -void QgsReportOrganizerWidget::toggleFooter( bool enabled ) -{ - QgsAbstractReportSection *parent = mSectionModel->sectionForIndex( mViewSections->currentIndex() ); - if ( !parent ) - parent = mReport; - parent->setFooterEnabled( enabled ); -} - -void QgsReportOrganizerWidget::editHeader() -{ - QgsAbstractReportSection *parent = mSectionModel->sectionForIndex( mViewSections->currentIndex() ); - if ( !parent ) - parent = mReport; - - if ( !parent->header() ) - { - std::unique_ptr< QgsLayout > header = qgis::make_unique< QgsLayout >( mReport->layoutProject() ); - header->initializeDefaults(); - parent->setHeader( header.release() ); - } - - mDesigner->setCurrentLayout( parent->header() ); -} - -void QgsReportOrganizerWidget::editFooter() -{ - QgsAbstractReportSection *parent = mSectionModel->sectionForIndex( mViewSections->currentIndex() ); - if ( !parent ) - parent = mReport; - - if ( !parent->footer() ) - { - std::unique_ptr< QgsLayout > footer = qgis::make_unique< QgsLayout >( mReport->layoutProject() ); - footer->initializeDefaults(); - parent->setFooter( footer.release() ); - } - - mDesigner->setCurrentLayout( parent->footer() ); -} - void QgsReportOrganizerWidget::selectionChanged( const QModelIndex ¤t, const QModelIndex & ) { QgsAbstractReportSection *parent = mSectionModel->sectionForIndex( current ); if ( !parent ) parent = mReport; - whileBlocking( mCheckShowHeader )->setChecked( parent->headerEnabled() ); - whileBlocking( mCheckShowFooter )->setChecked( parent->footerEnabled() ); - delete mConfigWidget; if ( QgsReportSectionLayout *section = dynamic_cast< QgsReportSectionLayout * >( parent ) ) { @@ -179,6 +125,12 @@ void QgsReportOrganizerWidget::selectionChanged( const QModelIndex ¤t, con mSettingsFrame->layout()->addWidget( widget ); mConfigWidget = widget; } + else if ( QgsReport *section = dynamic_cast< QgsReport * >( parent ) ) + { + QgsReportSectionWidget *widget = new QgsReportSectionWidget( this, mDesigner, section ); + mSettingsFrame->layout()->addWidget( widget ); + mConfigWidget = widget; + } else { mConfigWidget = nullptr; diff --git a/src/app/layout/qgsreportorganizerwidget.h b/src/app/layout/qgsreportorganizerwidget.h index 94788bfd41d..7184d9a7361 100644 --- a/src/app/layout/qgsreportorganizerwidget.h +++ b/src/app/layout/qgsreportorganizerwidget.h @@ -39,10 +39,6 @@ class QgsReportOrganizerWidget: public QgsPanelWidget, private Ui::QgsReportOrga void addLayoutSection(); void addFieldGroupSection(); void removeSection(); - void toggleHeader( bool enabled ); - void toggleFooter( bool enabled ); - void editHeader(); - void editFooter(); void selectionChanged( const QModelIndex ¤t, const QModelIndex &previous ); private: diff --git a/src/app/layout/qgsreportsectionwidget.cpp b/src/app/layout/qgsreportsectionwidget.cpp new file mode 100644 index 00000000000..237e3bf868c --- /dev/null +++ b/src/app/layout/qgsreportsectionwidget.cpp @@ -0,0 +1,78 @@ +/*************************************************************************** + qgsreportsectionwidget.cpp + ------------------------ + begin : December 2017 + copyright : (C) 2017 by Nyall Dawson + email : nyall dot dawson at gmail dot com + ***************************************************************************/ +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#include "qgsreportsectionwidget.h" +#include "qgsreport.h" +#include "qgslayout.h" +#include "qgslayoutdesignerdialog.h" + +QgsReportSectionWidget::QgsReportSectionWidget( QWidget *parent, QgsLayoutDesignerDialog *designer, QgsReport *section ) + : QWidget( parent ) + , mSection( section ) + , mDesigner( designer ) +{ + setupUi( this ); + + connect( mButtonEditHeader, &QPushButton::clicked, this, &QgsReportSectionWidget::editHeader ); + connect( mButtonEditFooter, &QPushButton::clicked, this, &QgsReportSectionWidget::editFooter ); + + mCheckShowHeader->setChecked( section->headerEnabled() ); + mCheckShowFooter->setChecked( section->footerEnabled() ); + + connect( mCheckShowHeader, &QCheckBox::toggled, this, &QgsReportSectionWidget::toggleHeader ); + connect( mCheckShowFooter, &QCheckBox::toggled, this, &QgsReportSectionWidget::toggleFooter ); +} + +void QgsReportSectionWidget::toggleHeader( bool enabled ) +{ + mSection->setHeaderEnabled( enabled ); +} + +void QgsReportSectionWidget::toggleFooter( bool enabled ) +{ + mSection->setFooterEnabled( enabled ); +} + +void QgsReportSectionWidget::editHeader() +{ + if ( !mSection->header() ) + { + std::unique_ptr< QgsLayout > header = qgis::make_unique< QgsLayout >( mSection->project() ); + header->initializeDefaults(); + mSection->setHeader( header.release() ); + } + + if ( mSection->header() ) + { + mDesigner->setCurrentLayout( mSection->header() ); + } +} + +void QgsReportSectionWidget::editFooter() +{ + if ( !mSection->footer() ) + { + std::unique_ptr< QgsLayout > footer = qgis::make_unique< QgsLayout >( mSection->project() ); + footer->initializeDefaults(); + mSection->setFooter( footer.release() ); + } + + if ( mSection->footer() ) + { + mDesigner->setCurrentLayout( mSection->footer() ); + } +} + diff --git a/src/app/layout/qgsreportsectionwidget.h b/src/app/layout/qgsreportsectionwidget.h new file mode 100644 index 00000000000..e2c99bba35a --- /dev/null +++ b/src/app/layout/qgsreportsectionwidget.h @@ -0,0 +1,45 @@ +/*************************************************************************** + qgsreportsectionwidget.h + ---------------------- + begin : December 2017 + copyright : (C) 2017 by Nyall Dawson + email : nyall dot dawson at gmail dot com + ***************************************************************************/ +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#ifndef QGSREPORTSECTIONWIDGET_H +#define QGSREPORTSECTIONWIDGET_H + +#include "ui_qgsreportwidgetsectionbase.h" + +class QgsLayoutDesignerDialog; +class QgsReport; + +class QgsReportSectionWidget: public QWidget, private Ui::QgsReportWidgetSectionBase +{ + Q_OBJECT + public: + QgsReportSectionWidget( QWidget *parent, QgsLayoutDesignerDialog *designer, QgsReport *section ); + + private slots: + + void toggleHeader( bool enabled ); + void toggleFooter( bool enabled ); + void editHeader(); + void editFooter(); + + private: + + QgsReport *mSection = nullptr; + QgsLayoutDesignerDialog *mDesigner = nullptr; + +}; + +#endif // QGSREPORTSECTIONWIDGET_H diff --git a/src/core/layout/qgsreportsectionfieldgroup.cpp b/src/core/layout/qgsreportsectionfieldgroup.cpp index 693188d5f9c..460dd9f572e 100644 --- a/src/core/layout/qgsreportsectionfieldgroup.cpp +++ b/src/core/layout/qgsreportsectionfieldgroup.cpp @@ -45,6 +45,7 @@ QgsReportSectionFieldGroup *QgsReportSectionFieldGroup::clone() const copy->setLayer( mCoverageLayer.get() ); copy->setField( mField ); copy->setSortAscending( mSortAscending ); + copy->setBodyEnabled( mBodyEnabled ); return copy.release(); } @@ -124,8 +125,8 @@ QgsLayout *QgsReportSectionFieldGroup::nextBody( bool &ok ) updateChildContexts( f ); - ok = true; - if ( mBody ) + ok = mBodyEnabled; + if ( mBody && mBodyEnabled ) { mBody->reportContext().blockSignals( true ); mBody->reportContext().setLayer( mCoverageLayer.get() ); @@ -133,7 +134,7 @@ QgsLayout *QgsReportSectionFieldGroup::nextBody( bool &ok ) mBody->reportContext().setFeature( f ); } - return mBody.get(); + return mBodyEnabled ? mBody.get() : nullptr; } void QgsReportSectionFieldGroup::reset() @@ -157,7 +158,7 @@ bool QgsReportSectionFieldGroup::writePropertiesToElement( QDomElement &element, { element.setAttribute( QStringLiteral( "field" ), mField ); element.setAttribute( QStringLiteral( "ascending" ), mSortAscending ? "1" : "0" ); - + element.setAttribute( QStringLiteral( "bodyEnabled" ), mBodyEnabled ? "1" : "0" ); if ( mCoverageLayer ) { element.setAttribute( QStringLiteral( "coverageLayer" ), mCoverageLayer.layerId ); @@ -179,7 +180,7 @@ bool QgsReportSectionFieldGroup::readPropertiesFromElement( const QDomElement &e { mField = element.attribute( QStringLiteral( "field" ) ); mSortAscending = element.attribute( QStringLiteral( "ascending" ) ).toInt(); - + mBodyEnabled = element.attribute( QStringLiteral( "bodyEnabled" ) ).toInt(); QString layerId = element.attribute( QStringLiteral( "coverageLayer" ) ); QString layerName = element.attribute( QStringLiteral( "coverageLayerName" ) ); QString layerSource = element.attribute( QStringLiteral( "coverageLayerSource" ) ); @@ -223,7 +224,7 @@ QgsFeature QgsReportSectionFieldGroup::getNextFeature() QgsFeature f; QVariant currentValue; bool first = true; - while ( first || ( !mBody && mEncounteredValues.contains( currentValue ) ) ) + while ( first || ( ( !mBody || !mBodyEnabled ) && mEncounteredValues.contains( currentValue ) ) ) { if ( !mFeatures.nextFeature( f ) ) { diff --git a/src/core/layout/qgsreportsectionfieldgroup.h b/src/core/layout/qgsreportsectionfieldgroup.h index df01219c9bb..01fdde4fd65 100644 --- a/src/core/layout/qgsreportsectionfieldgroup.h +++ b/src/core/layout/qgsreportsectionfieldgroup.h @@ -50,6 +50,8 @@ class CORE_EXPORT QgsReportSectionFieldGroup : public QgsAbstractReportSection /** * Returns the body layout for the section. * \see setBody() + * \see bodyEnabled() + * \see setBodyEnabled() */ QgsLayout *body() { return mBody.get(); } @@ -57,9 +59,28 @@ class CORE_EXPORT QgsReportSectionFieldGroup : public QgsAbstractReportSection * Sets the \a body layout for the section. Ownership of \a body * is transferred to the report section. * \see body() + * \see bodyEnabled() + * \see setBodyEnabled() */ void setBody( QgsLayout *body SIP_TRANSFER ) { mBody.reset( body ); } + /** + * Returns true if the body for the section is enabled. + * \see setBodyEnabled() + * \see body() + * \see setBody() + */ + bool bodyEnabled() const { return mBodyEnabled; } + + /** + * Sets whether the body for the section is \a enabled. + * \see bodyEnabled() + * \see body() + * \see setBody() + */ + void setBodyEnabled( bool enabled ) { mBodyEnabled = enabled; } + + /** * Returns the vector layer associated with this section. * \see setLayer() @@ -123,6 +144,7 @@ class CORE_EXPORT QgsReportSectionFieldGroup : public QgsAbstractReportSection QgsFeature mLastFeature; QSet< QVariant > mEncounteredValues; + bool mBodyEnabled = false; std::unique_ptr< QgsLayout > mBody; QgsFeatureRequest buildFeatureRequest() const; diff --git a/src/core/layout/qgsreportsectionlayout.cpp b/src/core/layout/qgsreportsectionlayout.cpp index 97798156aed..285f334cd8d 100644 --- a/src/core/layout/qgsreportsectionlayout.cpp +++ b/src/core/layout/qgsreportsectionlayout.cpp @@ -35,6 +35,8 @@ QgsReportSectionLayout *QgsReportSectionLayout::clone() const else copy->mBody.reset(); + copy->mBodyEnabled = mBodyEnabled; + return copy.release(); } @@ -46,7 +48,7 @@ bool QgsReportSectionLayout::beginRender() QgsLayout *QgsReportSectionLayout::nextBody( bool &ok ) { - if ( !mExportedBody && mBody ) + if ( !mExportedBody && mBody && mBodyEnabled ) { mExportedBody = true; ok = true; @@ -67,6 +69,7 @@ bool QgsReportSectionLayout::writePropertiesToElement( QDomElement &element, QDo bodyElement.appendChild( mBody->writeXml( doc, context ) ); element.appendChild( bodyElement ); } + element.setAttribute( QStringLiteral( "bodyEnabled" ), mBodyEnabled ? "1" : "0" ); return true; } @@ -80,6 +83,7 @@ bool QgsReportSectionLayout::readPropertiesFromElement( const QDomElement &eleme body->readXml( bodyLayoutElem, doc, context ); mBody = std::move( body ); } + mBodyEnabled = element.attribute( QStringLiteral( "bodyEnabled" ) ).toInt(); return true; } diff --git a/src/core/layout/qgsreportsectionlayout.h b/src/core/layout/qgsreportsectionlayout.h index e60dbbc5acb..6dbc51f692b 100644 --- a/src/core/layout/qgsreportsectionlayout.h +++ b/src/core/layout/qgsreportsectionlayout.h @@ -47,6 +47,8 @@ class CORE_EXPORT QgsReportSectionLayout : public QgsAbstractReportSection /** * Returns the body layout for the section. * \see setBody() + * \see bodyEnabled() + * \see setBodyEnabled() */ QgsLayout *body() { return mBody.get(); } @@ -54,9 +56,27 @@ class CORE_EXPORT QgsReportSectionLayout : public QgsAbstractReportSection * Sets the \a body layout for the section. Ownership of \a body * is transferred to the report section. * \see body() + * \see bodyEnabled() + * \see setBodyEnabled() */ void setBody( QgsLayout *body SIP_TRANSFER ) { mBody.reset( body ); } + /** + * Returns true if the body for the section is enabled. + * \see setBodyEnabled() + * \see body() + * \see setBody() + */ + bool bodyEnabled() const { return mBodyEnabled; } + + /** + * Sets whether the body for the section is \a enabled. + * \see bodyEnabled() + * \see body() + * \see setBody() + */ + void setBodyEnabled( bool enabled ) { mBodyEnabled = enabled; } + QgsReportSectionLayout *clone() const override SIP_FACTORY; bool beginRender() override; QgsLayout *nextBody( bool &ok ) override; @@ -70,7 +90,7 @@ class CORE_EXPORT QgsReportSectionLayout : public QgsAbstractReportSection bool mExportedBody = false; std::unique_ptr< QgsLayout > mBody; - + bool mBodyEnabled = true; }; ///@endcond diff --git a/src/ui/layout/qgsreportorganizerwidgetbase.ui b/src/ui/layout/qgsreportorganizerwidgetbase.ui index 8fcf04b4c48..7960505c73d 100644 --- a/src/ui/layout/qgsreportorganizerwidgetbase.ui +++ b/src/ui/layout/qgsreportorganizerwidgetbase.ui @@ -114,51 +114,6 @@ - - - - - - Edit - - - - - - - Show header - - - - - - - Edit - - - - - - - Show footer - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - diff --git a/src/ui/layout/qgsreportwidgetfieldgroupsectionbase.ui b/src/ui/layout/qgsreportwidgetfieldgroupsectionbase.ui index 0f92ba0798a..f32ec4649d6 100644 --- a/src/ui/layout/qgsreportwidgetfieldgroupsectionbase.ui +++ b/src/ui/layout/qgsreportwidgetfieldgroupsectionbase.ui @@ -6,8 +6,8 @@ 0 0 - 705 - 231 + 611 + 415 @@ -16,41 +16,14 @@ - - - - Section body - - - - - + + Edit - - - - Layer - - - - - - - - - - Field - - - - - - - + Qt::Horizontal @@ -63,13 +36,68 @@ - + + + + Field + + + + Sort ascending + + + + Layer + + + + + + + + + + Edit + + + + + + + + + + Include footer + + + + + + + Include header + + + + + + + Edit + + + + + + + Include body + + + @@ -99,8 +127,6 @@
qgsfieldcombobox.h
- - - + diff --git a/src/ui/layout/qgsreportwidgetlayoutsectionbase.ui b/src/ui/layout/qgsreportwidgetlayoutsectionbase.ui index 292d1080f3f..afb8fc4ec1b 100644 --- a/src/ui/layout/qgsreportwidgetlayoutsectionbase.ui +++ b/src/ui/layout/qgsreportwidgetlayoutsectionbase.ui @@ -6,8 +6,8 @@ 0 0 - 723 - 89 + 385 + 237
@@ -15,23 +15,23 @@ - - - - - Section body - - - + - + Edit - - + + + + Include header + + + + + Qt::Horizontal @@ -43,6 +43,34 @@ + + + + Include footer + + + + + + + Edit + + + + + + + Edit + + + + + + + Include body + + + diff --git a/src/ui/layout/qgsreportwidgetsectionbase.ui b/src/ui/layout/qgsreportwidgetsectionbase.ui new file mode 100644 index 00000000000..ed0ed25f976 --- /dev/null +++ b/src/ui/layout/qgsreportwidgetsectionbase.ui @@ -0,0 +1,79 @@ + + + QgsReportWidgetSectionBase + + + + 0 + 0 + 460 + 174 + + + + Layout Manager + + + + + + + + Edit + + + + + + + Include report header + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Include report footer + + + + + + + Edit + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + +