diff --git a/python/core/composer/qgscomposerframe.sip b/python/core/composer/qgscomposerframe.sip index 811a02785f4..035e32931ef 100644 --- a/python/core/composer/qgscomposerframe.sip +++ b/python/core/composer/qgscomposerframe.sip @@ -55,6 +55,20 @@ class QgsComposerFrame: QgsComposerItem * @see hidePageIfEmpty */ void setHidePageIfEmpty( const bool hidePageIfEmpty ); + + /**Returns whether the background and frame border should be hidden if this frame is empty + * @returns true if background and border should be hidden if frame is empty + * @note added in QGIS 2.5 + * @see setHideBackgroundIfEmpty + */ + bool hideBackgroundIfEmpty() const; + + /**Sets whether the background and frame border should be hidden if this frame is empty + * @param hideBackgroundIfEmpty set to true if background and border should be hidden if frame is empty + * @note added in QGIS 2.5 + * @see hideBackgroundIfEmpty + */ + void setHideBackgroundIfEmpty( const bool hideBackgroundIfEmpty ); /**Returns whether the frame is empty * @returns true if frame is empty diff --git a/src/app/composer/qgscomposerattributetablewidget.cpp b/src/app/composer/qgscomposerattributetablewidget.cpp index 0d14782ab3f..4149079afa2 100644 --- a/src/app/composer/qgscomposerattributetablewidget.cpp +++ b/src/app/composer/qgscomposerattributetablewidget.cpp @@ -515,6 +515,7 @@ void QgsComposerAttributeTableWidget::updateGuiElements() mAddFramePushButton->setEnabled( mComposerTable->resizeMode() == QgsComposerMultiFrame::UseExistingFrames ); mEmptyFrameCheckBox->setChecked( mFrame->hidePageIfEmpty() ); + mHideEmptyBgCheckBox->setChecked( mFrame->hideBackgroundIfEmpty() ); toggleSourceControls(); @@ -616,6 +617,7 @@ void QgsComposerAttributeTableWidget::blockAllSignals( bool b ) mEmptyModeComboBox->blockSignals( b ); mEmptyMessageLineEdit->blockSignals( b ); mEmptyFrameCheckBox->blockSignals( b ); + mHideEmptyBgCheckBox->blockSignals( b ); } void QgsComposerAttributeTableWidget::setMaximumNumberOfFeatures( int n ) @@ -670,7 +672,6 @@ void QgsComposerAttributeTableWidget::on_mUniqueOnlyCheckBox_stateChanged( int s } } - void QgsComposerAttributeTableWidget::on_mEmptyFrameCheckBox_toggled( bool checked ) { if ( !mFrame ) @@ -683,6 +684,18 @@ void QgsComposerAttributeTableWidget::on_mEmptyFrameCheckBox_toggled( bool check mFrame->endCommand(); } +void QgsComposerAttributeTableWidget::on_mHideEmptyBgCheckBox_toggled( bool checked ) +{ + if ( !mFrame ) + { + return; + } + + mFrame->beginCommand( tr( "Hide background if empty toggled" ) ); + mFrame->setHideBackgroundIfEmpty( checked ); + mFrame->endCommand(); +} + void QgsComposerAttributeTableWidget::on_mIntersectAtlasCheckBox_stateChanged( int state ) { if ( !mComposerTable ) diff --git a/src/app/composer/qgscomposerattributetablewidget.h b/src/app/composer/qgscomposerattributetablewidget.h index a31b4804588..e1bfa36b2be 100644 --- a/src/app/composer/qgscomposerattributetablewidget.h +++ b/src/app/composer/qgscomposerattributetablewidget.h @@ -75,6 +75,7 @@ class QgsComposerAttributeTableWidget: public QgsComposerItemBaseWidget, private void on_mIntersectAtlasCheckBox_stateChanged( int state ); void on_mUniqueOnlyCheckBox_stateChanged( int state ); void on_mEmptyFrameCheckBox_toggled( bool checked ); + void on_mHideEmptyBgCheckBox_toggled( bool checked ); /**Inserts a new maximum number of features into the spin box (without the spinbox emitting a signal)*/ void setMaximumNumberOfFeatures( int n ); @@ -85,7 +86,6 @@ class QgsComposerAttributeTableWidget: public QgsComposerItemBaseWidget, private void atlasToggled(); void updateRelationsCombo(); - }; #endif // QGSCOMPOSERATTRIBUTETABLEWIDGET_H diff --git a/src/app/composer/qgscomposerhtmlwidget.cpp b/src/app/composer/qgscomposerhtmlwidget.cpp index 3ce07da063a..d1f64f1e453 100644 --- a/src/app/composer/qgscomposerhtmlwidget.cpp +++ b/src/app/composer/qgscomposerhtmlwidget.cpp @@ -101,6 +101,7 @@ void QgsComposerHtmlWidget::blockSignals( bool block ) mRadioUrlSource->blockSignals( block ); mEvaluateExpressionsCheckbox->blockSignals( block ); mEmptyFrameCheckBox->blockSignals( block ); + mHideEmptyBgCheckBox->blockSignals( block ); } void QgsComposerHtmlWidget::on_mUrlLineEdit_editingFinished() @@ -278,6 +279,18 @@ void QgsComposerHtmlWidget::on_mEmptyFrameCheckBox_toggled( bool checked ) mFrame->endCommand(); } +void QgsComposerHtmlWidget::on_mHideEmptyBgCheckBox_toggled( bool checked ) +{ + if ( !mFrame ) + { + return; + } + + mFrame->beginCommand( tr( "Hide background if empty toggled" ) ); + mFrame->setHideBackgroundIfEmpty( checked ); + mFrame->endCommand(); +} + void QgsComposerHtmlWidget::on_mRadioManualSource_clicked( bool checked ) { if ( !mHtml ) @@ -447,6 +460,7 @@ void QgsComposerHtmlWidget::setGuiElementValues() mStylesheetEditor->setText( mHtml->userStylesheet() ); mEmptyFrameCheckBox->setChecked( mFrame->hidePageIfEmpty() ); + mHideEmptyBgCheckBox->setChecked( mFrame->hideBackgroundIfEmpty() ); populateDataDefinedButtons(); diff --git a/src/app/composer/qgscomposerhtmlwidget.h b/src/app/composer/qgscomposerhtmlwidget.h index 60f0d744820..bdbef70ea84 100644 --- a/src/app/composer/qgscomposerhtmlwidget.h +++ b/src/app/composer/qgscomposerhtmlwidget.h @@ -48,11 +48,13 @@ class QgsComposerHtmlWidget: public QgsComposerItemBaseWidget, private Ui::QgsCo void on_mReloadPushButton2_clicked(); void on_mAddFramePushButton_clicked(); void on_mEmptyFrameCheckBox_toggled( bool checked ); + void on_mHideEmptyBgCheckBox_toggled( bool checked ); /**Sets the GUI elements to the values of mHtmlItem*/ void setGuiElementValues(); protected: + QgsComposerItem::DataDefinedProperty ddPropertyForWidget( QgsDataDefinedButton *widget ); protected slots: diff --git a/src/core/composer/qgscomposerframe.cpp b/src/core/composer/qgscomposerframe.cpp index 70affb362e4..02b3e1682bc 100644 --- a/src/core/composer/qgscomposerframe.cpp +++ b/src/core/composer/qgscomposerframe.cpp @@ -21,6 +21,7 @@ QgsComposerFrame::QgsComposerFrame( QgsComposition* c, QgsComposerMultiFrame* mf : QgsComposerItem( x, y, width, height, c ) , mMultiFrame( mf ) , mHidePageIfEmpty( false ) + , mHideBackgroundIfEmpty( false ) { //repaint frame when multiframe content changes connect( mf, SIGNAL( contentsChanged() ), this, SLOT( repaint() ) ); @@ -35,6 +36,7 @@ QgsComposerFrame::QgsComposerFrame() : QgsComposerItem( 0, 0, 0, 0, 0 ) , mMultiFrame( 0 ) , mHidePageIfEmpty( false ) + , mHideBackgroundIfEmpty( false ) { } @@ -50,7 +52,7 @@ bool QgsComposerFrame::writeXML( QDomElement& elem, QDomDocument & doc ) const frameElem.setAttribute( "sectionWidth", QString::number( mSection.width() ) ); frameElem.setAttribute( "sectionHeight", QString::number( mSection.height() ) ); frameElem.setAttribute( "hidePageIfEmpty", mHidePageIfEmpty ); - + frameElem.setAttribute( "hideBackgroundIfEmpty", mHideBackgroundIfEmpty ); elem.appendChild( frameElem ); return _writeXML( frameElem, doc ); @@ -64,6 +66,7 @@ bool QgsComposerFrame::readXML( const QDomElement& itemElem, const QDomDocument& double height = itemElem.attribute( "sectionHeight" ).toDouble(); mSection = QRectF( x, y, width, height ); mHidePageIfEmpty = itemElem.attribute( "hidePageIfEmpty", "0" ).toInt(); + mHideBackgroundIfEmpty = itemElem.attribute( "hideBackgroundIfEmpty", "0" ).toInt(); QDomElement composerItem = itemElem.firstChildElement( "ComposerItem" ); if ( composerItem.isNull() ) { @@ -77,6 +80,17 @@ void QgsComposerFrame::setHidePageIfEmpty( const bool hidePageIfEmpty ) mHidePageIfEmpty = hidePageIfEmpty; } +void QgsComposerFrame::setHideBackgroundIfEmpty( const bool hideBackgroundIfEmpty ) +{ + if ( hideBackgroundIfEmpty == mHideBackgroundIfEmpty ) + { + return; + } + + mHideBackgroundIfEmpty = hideBackgroundIfEmpty; + update(); +} + bool QgsComposerFrame::isEmpty() const { if ( !mMultiFrame ) @@ -152,7 +166,12 @@ void QgsComposerFrame::paint( QPainter* painter, const QStyleOptionGraphicsItem* return; } - drawBackground( painter ); + bool empty = isEmpty(); + + if ( !empty || !mHideBackgroundIfEmpty ) + { + drawBackground( painter ); + } if ( mMultiFrame ) { //calculate index of frame @@ -160,7 +179,10 @@ void QgsComposerFrame::paint( QPainter* painter, const QStyleOptionGraphicsItem* mMultiFrame->render( painter, mSection, frameIndex ); } - drawFrame( painter ); + if ( !empty || !mHideBackgroundIfEmpty ) + { + drawFrame( painter ); + } if ( isSelected() ) { drawSelectionBoxes( painter ); diff --git a/src/core/composer/qgscomposerframe.h b/src/core/composer/qgscomposerframe.h index 9b1a59b5913..731466d8961 100644 --- a/src/core/composer/qgscomposerframe.h +++ b/src/core/composer/qgscomposerframe.h @@ -78,6 +78,20 @@ class CORE_EXPORT QgsComposerFrame: public QgsComposerItem */ void setHidePageIfEmpty( const bool hidePageIfEmpty ); + /**Returns whether the background and frame border should be hidden if this frame is empty + * @returns true if background and border should be hidden if frame is empty + * @note added in QGIS 2.5 + * @see setHideBackgroundIfEmpty + */ + bool hideBackgroundIfEmpty() const { return mHideBackgroundIfEmpty; } + + /**Sets whether the background and frame border should be hidden if this frame is empty + * @param hideBackgroundIfEmpty set to true if background and border should be hidden if frame is empty + * @note added in QGIS 2.5 + * @see hideBackgroundIfEmpty + */ + void setHideBackgroundIfEmpty( const bool hideBackgroundIfEmpty ); + /**Returns whether the frame is empty * @returns true if frame is empty * @note added in QGIS 2.5 @@ -92,6 +106,9 @@ class CORE_EXPORT QgsComposerFrame: public QgsComposerItem /**if true, composition will not export page if this frame is empty*/ bool mHidePageIfEmpty; + /**if true, background and outside frame will not be drawn if frame is empty*/ + bool mHideBackgroundIfEmpty; + }; #endif // QGSCOMPOSERFRAME_H diff --git a/src/ui/qgscomposerattributetablewidgetbase.ui b/src/ui/qgscomposerattributetablewidgetbase.ui index 7300760b48f..2329ccb1f46 100755 --- a/src/ui/qgscomposerattributetablewidgetbase.ui +++ b/src/ui/qgscomposerattributetablewidgetbase.ui @@ -45,9 +45,9 @@ 0 - -312 + -340 392 - 1104 + 1132 @@ -541,13 +541,6 @@ false - - - - Add Frame - - - @@ -568,6 +561,13 @@ + + + + Add Frame + + + @@ -575,6 +575,13 @@ + + + + Don't draw background if frame is empty + + + diff --git a/src/ui/qgscomposerhtmlwidgetbase.ui b/src/ui/qgscomposerhtmlwidgetbase.ui index 64a618d39dc..0179f56cb87 100644 --- a/src/ui/qgscomposerhtmlwidgetbase.ui +++ b/src/ui/qgscomposerhtmlwidgetbase.ui @@ -45,9 +45,9 @@ 0 - -10 + -40 391 - 489 + 517 @@ -146,16 +146,6 @@ composeritem - - - - Resize mode - - - true - - - @@ -166,6 +156,13 @@ + + + + Don't export page if frame is empty + + + @@ -173,10 +170,20 @@ - - + + - Don't export page if frame is empty + Resize mode + + + true + + + + + + + Don't draw background if frame is empty