Add readOnly property to QgsVectorLayer

This commit is contained in:
Matthias Kuhn 2016-08-19 16:33:12 +02:00
parent 1fda77c798
commit 11c626d8e1
3 changed files with 21 additions and 0 deletions

View File

@ -1641,6 +1641,14 @@ class QgsVectorLayer : QgsMapLayer
* @Note added in QGIS 3.0 * @Note added in QGIS 3.0
*/ */
void editFormConfigChanged(); void editFormConfigChanged();
/**
* Emitted when the read only state of this layer is changed.
* Only applies to manually set readonly state, not to the edit mode.
*
* @note Added in QGIS 3.0
*/
void readOnlyChanged();
protected: protected:
/** Set the extent */ /** Set the extent */
void setExtent( const QgsRectangle &rect ); void setExtent( const QgsRectangle &rect );

View File

@ -2615,6 +2615,7 @@ bool QgsVectorLayer::setReadOnly( bool readonly )
return false; return false;
mReadOnly = readonly; mReadOnly = readonly;
emit readOnlyChanged();
return true; return true;
} }

View File

@ -413,6 +413,7 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer, public QgsExpressionConte
Q_PROPERTY( QString displayExpression READ displayExpression WRITE setDisplayExpression NOTIFY displayExpressionChanged ) Q_PROPERTY( QString displayExpression READ displayExpression WRITE setDisplayExpression NOTIFY displayExpressionChanged )
Q_PROPERTY( QString mapTipTemplate READ mapTipTemplate WRITE setMapTipTemplate NOTIFY mapTipTemplateChanged ) Q_PROPERTY( QString mapTipTemplate READ mapTipTemplate WRITE setMapTipTemplate NOTIFY mapTipTemplateChanged )
Q_PROPERTY( QgsEditFormConfig editFormConfig READ editFormConfig WRITE setEditFormConfig NOTIFY editFormConfigChanged ) Q_PROPERTY( QgsEditFormConfig editFormConfig READ editFormConfig WRITE setEditFormConfig NOTIFY editFormConfigChanged )
Q_PROPERTY( bool readOnly READ isReadOnly WRITE setReadOnly NOTIFY readOnlyChanged )
public: public:
@ -1765,9 +1766,20 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer, public QgsExpressionConte
/** /**
* Will be emitted whenever the edit form configuration of this layer changes. * Will be emitted whenever the edit form configuration of this layer changes.
*
* @note added in QGIS 3.0
*/ */
void editFormConfigChanged(); void editFormConfigChanged();
/**
* Emitted when the read only state of this layer is changed.
* Only applies to manually set readonly state, not to the edit mode.
*
* @note Added in QGIS 3.0
*/
void readOnlyChanged();
private slots: private slots:
void onJoinedFieldsChanged(); void onJoinedFieldsChanged();
void onFeatureDeleted( QgsFeatureId fid ); void onFeatureDeleted( QgsFeatureId fid );