mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-13 00:03:09 -04:00
Provide a public API for invalidating connections.
QgsVectorDataProvider::forceReload() is the virtual method. It is implemented in the OGR provider. See here for reference: http://gis.stackexchange.com/questions/159950/make-a-qgis-layer-update-from-a-changed-data-source
This commit is contained in:
parent
812b01238f
commit
aeeca48ac9
@ -320,6 +320,8 @@ class QgsVectorDataProvider : QgsDataProvider
|
||||
*/
|
||||
virtual QgsTransaction* transaction() const;
|
||||
|
||||
virtual void forceReload();
|
||||
|
||||
protected:
|
||||
void clearMinMaxCache();
|
||||
void fillMinMaxCache();
|
||||
|
@ -371,6 +371,15 @@ class CORE_EXPORT QgsVectorDataProvider : public QgsDataProvider
|
||||
*/
|
||||
virtual QgsTransaction* transaction() const { return 0; }
|
||||
|
||||
/**
|
||||
* Forces a reload of the underlying datasource if the provider implements this
|
||||
* method.
|
||||
* In particular on the OGR provider, a pooled connection will be invalidated.
|
||||
* This forces QGIS to reopen a file or connection.
|
||||
* This can be required if the underlying file is replaced.
|
||||
*/
|
||||
virtual void forceReload() {}
|
||||
|
||||
protected:
|
||||
void clearMinMaxCache();
|
||||
void fillMinMaxCache();
|
||||
|
@ -2439,6 +2439,11 @@ QByteArray QgsOgrProvider::quotedIdentifier( QByteArray field )
|
||||
return QgsOgrUtils::quotedIdentifier( field, ogrDriverName );
|
||||
}
|
||||
|
||||
void QgsOgrProvider::forceReload()
|
||||
{
|
||||
QgsOgrConnPool::instance()->invalidateConnections( filePath() );
|
||||
}
|
||||
|
||||
QByteArray QgsOgrUtils::quotedIdentifier( QByteArray field, const QString& ogrDriverName )
|
||||
{
|
||||
if ( ogrDriverName == "MySQL" )
|
||||
|
@ -263,6 +263,13 @@ class QgsOgrProvider : public QgsVectorDataProvider
|
||||
|
||||
QByteArray quotedIdentifier( QByteArray field );
|
||||
|
||||
/**
|
||||
* A forced reload invalidates the underlying connection.
|
||||
* E.g. in case a shapefile is replaced, the old file will be closed
|
||||
* and the new file will be opened.
|
||||
*/
|
||||
void forceReload();
|
||||
|
||||
protected:
|
||||
/** Loads fields from input file to member attributeFields */
|
||||
void loadFields();
|
||||
|
Loading…
x
Reference in New Issue
Block a user