Skip to content
Permalink
Browse files

[reports] Hide redundant edit header/footer buttons for

fixed layout sections

These have no real meaning for fixed layout sections.
  • Loading branch information
nyalldawson committed Feb 23, 2018
1 parent 3e86804 commit de2c900eab591be1d9c3b069be3270fd877ceb5e
@@ -29,69 +29,15 @@ QgsReportLayoutSectionWidget::QgsReportLayoutSectionWidget( QgsReportOrganizerWi
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() );
mButtonEditHeader->setEnabled( section->headerEnabled() );
mCheckShowFooter->setChecked( section->footerEnabled() );
mButtonEditFooter->setEnabled( section->footerEnabled() );
mCheckShowBody->setChecked( section->bodyEnabled() );
mButtonEditBody->setEnabled( section->bodyEnabled() );

connect( mCheckShowHeader, &QCheckBox::toggled, this, &QgsReportLayoutSectionWidget::toggleHeader );
connect( mCheckShowFooter, &QCheckBox::toggled, this, &QgsReportLayoutSectionWidget::toggleFooter );
connect( mCheckShowBody, &QCheckBox::toggled, this, &QgsReportLayoutSectionWidget::toggleBody );

connect( mCheckShowHeader, &QCheckBox::toggled, mButtonEditHeader, &QPushButton::setEnabled );
connect( mCheckShowFooter, &QCheckBox::toggled, mButtonEditFooter, &QPushButton::setEnabled );
connect( mCheckShowBody, &QCheckBox::toggled, mButtonEditBody, &QPushButton::setEnabled );
}

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() );
mDesigner->setSectionTitle( tr( "Header: %1" ).arg( mSection->description() ) );
mOrganizer->setEditedSection( mSection );
}
}

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() );
mDesigner->setSectionTitle( tr( "Footer: %1" ).arg( mSection->description() ) );
mOrganizer->setEditedSection( mSection );
}
}

void QgsReportLayoutSectionWidget::toggleBody( bool enabled )
{
mSection->setBodyEnabled( enabled );
@@ -31,10 +31,6 @@ 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();

@@ -17,20 +17,20 @@
<item>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="1">
<widget class="QPushButton" name="mButtonEditHeader">
<widget class="QPushButton" name="mButtonEditBody">
<property name="text">
<string>Edit</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QCheckBox" name="mCheckShowHeader">
<widget class="QCheckBox" name="mCheckShowBody">
<property name="text">
<string>Include header</string>
<string>Include section</string>
</property>
</widget>
</item>
<item row="2" column="2">
<item row="0" column="2">
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
@@ -43,34 +43,6 @@
</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>

0 comments on commit de2c900

Please sign in to comment.
You can’t perform that action at this time.