@@ -53,6 +53,7 @@ class CORE_EXPORT QgsMapLayer : public QObject
5353 Q_OBJECT
5454
5555 Q_PROPERTY ( QString name READ name WRITE setName NOTIFY nameChanged )
56+ Q_PROPERTY ( int autoRefreshInterval READ autoRefreshInterval WRITE setAutoRefreshInterval NOTIFY autoRefreshIntervalChanged )
5657
5758 public:
5859
@@ -646,6 +647,44 @@ class CORE_EXPORT QgsMapLayer : public QObject
646647 */
647648 bool hasScaleBasedVisibility () const ;
648649
650+ /* *
651+ * Returns true if auto refresh is enabled for the layer.
652+ * @note added in QGIS 3.0
653+ * @see autoRefreshInterval()
654+ * @see setAutoRefreshEnabled()
655+ */
656+ bool hasAutoRefreshEnabled () const ;
657+
658+ /* *
659+ * Returns the auto refresh interval (in milliseconds). Note that
660+ * auto refresh is only active when hasAutoRefreshEnabled() is true.
661+ * @note added in QGIS 3.0
662+ * @see autoRefreshEnabled()
663+ * @see setAutoRefreshInterval()
664+ */
665+ int autoRefreshInterval () const ;
666+
667+ /* *
668+ * Sets the auto refresh interval (in milliseconds) for the layer. This
669+ * will cause the layer to be automatically redrawn on a matching interval.
670+ * Note that auto refresh must be enabled by calling setAutoRefreshEnabled().
671+ *
672+ * Note that auto refresh triggers deferred repaints of the layer. Any map
673+ * canvas must be refreshed separately in order to view the refreshed layer.
674+ * @note added in QGIS 3.0
675+ * @see autoRefreshInterval()
676+ * @see setAutoRefreshEnabled()
677+ */
678+ void setAutoRefreshInterval ( int interval );
679+
680+ /* *
681+ * Sets whether auto refresh is enabled for the layer.
682+ * @note added in QGIS 3.0
683+ * @see hasAutoRefreshEnabled()
684+ * @see setAutoRefreshInterval()
685+ */
686+ void setAutoRefreshEnabled ( bool enabled );
687+
649688 public slots:
650689
651690 // ! Event handler for when a coordinate transform fails due to bad vertex error
@@ -678,12 +717,14 @@ class CORE_EXPORT QgsMapLayer : public QObject
678717 void setScaleBasedVisibility ( const bool enabled );
679718
680719 /* *
681- * Will advice the map canvas (and any other interested party) that this layer requires to be repainted.
720+ * Will advise the map canvas (and any other interested party) that this layer requires to be repainted.
682721 * Will emit a repaintRequested() signal.
722+ * If \a deferredUpdate is true then the layer will only be repainted when the canvas is next
723+ * re-rendered, and will not trigger any canvas redraws itself.
683724 *
684725 * @note in 2.6 function moved from vector/raster subclasses to QgsMapLayer
685726 */
686- void triggerRepaint ();
727+ void triggerRepaint ( bool deferredUpdate = false );
687728
688729 // ! \brief Obtain Metadata for this layer
689730 virtual QString metadata () const ;
@@ -732,8 +773,10 @@ class CORE_EXPORT QgsMapLayer : public QObject
732773
733774 /* * By emitting this signal the layer tells that either appearance or content have been changed
734775 * and any view showing the rendered layer should refresh itself.
776+ * If \a deferredUpdate is true then the layer will only be repainted when the canvas is next
777+ * re-rendered, and will not trigger any canvas redraws itself.
735778 */
736- void repaintRequested ();
779+ void repaintRequested ( bool deferredUpdate = false );
737780
738781 // ! This is used to send a request that any mapcanvas using this layer update its extents
739782 void recalculateExtents () const ;
@@ -782,6 +825,13 @@ class CORE_EXPORT QgsMapLayer : public QObject
782825 */
783826 void willBeDeleted ();
784827
828+ /* *
829+ * Emitted when the auto refresh interval changes.
830+ * @see setAutoRefreshInterval()
831+ * @note added in QGIS 3.0
832+ */
833+ void autoRefreshIntervalChanged ( int interval );
834+
785835 protected:
786836 // ! Set the extent
787837 virtual void setExtent ( const QgsRectangle &rect );
@@ -916,6 +966,10 @@ class CORE_EXPORT QgsMapLayer : public QObject
916966
917967 // ! Manager of multiple styles available for a layer (may be null)
918968 QgsMapLayerStyleManager* mStyleManager ;
969+
970+ // ! Timer for triggering automatic refreshes of the layer
971+ QTimer mRefreshTimer ;
972+
919973};
920974
921975Q_DECLARE_METATYPE ( QgsMapLayer* )
0 commit comments