mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-13 00:03:09 -04:00
Move setDataSource to QgsMapLayer
also setter and getter for providerType
This commit is contained in:
parent
7bbd1ca252
commit
c32d542be5
@ -966,6 +966,31 @@ Write just the symbology information for the layer into the document
|
||||
.. versionadded:: 2.16
|
||||
%End
|
||||
|
||||
|
||||
virtual void setDataSource( const QString &dataSource, const QString &baseName, const QString &provider, const QgsDataProvider::ProviderOptions &options, bool loadDefaultStyleFlag = false );
|
||||
%Docstring
|
||||
Updates the data source of the layer. The layer's renderer and legend will be preserved only
|
||||
if the geometry type of the new data source matches the current geometry type of the layer.
|
||||
|
||||
Subclasses should override this method: default implementation does nothing.
|
||||
|
||||
:param dataSource: new layer data source
|
||||
:param baseName: base name of the layer
|
||||
:param provider: provider string
|
||||
:param options: provider options
|
||||
:param loadDefaultStyleFlag: set to true to reset the layer's style to the default for the
|
||||
data source
|
||||
|
||||
.. seealso:: :py:func:`dataSourceChanged`
|
||||
|
||||
.. versionadded:: 3.6
|
||||
%End
|
||||
|
||||
QString providerType() const;
|
||||
%Docstring
|
||||
Returns the provider type (provider key) for this layer
|
||||
%End
|
||||
|
||||
QUndoStack *undoStack();
|
||||
%Docstring
|
||||
Returns pointer to layer's undo stack
|
||||
@ -1212,6 +1237,7 @@ Returns true if the refresh on provider nofification is enabled
|
||||
.. versionadded:: 3.0
|
||||
%End
|
||||
|
||||
|
||||
public slots:
|
||||
|
||||
void setMinimumScale( double scale );
|
||||
@ -1432,6 +1458,15 @@ Emitted when layer's flags have been modified.
|
||||
.. seealso:: :py:func:`flags`
|
||||
|
||||
.. versionadded:: 3.4
|
||||
%End
|
||||
|
||||
void dataSourceChanged();
|
||||
%Docstring
|
||||
Emitted whenever the layer's data source has been changed.
|
||||
|
||||
.. seealso:: :py:func:`setDataSource`
|
||||
|
||||
.. versionadded:: 3.5
|
||||
%End
|
||||
|
||||
protected:
|
||||
@ -1535,6 +1570,11 @@ Read style data common to all layer types
|
||||
.. versionadded:: 3.0
|
||||
%End
|
||||
|
||||
void setProviderType( const QString &providerType );
|
||||
%Docstring
|
||||
Sets the ``providerType`` (provider key)
|
||||
%End
|
||||
|
||||
|
||||
void appendError( const QgsErrorMessage &error );
|
||||
%Docstring
|
||||
@ -1563,6 +1603,8 @@ Checks whether a new set of dependencies will introduce a cycle
|
||||
%End
|
||||
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
QFlags<QgsMapLayer::LayerFlag> operator|(QgsMapLayer::LayerFlag f1, QFlags<QgsMapLayer::LayerFlag> f2);
|
||||
|
@ -1573,6 +1573,21 @@ bool QgsMapLayer::writeStyle( QDomNode &node, QDomDocument &doc, QString &errorM
|
||||
return false;
|
||||
}
|
||||
|
||||
void QgsMapLayer::setDataSource( const QString &dataSource, const QString &baseName, const QString &provider, const QgsDataProvider::ProviderOptions &options, bool loadDefaultStyleFlag )
|
||||
{
|
||||
Q_UNUSED( dataSource );
|
||||
Q_UNUSED( baseName );
|
||||
Q_UNUSED( provider );
|
||||
Q_UNUSED( options );
|
||||
Q_UNUSED( loadDefaultStyleFlag );
|
||||
}
|
||||
|
||||
|
||||
QString QgsMapLayer::providerType() const
|
||||
{
|
||||
return mProviderKey;
|
||||
}
|
||||
|
||||
void QgsMapLayer::readCommonStyle( const QDomElement &layerElement, const QgsReadWriteContext &context,
|
||||
QgsMapLayer::StyleCategories categories )
|
||||
{
|
||||
@ -1818,6 +1833,11 @@ bool QgsMapLayer::isReadOnly() const
|
||||
return true;
|
||||
}
|
||||
|
||||
void QgsMapLayer::setProviderType( const QString &providerType )
|
||||
{
|
||||
mProviderKey = providerType;
|
||||
}
|
||||
|
||||
QSet<QgsMapLayerDependency> QgsMapLayer::dependencies() const
|
||||
{
|
||||
return mDependencies;
|
||||
|
@ -38,6 +38,7 @@
|
||||
#include "qgslayermetadata.h"
|
||||
#include "qgsmaplayerstyle.h"
|
||||
#include "qgsreadwritecontext.h"
|
||||
#include "qgsdataprovider.h"
|
||||
|
||||
class QgsAbstract3DRenderer;
|
||||
class QgsDataProvider;
|
||||
@ -886,6 +887,29 @@ class CORE_EXPORT QgsMapLayer : public QObject
|
||||
virtual bool writeStyle( QDomNode &node, QDomDocument &doc, QString &errorMessage, const QgsReadWriteContext &context,
|
||||
StyleCategories categories = AllStyleCategories ) const;
|
||||
|
||||
|
||||
/**
|
||||
* Updates the data source of the layer. The layer's renderer and legend will be preserved only
|
||||
* if the geometry type of the new data source matches the current geometry type of the layer.
|
||||
*
|
||||
* Subclasses should override this method: default implementation does nothing.
|
||||
*
|
||||
* \param dataSource new layer data source
|
||||
* \param baseName base name of the layer
|
||||
* \param provider provider string
|
||||
* \param options provider options
|
||||
* \param loadDefaultStyleFlag set to true to reset the layer's style to the default for the
|
||||
* data source
|
||||
* \see dataSourceChanged()
|
||||
* \since QGIS 3.6
|
||||
*/
|
||||
virtual void setDataSource( const QString &dataSource, const QString &baseName, const QString &provider, const QgsDataProvider::ProviderOptions &options, bool loadDefaultStyleFlag = false );
|
||||
|
||||
/**
|
||||
* Returns the provider type (provider key) for this layer
|
||||
*/
|
||||
QString providerType() const;
|
||||
|
||||
//! Returns pointer to layer's undo stack
|
||||
QUndoStack *undoStack();
|
||||
|
||||
@ -1077,6 +1101,7 @@ class CORE_EXPORT QgsMapLayer : public QObject
|
||||
*/
|
||||
bool isRefreshOnNotifyEnabled() const { return mIsRefreshOnNofifyEnabled; }
|
||||
|
||||
|
||||
public slots:
|
||||
|
||||
/**
|
||||
@ -1253,6 +1278,15 @@ class CORE_EXPORT QgsMapLayer : public QObject
|
||||
*/
|
||||
void flagsChanged();
|
||||
|
||||
/**
|
||||
* Emitted whenever the layer's data source has been changed.
|
||||
*
|
||||
* \see setDataSource()
|
||||
*
|
||||
* \since QGIS 3.5
|
||||
*/
|
||||
void dataSourceChanged();
|
||||
|
||||
private slots:
|
||||
|
||||
void onNotifiedTriggerRepaint( const QString &message );
|
||||
@ -1340,6 +1374,9 @@ class CORE_EXPORT QgsMapLayer : public QObject
|
||||
void readCommonStyle( const QDomElement &layerElement, const QgsReadWriteContext &context,
|
||||
StyleCategories categories = AllStyleCategories );
|
||||
|
||||
//! Sets the \a providerType (provider key)
|
||||
void setProviderType( const QString &providerType );
|
||||
|
||||
#ifndef SIP_RUN
|
||||
#if 0
|
||||
//! Debugging member - invoked when a connect() is made to this object
|
||||
@ -1400,6 +1437,10 @@ class CORE_EXPORT QgsMapLayer : public QObject
|
||||
bool mIsRefreshOnNofifyEnabled = false;
|
||||
QString mRefreshOnNofifyMessage;
|
||||
|
||||
//! Data provider key (name of the data provider)
|
||||
QString mProviderKey;
|
||||
|
||||
|
||||
private:
|
||||
|
||||
virtual QString baseURI( PropertyType type ) const;
|
||||
|
Loading…
x
Reference in New Issue
Block a user