Skip to content

Commit

Permalink
Automatically trigger annotation layer repaint when contents change
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Aug 27, 2020
1 parent 69665cd commit 5849ddd
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
16 changes: 16 additions & 0 deletions src/core/annotations/qgsannotationlayer.cpp
Expand Up @@ -47,6 +47,9 @@ QString QgsAnnotationLayer::addItem( QgsAnnotationItem *item )
{
const QString uuid = QUuid::createUuid().toString();
mItems.insert( uuid, item );

triggerRepaint();

return uuid;
}

Expand All @@ -56,13 +59,24 @@ bool QgsAnnotationLayer::removeItem( const QString &id )
return false;

delete mItems.take( id );

triggerRepaint();

return true;
}

void QgsAnnotationLayer::clear()
{
qDeleteAll( mItems );
mItems.clear();

triggerRepaint();
}

void QgsAnnotationLayer::setOpacity( double opacity )
{
mOpacity = opacity;
triggerRepaint();
}

QgsAnnotationLayer *QgsAnnotationLayer::clone() const
Expand Down Expand Up @@ -139,6 +153,8 @@ bool QgsAnnotationLayer::readXml( const QDomNode &layerNode, QgsReadWriteContext
QString errorMsg;
readSymbology( layerNode, errorMsg, context );

triggerRepaint();

return mValid;
}

Expand Down
2 changes: 1 addition & 1 deletion src/core/annotations/qgsannotationlayer.h
Expand Up @@ -109,7 +109,7 @@ class CORE_EXPORT QgsAnnotationLayer : public QgsMapLayer
* and 1.0 (fully opaque).
* \see opacity()
*/
void setOpacity( double opacity ) { mOpacity = opacity; }
void setOpacity( double opacity );

/**
* Returns the opacity for the annotation layer, where opacity is a value between 0 (totally transparent)
Expand Down

0 comments on commit 5849ddd

Please sign in to comment.