21 #include "qgis_core.h"
59 #define QGSCLIPBOARD_MAPLAYER_MIME "application/qgis.maplayer"
85 Q_PROPERTY( QString name READ name WRITE setName NOTIFY nameChanged )
86 Q_PROPERTY(
int autoRefreshInterval READ autoRefreshInterval WRITE setAutoRefreshInterval NOTIFY autoRefreshIntervalChanged )
87 Q_PROPERTY(
QgsLayerMetadata metadata READ metadata WRITE setMetadata NOTIFY metadataChanged )
92 QgsMapLayer * layer = qobject_cast<QgsMapLayer *>( sipCpp );
98 switch ( layer->type() )
101 sipType = sipType_QgsVectorLayer;
104 sipType = sipType_QgsRasterLayer;
107 sipType = sipType_QgsPluginLayer;
110 sipType = sipType_QgsMeshLayer;
113 sipType = sipType_QgsVectorTileLayer;
142 Identifiable = 1 << 0,
147 Q_DECLARE_FLAGS( LayerFlags, LayerFlag )
156 LayerConfiguration = 1 << 0,
158 Symbology3D = 1 << 2,
165 AttributeTable = 1 << 9,
167 CustomProperties = 1 << 11,
168 GeometryOptions = 1 << 12,
171 AllStyleCategories = LayerConfiguration | Symbology | Symbology3D | Labeling | Fields | Forms | Actions |
172 MapTips | Diagrams | AttributeTable | Rendering | CustomProperties | GeometryOptions | Relations | Temporal,
174 Q_ENUM( StyleCategory )
175 Q_DECLARE_FLAGS( StyleCategories, StyleCategory )
176 Q_FLAG( StyleCategories )
213 QgsMapLayer::LayerFlags flags()
const;
222 void setFlags( QgsMapLayer::LayerFlags flags );
229 static QString extensionPropertyType( PropertyType type );
239 void setName(
const QString &name );
245 QString name()
const;
264 void setShortName( const QString &shortName ) { mShortName = shortName; }
271 QString shortName()
const;
278 void setTitle(
const QString &title ) { mTitle = title; }
286 QString
title()
const {
return mTitle; }
294 void setAbstract(
const QString &
abstract ) { mAbstract =
abstract; }
302 QString
abstract()
const {
return mAbstract; }
329 void setDataUrl(
const QString &dataUrl ) { mDataUrl = dataUrl; }
457 void setBlendMode( QPainter::CompositionMode blendMode );
463 QPainter::CompositionMode blendMode()
const;
487 bool isValid()
const;
495 QString publicSource()
const;
502 QString source()
const;
508 virtual QStringList subLayers()
const;
514 virtual void setLayerOrder(
const QStringList &layers );
521 virtual void setSubLayerVisibility(
const QString &name,
bool visible );
524 virtual bool isEditable()
const;
530 virtual bool isSpatial()
const;
540 virtual bool isTemporary()
const;
548 FlagDontResolveLayers = 1 << 0,
550 Q_DECLARE_FLAGS( ReadFlags, ReadFlag )
569 bool readLayerXml(
const QDomElement &layerElement,
QgsReadWriteContext &context, QgsMapLayer::ReadFlags flags = QgsMapLayer::ReadFlags() );
588 bool writeLayerXml( QDomElement &layerElement, QDomDocument &document,
const QgsReadWriteContext &context )
const;
594 virtual void resolveReferences(
QgsProject *project );
601 Q_INVOKABLE QStringList customPropertyKeys()
const;
608 Q_INVOKABLE
void setCustomProperty(
const QString &key,
const QVariant &value );
614 Q_INVOKABLE QVariant customProperty(
const QString &value,
const QVariant &defaultValue = QVariant() )
const;
633 void removeCustomProperty(
const QString &key );
664 static QString formatLayerName(
const QString &name );
673 virtual QString metadataUri()
const;
681 void exportNamedMetadata( QDomDocument &doc, QString &errorMsg )
const;
692 virtual QString saveDefaultMetadata(
bool &resultFlag
SIP_OUT );
708 QString saveNamedMetadata(
const QString &uri,
bool &resultFlag );
724 virtual QString loadNamedMetadata(
const QString &uri,
bool &resultFlag
SIP_OUT );
735 QString loadDefaultMetadata(
bool &resultFlag );
745 bool loadNamedMetadataFromDatabase(
const QString &db,
const QString &uri, QString &qmd );
754 bool importNamedMetadata( QDomDocument &document, QString &errorMessage );
763 virtual QString styleURI()
const;
774 virtual QString loadDefaultStyle(
bool &resultFlag
SIP_OUT );
800 virtual bool loadNamedStyleFromDatabase(
const QString &db,
const QString &uri, QString &qml
SIP_OUT );
811 virtual bool importNamedStyle( QDomDocument &doc, QString &errorMsg
SIP_OUT,
832 virtual void exportSldStyle( QDomDocument &doc, QString &errorMsg )
const;
843 virtual QString saveDefaultStyle(
bool &resultFlag
SIP_OUT );
860 virtual QString saveNamedStyle(
const QString &uri,
bool &resultFlag
SIP_OUT, StyleCategories categories = AllStyleCategories );
870 virtual QString saveSldStyle(
const QString &uri,
bool &resultFlag )
const;
880 virtual QString loadSldStyle(
const QString &uri,
bool &resultFlag );
882 virtual bool readSld(
const QDomNode &node, QString &errorMessage )
883 { Q_UNUSED( node ) errorMessage = QStringLiteral(
"Layer type %1 not supported" ).arg(
static_cast<int>( type() ) );
return false; }
895 virtual bool readSymbology(
const QDomNode &node, QString &errorMessage,
908 virtual bool readStyle(
const QDomNode &node, QString &errorMessage,
921 virtual bool writeSymbology( QDomNode &node, QDomDocument &doc, QString &errorMessage,
const QgsReadWriteContext &context,
922 StyleCategories categories = AllStyleCategories )
const = 0;
936 virtual bool writeStyle( QDomNode &node, QDomDocument &doc, QString &errorMessage,
const QgsReadWriteContext &context,
937 StyleCategories categories = AllStyleCategories )
const;
955 virtual void setDataSource(
const QString &dataSource,
const QString &baseName,
const QString &provider,
const QgsDataProvider::ProviderOptions &options,
bool loadDefaultStyleFlag =
false );
960 QString providerType()
const;
963 QUndoStack *undoStack();
969 QUndoStack *undoStackStyles();
974 void setLegendUrl(
const QString &legendUrl ) { mLegendUrl = legendUrl; }
1031 bool isInScaleRange(
double scale )
const;
1043 double minimumScale()
const;
1055 double maximumScale()
const;
1065 bool hasScaleBasedVisibility()
const;
1073 bool hasAutoRefreshEnabled()
const;
1082 int autoRefreshInterval()
const;
1095 void setAutoRefreshInterval(
int interval );
1103 void setAutoRefreshEnabled(
bool enabled );
1125 virtual QString htmlMetadata()
const;
1128 virtual QDateTime timestamp()
const;
1137 virtual QSet<QgsMapLayerDependency> dependencies()
const;
1161 QString originalXmlProperties()
const;
1170 void setOriginalXmlProperties(
const QString &originalXmlProperties );
1176 static QString generateId(
const QString &layerName );
1207 void setMinimumScale(
double scale );
1218 void setMaximumScale(
double scale );
1227 void setScaleBasedVisibility(
bool enabled );
1237 void triggerRepaint(
bool deferredUpdate =
false );
1243 void emitStyleChanged();
1253 virtual bool setDependencies(
const QSet<QgsMapLayerDependency> &layers );
1260 void setRefreshOnNotifyEnabled(
bool enabled );
1279 SIP_PYOBJECT __repr__();
1281 QString str = QStringLiteral(
"<QgsMapLayer: '%1' (%2)>" ).arg( sipCpp->name(), sipCpp->dataProvider() ? sipCpp->dataProvider()->name() : QStringLiteral(
"Invalid" ) );
1282 sipRes = PyUnicode_FromString( str.toUtf8().constData() );
1294 void beforeResolveReferences(
QgsProject *project );
1297 void statusChanged(
const QString &status );
1315 void repaintRequested(
bool deferredUpdate =
false );
1318 void recalculateExtents()
const;
1324 void blendModeChanged( QPainter::CompositionMode blendMode );
1330 void rendererChanged();
1339 void styleChanged();
1345 void legendChanged();
1351 void renderer3DChanged();
1357 void configChanged();
1362 void dependenciesChanged();
1370 void willBeDeleted();
1377 void autoRefreshIntervalChanged(
int interval );
1385 void metadataChanged();
1393 void flagsChanged();
1402 void dataSourceChanged();
1409 void styleLoaded( QgsMapLayer::StyleCategories categories );
1414 void onNotifiedTriggerRepaint(
const QString &message );
1429 void setValid(
bool valid );
1441 virtual bool writeXml( QDomNode &layer_node, QDomDocument &document,
const QgsReadWriteContext &context )
const;
1454 virtual QString encodedSource(
const QString &source,
const QgsReadWriteContext &context )
const;
1468 virtual QString decodedSource(
const QString &source,
const QString &dataProvider,
const QgsReadWriteContext &context )
const;
1474 void readCustomProperties(
const QDomNode &layerNode,
const QString &keyStartsWith = QString() );
1477 void writeCustomProperties( QDomNode &layerNode, QDomDocument &doc )
const;
1480 void readStyleManager(
const QDomNode &layerNode );
1482 void writeStyleManager( QDomNode &layerNode, QDomDocument &doc )
const;
1488 void writeCommonStyle( QDomElement &layerElement, QDomDocument &document,
1490 StyleCategories categories = AllStyleCategories )
const;
1496 void readCommonStyle(
const QDomElement &layerElement,
const QgsReadWriteContext &context,
1497 StyleCategories categories = AllStyleCategories );
1500 void setProviderType(
const QString &providerType );
1504 void connectNotify(
const char *signal )
override;
1518 bool mValid =
false;
1563 bool mIsRefreshOnNofifyEnabled =
false;
1572 QgsMapLayer::ReadFlags mReadFlags = QgsMapLayer::ReadFlags();
1579 bool mShouldValidateCrs =
true;
1585 bool &resultFlag, StyleCategories categories = AllStyleCategories );
1587 bool &resultFlag, StyleCategories categories = AllStyleCategories );
1588 bool loadNamedPropertyFromDatabase(
const QString &db,
const QString &uri, QString &xml,
QgsMapLayer::PropertyType type );
1594 virtual bool isReadOnly()
const;
1607 LayerFlags mFlags = LayerFlags( Identifiable | Removable | Searchable );
1610 QPainter::CompositionMode mBlendMode = QPainter::CompositionMode_SourceOver;
1618 double mMinScale = 0;
1620 double mMaxScale = 100000000;
1622 bool mScaleBasedVisibility =
false;
1625 QUndoStack *mUndoStack =
nullptr;
1627 QUndoStack *mUndoStackStyles =
nullptr;
1639 QTimer *mRefreshTimer =
nullptr;
1651 QString mOriginalXmlProperties;
1654 bool mRepaintRequestedFired =
false;
1658 Q_DECLARE_OPERATORS_FOR_FLAGS( QgsMapLayer::LayerFlags )
1659 Q_DECLARE_OPERATORS_FOR_FLAGS( QgsMapLayer::StyleCategories )
1660 Q_DECLARE_OPERATORS_FOR_FLAGS( QgsMapLayer::ReadFlags )