mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-15 00:04:00 -04:00
Nicer ui widgets for sections, add missing control for
disabling body sections
This commit is contained in:
parent
d2c880af50
commit
51a7efbe4b
@ -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.
|
||||
|
@ -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/;
|
||||
|
@ -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
|
||||
|
@ -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()
|
||||
|
@ -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 );
|
||||
|
@ -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()
|
||||
|
@ -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:
|
||||
|
@ -22,6 +22,7 @@
|
||||
#include "qgslayout.h"
|
||||
#include "qgslayoutdesignerdialog.h"
|
||||
#include "qgsreportlayoutsectionwidget.h"
|
||||
#include "qgsreportsectionwidget.h"
|
||||
#include "qgsreportfieldgroupsectionwidget.h"
|
||||
#include <QMenu>
|
||||
#include <QMessageBox>
|
||||
@ -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;
|
||||
|
@ -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:
|
||||
|
78
src/app/layout/qgsreportsectionwidget.cpp
Normal file
78
src/app/layout/qgsreportsectionwidget.cpp
Normal file
@ -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() );
|
||||
}
|
||||
}
|
||||
|
45
src/app/layout/qgsreportsectionwidget.h
Normal file
45
src/app/layout/qgsreportsectionwidget.h
Normal file
@ -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
|
@ -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 ) )
|
||||
{
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
@ -114,51 +114,6 @@
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="1" column="1">
|
||||
<widget class="QPushButton" name="mButtonEditFooter">
|
||||
<property name="text">
|
||||
<string>Edit</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QCheckBox" name="mCheckShowHeader">
|
||||
<property name="text">
|
||||
<string>Show header</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QPushButton" name="mButtonEditHeader">
|
||||
<property name="text">
|
||||
<string>Edit</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QCheckBox" name="mCheckShowFooter">
|
||||
<property name="text">
|
||||
<string>Show footer</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QFrame" name="mSettingsFrame">
|
||||
<property name="frameShape">
|
||||
|
@ -6,8 +6,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>705</width>
|
||||
<height>231</height>
|
||||
<width>611</width>
|
||||
<height>415</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@ -16,41 +16,14 @@
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Section body</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QPushButton" name="mButtonEditBody">
|
||||
<item row="5" column="1">
|
||||
<widget class="QPushButton" name="mButtonEditFooter">
|
||||
<property name="text">
|
||||
<string>Edit</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Layer</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1" colspan="2">
|
||||
<widget class="QgsMapLayerComboBox" name="mLayerComboBox"/>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>Field</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1" colspan="2">
|
||||
<widget class="QgsFieldComboBox" name="mFieldComboBox"/>
|
||||
</item>
|
||||
<item row="3" column="2">
|
||||
<item row="4" column="2">
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
@ -63,13 +36,68 @@
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="2" column="1" colspan="2">
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>Field</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1" colspan="2">
|
||||
<widget class="QCheckBox" name="mSortAscendingCheckBox">
|
||||
<property name="text">
|
||||
<string>Sort ascending</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Layer</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1" colspan="2">
|
||||
<widget class="QgsMapLayerComboBox" name="mLayerComboBox"/>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<widget class="QPushButton" name="mButtonEditBody">
|
||||
<property name="text">
|
||||
<string>Edit</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1" colspan="2">
|
||||
<widget class="QgsFieldComboBox" name="mFieldComboBox"/>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<widget class="QCheckBox" name="mCheckShowFooter">
|
||||
<property name="text">
|
||||
<string>Include footer</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QCheckBox" name="mCheckShowHeader">
|
||||
<property name="text">
|
||||
<string>Include header</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QPushButton" name="mButtonEditHeader">
|
||||
<property name="text">
|
||||
<string>Edit</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QCheckBox" name="mCheckShowBody">
|
||||
<property name="text">
|
||||
<string>Include body</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
@ -99,8 +127,6 @@
|
||||
<header>qgsfieldcombobox.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources>
|
||||
<include location="../../../images/images.qrc"/>
|
||||
</resources>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
|
@ -6,8 +6,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>723</width>
|
||||
<height>89</height>
|
||||
<width>385</width>
|
||||
<height>237</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@ -15,23 +15,23 @@
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Section body</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="0" column="1">
|
||||
<widget class="QPushButton" name="mButtonEditBody">
|
||||
<widget class="QPushButton" name="mButtonEditHeader">
|
||||
<property name="text">
|
||||
<string>Edit</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<item row="0" column="0">
|
||||
<widget class="QCheckBox" name="mCheckShowHeader">
|
||||
<property name="text">
|
||||
<string>Include header</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="2">
|
||||
<spacer name="horizontalSpacer_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
@ -43,6 +43,34 @@
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QCheckBox" name="mCheckShowFooter">
|
||||
<property name="text">
|
||||
<string>Include footer</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QPushButton" name="mButtonEditFooter">
|
||||
<property name="text">
|
||||
<string>Edit</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QPushButton" name="mButtonEditBody">
|
||||
<property name="text">
|
||||
<string>Edit</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QCheckBox" name="mCheckShowBody">
|
||||
<property name="text">
|
||||
<string>Include body</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
|
79
src/ui/layout/qgsreportwidgetsectionbase.ui
Normal file
79
src/ui/layout/qgsreportwidgetsectionbase.ui
Normal file
@ -0,0 +1,79 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>QgsReportWidgetSectionBase</class>
|
||||
<widget class="QWidget" name="QgsReportWidgetSectionBase">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>460</width>
|
||||
<height>174</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Layout Manager</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="0" column="1">
|
||||
<widget class="QPushButton" name="mButtonEditHeader">
|
||||
<property name="text">
|
||||
<string>Edit</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QCheckBox" name="mCheckShowHeader">
|
||||
<property name="text">
|
||||
<string>Include report header</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<spacer name="horizontalSpacer_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QCheckBox" name="mCheckShowFooter">
|
||||
<property name="text">
|
||||
<string>Include report footer</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QPushButton" name="mButtonEditFooter">
|
||||
<property name="text">
|
||||
<string>Edit</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
Loading…
x
Reference in New Issue
Block a user