21 #include "qgis_core.h" 58 #define QGSCLIPBOARD_MAPLAYER_MIME "application/qgis.maplayer" 83 Q_PROPERTY( QString name READ name WRITE setName NOTIFY nameChanged )
84 Q_PROPERTY(
int autoRefreshInterval READ autoRefreshInterval WRITE setAutoRefreshInterval NOTIFY autoRefreshIntervalChanged )
85 Q_PROPERTY(
QgsLayerMetadata metadata READ metadata WRITE setMetadata NOTIFY metadataChanged )
96 switch ( layer->type() )
99 sipType = sipType_QgsVectorLayer;
102 sipType = sipType_QgsRasterLayer;
105 sipType = sipType_QgsPluginLayer;
108 sipType = sipType_QgsMeshLayer;
137 Identifiable = 1 << 0,
151 LayerConfiguration = 1 << 0,
153 Symbology3D = 1 << 2,
160 AttributeTable = 1 << 9,
162 CustomProperties = 1 << 11,
163 GeometryOptions = 1 << 12,
164 AllStyleCategories = LayerConfiguration | Symbology | Symbology3D | Labeling | Fields | Forms | Actions |
165 MapTips | Diagrams | AttributeTable | Rendering | CustomProperties | GeometryOptions,
169 Q_FLAG( StyleCategories )
206 QgsMapLayer::LayerFlags flags()
const;
215 void setFlags( QgsMapLayer::LayerFlags flags );
222 static QString extensionPropertyType(
PropertyType type );
232 void setName(
const QString &name );
238 QString name()
const;
257 void setShortName( const QString &shortName ) { mShortName = shortName; }
264 QString shortName()
const;
271 void setTitle(
const QString &title ) { mTitle = title; }
279 QString
title()
const {
return mTitle; }
287 void setAbstract(
const QString &
abstract ) { mAbstract =
abstract; }
295 QString
abstract()
const {
return mAbstract; }
322 void setDataUrl(
const QString &dataUrl ) { mDataUrl = dataUrl; }
450 void setBlendMode( QPainter::CompositionMode blendMode );
456 QPainter::CompositionMode blendMode()
const;
480 bool isValid()
const;
488 QString publicSource()
const;
495 QString source()
const;
501 virtual QStringList subLayers()
const;
507 virtual void setLayerOrder(
const QStringList &layers );
514 virtual void setSubLayerVisibility(
const QString &name,
bool visible );
517 virtual bool isEditable()
const;
523 virtual bool isSpatial()
const;
531 FlagDontResolveLayers = 1 << 0,
533 Q_DECLARE_FLAGS( ReadFlags,
ReadFlag )
552 bool readLayerXml(
const QDomElement &layerElement,
QgsReadWriteContext &context, QgsMapLayer::ReadFlags flags =
nullptr );
571 bool writeLayerXml( QDomElement &layerElement, QDomDocument &document,
const QgsReadWriteContext &context )
const;
577 virtual void resolveReferences(
QgsProject *project );
584 QStringList customPropertyKeys()
const;
591 void setCustomProperty(
const QString &key,
const QVariant &value );
597 QVariant customProperty(
const QString &value,
const QVariant &defaultValue = QVariant() )
const;
609 void removeCustomProperty(
const QString &key );
640 static QString formatLayerName(
const QString &name );
649 virtual QString metadataUri()
const;
657 void exportNamedMetadata( QDomDocument &doc, QString &errorMsg )
const;
668 virtual QString saveDefaultMetadata(
bool &resultFlag
SIP_OUT );
684 QString saveNamedMetadata(
const QString &uri,
bool &resultFlag );
700 virtual QString loadNamedMetadata(
const QString &uri,
bool &resultFlag
SIP_OUT );
711 QString loadDefaultMetadata(
bool &resultFlag );
721 bool loadNamedMetadataFromDatabase(
const QString &db,
const QString &uri, QString &qmd );
730 bool importNamedMetadata( QDomDocument &document, QString &errorMessage );
739 virtual QString styleURI()
const;
750 virtual QString loadDefaultStyle(
bool &resultFlag
SIP_OUT );
776 virtual bool loadNamedStyleFromDatabase(
const QString &db,
const QString &uri, QString &qml
SIP_OUT );
787 virtual bool importNamedStyle( QDomDocument &doc, QString &errorMsg
SIP_OUT,
808 virtual void exportSldStyle( QDomDocument &doc, QString &errorMsg )
const;
819 virtual QString saveDefaultStyle(
bool &resultFlag SIP_OUT );
836 virtual QString saveNamedStyle(
const QString &uri,
bool &resultFlag SIP_OUT, StyleCategories categories = AllStyleCategories );
846 virtual QString saveSldStyle(
const QString &uri,
bool &resultFlag )
const;
856 virtual QString loadSldStyle(
const QString &uri,
bool &resultFlag );
858 virtual bool readSld(
const QDomNode &node, QString &errorMessage )
859 { Q_UNUSED( node ) errorMessage = QStringLiteral(
"Layer type %1 not supported" ).arg( static_cast<int>( type() ) );
return false; }
871 virtual bool readSymbology(
const QDomNode &node, QString &errorMessage,
884 virtual bool readStyle(
const QDomNode &node, QString &errorMessage,
897 virtual bool writeSymbology( QDomNode &node, QDomDocument &doc, QString &errorMessage,
const QgsReadWriteContext &context,
898 StyleCategories categories = AllStyleCategories )
const = 0;
912 virtual bool writeStyle( QDomNode &node, QDomDocument &doc, QString &errorMessage,
const QgsReadWriteContext &context,
913 StyleCategories categories = AllStyleCategories )
const;
931 virtual void setDataSource(
const QString &dataSource,
const QString &baseName,
const QString &provider,
const QgsDataProvider::ProviderOptions &options,
bool loadDefaultStyleFlag =
false );
936 QString providerType()
const;
939 QUndoStack *undoStack();
945 QUndoStack *undoStackStyles();
950 void setLegendUrl(
const QString &legendUrl ) { mLegendUrl = legendUrl; }
1007 bool isInScaleRange(
double scale )
const;
1019 double minimumScale()
const;
1031 double maximumScale()
const;
1041 bool hasScaleBasedVisibility()
const;
1049 bool hasAutoRefreshEnabled()
const;
1058 int autoRefreshInterval()
const;
1071 void setAutoRefreshInterval(
int interval );
1079 void setAutoRefreshEnabled(
bool enabled );
1101 virtual QString htmlMetadata()
const;
1104 virtual QDateTime timestamp()
const;
1113 virtual QSet<QgsMapLayerDependency> dependencies()
const;
1137 QString originalXmlProperties()
const;
1146 void setOriginalXmlProperties(
const QString &originalXmlProperties );
1152 static QString generateId(
const QString &layerName );
1176 void setMinimumScale(
double scale );
1187 void setMaximumScale(
double scale );
1196 void setScaleBasedVisibility(
bool enabled );
1206 void triggerRepaint(
bool deferredUpdate =
false );
1212 void emitStyleChanged();
1222 virtual bool setDependencies(
const QSet<QgsMapLayerDependency> &layers );
1229 void setRefreshOnNotifyEnabled(
bool enabled );
1248 SIP_PYOBJECT __repr__();
1250 QString str = QStringLiteral(
"<QgsMapLayer: '%1' (%2)>" ).arg( sipCpp->name(), sipCpp->dataProvider()->name() );
1251 sipRes = PyUnicode_FromString( str.toUtf8().constData() );
1263 void beforeResolveReferences(
QgsProject *project );
1266 void statusChanged(
const QString &status );
1284 void repaintRequested(
bool deferredUpdate =
false );
1287 void recalculateExtents()
const;
1293 void blendModeChanged( QPainter::CompositionMode blendMode );
1299 void rendererChanged();
1308 void styleChanged();
1314 void legendChanged();
1320 void renderer3DChanged();
1326 void configChanged();
1331 void dependenciesChanged();
1339 void willBeDeleted();
1346 void autoRefreshIntervalChanged(
int interval );
1354 void metadataChanged();
1362 void flagsChanged();
1371 void dataSourceChanged();
1376 void onNotifiedTriggerRepaint(
const QString &message );
1391 void setValid(
bool valid );
1403 virtual bool writeXml( QDomNode &layer_node, QDomDocument &document,
const QgsReadWriteContext &context )
const;
1416 virtual QString encodedSource(
const QString &source,
const QgsReadWriteContext &context )
const;
1430 virtual QString decodedSource(
const QString &source,
const QString &dataProvider,
const QgsReadWriteContext &context )
const;
1436 void readCustomProperties(
const QDomNode &layerNode,
const QString &keyStartsWith = QString() );
1439 void writeCustomProperties( QDomNode &layerNode, QDomDocument &doc )
const;
1442 void readStyleManager(
const QDomNode &layerNode );
1444 void writeStyleManager( QDomNode &layerNode, QDomDocument &doc )
const;
1450 void writeCommonStyle( QDomElement &layerElement, QDomDocument &document,
1452 StyleCategories categories = AllStyleCategories )
const;
1458 void readCommonStyle(
const QDomElement &layerElement,
const QgsReadWriteContext &context,
1459 StyleCategories categories = AllStyleCategories );
1462 void setProviderType(
const QString &providerType );
1466 void connectNotify(
const char *signal )
override;
1480 bool mValid =
false;
1525 bool mIsRefreshOnNofifyEnabled =
false;
1534 QgsMapLayer::ReadFlags mReadFlags =
nullptr;
1541 bool mShouldValidateCrs =
true;
1547 bool &resultFlag, StyleCategories categories = AllStyleCategories );
1549 bool &resultFlag, StyleCategories categories = AllStyleCategories );
1550 bool loadNamedPropertyFromDatabase(
const QString &db,
const QString &uri, QString &xml,
QgsMapLayer::PropertyType type );
1556 virtual bool isReadOnly()
const;
1569 LayerFlags mFlags = LayerFlags( Identifiable | Removable | Searchable );
1572 QPainter::CompositionMode mBlendMode = QPainter::CompositionMode_SourceOver;
1580 double mMinScale = 0;
1582 double mMaxScale = 100000000;
1584 bool mScaleBasedVisibility =
false;
1587 QUndoStack *mUndoStack =
nullptr;
1589 QUndoStack *mUndoStackStyles =
nullptr;
1601 QTimer *mRefreshTimer =
nullptr;
1613 QString mOriginalXmlProperties;
1616 bool mRepaintRequestedFired =
false;
1620 Q_DECLARE_OPERATORS_FOR_FLAGS( QgsMapLayer::LayerFlags )
1621 Q_DECLARE_OPERATORS_FOR_FLAGS( QgsMapLayer::StyleCategories )
1622 Q_DECLARE_OPERATORS_FOR_FLAGS( QgsMapLayer::ReadFlags )
QString attributionUrl() const
Returns the attribution URL of the layer used by QGIS Server in GetCapabilities request.
void setMetadataUrl(const QString &metaUrl)
Sets the metadata URL of the layer used by QGIS Server in GetCapabilities request.
The class is used as a container of context for various read/write operations on other objects...
QString dataUrlFormat() const
Returns the DataUrl format of the layer used by QGIS Server in GetCapabilities request.
A rectangle specified with double values.
Base class for all map layer types.
Base class for all renderers that may to participate in 3D view.
QString dataUrl() const
Returns the DataUrl of the layer used by QGIS Server in GetCapabilities request.
QString mProviderKey
Data provider key (name of the data provider)
PropertyType
Maplayer has a style and a metadata property.
virtual void reload()
Synchronises with changes in the datasource.
#define SIP_MONKEYPATCH_SCOPEENUM_UNNEST(OUTSIDE_CLASS, FORMERNAME)
void setMetadataUrlType(const QString &metaUrlType)
Set the metadata type of the layer used by QGIS Server in GetCapabilities request MetadataUrlType ind...
Abstract base class for spatial data provider implementations.
const QgsCoordinateReferenceSystem & crs
An interface for classes which can visit style entity (e.g.
QPointer< QgsMapLayer > QgsWeakMapLayerPointer
Weak pointer for QgsMapLayer.
QString mLayerName
Name of the layer - used for display.
bool isRefreshOnNotifyEnabled() const
Returns true if the refresh on provider nofification is enabled.
QgsRectangle mExtent
Extent of the layer.
QString mMetadataUrl
MetadataUrl of the layer.
void setLegendUrlFormat(const QString &legendUrlFormat)
Sets the format for a URL based layer legend.
QString metadataUrlFormat() const
Returns the metadata format of the layer used by QGIS Server in GetCapabilities request.
void setKeywordList(const QString &keywords)
Sets the keyword list of the layer used by QGIS Server in GetCapabilities request.
ReadFlag
Flags which control project read behavior.
void setTitle(const QString &title)
Sets the title of the layer used by QGIS Server in GetCapabilities request.
QSet< QgsMapLayerDependency > mDependencies
List of layers that may modify this layer on modification.
QString keywordList() const
Returns the keyword list of the layer used by QGIS Server in GetCapabilities request.
QString mDataUrl
DataUrl of the layer.
The QgsMapLayerLegend class is abstract interface for implementations of legends for one map layer...
Q_DECLARE_METATYPE(QgsMeshTimeSettings)
QString legendUrl() const
Returns the URL for the layer's legend.
Encapsulates a QGIS project, including sets of map layers and their styles, layouts, annotations, canvases, etc.
QgsErrorMessage represents single error message.
Contains information about the context in which a coordinate transform is executed.
void setDataUrlFormat(const QString &dataUrlFormat)
Sets the DataUrl format of the layer used by QGIS Server in GetCapabilities request.
virtual bool readSld(const QDomNode &node, QString &errorMessage)
QString legendUrlFormat() const
Returns the format for a URL based layer legend.
QString mMetadataUrlFormat
void setLegendUrl(const QString &legendUrl)
Sets the URL for the layer's legend.
void setMetadataUrlFormat(const QString &metaUrlFormat)
Sets the metadata format of the layer used by QGIS Server in GetCapabilities request.
QString title() const
Returns the title of the layer used by QGIS Server in GetCapabilities request.
LayerFlag
Flags for the map layer.
StyleCategory
Categories of style to distinguish appropriate sections for import/export.
QString mAttribution
Attribution of the layer.
QString mAbstract
Description of the layer.
QString mRefreshOnNofifyMessage
Contains information about the context of a rendering operation.
Setting options for creating vector data providers.
Q_DECL_DEPRECATED bool hasDependencyCycle(const QSet< QgsMapLayerDependency > &) const
Checks whether a new set of dependencies will introduce a cycle this method is now deprecated and alw...
QString mDataSource
Data source description string, varies by layer type.
QgsError is container for error messages (report).
QList< QgsWeakMapLayerPointer > QgsWeakMapLayerPointerList
A list of weak pointers to QgsMapLayers.
QString mLegendUrl
WMS legend.
This class represents a coordinate reference system (CRS).
#define SIP_CONVERT_TO_SUBCLASS_CODE(code)
Simple key-value store (keys = strings, values = variants) that supports loading/saving to/from XML i...
void setAttributionUrl(const QString &attribUrl)
Sets the attribution URL of the layer used by QGIS Server in GetCapabilities request.
void appendError(const QgsErrorMessage &error)
Add error message.
Base class for utility classes that encapsulate information necessary for rendering of map layers...
bool readOnly() const
Returns if this layer is read only.
QString metadataUrl() const
Returns the metadata URL of the layer used by QGIS Server in GetCapabilities request.
QgsMapLayerType
Types of layers that can be added to a map.
void setAttribution(const QString &attrib)
Sets the attribution of the layer used by QGIS Server in GetCapabilities request. ...
void setRefreshOnNofifyMessage(const QString &message)
Set the notification message that triggers repaint If refresh on notification is enabled, the notification will triggerRepaint only if the notification message is equal to.
Management of styles for use with one map layer.
QString refreshOnNotifyMessage() const
Returns the message that should be notified by the provider to triggerRepaint.
void setDataUrl(const QString &dataUrl)
Sets the DataUrl of the layer used by QGIS Server in GetCapabilities request.
void setError(const QgsError &error)
Sets error message.
void setAbstract(const QString &abstract)
Sets the abstract of the layer used by QGIS Server in GetCapabilities request.
QString attribution() const
Returns the attribution of the layer used by QGIS Server in GetCapabilities request.
QString metadataUrlType() const
Returns the metadata type of the layer used by QGIS Server in GetCapabilities request.