mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-14 00:07:35 -04:00
Create undo/redo commands when changing item visibility
This commit is contained in:
parent
3e933dcda8
commit
bb2e1efdb8
@ -113,6 +113,16 @@ class QgsLayoutItem : QgsLayoutObject, QGraphicsRectItem, QgsLayoutUndoObjectInt
|
||||
Sets whether the item should be selected.
|
||||
%End
|
||||
|
||||
virtual void setVisibility( const bool visible );
|
||||
%Docstring
|
||||
Sets whether the item is ``visible``.
|
||||
.. note::
|
||||
|
||||
QGraphicsItem.setVisible should not be called directly
|
||||
on a QgsLayoutItem, as some item types (e.g., groups) need to override
|
||||
the visibility toggle.
|
||||
%End
|
||||
|
||||
void setLocked( const bool locked );
|
||||
%Docstring
|
||||
Sets whether the item is ``locked``, preventing mouse interactions with the item.
|
||||
|
@ -85,14 +85,13 @@ void QgsLayoutItem::setId( const QString &id )
|
||||
mId = id;
|
||||
setToolTip( id );
|
||||
|
||||
//TODO
|
||||
#if 0
|
||||
//inform model that id data has changed
|
||||
if ( mComposition )
|
||||
if ( mLayout )
|
||||
{
|
||||
mComposition->itemsModel()->updateItemDisplayName( this );
|
||||
mLayout->itemsModel()->updateItemDisplayName( this );
|
||||
}
|
||||
|
||||
#if 0 //TODO
|
||||
emit itemChanged();
|
||||
#endif
|
||||
}
|
||||
@ -107,6 +106,29 @@ void QgsLayoutItem::setSelected( bool selected )
|
||||
}
|
||||
}
|
||||
|
||||
void QgsLayoutItem::setVisibility( const bool visible )
|
||||
{
|
||||
if ( visible == isVisible() )
|
||||
{
|
||||
//nothing to do
|
||||
return;
|
||||
}
|
||||
|
||||
if ( mLayout && !mBlockUndoCommands )
|
||||
mLayout->undoStack()->beginCommand( this, visible ? tr( "Item shown" ) : tr( "Item hidden" ) );
|
||||
|
||||
QGraphicsItem::setVisible( visible );
|
||||
|
||||
if ( mLayout && !mBlockUndoCommands )
|
||||
mLayout->undoStack()->endCommand();
|
||||
|
||||
//inform model that visibility has changed
|
||||
if ( mLayout )
|
||||
{
|
||||
mLayout->itemsModel()->updateItemVisibility( this );
|
||||
}
|
||||
}
|
||||
|
||||
void QgsLayoutItem::setLocked( const bool locked )
|
||||
{
|
||||
if ( locked == mIsLocked )
|
||||
@ -750,7 +772,7 @@ bool QgsLayoutItem::readPropertiesFromElement( const QDomElement &element, const
|
||||
setLocked( false );
|
||||
}
|
||||
//visibility
|
||||
setVisible( element.attribute( "visibility", "1" ) != "0" );
|
||||
setVisibility( element.attribute( "visibility", "1" ) != "0" );
|
||||
setZValue( element.attribute( "zValue" ).toDouble() );
|
||||
|
||||
//frame
|
||||
|
@ -133,6 +133,14 @@ class CORE_EXPORT QgsLayoutItem : public QgsLayoutObject, public QGraphicsRectIt
|
||||
*/
|
||||
virtual void setSelected( bool selected );
|
||||
|
||||
/**
|
||||
* Sets whether the item is \a visible.
|
||||
* \note QGraphicsItem::setVisible should not be called directly
|
||||
* on a QgsLayoutItem, as some item types (e.g., groups) need to override
|
||||
* the visibility toggle.
|
||||
*/
|
||||
virtual void setVisibility( const bool visible );
|
||||
|
||||
/**
|
||||
* Sets whether the item is \a locked, preventing mouse interactions with the item.
|
||||
* \see isLocked()
|
||||
|
@ -207,7 +207,7 @@ bool QgsLayoutModel::setData( const QModelIndex &index, const QVariant &value, i
|
||||
{
|
||||
case Visibility:
|
||||
//first column is item visibility
|
||||
item->setVisible( value.toBool() );
|
||||
item->setVisibility( value.toBool() );
|
||||
return true;
|
||||
|
||||
case LockStatus:
|
||||
|
Loading…
x
Reference in New Issue
Block a user