21 #include "qgis_core.h" 57 #define QGSCLIPBOARD_MAPLAYER_MIME "application/qgis.maplayer" 68 Q_PROPERTY( QString name READ name WRITE setName NOTIFY nameChanged )
69 Q_PROPERTY(
int autoRefreshInterval READ autoRefreshInterval WRITE setAutoRefreshInterval NOTIFY autoRefreshIntervalChanged )
70 Q_PROPERTY(
QgsLayerMetadata metadata READ metadata WRITE setMetadata NOTIFY metadataChanged )
81 switch ( layer->type() )
84 sipType = sipType_QgsVectorLayer;
87 sipType = sipType_QgsRasterLayer;
90 sipType = sipType_QgsPluginLayer;
93 sipType = sipType_QgsMeshLayer;
131 Identifiable = 1 << 0,
145 LayerConfiguration = 1 << 0,
147 Symbology3D = 1 << 2,
154 AttributeTable = 1 << 9,
156 CustomProperties = 1 << 11,
157 GeometryOptions = 1 << 12,
158 AllStyleCategories = LayerConfiguration | Symbology | Symbology3D | Labeling | Fields | Forms | Actions |
159 MapTips | Diagrams | AttributeTable | Rendering | CustomProperties | GeometryOptions,
163 Q_FLAG( StyleCategories )
200 QgsMapLayer::LayerFlags flags()
const;
209 void setFlags( QgsMapLayer::LayerFlags flags );
216 static QString extensionPropertyType(
PropertyType type );
226 void setName(
const QString &name );
232 QString name()
const;
251 void setShortName( const QString &shortName ) { mShortName = shortName; }
265 void setTitle(
const QString &title ) { mTitle = title; }
273 QString
title()
const {
return mTitle; }
281 void setAbstract(
const QString &
abstract ) { mAbstract =
abstract; }
289 QString
abstract()
const {
return mAbstract; }
316 void setDataUrl(
const QString &dataUrl ) { mDataUrl = dataUrl; }
444 void setBlendMode( QPainter::CompositionMode blendMode );
450 QPainter::CompositionMode blendMode()
const;
474 bool isValid()
const;
482 QString publicSource()
const;
489 QString source()
const;
495 virtual QStringList subLayers()
const;
501 virtual void setLayerOrder(
const QStringList &layers );
508 virtual void setSubLayerVisibility(
const QString &name,
bool visible );
511 virtual bool isEditable()
const;
517 virtual bool isSpatial()
const;
554 bool writeLayerXml( QDomElement &layerElement, QDomDocument &document,
const QgsReadWriteContext &context )
const;
560 virtual void resolveReferences(
QgsProject *project );
567 QStringList customPropertyKeys()
const;
574 void setCustomProperty(
const QString &key,
const QVariant &value );
580 QVariant customProperty(
const QString &value,
const QVariant &defaultValue = QVariant() )
const;
592 void removeCustomProperty(
const QString &key );
615 static QString formatLayerName(
const QString &name );
624 virtual QString metadataUri()
const;
632 void exportNamedMetadata( QDomDocument &doc, QString &errorMsg )
const;
643 virtual QString saveDefaultMetadata(
bool &resultFlag
SIP_OUT );
659 QString saveNamedMetadata(
const QString &uri,
bool &resultFlag );
675 virtual QString loadNamedMetadata(
const QString &uri,
bool &resultFlag SIP_OUT );
686 QString loadDefaultMetadata(
bool &resultFlag );
696 bool loadNamedMetadataFromDatabase(
const QString &db,
const QString &uri, QString &qmd );
705 bool importNamedMetadata( QDomDocument &document, QString &errorMessage );
714 virtual QString styleURI()
const;
725 virtual QString loadDefaultStyle(
bool &resultFlag SIP_OUT );
742 virtual QString loadNamedStyle(
const QString &uri,
bool &resultFlag SIP_OUT, QgsMapLayer::StyleCategories categories =
QgsMapLayer::AllStyleCategories );
751 virtual bool loadNamedStyleFromDatabase(
const QString &db,
const QString &uri, QString &qml SIP_OUT );
762 virtual bool importNamedStyle( QDomDocument &doc, QString &errorMsg SIP_OUT,
783 virtual void exportSldStyle( QDomDocument &doc, QString &errorMsg )
const;
794 virtual QString saveDefaultStyle(
bool &resultFlag SIP_OUT );
811 virtual QString saveNamedStyle(
const QString &uri,
bool &resultFlag SIP_OUT, StyleCategories categories = AllStyleCategories );
821 virtual QString saveSldStyle(
const QString &uri,
bool &resultFlag )
const;
831 virtual QString loadSldStyle(
const QString &uri,
bool &resultFlag );
833 virtual bool readSld(
const QDomNode &node, QString &errorMessage )
834 { Q_UNUSED( node ); errorMessage = QStringLiteral(
"Layer type %1 not supported" ).arg( type() );
return false; }
846 virtual bool readSymbology(
const QDomNode &node, QString &errorMessage,
859 virtual bool readStyle(
const QDomNode &node, QString &errorMessage,
872 virtual bool writeSymbology( QDomNode &node, QDomDocument &doc, QString &errorMessage,
const QgsReadWriteContext &context,
873 StyleCategories categories = AllStyleCategories )
const = 0;
887 virtual bool writeStyle( QDomNode &node, QDomDocument &doc, QString &errorMessage,
const QgsReadWriteContext &context,
888 StyleCategories categories = AllStyleCategories )
const;
906 virtual void setDataSource(
const QString &dataSource,
const QString &baseName,
const QString &provider,
const QgsDataProvider::ProviderOptions &options,
bool loadDefaultStyleFlag =
false );
911 QString providerType()
const;
914 QUndoStack *undoStack();
920 QUndoStack *undoStackStyles();
925 void setLegendUrl(
const QString &legendUrl ) { mLegendUrl = legendUrl; }
982 bool isInScaleRange(
double scale )
const;
994 double minimumScale()
const;
1006 double maximumScale()
const;
1016 bool hasScaleBasedVisibility()
const;
1024 bool hasAutoRefreshEnabled()
const;
1033 int autoRefreshInterval()
const;
1046 void setAutoRefreshInterval(
int interval );
1054 void setAutoRefreshEnabled(
bool enabled );
1076 virtual QString htmlMetadata()
const;
1079 virtual QDateTime timestamp()
const;
1088 virtual QSet<QgsMapLayerDependency> dependencies()
const;
1112 QString originalXmlProperties()
const;
1121 void setOriginalXmlProperties(
const QString &originalXmlProperties );
1134 void setMinimumScale(
double scale );
1145 void setMaximumScale(
double scale );
1154 void setScaleBasedVisibility(
bool enabled );
1164 void triggerRepaint(
bool deferredUpdate =
false );
1170 void emitStyleChanged();
1180 virtual bool setDependencies(
const QSet<QgsMapLayerDependency> &layers );
1187 void setRefreshOnNotifyEnabled(
bool enabled );
1201 void statusChanged(
const QString &status );
1219 void repaintRequested(
bool deferredUpdate =
false );
1222 void recalculateExtents()
const;
1228 void blendModeChanged( QPainter::CompositionMode blendMode );
1234 void rendererChanged();
1243 void styleChanged();
1249 void legendChanged();
1255 void renderer3DChanged();
1261 void configChanged();
1266 void dependenciesChanged();
1274 void willBeDeleted();
1281 void autoRefreshIntervalChanged(
int interval );
1289 void metadataChanged();
1297 void flagsChanged();
1306 void dataSourceChanged();
1310 void onNotifiedTriggerRepaint(
const QString &message );
1325 void setValid(
bool valid );
1337 virtual bool writeXml( QDomNode &layer_node, QDomDocument &document,
const QgsReadWriteContext &context )
const;
1350 virtual QString encodedSource(
const QString &source,
const QgsReadWriteContext &context )
const;
1364 virtual QString decodedSource(
const QString &source,
const QString &dataProvider,
const QgsReadWriteContext &context )
const;
1370 void readCustomProperties(
const QDomNode &layerNode,
const QString &keyStartsWith = QString() );
1373 void writeCustomProperties( QDomNode &layerNode, QDomDocument &doc )
const;
1376 void readStyleManager(
const QDomNode &layerNode );
1378 void writeStyleManager( QDomNode &layerNode, QDomDocument &doc )
const;
1384 void writeCommonStyle( QDomElement &layerElement, QDomDocument &document,
1386 StyleCategories categories = AllStyleCategories )
const;
1392 void readCommonStyle(
const QDomElement &layerElement,
const QgsReadWriteContext &context,
1393 StyleCategories categories = AllStyleCategories );
1396 void setProviderType(
const QString &providerType );
1400 void connectNotify(
const char *signal )
override;
1414 bool mValid =
false;
1453 bool hasDependencyCycle(
const QSet<QgsMapLayerDependency> &layers )
const;
1455 bool mIsRefreshOnNofifyEnabled =
false;
1466 bool &resultFlag, StyleCategories categories = AllStyleCategories );
1468 bool &resultFlag, StyleCategories categories = AllStyleCategories );
1469 bool loadNamedPropertyFromDatabase(
const QString &db,
const QString &uri, QString &xml,
QgsMapLayer::PropertyType type );
1475 virtual bool isReadOnly()
const;
1488 LayerFlags mFlags = LayerFlags( Identifiable | Removable | Searchable );
1491 QPainter::CompositionMode mBlendMode = QPainter::CompositionMode_SourceOver;
1499 double mMinScale = 0;
1501 double mMaxScale = 100000000;
1503 bool mScaleBasedVisibility =
false;
1506 QUndoStack *mUndoStack =
nullptr;
1508 QUndoStack *mUndoStackStyles =
nullptr;
1520 QTimer *mRefreshTimer =
nullptr;
1532 QString mOriginalXmlProperties;
1537 Q_DECLARE_OPERATORS_FOR_FLAGS( QgsMapLayer::LayerFlags )
1538 Q_DECLARE_OPERATORS_FOR_FLAGS( QgsMapLayer::StyleCategories )
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 shortName() const
Returns the short name of the layer used by QGIS Server to identify the layer.
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.
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
QPointer< QgsMapLayer > QgsWeakMapLayerPointer
Weak pointer for QgsMapLayer.
Q_DECLARE_METATYPE(QModelIndex)
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.
void setTitle(const QString &title)
Sets the title of the layer used by QGIS Server in GetCapabilities request.
LayerType
Types of layers that can be added to a map.
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...
QString legendUrl() const
Returns the URL for the layer's legend.
Reads and writes project states.
QgsErrorMessage represents single error message.
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.
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.
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 repaine 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.