Skip to content

Commit 11c626d

Browse files
committed
Add readOnly property to QgsVectorLayer
1 parent 1fda77c commit 11c626d

File tree

3 files changed

+21
-0
lines changed

3 files changed

+21
-0
lines changed

python/core/qgsvectorlayer.sip

+8
Original file line numberDiff line numberDiff line change
@@ -1641,6 +1641,14 @@ class QgsVectorLayer : QgsMapLayer
16411641
* @Note added in QGIS 3.0
16421642
*/
16431643
void editFormConfigChanged();
1644+
1645+
/**
1646+
* Emitted when the read only state of this layer is changed.
1647+
* Only applies to manually set readonly state, not to the edit mode.
1648+
*
1649+
* @note Added in QGIS 3.0
1650+
*/
1651+
void readOnlyChanged();
16441652
protected:
16451653
/** Set the extent */
16461654
void setExtent( const QgsRectangle &rect );

src/core/qgsvectorlayer.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -2615,6 +2615,7 @@ bool QgsVectorLayer::setReadOnly( bool readonly )
26152615
return false;
26162616

26172617
mReadOnly = readonly;
2618+
emit readOnlyChanged();
26182619
return true;
26192620
}
26202621

src/core/qgsvectorlayer.h

+12
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,7 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer, public QgsExpressionConte
413413
Q_PROPERTY( QString displayExpression READ displayExpression WRITE setDisplayExpression NOTIFY displayExpressionChanged )
414414
Q_PROPERTY( QString mapTipTemplate READ mapTipTemplate WRITE setMapTipTemplate NOTIFY mapTipTemplateChanged )
415415
Q_PROPERTY( QgsEditFormConfig editFormConfig READ editFormConfig WRITE setEditFormConfig NOTIFY editFormConfigChanged )
416+
Q_PROPERTY( bool readOnly READ isReadOnly WRITE setReadOnly NOTIFY readOnlyChanged )
416417

417418
public:
418419

@@ -1765,9 +1766,20 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer, public QgsExpressionConte
17651766

17661767
/**
17671768
* Will be emitted whenever the edit form configuration of this layer changes.
1769+
*
1770+
* @note added in QGIS 3.0
17681771
*/
17691772
void editFormConfigChanged();
17701773

1774+
/**
1775+
* Emitted when the read only state of this layer is changed.
1776+
* Only applies to manually set readonly state, not to the edit mode.
1777+
*
1778+
* @note Added in QGIS 3.0
1779+
*/
1780+
void readOnlyChanged();
1781+
1782+
17711783
private slots:
17721784
void onJoinedFieldsChanged();
17731785
void onFeatureDeleted( QgsFeatureId fid );

0 commit comments

Comments
 (0)