[QGIS Commit] r14264 - in trunk/qgis: python/core src/app src/core
src/core/raster src/providers/wfs src/providers/wms
svn_qgis at osgeo.org
svn_qgis at osgeo.org
Mon Sep 20 07:27:12 EDT 2010
Author: mhugent
Date: 2010-09-20 11:27:12 +0000 (Mon, 20 Sep 2010)
New Revision: 14264
Modified:
trunk/qgis/python/core/qgsdataprovider.sip
trunk/qgis/python/core/qgsmaplayer.sip
trunk/qgis/python/core/qgsmaplayerregistry.sip
trunk/qgis/python/core/qgsrasterlayer.sip
trunk/qgis/python/core/qgsvectorlayer.sip
trunk/qgis/src/app/qgisapp.cpp
trunk/qgis/src/core/qgsdataprovider.h
trunk/qgis/src/core/qgsmaplayer.h
trunk/qgis/src/core/qgsmaplayerregistry.cpp
trunk/qgis/src/core/qgsmaplayerregistry.h
trunk/qgis/src/core/qgsvectorlayer.cpp
trunk/qgis/src/core/qgsvectorlayer.h
trunk/qgis/src/core/raster/qgsrasterlayer.cpp
trunk/qgis/src/core/raster/qgsrasterlayer.h
trunk/qgis/src/providers/wfs/qgswfsdata.cpp
trunk/qgis/src/providers/wfs/qgswfsprovider.cpp
trunk/qgis/src/providers/wfs/qgswfsprovider.h
trunk/qgis/src/providers/wms/qgswmsprovider.cpp
trunk/qgis/src/providers/wms/qgswmsprovider.h
Log:
[FEATURE]: added reload method to map layers and provider interface. Like this, caching providers (currently WMS and WFS) can synchronize with changes in the datasource
Modified: trunk/qgis/python/core/qgsdataprovider.sip
===================================================================
--- trunk/qgis/python/core/qgsdataprovider.sip 2010-09-20 01:28:21 UTC (rev 14263)
+++ trunk/qgis/python/core/qgsdataprovider.sip 2010-09-20 11:27:12 UTC (rev 14264)
@@ -178,6 +178,10 @@
*/
virtual QString fileRasterFilters() const;
+ /**Reloads the data from the the source. Needs to be implemented by providers with data caches to
+ synchronize with changes in the data source*/
+ virtual void reloadData();
+
signals:
/**
Modified: trunk/qgis/python/core/qgsmaplayer.sip
===================================================================
--- trunk/qgis/python/core/qgsmaplayer.sip 2010-09-20 01:28:21 UTC (rev 14263)
+++ trunk/qgis/python/core/qgsmaplayer.sip 2010-09-20 11:27:12 UTC (rev 14264)
@@ -70,6 +70,10 @@
*/
const QString & name() const;
+ /**Synchronises with changes in the datasource
+ @note added in version 1.6*/
+ virtual void reload();
+
/** Render the layer, to be overridden in child classes
*/
virtual bool draw(QgsRenderContext& rendererContext);
Modified: trunk/qgis/python/core/qgsmaplayerregistry.sip
===================================================================
--- trunk/qgis/python/core/qgsmaplayerregistry.sip 2010-09-20 01:28:21 UTC (rev 14263)
+++ trunk/qgis/python/core/qgsmaplayerregistry.sip 2010-09-20 11:27:12 UTC (rev 14264)
@@ -67,6 +67,10 @@
*/
void clearAllLayerCaches();
+ /**Reload all provider data caches (currently used for WFS and WMS providers)
+ @note: this method was added in QGIS 1.6*/
+ void reloadAllLayers();
+
signals:
/** emitted when a layer is removed from the registry
Modified: trunk/qgis/python/core/qgsrasterlayer.sip
===================================================================
--- trunk/qgis/python/core/qgsrasterlayer.sip 2010-09-20 01:28:21 UTC (rev 14263)
+++ trunk/qgis/python/core/qgsrasterlayer.sip 2010-09-20 11:27:12 UTC (rev 14264)
@@ -303,6 +303,10 @@
/** Returns the data provider in a const-correct manner */
//const QgsRasterDataProvider* dataProvider() const;
+ /**Synchronises with changes in the datasource
+ @note added in version 1.6*/
+ virtual void reload();
+
/** \brief This is called when the view on the raster layer needs to be redrawn */
bool draw( QgsRenderContext& rendererContext );
Modified: trunk/qgis/python/core/qgsvectorlayer.sip
===================================================================
--- trunk/qgis/python/core/qgsvectorlayer.sip 2010-09-20 01:28:21 UTC (rev 14263)
+++ trunk/qgis/python/core/qgsvectorlayer.sip 2010-09-20 11:27:12 UTC (rev 14264)
@@ -333,6 +333,10 @@
int snapWithContext(const QgsPoint& startPoint, double snappingTolerance, QMultiMap<double, QgsSnappingResult>& snappingResults /Out/,
QgsSnapper::SnappingType snap_to);
+ /**Synchronises with changes in the datasource
+ @note added in version 1.6*/
+ virtual void reload();
+
/** Draws the layer using coordinate transformation
* @return FALSE if an error occurred during drawing
*/
Modified: trunk/qgis/src/app/qgisapp.cpp
===================================================================
--- trunk/qgis/src/app/qgisapp.cpp 2010-09-20 01:28:21 UTC (rev 14263)
+++ trunk/qgis/src/app/qgisapp.cpp 2010-09-20 11:27:12 UTC (rev 14264)
@@ -4706,6 +4706,8 @@
{
//clear all caches first
QgsMapLayerRegistry::instance()->clearAllLayerCaches();
+ //reload cached provider data
+ QgsMapLayerRegistry::instance()->reloadAllLayers();
//then refresh
mMapCanvas->refresh();
}
Modified: trunk/qgis/src/core/qgsdataprovider.h
===================================================================
--- trunk/qgis/src/core/qgsdataprovider.h 2010-09-20 01:28:21 UTC (rev 14263)
+++ trunk/qgis/src/core/qgsdataprovider.h 2010-09-20 11:27:12 UTC (rev 14264)
@@ -267,6 +267,10 @@
return "";
}
+ /**Reloads the data from the the source. Needs to be implemented by providers with data caches to
+ synchronize with changes in the data source*/
+ virtual void reloadData() {}
+
signals:
/**
Modified: trunk/qgis/src/core/qgsmaplayer.h
===================================================================
--- trunk/qgis/src/core/qgsmaplayer.h 2010-09-20 01:28:21 UTC (rev 14263)
+++ trunk/qgis/src/core/qgsmaplayer.h 2010-09-20 11:27:12 UTC (rev 14264)
@@ -79,6 +79,10 @@
*/
QString const & name() const;
+ /**Synchronises with changes in the datasource
+ @note added in version 1.6*/
+ virtual void reload() {}
+
/** This is the method that does the actual work of
* drawing the layer onto a paint device.
* @param QgsRenderContext - describes the extents,
Modified: trunk/qgis/src/core/qgsmaplayerregistry.cpp
===================================================================
--- trunk/qgis/src/core/qgsmaplayerregistry.cpp 2010-09-20 01:28:21 UTC (rev 14263)
+++ trunk/qgis/src/core/qgsmaplayerregistry.cpp 2010-09-20 11:27:12 UTC (rev 14264)
@@ -22,7 +22,6 @@
#include "qgsmaplayer.h"
#include "qgslogger.h"
-
//
// Static calls to enforce singleton behaviour
//
@@ -128,6 +127,19 @@
}
} // QgsMapLayerRegistry::clearAllLayerCaches()
+void QgsMapLayerRegistry::reloadAllLayers()
+{
+ QMap<QString, QgsMapLayer *>::iterator it;
+ for ( it = mMapLayers.begin(); it != mMapLayers.end() ; ++it )
+ {
+ QgsMapLayer* layer = it.value();
+ if ( layer )
+ {
+ layer->reload();
+ }
+ }
+}
+
QMap<QString, QgsMapLayer*> & QgsMapLayerRegistry::mapLayers()
{
return mMapLayers;
Modified: trunk/qgis/src/core/qgsmaplayerregistry.h
===================================================================
--- trunk/qgis/src/core/qgsmaplayerregistry.h 2010-09-20 01:28:21 UTC (rev 14263)
+++ trunk/qgis/src/core/qgsmaplayerregistry.h 2010-09-20 11:27:12 UTC (rev 14264)
@@ -89,6 +89,11 @@
* @note this method was added in QGIS 1.4
*/
void clearAllLayerCaches();
+
+ /**Reload all provider data caches (currently used for WFS and WMS providers)
+ @note: this method was added in QGIS 1.6*/
+ void reloadAllLayers();
+
signals:
/** emitted when a layer is removed from the registry
Modified: trunk/qgis/src/core/qgsvectorlayer.cpp
===================================================================
--- trunk/qgis/src/core/qgsvectorlayer.cpp 2010-09-20 01:28:21 UTC (rev 14263)
+++ trunk/qgis/src/core/qgsvectorlayer.cpp 2010-09-20 11:27:12 UTC (rev 14264)
@@ -888,6 +888,14 @@
stopRendererV2( rendererContext, selRenderer );
}
+void QgsVectorLayer::reload()
+{
+ if ( mDataProvider )
+ {
+ mDataProvider->reloadData();
+ }
+}
+
bool QgsVectorLayer::draw( QgsRenderContext& rendererContext )
{
//set update threshold before each draw to make sure the current setting is picked up
Modified: trunk/qgis/src/core/qgsvectorlayer.h
===================================================================
--- trunk/qgis/src/core/qgsvectorlayer.h 2010-09-20 01:28:21 UTC (rev 14263)
+++ trunk/qgis/src/core/qgsvectorlayer.h 2010-09-20 11:27:12 UTC (rev 14264)
@@ -380,6 +380,10 @@
QgsSnappingResult > & snappingResults,
QgsSnapper::SnappingType snap_to );
+ /**Synchronises with changes in the datasource
+ @note added in version 1.6*/
+ virtual void reload();
+
/** Draws the layer
* @return false if an error occurred during drawing
*/
Modified: trunk/qgis/src/core/raster/qgsrasterlayer.cpp
===================================================================
--- trunk/qgis/src/core/raster/qgsrasterlayer.cpp 2010-09-20 01:28:21 UTC (rev 14263)
+++ trunk/qgis/src/core/raster/qgsrasterlayer.cpp 2010-09-20 11:27:12 UTC (rev 14264)
@@ -1,4 +1,4 @@
-/* **************************************************************************
+/***************************************************************************
qgsrasterlayer.cpp - description
-------------------
begin : Sat Jun 22 2002
@@ -824,7 +824,7 @@
continue; // NULL
}
- myRasterBandStats.sum += myValue;
+ myRasterBandStats.sum += myValue;
++myRasterBandStats.elementCount;
//only use this element if we have a non null element
if ( myFirstIterationFlag )
@@ -1385,6 +1385,14 @@
return mDataProvider;
}
+void QgsRasterLayer::reload()
+{
+ if ( mDataProvider )
+ {
+ mDataProvider->reloadData();
+ }
+}
+
bool QgsRasterLayer::draw( QgsRenderContext& rendererContext )
{
QgsDebugMsg( "entered. (renderContext)" );
Modified: trunk/qgis/src/core/raster/qgsrasterlayer.h
===================================================================
--- trunk/qgis/src/core/raster/qgsrasterlayer.h 2010-09-20 01:28:21 UTC (rev 14263)
+++ trunk/qgis/src/core/raster/qgsrasterlayer.h 2010-09-20 11:27:12 UTC (rev 14264)
@@ -471,6 +471,10 @@
/** Returns the data provider in a const-correct manner */
const QgsRasterDataProvider* dataProvider() const;
+ /**Synchronises with changes in the datasource
+ @note added in version 1.6*/
+ virtual void reload();
+
/** \brief This is called when the view on the raster layer needs to be redrawn */
bool draw( QgsRenderContext& rendererContext );
Modified: trunk/qgis/src/providers/wfs/qgswfsdata.cpp
===================================================================
--- trunk/qgis/src/providers/wfs/qgswfsdata.cpp 2010-09-20 01:28:21 UTC (rev 14263)
+++ trunk/qgis/src/providers/wfs/qgswfsdata.cpp 2010-09-20 11:27:12 UTC (rev 14264)
@@ -138,6 +138,7 @@
}
}
+ XML_ParserFree( p );
return 0;
}
Modified: trunk/qgis/src/providers/wfs/qgswfsprovider.cpp
===================================================================
--- trunk/qgis/src/providers/wfs/qgswfsprovider.cpp 2010-09-20 01:28:21 UTC (rev 14263)
+++ trunk/qgis/src/providers/wfs/qgswfsprovider.cpp 2010-09-20 11:27:12 UTC (rev 14264)
@@ -52,28 +52,36 @@
mFeatureCount( 0 ),
mValid( true )
{
- mSpatialIndex = new QgsSpatialIndex;
- if ( getFeature( uri ) == 0 )
+ mSpatialIndex = 0;
+ reloadData();
+ if ( mValid )
{
- mValid = true;
getLayerCapabilities();
-
- //set spatial filter to the whole extent
- //select(mExtent, false); //MH TODO: fix this in provider0_9-branch
}
- else
- {
- mValid = false;
- }
}
QgsWFSProvider::~QgsWFSProvider()
{
+ deleteData();
+ delete mSpatialIndex;
+}
+
+void QgsWFSProvider::reloadData()
+{
+ deleteData();
+ delete mSpatialIndex;
+ mSpatialIndex = new QgsSpatialIndex;
+ mValid = !getFeature( dataSourceUri() );
+}
+
+void QgsWFSProvider::deleteData()
+{
mSelectedFeatures.clear();
for ( int i = 0; i < mFeatures.size(); i++ )
+ {
delete mFeatures[i];
+ }
mFeatures.clear();
- delete mSpatialIndex;
}
void QgsWFSProvider::copyFeature( QgsFeature* f, QgsFeature& feature, bool fetchGeometry, QgsAttributeList fetchAttributes )
@@ -626,6 +634,7 @@
int QgsWFSProvider::describeFeatureType( const QString& uri, QString& geometryAttribute, QgsFieldMap& fields )
{
+ fields.clear();
switch ( mEncoding )
{
case QgsWFSProvider::GET:
Modified: trunk/qgis/src/providers/wfs/qgswfsprovider.h
===================================================================
--- trunk/qgis/src/providers/wfs/qgswfsprovider.h 2010-09-20 01:28:21 UTC (rev 14263)
+++ trunk/qgis/src/providers/wfs/qgswfsprovider.h 2010-09-20 11:27:12 UTC (rev 14264)
@@ -136,6 +136,10 @@
*/
virtual bool changeAttributeValues( const QgsChangedAttributesMap &attr_map );
+ /**Reloads the data from the the source. Needs to be implemented by providers with data caches to
+ synchronize with changes in the data source*/
+ virtual void reloadData();
+
signals:
void dataReadProgressMessage( QString message );
@@ -282,6 +286,8 @@
void appendSupportedOperations( const QDomElement& operationsElem, int& capabilities ) const;
/**Shows a message box with the exception string (or does nothing if the xml document is not an exception)*/
void handleException( const QDomDocument& serverResponse ) const;
+
+ void deleteData();
};
#endif
Modified: trunk/qgis/src/providers/wms/qgswmsprovider.cpp
===================================================================
--- trunk/qgis/src/providers/wms/qgswmsprovider.cpp 2010-09-20 01:28:21 UTC (rev 14263)
+++ trunk/qgis/src/providers/wms/qgswmsprovider.cpp 2010-09-20 11:27:12 UTC (rev 14264)
@@ -2813,6 +2813,11 @@
return WMS_DESCRIPTION;
} // QgsWmsProvider::description()
+void QgsWmsProvider::reloadData()
+{
+ delete cachedImage;
+ cachedImage = 0;
+}
/**
* Class factory to return a pointer to a newly created
Modified: trunk/qgis/src/providers/wms/qgswmsprovider.h
===================================================================
--- trunk/qgis/src/providers/wms/qgswmsprovider.h 2010-09-20 01:28:21 UTC (rev 14263)
+++ trunk/qgis/src/providers/wms/qgswmsprovider.h 2010-09-20 11:27:12 UTC (rev 14264)
@@ -616,7 +616,11 @@
*/
QString description() const;
+ /**Reloads the data from the the source. Needs to be implemented by providers with data caches to
+ synchronize with changes in the data source*/
+ virtual void reloadData();
+
signals:
/** \brief emit a signal to notify of a progress event */
More information about the QGIS-commit
mailing list