Skip to content

Commit

Permalink
Move triggerRepaint() to QgsMapLayer, use it instead of deprecated cl…
Browse files Browse the repository at this point in the history
…earCacheImage()
  • Loading branch information
wonder-sk committed Sep 11, 2014
1 parent ed11c57 commit fba5c5a
Show file tree
Hide file tree
Showing 12 changed files with 29 additions and 32 deletions.
10 changes: 9 additions & 1 deletion python/core/qgsmaplayer.sip
Original file line number Diff line number Diff line change
Expand Up @@ -395,9 +395,17 @@ class QgsMapLayer : QObject
bool hasScaleBasedVisibility() const;

/** Clear cached image
* @deprecated in 2.4 - caches listen to repaintRequested() signal to invalidate the cached image */
* @deprecated in 2.4 - use triggerRepaint() - caches automatically listen to repaintRequested() signal to invalidate the cached image */
void clearCacheImage() /Deprecated/;

/**
* Will advice the map canvas (and any other interested party) that this layer requires to be repainted.
* Will emit a repaintRequested() signal.
*
* @note in 2.6 function moved from vector/raster subclasses to QgsMapLayer
*/
void triggerRepaint();

/** \brief Obtain Metadata for this layer */
virtual QString metadata();

Expand Down
2 changes: 0 additions & 2 deletions python/core/qgsvectorlayer.sip
Original file line number Diff line number Diff line change
Expand Up @@ -1157,8 +1157,6 @@ class QgsVectorLayer : QgsMapLayer
*/
void removeSelection();

void triggerRepaint();

/** Update the extents for the layer. This is necessary if features are
* added/deleted or the layer has been subsetted.
*/
Expand Down
3 changes: 0 additions & 3 deletions python/core/raster/qgsrasterlayer.sip
Original file line number Diff line number Diff line change
Expand Up @@ -191,9 +191,6 @@ class QgsRasterLayer : QgsMapLayer
QImage previewAsImage( QSize size, QColor bgColor = QColor( 255, 255, 255 ),
QImage::Format format = QImage::Format_ARGB32_Premultiplied );

/** \brief Emit a signal asking for a repaint. (inherited from maplayer) */
void triggerRepaint();

/**
* Reorders the *previously selected* sublayers of this layer from bottom to top
*
Expand Down
8 changes: 4 additions & 4 deletions src/app/qgisapp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6984,7 +6984,7 @@ void QgisApp::setLayerCRS()
if ( child->layer() )
{
child->layer()->setCrs( crs );
child->layer()->clearCacheImage();
child->layer()->triggerRepaint();
}
}
}
Expand All @@ -6994,7 +6994,7 @@ void QgisApp::setLayerCRS()
if ( nodeLayer->layer() )
{
nodeLayer->layer()->setCrs( crs );
nodeLayer->layer()->clearCacheImage();
nodeLayer->layer()->triggerRepaint();
}
}
}
Expand Down Expand Up @@ -7111,7 +7111,7 @@ void QgisApp::legendGroupSetCRS()
if ( nodeLayer->layer() )
{
nodeLayer->layer()->setCrs( crs );
nodeLayer->layer()->clearCacheImage();
nodeLayer->layer()->triggerRepaint();
}
}
}
Expand Down Expand Up @@ -8587,7 +8587,7 @@ void QgisApp::layersWereAdded( QList<QgsMapLayer *> theLayers )

if ( provider )
{
connect( provider, SIGNAL( dataChanged() ), layer, SLOT( clearCacheImage() ) );
connect( provider, SIGNAL( dataChanged() ), layer, SLOT( triggerRepaint() ) );
connect( provider, SIGNAL( dataChanged() ), mMapCanvas, SLOT( refresh() ) );
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/browser/qgsbrowser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@ void QgsBrowser::updateCurrentTab()
QgsRasterLayer *rlayer = qobject_cast< QgsRasterLayer * >( mLayer );
if ( rlayer )
{
connect( rlayer->dataProvider(), SIGNAL( dataChanged() ), rlayer, SLOT( clearCacheImage() ) );
connect( rlayer->dataProvider(), SIGNAL( dataChanged() ), rlayer, SLOT( triggerRepaint() ) );
connect( rlayer->dataProvider(), SIGNAL( dataChanged() ), mapCanvas, SLOT( refresh() ) );
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/core/layertree/qgslayertreemodellegendnode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ bool QgsSymbolV2LegendNode::setData( const QVariant& value, int role )
emit dataChanged();

if ( mLayerNode->isVisible() )
vlayer->clearCacheImage();
vlayer->triggerRepaint();

return true;
}
Expand Down
5 changes: 5 additions & 0 deletions src/core/qgsmaplayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1403,6 +1403,11 @@ void QgsMapLayer::clearCacheImage()
emit repaintRequested();
}

void QgsMapLayer::triggerRepaint()
{
emit repaintRequested();
}

QString QgsMapLayer::metadata()
{
return QString();
Expand Down
10 changes: 9 additions & 1 deletion src/core/qgsmaplayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -413,9 +413,17 @@ class CORE_EXPORT QgsMapLayer : public QObject
bool hasScaleBasedVisibility() const;

/** Clear cached image
* @deprecated in 2.4 - caches listen to repaintRequested() signal to invalidate the cached image */
* @deprecated in 2.4 - use triggerRepaint() - caches automatically listen to repaintRequested() signal to invalidate the cached image */
Q_DECL_DEPRECATED void clearCacheImage();

/**
* Will advice the map canvas (and any other interested party) that this layer requires to be repainted.
* Will emit a repaintRequested() signal.
*
* @note in 2.6 function moved from vector/raster subclasses to QgsMapLayer
*/
void triggerRepaint();

/** \brief Obtain Metadata for this layer */
virtual QString metadata();

Expand Down
5 changes: 0 additions & 5 deletions src/core/qgsvectorlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -566,11 +566,6 @@ void QgsVectorLayer::removeSelection()
setSelectedFeatures( QgsFeatureIds() );
}

void QgsVectorLayer::triggerRepaint()
{
emit repaintRequested();
}

QgsVectorDataProvider* QgsVectorLayer::dataProvider()
{
return mDataProvider;
Expand Down
6 changes: 0 additions & 6 deletions src/core/qgsvectorlayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -1514,12 +1514,6 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer
*/
void removeSelection();

/**
* Will advice the map canvas (and any other interested party) that this layer requires to be repainted.
* Will emit a repaintRequested() signal.
*/
void triggerRepaint();

/** Update the extents for the layer. This is necessary if features are
* added/deleted or the layer has been subsetted.
*/
Expand Down
5 changes: 0 additions & 5 deletions src/core/raster/qgsrasterlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1189,11 +1189,6 @@ QImage QgsRasterLayer::previewAsImage( QSize size, QColor bgColor, QImage::Forma
return myQImage;
}

void QgsRasterLayer::triggerRepaint()
{
emit repaintRequested();
}

void QgsRasterLayer::updateProgress( int theProgress, int theMax )
{
Q_UNUSED( theProgress );
Expand Down
3 changes: 0 additions & 3 deletions src/core/raster/qgsrasterlayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -351,9 +351,6 @@ class CORE_EXPORT QgsRasterLayer : public QgsMapLayer
QImage previewAsImage( QSize size, QColor bgColor = Qt::white,
QImage::Format format = QImage::Format_ARGB32_Premultiplied );

/** \brief Emit a signal asking for a repaint. (inherited from maplayer) */
void triggerRepaint();

/**
* Reorders the *previously selected* sublayers of this layer from bottom to top
*
Expand Down

0 comments on commit fba5c5a

Please sign in to comment.