[layouts] Fix grids cannot be disabled, ui widgets for grids get incorrectly

disabled blocking the ability to re-enable grids (master only)
This commit is contained in:
Nyall Dawson 2019-09-13 08:59:22 +10:00
parent f4d407d9ee
commit 587c011046
6 changed files with 17 additions and 20 deletions

View File

@ -285,6 +285,9 @@ map item separately.
.. seealso:: :py:func:`maxExtension`
%End
virtual void setEnabled( bool enabled );
void setUnits( GridUnit unit );
%Docstring

View File

@ -103,7 +103,7 @@ Returns the friendly display name for the item.
.. seealso:: :py:func:`setName`
%End
void setEnabled( bool enabled );
virtual void setEnabled( bool enabled );
%Docstring
Controls whether the item will be drawn. Set ``enabled`` to ``True`` to enable drawing of the item.

View File

@ -1142,16 +1142,9 @@ QgsLayoutItemMapGrid *QgsLayoutMapWidget::currentGrid()
return mMapItem->grids()->grid( item->data( Qt::UserRole ).toString() );
}
void QgsLayoutMapWidget::mGridListWidget_currentItemChanged( QListWidgetItem *current, QListWidgetItem *previous )
void QgsLayoutMapWidget::mGridListWidget_currentItemChanged( QListWidgetItem *current, QListWidgetItem * )
{
Q_UNUSED( previous )
if ( !current )
{
mGridPropertiesButton->setEnabled( false );
return;
}
mGridPropertiesButton->setEnabled( currentGrid()->enabled() );
mGridPropertiesButton->setEnabled( static_cast< bool >( current ) );
}
void QgsLayoutMapWidget::mGridListWidget_itemChanged( QListWidgetItem *item )
@ -1501,14 +1494,7 @@ void QgsLayoutMapWidget::mOverviewCheckBox_toggled( bool state )
}
mMapItem->layout()->undoStack()->beginCommand( mMapItem, tr( "Overview Display Toggled" ) );
if ( state )
{
overview->setEnabled( true );
}
else
{
overview->setEnabled( false );
}
overview->setEnabled( state );
mMapItem->invalidateCache();
mMapItem->layout()->undoStack()->endCommand();
}

View File

@ -1968,7 +1968,7 @@ void QgsLayoutItemMapGrid::refreshDataDefinedProperties()
{
QgsExpressionContext context = createExpressionContext();
mEvaluatedEnabled = mDataDefinedProperties.valueAsBool( QgsLayoutObject::MapGridEnabled, context, true );
mEvaluatedEnabled = mDataDefinedProperties.valueAsBool( QgsLayoutObject::MapGridEnabled, context, enabled() );
switch ( mGridUnit )
{
case MapUnit:
@ -2230,6 +2230,12 @@ void QgsLayoutItemMapGrid::calculateMaxExtension( double &top, double &right, do
left = extension.left;
}
void QgsLayoutItemMapGrid::setEnabled( bool enabled )
{
QgsLayoutItemMapItem::setEnabled( enabled );
refreshDataDefinedProperties();
}
void QgsLayoutItemMapGrid::setUnits( const QgsLayoutItemMapGrid::GridUnit unit )
{
if ( unit == mGridUnit )

View File

@ -309,6 +309,8 @@ class CORE_EXPORT QgsLayoutItemMapGrid : public QgsLayoutItemMapItem
*/
void calculateMaxExtension( double &top, double &right, double &bottom, double &left ) const;
void setEnabled( bool enabled ) override;
//
// GRID UNITS
//

View File

@ -115,7 +115,7 @@ class CORE_EXPORT QgsLayoutItemMapItem : public QgsLayoutObject
* Controls whether the item will be drawn. Set \a enabled to TRUE to enable drawing of the item.
* \see enabled()
*/
void setEnabled( bool enabled );
virtual void setEnabled( bool enabled );
/**
* Returns whether the item will be drawn.