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,
165 AllStyleCategories = LayerConfiguration | Symbology | Symbology3D | Labeling | Fields | Forms | Actions |
166 MapTips | Diagrams | AttributeTable | Rendering | CustomProperties | GeometryOptions | Relations,
170 Q_FLAG( StyleCategories )
207 QgsMapLayer::LayerFlags flags()
const;
216 void setFlags( QgsMapLayer::LayerFlags flags );
223 static QString extensionPropertyType(
PropertyType type );
233 void setName(
const QString &name );
239 QString name()
const;
258 void setShortName( const QString &shortName ) { mShortName = shortName; }
265 QString shortName()
const;
272 void setTitle(
const QString &title ) { mTitle = title; }
280 QString
title()
const {
return mTitle; }
288 void setAbstract(
const QString &
abstract ) { mAbstract =
abstract; }
296 QString
abstract()
const {
return mAbstract; }
323 void setDataUrl(
const QString &dataUrl ) { mDataUrl = dataUrl; }
451 void setBlendMode( QPainter::CompositionMode blendMode );
457 QPainter::CompositionMode blendMode()
const;
481 bool isValid()
const;
489 QString publicSource()
const;
496 QString source()
const;
502 virtual QStringList subLayers()
const;
508 virtual void setLayerOrder(
const QStringList &layers );
515 virtual void setSubLayerVisibility(
const QString &name,
bool visible );
518 virtual bool isEditable()
const;
524 virtual bool isSpatial()
const;
534 virtual bool isTemporary()
const;
542 FlagDontResolveLayers = 1 << 0,
544 Q_DECLARE_FLAGS( ReadFlags,
ReadFlag )
563 bool readLayerXml(
const QDomElement &layerElement,
QgsReadWriteContext &context, QgsMapLayer::ReadFlags flags =
nullptr );
582 bool writeLayerXml( QDomElement &layerElement, QDomDocument &document,
const QgsReadWriteContext &context )
const;
588 virtual void resolveReferences(
QgsProject *project );
595 Q_INVOKABLE QStringList customPropertyKeys()
const;
602 Q_INVOKABLE
void setCustomProperty(
const QString &key,
const QVariant &value );
608 Q_INVOKABLE QVariant customProperty(
const QString &value,
const QVariant &defaultValue = QVariant() )
const;
620 void removeCustomProperty(
const QString &key );
651 static QString formatLayerName(
const QString &name );
660 virtual QString metadataUri()
const;
668 void exportNamedMetadata( QDomDocument &doc, QString &errorMsg )
const;
679 virtual QString saveDefaultMetadata(
bool &resultFlag
SIP_OUT );
695 QString saveNamedMetadata(
const QString &uri,
bool &resultFlag );
711 virtual QString loadNamedMetadata(
const QString &uri,
bool &resultFlag
SIP_OUT );
722 QString loadDefaultMetadata(
bool &resultFlag );
732 bool loadNamedMetadataFromDatabase(
const QString &db,
const QString &uri, QString &qmd );
741 bool importNamedMetadata( QDomDocument &document, QString &errorMessage );
750 virtual QString styleURI()
const;
761 virtual QString loadDefaultStyle(
bool &resultFlag
SIP_OUT );
787 virtual bool loadNamedStyleFromDatabase(
const QString &db,
const QString &uri, QString &qml
SIP_OUT );
798 virtual bool importNamedStyle( QDomDocument &doc, QString &errorMsg
SIP_OUT,
819 virtual void exportSldStyle( QDomDocument &doc, QString &errorMsg )
const;
830 virtual QString saveDefaultStyle(
bool &resultFlag SIP_OUT );
847 virtual QString saveNamedStyle(
const QString &uri,
bool &resultFlag SIP_OUT, StyleCategories categories = AllStyleCategories );
857 virtual QString saveSldStyle(
const QString &uri,
bool &resultFlag )
const;
867 virtual QString loadSldStyle(
const QString &uri,
bool &resultFlag );
869 virtual bool readSld(
const QDomNode &node, QString &errorMessage )
870 { Q_UNUSED( node ) errorMessage = QStringLiteral(
"Layer type %1 not supported" ).arg( static_cast<int>( type() ) );
return false; }
882 virtual bool readSymbology(
const QDomNode &node, QString &errorMessage,
895 virtual bool readStyle(
const QDomNode &node, QString &errorMessage,
908 virtual bool writeSymbology( QDomNode &node, QDomDocument &doc, QString &errorMessage,
const QgsReadWriteContext &context,
909 StyleCategories categories = AllStyleCategories )
const = 0;
923 virtual bool writeStyle( QDomNode &node, QDomDocument &doc, QString &errorMessage,
const QgsReadWriteContext &context,
924 StyleCategories categories = AllStyleCategories )
const;
942 virtual void setDataSource(
const QString &dataSource,
const QString &baseName,
const QString &provider,
const QgsDataProvider::ProviderOptions &options,
bool loadDefaultStyleFlag =
false );
947 QString providerType()
const;
950 QUndoStack *undoStack();
956 QUndoStack *undoStackStyles();
961 void setLegendUrl(
const QString &legendUrl ) { mLegendUrl = legendUrl; }
1018 bool isInScaleRange(
double scale )
const;
1030 double minimumScale()
const;
1042 double maximumScale()
const;
1052 bool hasScaleBasedVisibility()
const;
1060 bool hasAutoRefreshEnabled()
const;
1069 int autoRefreshInterval()
const;
1082 void setAutoRefreshInterval(
int interval );
1090 void setAutoRefreshEnabled(
bool enabled );
1112 virtual QString htmlMetadata()
const;
1115 virtual QDateTime timestamp()
const;
1124 virtual QSet<QgsMapLayerDependency> dependencies()
const;
1148 QString originalXmlProperties()
const;
1157 void setOriginalXmlProperties(
const QString &originalXmlProperties );
1163 static QString generateId(
const QString &layerName );
1187 void setMinimumScale(
double scale );
1198 void setMaximumScale(
double scale );
1207 void setScaleBasedVisibility(
bool enabled );
1217 void triggerRepaint(
bool deferredUpdate =
false );
1223 void emitStyleChanged();
1233 virtual bool setDependencies(
const QSet<QgsMapLayerDependency> &layers );
1240 void setRefreshOnNotifyEnabled(
bool enabled );
1259 SIP_PYOBJECT __repr__();
1261 QString str = QStringLiteral(
"<QgsMapLayer: '%1' (%2)>" ).arg( sipCpp->name(), sipCpp->dataProvider()->name() );
1262 sipRes = PyUnicode_FromString( str.toUtf8().constData() );
1274 void beforeResolveReferences(
QgsProject *project );
1277 void statusChanged(
const QString &status );
1295 void repaintRequested(
bool deferredUpdate =
false );
1298 void recalculateExtents()
const;
1304 void blendModeChanged( QPainter::CompositionMode blendMode );
1310 void rendererChanged();
1319 void styleChanged();
1325 void legendChanged();
1331 void renderer3DChanged();
1337 void configChanged();
1342 void dependenciesChanged();
1350 void willBeDeleted();
1357 void autoRefreshIntervalChanged(
int interval );
1365 void metadataChanged();
1373 void flagsChanged();
1382 void dataSourceChanged();
1389 void styleLoaded( QgsMapLayer::StyleCategories categories );
1394 void onNotifiedTriggerRepaint(
const QString &message );
1409 void setValid(
bool valid );
1421 virtual bool writeXml( QDomNode &layer_node, QDomDocument &document,
const QgsReadWriteContext &context )
const;
1434 virtual QString encodedSource(
const QString &source,
const QgsReadWriteContext &context )
const;
1448 virtual QString decodedSource(
const QString &source,
const QString &dataProvider,
const QgsReadWriteContext &context )
const;
1454 void readCustomProperties(
const QDomNode &layerNode,
const QString &keyStartsWith = QString() );
1457 void writeCustomProperties( QDomNode &layerNode, QDomDocument &doc )
const;
1460 void readStyleManager(
const QDomNode &layerNode );
1462 void writeStyleManager( QDomNode &layerNode, QDomDocument &doc )
const;
1468 void writeCommonStyle( QDomElement &layerElement, QDomDocument &document,
1470 StyleCategories categories = AllStyleCategories )
const;
1476 void readCommonStyle(
const QDomElement &layerElement,
const QgsReadWriteContext &context,
1477 StyleCategories categories = AllStyleCategories );
1480 void setProviderType(
const QString &providerType );
1484 void connectNotify(
const char *signal )
override;
1498 bool mValid =
false;
1543 bool mIsRefreshOnNofifyEnabled =
false;
1552 QgsMapLayer::ReadFlags mReadFlags =
nullptr;
1559 bool mShouldValidateCrs =
true;
1565 bool &resultFlag, StyleCategories categories = AllStyleCategories );
1567 bool &resultFlag, StyleCategories categories = AllStyleCategories );
1568 bool loadNamedPropertyFromDatabase(
const QString &db,
const QString &uri, QString &xml,
QgsMapLayer::PropertyType type );
1574 virtual bool isReadOnly()
const;
1587 LayerFlags mFlags = LayerFlags( Identifiable | Removable | Searchable );
1590 QPainter::CompositionMode mBlendMode = QPainter::CompositionMode_SourceOver;
1598 double mMinScale = 0;
1600 double mMaxScale = 100000000;
1602 bool mScaleBasedVisibility =
false;
1605 QUndoStack *mUndoStack =
nullptr;
1607 QUndoStack *mUndoStackStyles =
nullptr;
1619 QTimer *mRefreshTimer =
nullptr;
1631 QString mOriginalXmlProperties;
1634 bool mRepaintRequestedFired =
false;
1638 Q_DECLARE_OPERATORS_FOR_FLAGS( QgsMapLayer::LayerFlags )
1639 Q_DECLARE_OPERATORS_FOR_FLAGS( QgsMapLayer::StyleCategories )
1640 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.